/* ---------- tokens ---------- */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --border: #dadfe9;
  --text: #15181f;
  --text-2: #4b5363;
  --muted: #6b7384;
  --link: #b4255a;
  --accent: #d6336c;
  --accent-ink: #ffffff;
  --accent-soft: #fdeaf1;
  --good: #1f8a5b;
  --warn: #9a6a12;
  --danger: #c92a3b;
  --focus: #2f6fdb;
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12;
    --surface: #141822;
    --surface-2: #1b2030;
    --border: #2a3041;
    --text: #e9ecf3;
    --text-2: #b4bccb;
    --muted: #8e98ad;
    --link: #ff7aa2;
    --accent: #ff5d8f;
    --accent-ink: #1a0a10;
    --accent-soft: #341826;
    --good: #43d08a;
    --warn: #f1b64a;
    --danger: #ff6b7a;
    --focus: #7fb0ff;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 16px; top: -48px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); z-index: 20; }
.skip:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.brand__mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, #feda75 0%, #fa7e1e 30%, #d62976 60%, #962fbf 82%, #4f5bd5 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.topbar__nav { display: flex; gap: 18px; font-size: 14px; }
.topbar__nav a { color: var(--text-2); text-decoration: none; }
.topbar__nav a:hover { color: var(--text); text-decoration: underline; }

/* ---------- intake ---------- */
.intake { padding: 44px 0 8px; }
h1 { font-size: clamp(28px, 5vw, 36px); font-weight: 700; letter-spacing: -0.025em; }
.lede { margin-top: 12px; font-size: 17px; color: var(--text-2); max-width: 62ch; }
.drop {
  margin-top: 24px; padding: 32px 20px;
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface); text-align: center; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop.is-busy { opacity: .7; pointer-events: none; }
.drop__icon { width: 44px; height: 44px; color: var(--accent); margin: 0 auto 10px; display: block; }
.drop__title { font-weight: 600; font-size: 17px; }
.drop__sub { margin: 4px auto 0; font-size: 14px; color: var(--muted); max-width: 48ch; }
.drop .btn { margin-top: 16px; }
.staged { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.chip--ok { color: var(--good); }
.chip--missing { color: var(--danger); border-style: dashed; }
.status { margin-top: 12px; min-height: 24px; font-size: 14px; color: var(--text-2); }
.status--error { color: var(--danger); }
.status--ok { color: var(--good); }
.status--warn { color: var(--warn); }
.hint { margin-top: 10px; font-size: 14px; }
.hint a, .steps a, .plain a, .note a { color: var(--link); }

/* ---------- results ---------- */
.results { margin-top: 36px; scroll-margin-top: 72px; }
.results__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results__from { font-size: 14px; color: var(--muted); }
.hero { margin-top: 18px; }
.hero__value { font-size: clamp(56px, 12vw, 72px); font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
.hero__label { margin-top: 6px; font-size: 17px; color: var(--text-2); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.tile__label { font-size: 13px; color: var(--muted); }
.tile__value { margin-top: 2px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }

/* tabs */
.tabs { display: flex; gap: 6px; margin-top: 24px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-weight: 500; font-size: 14px; white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.tab__count { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 600; }
.tabdesc { margin-top: 10px; font-size: 14px; color: var(--muted); min-height: 21px; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.search { flex: 1 1 200px; }
.search input, .select select {
  width: 100%; height: 38px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.search input::-webkit-search-decoration { -webkit-appearance: none; }
.select { position: relative; flex: 0 1 auto; }
.select select { padding-right: 32px; max-width: 320px; }
.select::after {
  content: ''; position: absolute; right: 13px; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.toolbar__actions { display: flex; gap: 8px; margin-left: auto; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 600; font-size: 15px;
  text-decoration: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s, filter .12s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn--danger { color: var(--danger); }

/* list */
.list { list-style: none; margin: 12px 0 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list:empty { display: none; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 60px; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
.row--ignored { opacity: .55; }
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: hsl(var(--av) 60% 90%); color: hsl(var(--av) 50% 32%);
}
@media (prefers-color-scheme: dark) {
  .avatar { background: hsl(var(--av) 35% 24%); color: hsl(var(--av) 70% 82%); }
}
.avatar--h0 { --av: 350; } .avatar--h1 { --av: 25; } .avatar--h2 { --av: 50; } .avatar--h3 { --av: 140; }
.avatar--h4 { --av: 180; } .avatar--h5 { --av: 215; } .avatar--h6 { --av: 260; } .avatar--h7 { --av: 300; }
.row__main { flex: 1 1 auto; min-width: 0; }
.row__name { font-weight: 600; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.row__name .at { color: var(--muted); font-weight: 500; }
.row__name:hover { text-decoration: underline; }
.row__meta { margin-top: 2px; font-size: 13px; color: var(--muted); }
.group { padding: 14px 12px 8px; background: var(--surface-2); border-top: 1px solid var(--border); }
.group h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.group__count { margin-left: 6px; font-variant-numeric: tabular-nums; color: var(--muted); }
.group__desc { margin-top: 2px; font-size: 13px; color: var(--muted); }
.empty { margin-top: 12px; padding: 28px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.more { margin-top: 12px; text-align: center; }

/* ---------- cards ---------- */
.card { margin-top: 28px; padding: 22px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card h2 { font-size: 20px; font-weight: 700; }
.muted { margin-top: 8px; color: var(--muted); font-size: 14px; }
.steps { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; padding-left: 40px; margin-top: 12px; counter-increment: step; color: var(--text-2); }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
}
.steps strong { color: var(--text); }
.note { margin-top: 16px; font-size: 14px; color: var(--muted); }
.plain { margin: 12px 0 0; padding-left: 20px; color: var(--text-2); }
.plain li + li { margin-top: 6px; }
.snapshots { list-style: none; margin: 12px 0 0; padding: 0; }
.snapshots:empty { display: none; }
.snap { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.snap:first-child { border-top: 0; }
.snap__main { flex: 1 1 240px; min-width: 0; }
.snap__title { font-weight: 600; }
.snap__meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.snap__actions { display: flex; gap: 8px; }
.badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; vertical-align: middle; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- footer ---------- */
.foot { margin-top: 40px; padding: 24px 0 calc(32px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- responsive / motion ---------- */
@media (max-width: 600px) {
  .topbar__nav { gap: 12px; font-size: 13px; }
  .intake { padding-top: 28px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar__actions { margin-left: 0; width: 100%; }
  .toolbar__actions .btn { flex: 1; }
  .card { padding: 18px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
