:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #17181c;
  --muted: #5d6170;
  --line: #e4e4e0;
  --accent: #4b3fe0;
  --accent-ink: #ffffff;
  --accent-soft: #eeecfd;
  --ok: #1f7a4a;
  --ok-soft: #e4f4ea;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111215; --panel: #1a1b20; --ink: #ececef; --muted: #a2a5b1; --line: #2c2e35;
    --accent: #8f86ff; --accent-ink: #0f0f14; --accent-soft: #24223d;
    --ok: #63d19a; --ok-soft: #16291f; --warn: #f0c060; --warn-soft: #2d2412; --bad: #ff8a80; --bad-soft: #321a19;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 2rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
code, pre, .mono { font-family: var(--mono); font-size: .85em; }
:not(pre) > code { background: var(--accent-soft); padding: .1em .35em; border-radius: 5px; }
pre { background: #15161a; color: #e8e8ec; padding: 14px 16px; border-radius: 10px; overflow-x: auto; margin: 0 0 1em; line-height: 1.5; }

/* Layout */
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-size: 13px; }
.topbar .spacer { flex: 1; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 32px 24px 64px; }
.narrow { max-width: 720px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card + .card { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=email], input[type=url], select {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field + .field { margin-top: 16px; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 16px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; font-weight: 600; }
button:disabled { opacity: .55; cursor: not-allowed; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 4px; width: 18px; height: 18px; }

/* Secrets */
.secret { display: flex; gap: 8px; align-items: stretch; }
.secret code { flex: 1; min-width: 0; display: block; padding: 10px 12px; border-radius: 9px; border: 1px dashed var(--accent); background: var(--accent-soft); word-break: break-all; font-size: .85rem; }
.callout { padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: .9rem; }
.callout.ok { background: var(--ok-soft); color: var(--ok); }
.callout.bad { background: var(--bad-soft); color: var(--bad); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.badge.ready { background: var(--ok-soft); color: var(--ok); }
.badge.processing, .badge.awaiting_upload { background: var(--warn-soft); color: var(--warn); }
.badge.failed, .badge.revoked { background: var(--bad-soft); color: var(--bad); }

/* Onboarding stepper */
.onboard { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; align-items: start; }
.steps { list-style: none; margin: 0; padding: 0; position: sticky; top: 90px; }
.steps li { display: flex; gap: 12px; align-items: center; padding: 9px 0; color: var(--muted); font-weight: 600; }
.steps .dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; flex: none; background: var(--panel); }
.steps li.active { color: var(--ink); }
.steps li.active .dot { border-color: var(--accent); color: var(--accent); }
.steps li.done .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step-actions { display: flex; gap: 12px; justify-content: space-between; margin-top: 24px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .onboard { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .card { padding: 18px; }
  .secret { flex-direction: column; }
  .steps { position: static; display: flex; gap: 6px; overflow-x: auto; }
  .steps li span.label { display: none; }
}

/* Upload */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 32px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.player { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; display: block; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 10px 14px; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
td .row { flex-wrap: nowrap; gap: 8px; }
.table-wrap { overflow-x: auto; }
.thumb { width: 96px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: var(--line); display: block; }
.stat .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-size: .85rem; font-weight: 600; }

/* Dialog */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); padding: 24px; width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 10, 15, .55); }

/* Code tabs */
.codetabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.codetabs button { min-height: 32px; padding: 5px 12px; font-size: .85rem; }
.codetabs button[aria-selected=true] { background: var(--ink); color: var(--panel); border-color: var(--ink); }

/* Landing */
.hero { padding: 56px 0 24px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); max-width: 16ch; }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 56ch; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 32px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 50; }
@media (max-width: 560px) {
  .topbar { padding: 12px 16px; gap: 10px; }
  #who { display: none; }
  .wrap { padding: 20px 14px 48px; }
}
