/* =================================================================== tokens */
:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f5f5f6;
  --surface-3: #ececef;
  --border: #e8e8eb;
  --border-strong: #d9d9de;
  --text: #0c0c10;
  --text-2: #565661;
  --text-3: #8e8e99;
  --ink: #111113;
  --ink-hover: #2a2a2e;
  --ink-text: #ffffff;
  --accent: #2563eb;
  --accent-soft: #eef3fe;
  --accent-text: #1d4ed8;
  --ring: rgba(37, 99, 235, .25);
  --dot: rgba(12, 12, 16, .09);

  /* charts (validated: dataviz reference palette) */
  --series: #257de0;
  --series-wash: rgba(37, 125, 224, .10);
  --grid: #ececef;
  --axis: #c9c9cf;
  --i-info: #257de0;
  --i-comm: #f47230;
  --i-trans: #00b894;
  --i-nav: #9b9ba6;

  /* difficulty scale = status palette, always shown with a label */
  --kd-easy: #0aac23;
  --kd-med: #fbb315;
  --kd-hard: #f18a59;
  --kd-vhard: #dc3c3d;

  --warn-bg: #fff8eb; --warn-border: #fbe3b0; --warn-text: #8a4b06;
  --info-bg: #f3f6fd; --info-border: #dbe4fb; --info-text: #2a46a8;

  /* rank tracker: ordinal ramp (validated, top 3 darkest) + movement text */
  --rk-1: #1757ac; --rk-2: #257de0; --rk-3: #519ced; --rk-4: #84b9f3; --rk-none: #dcdce1;
  --up-text: #006c10; --down-text: #c22d2e;

  --shadow-xs: 0 1px 2px rgba(16, 16, 24, .04);
  --shadow-sm: 0 1px 2px rgba(16, 16, 24, .04), 0 2px 8px -2px rgba(16, 16, 24, .05);
  --shadow-md: 0 1px 2px rgba(16, 16, 24, .04), 0 12px 32px -8px rgba(16, 16, 24, .12);
  --shadow-lg: 0 2px 4px rgba(16, 16, 24, .03), 0 24px 64px -16px rgba(16, 16, 24, .22);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --font: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #09090b; --surface: #111114; --surface-2: #17171b; --surface-3: #212127;
    --border: #232329; --border-strong: #303038;
    --text: #ededf0; --text-2: #a1a1ab; --text-3: #6c6c77;
    --ink: #f4f4f5; --ink-hover: #dcdce0; --ink-text: #0c0c10;
    --accent: #5b93ff; --accent-soft: rgba(91, 147, 255, .12); --accent-text: #8fb4ff; --ring: rgba(91, 147, 255, .35);
    --dot: rgba(255, 255, 255, .07);
    --series: #338ced; --series-wash: rgba(51, 140, 237, .14); --grid: #222228; --axis: #3a3a42;
    --i-info: #338ced; --i-comm: #e76624; --i-trans: #00a888; --i-nav: #74747f;
    --warn-bg: rgba(251, 179, 21, .08); --warn-border: rgba(251, 179, 21, .25); --warn-text: #fcc860;
    --info-bg: rgba(91, 147, 255, .08); --info-border: rgba(91, 147, 255, .22); --info-text: #a9c4ff;
    --rk-1: #b6d5f8; --rk-2: #6aabf1; --rk-3: #2370cd; --rk-4: #1757ac; --rk-none: #2b2b32;
    --up-text: #53c556; --down-text: #f47374;
    --shadow-xs: none; --shadow-sm: 0 1px 0 rgba(255,255,255,.02);
    --shadow-md: 0 12px 32px -8px rgba(0,0,0,.6); --shadow-lg: 0 24px 64px -16px rgba(0,0,0,.75);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b; --surface: #111114; --surface-2: #17171b; --surface-3: #212127;
  --border: #232329; --border-strong: #303038;
  --text: #ededf0; --text-2: #a1a1ab; --text-3: #6c6c77;
  --ink: #f4f4f5; --ink-hover: #dcdce0; --ink-text: #0c0c10;
  --accent: #5b93ff; --accent-soft: rgba(91, 147, 255, .12); --accent-text: #8fb4ff; --ring: rgba(91, 147, 255, .35);
  --dot: rgba(255, 255, 255, .07);
  --series: #338ced; --series-wash: rgba(51, 140, 237, .14); --grid: #222228; --axis: #3a3a42;
  --i-info: #338ced; --i-comm: #e76624; --i-trans: #00a888; --i-nav: #74747f;
  --warn-bg: rgba(251, 179, 21, .08); --warn-border: rgba(251, 179, 21, .25); --warn-text: #fcc860;
  --info-bg: rgba(91, 147, 255, .08); --info-border: rgba(91, 147, 255, .22); --info-text: #a9c4ff;
  --rk-1: #b6d5f8; --rk-2: #6aabf1; --rk-3: #2370cd; --rk-4: #1757ac; --rk-none: #2b2b32;
  --up-text: #53c556; --down-text: #f47374;
  --shadow-xs: none; --shadow-sm: 0 1px 0 rgba(255,255,255,.02);
  --shadow-md: 0 12px 32px -8px rgba(0,0,0,.6); --shadow-lg: 0 24px 64px -16px rgba(0,0,0,.75);
}

/* =================================================================== base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.025em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
kbd {
  font: 500 11px var(--mono); min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-grid; place-items: center; border-radius: 5px;
  border: 1px solid var(--border-strong); color: var(--text-3); background: var(--surface);
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* =================================================================== layout */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 20;
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 12px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.main { min-width: 0; padding: 32px 40px 80px; }
.view { max-width: 1280px; margin: 0 auto; animation: enter .35s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -0.02em; padding: 4px 6px 8px; }
.logo { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--ink); color: var(--ink-text); flex: none; }
.new-btn { justify-content: flex-start; }
.new-btn kbd { margin-left: auto; border-color: rgba(255,255,255,.22); color: rgba(255,255,255,.6); background: transparent; }
:root[data-theme="dark"] .new-btn kbd { border-color: rgba(0,0,0,.2); color: rgba(0,0,0,.5); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .new-btn kbd { border-color: rgba(0,0,0,.2); color: rgba(0,0,0,.5); } }

.history { flex: 1; overflow-y: auto; margin: 4px -4px 0; padding: 0 4px; }
.h-group { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 14px 8px 6px; }
.h-item { display: block; padding: 7px 8px; border-radius: var(--r-sm); color: var(--text-2); transition: background .12s; }
.h-item:hover { background: var(--surface-2); }
.h-item.active { background: var(--surface-3); }
.h-title { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.h-sub { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-3); margin-top: 1px; }
.h-empty { padding: 12px 8px; font-size: 13px; color: var(--text-3); line-height: 1.45; }
.cc { font: 500 10px var(--mono); padding: 1px 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; }

.sources { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; background: var(--surface-2); }
.sources h5 { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.src { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 0; color: var(--text-2); }
.src b { font-weight: 500; color: var(--text); }
.src span:last-child { margin-left: auto; color: var(--text-3); font-size: 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.on { background: #0aac23; box-shadow: 0 0 0 3px rgba(10, 172, 35, .15); }
.dot.warn { background: #fbb315; box-shadow: 0 0 0 3px rgba(251, 179, 21, .18); }
.dot.off { background: transparent; border: 1.5px solid var(--text-3); }
.side-foot { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 0; }
.ver { font-size: 12px; color: var(--text-3); }
.signout { color: var(--text-2); padding: 4px 6px; margin-left: -6px; border-radius: 6px; }
.signout:hover { background: var(--surface-3); color: var(--text); }
.ver { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.me { display: inline-flex; align-items: center; gap: 7px; min-width: 0; color: var(--text); }
.me img, .me i { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.me i { display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.me b { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.me + .signout { margin-left: 0; font-size: 12px; color: var(--text-3); }
.topbar, .scrim { display: none; }

/* =================================================================== controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background .15s, border-color .15s, color .15s, transform .08s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn-ink { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.btn-ink:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn-ink:disabled { opacity: .5; cursor: progress; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover, .btn-ghost[aria-expanded="true"] { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-left: -1px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: var(--r-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.bordered { width: 34px; height: 34px; border-color: var(--border-strong); background: var(--surface); box-shadow: var(--shadow-xs); }
.icon-btn.danger:hover { color: var(--kd-vhard); border-color: color-mix(in srgb, var(--kd-vhard) 40%, transparent); }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .i-sun { display: none; }
  :root:where(:not([data-theme="light"])) .i-moon { display: block; }
}
.link-btn { background: none; border: 0; padding: 4px 8px; color: var(--accent-text); font-weight: 500; font-size: 13px; cursor: pointer; border-radius: 6px; }
.link-btn:hover { background: var(--accent-soft); }

.input, .select select {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface);
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.input:focus, .select select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.input:disabled { opacity: .5; }
.select { position: relative; display: block; }
.select select { appearance: none; padding-right: 30px; cursor: pointer; }
.select::after, .select-pill::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px; margin-top: -4px;
  border-right: 1.6px solid var(--text-3); border-bottom: 1.6px solid var(--text-3); transform: rotate(45deg); pointer-events: none;
}

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 10px; }
.segmented button {
  height: 28px; padding: 0 12px; border: 0; background: transparent; border-radius: 7px; cursor: pointer;
  font-weight: 500; font-size: 13px; color: var(--text-2); white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s;
}
.segmented button:hover:not(:disabled) { color: var(--text); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16,16,24,.08), 0 0 0 1px var(--border); }
.segmented button:disabled { opacity: .4; cursor: not-allowed; }

.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { position: relative; width: 30px; height: 18px; flex: none; border-radius: 99px; background: var(--border-strong); transition: background .2s; }
.toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(12px); }
.toggle input:focus-visible + i { box-shadow: 0 0 0 3px var(--ring); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.eyebrow { font-size: 12px; font-weight: 500; color: var(--text-3); }

/* =================================================================== home */
.home { position: relative; padding-top: 6vh; }
.home::before {
  content: ""; position: absolute; inset: -32px -40px auto; height: 560px; z-index: -1; pointer-events: none;
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 60% 70% at 50% 0%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 70% at 50% 0%, #000 30%, transparent 75%);
}
.hero { text-align: center; max-width: 760px; margin: 0 auto 30px; }
.hero-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px 0 10px; margin-bottom: 22px;
  border: 1px solid var(--border); border-radius: 99px; background: var(--surface); box-shadow: var(--shadow-xs);
  font-size: 12.5px; color: var(--text-2);
}
.hero-pill:empty { visibility: hidden; }
.hero h1 { font-size: clamp(34px, 5.2vw, 58px); line-height: 1.02; font-weight: 650; letter-spacing: -0.045em; }
.hero h1 span { color: var(--text-3); }
.lede { font-size: 16.5px; line-height: 1.55; color: var(--text-2); margin: 18px auto 0; max-width: 560px; }

.search { max-width: 760px; margin: 0 auto; }
.cmd {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 60px; padding: 8px 8px 8px 16px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-md);
  cursor: text; transition: border-color .15s, box-shadow .15s;
}
.cmd.focus { border-color: var(--text-3); box-shadow: var(--shadow-md), 0 0 0 4px var(--ring); }
.cmd-ic { color: var(--text-3); flex: none; margin-right: 4px; }
.cmd input { flex: 1; min-width: 200px; height: 42px; border: 0; outline: 0; background: transparent; font-size: 16px; }
.cmd input::placeholder { color: var(--text-3); }
.chips { display: contents; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 4px 0 10px;
  border-radius: 8px; background: var(--surface-3); color: var(--text); font-weight: 500; font-size: 14px;
  animation: pop .18s var(--ease);
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.chip button { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 5px; background: transparent; color: var(--text-3); cursor: pointer; }
.chip button:hover { background: var(--border-strong); color: var(--text); }
.btn-go { height: 44px; padding: 0 18px; border-radius: 11px; font-size: 14.5px; margin-left: auto; }

.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; }
.select-pill {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding-left: 11px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-xs);
  transition: border-color .15s;
}
.select-pill:hover { border-color: var(--border-strong); }
.select-pill:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.select-pill select { appearance: none; border: 0; outline: 0; background: transparent; height: 100%; padding: 0 30px 0 0; font-size: 13.5px; font-weight: 500; color: var(--text); cursor: pointer; }

.options { margin-top: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-sm); animation: enter .2s var(--ease); }
.opt-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.field span:first-child { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.opt-wide { grid-column: 1 / -1; }
.chip-clear { height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); font-size: 13px; font-weight: 500; cursor: pointer; }
.chip-clear:hover { background: var(--surface-3); color: var(--text); }
.examples .tip { color: var(--text-3); font-size: 13px; }
.examples .tip em { font-style: normal; color: var(--text-2); }
.opt-toggles { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.cost { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--text-2); text-align: center; flex-wrap: wrap; }
.cost b { color: var(--text); font-weight: 600; }

.examples { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 22px auto 0; max-width: 760px; font-size: 13px; color: var(--text-3); }
.examples:empty { display: none; }
.examples button { height: 28px; padding: 0 11px; border-radius: 99px; border: 1px dashed var(--border-strong); background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; }
.examples button:hover { border-style: solid; color: var(--text); background: var(--surface); }
.examples span { align-self: center; margin-right: 4px; }

.recent { max-width: 1040px; margin: 56px auto 0; }
.recent:empty { display: none; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 12px; }
.sec-head h3 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.sec-head span { font-size: 12.5px; color: var(--text-3); }
.recent-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.r-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; transition: border-color .15s, box-shadow .2s, transform .2s var(--ease); }
.r-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.r-top { display: flex; align-items: center; gap: 8px; }
.r-top .t { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.015em; }
.r-top .cc { margin-left: auto; }
.r-stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-3); }
.r-stats b { color: var(--text); font-weight: 600; }
.r-spark { height: 36px; }
.r-spark svg { width: 100%; height: 36px; display: block; }
.r-none { display: flex; align-items: center; height: 100%; font-size: 12.5px; color: var(--text-3); border-top: 1px dashed var(--border-strong); margin-top: 18px; padding-top: 8px; height: auto; }

/* =================================================================== job */
.job { max-width: 640px; margin: 8vh auto 0; overflow: hidden; }
.job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 24px 18px; }
.job-head h2 { font-size: 22px; margin-top: 3px; overflow-wrap: anywhere; }
.job-time { font: 500 13px var(--mono); color: var(--text-3); padding-top: 2px; }
.progress { height: 3px; background: var(--surface-3); margin: 0 24px; border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 99px; transition: width .5s var(--ease); }
.progress.indet i { width: 35% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
.steps { list-style: none; margin: 0; padding: 18px 24px 6px; display: grid; gap: 2px; }
.step { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 8px 0; color: var(--text-3); }
.step:not(:last-child)::before { content: ""; position: absolute; left: 10px; top: 32px; bottom: -6px; width: 1.5px; background: var(--border); }
.step.done:not(:last-child)::before { background: var(--ink); opacity: .25; }
.step .ic { position: relative; width: 21px; height: 21px; flex: none; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); background: var(--surface); font-size: 10.5px; font-weight: 600; margin-top: 1px; }
.step .st { font-weight: 500; color: var(--text-2); }
.step .sd { font-size: 12.5px; }
.step .dur { margin-left: auto; font: 12px var(--mono); color: var(--text-3); padding-top: 2px; }
.step.active .ic { border-color: var(--ink); border-right-color: transparent; animation: spin .7s linear infinite; }
.step.active .st { color: var(--text); }
.step.done .ic { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.step.done .st { color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }
.log { margin: 6px 24px 18px; }
.log summary { cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--text-3); padding: 6px 0; list-style: none; }
.log summary::-webkit-details-marker { display: none; }
.log summary::before { content: "▸ "; }
.log[open] summary::before { content: "▾ "; }
.console { margin-top: 6px; padding: 12px 14px; max-height: 220px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); font: 12px/1.7 var(--mono); color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.console .t { color: var(--text-3); margin-right: 10px; }
.console .warn { color: var(--warn-text); }
.job-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 0 24px 20px; }
.job-actions:empty { display: none; }
.job-err { margin: 4px 24px 16px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); font-size: 13.5px; }

/* =================================================================== run header */
.run-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.run-title { min-width: 0; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); }
.crumbs .tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-weight: 500; }
.crumbs .tag.src::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #0aac23; }
.run-title h1 { font-size: 34px; font-weight: 650; letter-spacing: -0.04em; margin-top: 10px; line-height: 1.1; overflow-wrap: anywhere; }
.seed-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.seed-list:empty { display: none; }
.seed-list span { font-size: 12.5px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-2); }
.run-actions { display: flex; gap: 8px; flex: none; }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; margin-bottom: 14px; border-radius: var(--r); border: 1px solid; font-size: 13.5px; line-height: 1.5; }
.banner svg { flex: none; margin-top: 1px; }
.banner b { font-weight: 600; }
.banner.info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.banner.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.banner.note { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.banner.note b { color: var(--text); }
.banner .btn { margin-left: auto; flex: none; }

/* =================================================================== KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { padding: 16px 18px 16px; display: flex; flex-direction: column; min-height: 132px; }
.kpi .k { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.kpi .v { font-size: 30px; font-weight: 600; letter-spacing: -0.035em; margin-top: 6px; line-height: 1.15; display: flex; align-items: center; gap: 12px; }
.kpi .v small { font-size: 14px; font-weight: 500; color: var(--text-3); letter-spacing: -0.01em; }
.kpi .s { font-size: 12.5px; color: var(--text-3); margin-top: auto; padding-top: 8px; }
.kpi .s b { color: var(--text-2); font-weight: 500; }
.seg { display: flex; gap: 2px; height: 8px; margin-top: auto; }
.seg i { display: block; height: 100%; border-radius: 99px; min-width: 4px; transition: opacity .15s; }
.seg-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.seg-legend span { display: inline-flex; align-items: center; gap: 5px; }
.seg-legend span::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.seg-legend b { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }

/* =================================================================== charts */
.charts { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.charts:empty { display: none; }
.chart-card { padding: 18px 18px 12px; min-width: 0; }
.chart-card:empty { display: none; }
.c-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.c-head h3 { font-size: 14px; font-weight: 600; letter-spacing: -0.015em; }
.c-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }
.c-note { font-size: 12px; color: var(--text-3); white-space: nowrap; text-align: right; }
.c-note b { display: block; font-size: 15px; color: var(--text); font-weight: 600; letter-spacing: -0.02em; }
.plot { position: relative; width: 100%; }
.plot svg { display: block; width: 100%; overflow: visible; }
.plot .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.plot .base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.plot .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.plot .area { fill: var(--series-wash); }
.plot .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .pt { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.plot .lbl { fill: var(--text); font-size: 11.5px; font-weight: 600; }
.plot .lbl2 { fill: var(--text-3); font-size: 11px; }
.plot .cross { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.plot .zone { fill: var(--accent-soft); }
.plot .zone-l { fill: var(--accent-text); font-size: 11px; font-weight: 600; }
.plot .dotm { fill: var(--series); stroke: var(--surface); stroke-width: 2; cursor: pointer; transition: r .12s; }
.plot .dotm.hot { stroke: var(--text); }
.plot .hit { fill: transparent; cursor: crosshair; }
.plot .bar { fill: var(--series); }
.plot .bar.dim { opacity: .35; }
.c-empty { display: grid; place-items: center; height: 200px; text-align: center; color: var(--text-3); font-size: 13px; padding: 0 20px; }

.tip {
  position: fixed; z-index: 60; pointer-events: none; opacity: 0; transform: translateY(4px);
  min-width: 140px; max-width: 280px; padding: 9px 11px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md);
  font-size: 12.5px; color: var(--text-2); transition: opacity .12s, transform .12s;
}
.tip.show { opacity: 1; transform: none; }
.tip .tt { font-weight: 600; color: var(--text); margin-bottom: 4px; letter-spacing: -0.01em; }
.tip .tr { display: flex; justify-content: space-between; gap: 16px; }
.tip .tr b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }

/* =================================================================== results */
.results { overflow: hidden; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 12px 0 8px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 15px 10px 14px; border: 0; background: none; cursor: pointer; font-weight: 500; color: var(--text-3); white-space: nowrap; transition: color .15s; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); }
.tab.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }
.tab .n { font: 500 11px var(--mono); padding: 1px 6px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); }
.search-sm { position: relative; display: flex; align-items: center; }
.search-sm svg { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.search-sm input { width: 240px; height: 32px; padding: 0 34px 0 32px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
.search-sm input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.search-sm kbd { position: absolute; right: 8px; }
.search-sm.narrow input { width: 168px; padding-right: 10px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tb-sep { width: 1px; height: 20px; background: var(--border-strong); margin: 0 2px; }
.range { display: inline-flex; align-items: center; height: 32px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); overflow: hidden; }
.range span { padding: 0 10px; font-size: 12.5px; font-weight: 500; color: var(--text-2); border-right: 1px solid var(--border); height: 100%; display: grid; place-items: center; background: var(--surface-2); }
.range input { width: 72px; height: 100%; border: 0; outline: 0; background: transparent; padding: 0 9px; font-size: 13px; }
.range input::-webkit-inner-spin-button { display: none; }
.range i { color: var(--text-3); font-style: normal; }
.range:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.chip-group { display: flex; gap: 4px; flex-wrap: wrap; }
.chip-group:empty { display: none; }
.f-chip {
  height: 30px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 99px; background: var(--surface);
  font-size: 12.5px; font-weight: 500; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, border-color .15s, color .15s;
}
.f-chip:hover { border-color: var(--text-3); color: var(--text); }
.f-chip .sw { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.f-chip.on { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.cluster-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 5px 0 11px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); font-size: 12.5px; font-weight: 500; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.cluster-pill button { border: 0; background: transparent; color: inherit; width: 20px; height: 20px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.cluster-pill button:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface); color: var(--text-3);
  font-size: 12px; font-weight: 500; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
thead th.sortable { cursor: pointer; transition: color .12s; }
thead th.sortable:hover { color: var(--text); }
thead th .arr { display: inline-block; width: 12px; margin-left: 3px; opacity: 0; transition: opacity .12s; }
thead th.sortable:hover .arr { opacity: .4; }
thead th.sorted { color: var(--text); }
thead th.sorted .arr { opacity: 1; }
th.r, td.r { text-align: right; }
th.c, td.c { text-align: center; }
tbody td { padding: 0 12px; height: 46px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr.sel td { background: var(--accent-soft); }
tbody tr.open td { background: var(--surface-3); }
tbody tr:last-child td { border-bottom: 0; }
td.kw { white-space: normal; min-width: 220px; max-width: 380px; }
.kw-cell { display: flex; align-items: center; gap: 8px; }
.kw-text { font-weight: 500; color: var(--text); line-height: 1.35; }
.kw-tools { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .12s; margin-left: auto; }
tr:hover .kw-tools { opacity: 1; }
.mini { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; border: 0; background: transparent; color: var(--text-3); cursor: pointer; }
.mini:hover { background: var(--border); color: var(--text); }
.var-tag { font: 600 10.5px var(--mono); padding: 1px 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); cursor: help; }
.score-btn { height: 24px; padding: 0 9px; border: 1px dashed var(--border-strong); border-radius: 6px; background: transparent; color: var(--text-2); font-size: 12px; font-weight: 500; cursor: pointer; }
.score-btn:hover { border-style: solid; color: var(--text); background: var(--surface); }
.q-tag { font: 600 10px var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border-strong); color: var(--text-3); }
.cb { width: 40px; padding-right: 0 !important; }
.cb input { width: 15px; height: 15px; accent-color: var(--ink); cursor: pointer; vertical-align: middle; }

/* KD ring */
.kd { display: inline-flex; align-items: center; gap: 8px; }
.ring { position: relative; width: 30px; height: 30px; flex: none; }
.ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .trk { fill: none; stroke: var(--surface-3); }
.ring .val { fill: none; stroke-linecap: round; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.ring.lg { width: 46px; height: 46px; }
.ring.lg b { font-size: 15px; }
.ring.est .trk { stroke-dasharray: 2 2; }
.kd small { font-size: 12px; color: var(--text-3); }
.kd small em { font-style: normal; opacity: .75; }

.intent { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.intent::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.vol { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.vol .vb { width: 56px; height: 3px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.vol .vb i { display: block; height: 100%; background: var(--series); border-radius: 99px; }
.spark { display: block; overflow: visible; }
.spark .l { fill: none; stroke: var(--series); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark .a { fill: var(--series-wash); }
.spark .e { fill: var(--series); }
.favs { display: inline-flex; align-items: center; }
.favs img { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--surface); margin-left: -5px; box-shadow: 0 0 0 1px var(--border); }
.favs img:first-child { margin-left: 0; }
.favs span { margin-left: 6px; font-size: 12px; color: var(--text-3); max-width: 104px; overflow: hidden; text-overflow: ellipsis; }
.cl-link { border: 0; background: none; padding: 3px 7px; margin-left: -7px; border-radius: 6px; color: var(--text-2); cursor: pointer; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; font-size: 13px; }
.cl-link:hover { background: var(--surface-3); color: var(--text); }
.src-t { font-size: 12px; color: var(--text-3); }

.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); }
.table-foot b { color: var(--text-2); font-weight: 500; }
.empty { padding: 64px 20px; text-align: center; color: var(--text-3); }
.empty b { display: block; color: var(--text); font-size: 15px; font-weight: 600; margin-bottom: 4px; }

/* clusters */
.cl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; padding: 14px; }
.cl-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); transition: border-color .15s, box-shadow .2s; }
.cl-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.cl-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cl-card h4 { font-size: 15px; letter-spacing: -0.02em; overflow-wrap: anywhere; line-height: 1.3; }
.cl-stats { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.cl-stats b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-bars { display: grid; gap: 6px; }
.cl-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px 42px; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); }
.cl-row span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-row .vb { height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.cl-row .vb i { display: block; height: 100%; background: var(--series); border-radius: 99px; }
.cl-row .n { text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; }
.cl-card .link-btn { align-self: flex-start; margin: auto 0 0 -8px; }

/* =================================================================== drawer */
.drawer-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(9, 9, 11, .28); opacity: 0; pointer-events: none; transition: opacity .25s; backdrop-filter: blur(1px); }
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 10px; right: 10px; bottom: 10px; z-index: 41; width: min(460px, calc(100vw - 20px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg);
  transform: translateX(calc(100% + 24px)); transition: transform .32s var(--ease); overflow-y: auto;
}
.drawer.open { transform: none; }
.dr-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.dr-head h2 { font-size: 20px; letter-spacing: -0.03em; line-height: 1.25; overflow-wrap: anywhere; }
.dr-head .eyebrow { margin-bottom: 4px; }
.dr-head .icon-btn { margin-left: auto; }
.dr-body { padding: 18px 20px 24px; display: grid; gap: 22px; }
.dr-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.dr-stat { background: var(--surface); padding: 12px 14px; }
.dr-stat .k { font-size: 12px; color: var(--text-3); }
.dr-stat .v { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; margin-top: 2px; display: flex; align-items: center; gap: 8px; }
.dr-stat .v small { font-size: 12.5px; color: var(--text-3); font-weight: 500; letter-spacing: 0; }
.dr-sec h4 { font-size: 13px; font-weight: 600; margin-bottom: 10px; letter-spacing: -0.01em; display: flex; justify-content: space-between; }
.dr-sec h4 span { font-weight: 400; color: var(--text-3); font-size: 12px; }
.serp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.serp-list li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); font-size: 13px; }
.serp-list li:hover { background: var(--surface-2); }
.serp-list .pos { font: 500 11px var(--mono); color: var(--text-3); width: 16px; text-align: right; }
.serp-list img { width: 16px; height: 16px; border-radius: 4px; }
.serp-list .d { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.serp-list .tag { font-size: 11px; color: var(--text-3); border: 1px solid var(--border); border-radius: 5px; padding: 0 6px; }
.sib { display: flex; flex-wrap: wrap; gap: 6px; }
.sib button { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 4px 9px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.sib button:hover { border-color: var(--border-strong); color: var(--text); }
.sib button em { font-style: normal; color: var(--text-3); margin-left: 5px; font-variant-numeric: tabular-nums; }
.dr-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* =================================================================== selection bar / toast */
.selbar {
  position: fixed; left: 50%; bottom: 22px; z-index: 35; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 16px; border-radius: 14px;
  background: var(--ink); color: var(--ink-text); box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500;
  animation: rise .25s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.selbar .n { margin-right: 8px; }
.selbar button { height: 32px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: inherit; cursor: pointer; font-weight: 500; opacity: .85; }
.selbar button:hover { background: rgba(127, 127, 127, .22); opacity: 1; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 70; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--ink-text); padding: 10px 16px; border-radius: 11px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg); transition: opacity .2s, transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.selbar:not([hidden]) ~ .toast { bottom: 80px; }

/* =================================================================== side nav */
.side-nav { display: grid; gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 500; font-size: 13.5px; transition: background .12s, color .12s; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.on { background: var(--surface-3); color: var(--text); }
.side-nav svg { color: var(--text-3); }
.side-nav a.on svg { color: var(--text); }

/* =================================================================== rank tracker */
.rk-empty { max-width: 560px; margin: 6vh auto 0; padding: 40px 36px; text-align: center; }
.rk-empty h2 { font-size: 22px; letter-spacing: -0.03em; }
.rk-empty p { color: var(--text-2); margin: 10px auto 22px; max-width: 440px; line-height: 1.55; }
.rk-empty-ic { width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 13px; display: grid; place-items: center; background: var(--surface-3); color: var(--text); }
.rk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.rk-card { display: flex; flex-direction: column; gap: 14px; padding: 18px; transition: border-color .15s, box-shadow .2s, transform .2s var(--ease); }
.rk-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.rk-card-top { display: flex; align-items: center; gap: 12px; }
.rk-card-top img { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border); padding: 5px; background: var(--surface); }
.rk-card-top .t { font-weight: 600; letter-spacing: -0.015em; }
.rk-card-top .d { font-size: 12.5px; color: var(--text-3); }
.rk-card-top .cc { margin-left: auto; }
.rk-card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rk-card-stats div { display: flex; flex-direction: column; gap: 1px; }
.rk-card-stats span { font-size: 12px; color: var(--text-3); }
.rk-card-stats b { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; }
.rk-card-stats .dl { font-size: 11.5px; }
.rk-title { display: flex; align-items: center; gap: 14px; }
.rk-title img { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); padding: 6px; background: var(--surface); }
.crumbs a.tag:hover { background: var(--border-strong); color: var(--text); }

.dl { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: 0; }
.dl.up { color: var(--up-text); }
.dl.down { color: var(--down-text); }
.dl.flat { color: var(--text-3); font-weight: 500; }
.kpi .v .dl { font-size: 13px; margin-left: 2px; }
.rk-moves { gap: 18px; }
.rk-moves .dl { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: -2px 0 8px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c); }

.rk-sov { padding: 18px; margin-bottom: 12px; }
.sov-rows { display: grid; gap: 4px; }
.sov-row { display: grid; grid-template-columns: minmax(150px, 230px) minmax(0, 1fr) 56px 70px 80px; align-items: center; gap: 14px; padding: 7px 8px; border-radius: var(--r-sm); font-size: 13px; }
.sov-row.you { background: var(--accent-soft); }
.sov-row .sd { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 500; }
.sov-row .sd img { width: 16px; height: 16px; border-radius: 4px; }
.sov-row .sd em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--accent-text); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 5px; padding: 0 5px; }
.sov-row .sb { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.sov-row .sb i { display: block; height: 100%; border-radius: 99px; background: var(--series); }
.sov-row .sv { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.sov-row .sm { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.sov-row .sm b { color: var(--text); font-weight: 500; }

.pos { display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 7px; border-radius: 7px; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; background: var(--surface-3); color: var(--text); }
.pos.top3 { background: var(--rk-1); color: #fff; }
.pos.top10 { background: var(--rk-2); color: #fff; }
.pos.top30 { background: color-mix(in srgb, var(--rk-3) 22%, transparent); }
.pos.top100 { background: color-mix(in srgb, var(--rk-4) 22%, transparent); }
.pos.none { background: transparent; color: var(--text-3); font-weight: 500; }
:root[data-theme="dark"] .pos.top3, :root[data-theme="dark"] .pos.top10 { color: #0b0b0f; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .pos.top3, :root:where(:not([data-theme="light"])) .pos.top10 { color: #0b0b0f; } }
td.ahead { font-weight: 700; color: var(--text); }
.ahead-key { font-weight: 700; color: var(--text-2); }
td.rk-url { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
td.rk-url a { color: var(--text-2); font-size: 12.5px; }
td.rk-url a:hover { color: var(--accent-text); text-decoration: underline; }
.rk-var { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.rk-var svg { flex: none; margin-top: 1px; color: var(--text-3); }
.rk-var b { color: var(--text); font-weight: 600; }
.rk-page { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--accent-text); word-break: break-all; }
.serp-list li.me { background: var(--accent-soft); }
.serp-list li.rival .d { font-weight: 600; }

.rk-form { padding: 24px; max-width: 860px; }
.rk-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.rk-form .span2 { grid-column: span 2; }
.rk-form .field > span:first-child em { font-style: normal; font-weight: 400; color: var(--text-3); }
.rk-form .field > span:first-child b { font-weight: 500; color: var(--text-3); }
.rk-form textarea.input { height: auto; padding: 10px 12px; line-height: 1.55; resize: vertical; font-family: var(--font); }
.rk-form .segmented { display: flex; }
.rk-form .segmented button { flex: 1; }
.rk-form .form-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.rk-form .cost { justify-content: flex-start; text-align: left; margin: 0; }

.kpi-src { margin-left: auto; font: 500 10.5px var(--mono); padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--text-3); }
.link-btn.inline { padding: 0 2px; font-size: 12.5px; vertical-align: baseline; }
.rk-kpis .kpi .v .rk-moves { display: inline-flex; gap: 8px; margin-left: 4px; }
.rk-kpis .kpi .v .rk-moves .dl { font-size: 14px; }
.bk-rows { display: grid; gap: 3px; margin-top: 8px; }
.bk-row { display: grid; grid-template-columns: 1fr auto 40px; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.bk-row b { font-weight: 600; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.bk-row .dl { font-size: 12px; justify-self: end; }
.bk { display: inline-flex; align-items: center; gap: 6px; }
.bk::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--border-strong)); }
.unchecked { font-size: 12px; font-weight: 500; color: var(--text-3); font-style: italic; white-space: nowrap; }
.m-fields { display: grid; gap: 12px; }
.m-fields .field > span:first-child em { font-style: normal; font-weight: 400; color: var(--text-3); }

/* =================================================================== modal */
.modal-scrim { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 16px; background: rgba(9, 9, 11, .35); backdrop-filter: blur(2px); animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } }
.modal { width: min(480px, 100%); padding: 22px; box-shadow: var(--shadow-lg); animation: enter .2s var(--ease); }
.modal h3 { font-size: 18px; letter-spacing: -0.025em; }
.m-sub { margin: 4px 0 14px; color: var(--text-2); font-size: 13.5px; }
.modal textarea.input { height: auto; padding: 10px 12px; line-height: 1.55; resize: vertical; font-family: var(--font); }
.m-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.m-list { display: grid; gap: 6px; max-height: 340px; overflow-y: auto; }
.m-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); cursor: pointer; text-align: left; transition: border-color .12s, background .12s; }
.m-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.m-item img, .m-item > svg { width: 20px; height: 20px; border-radius: 5px; flex: none; }
.m-item span { display: flex; flex-direction: column; }
.m-item b { font-weight: 600; font-size: 13.5px; }
.m-item em { font-style: normal; font-size: 12px; color: var(--text-3); }
.m-item.new { border-style: dashed; }
.selbar button svg { vertical-align: -2px; margin-right: 4px; }

/* =================================================================== interaction layer */
/* skeletons */
.sk {
  display: inline-block; vertical-align: middle; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.kpi > .sk, .kpi .s .sk, .c-head .sk, .chart-card > .sk, .run-title h1 .sk, .rk-card .sk, .run-title > .sk { display: block; }
.sk-rows { padding: 4px 0; }
.sk-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) 72px 40px 72px 110px; align-items: center; gap: 20px; height: 46px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.sk-row:last-child { border-bottom: 0; }
.sk-row .sk { display: block; }
.sk-row .sk:nth-child(3), .sk-row .sk:nth-child(5) { justify-self: end; }

/* data-source meters */
.src { flex-wrap: wrap; }
.meter { display: block; flex: none; width: calc(100% - 15px); height: 3px; margin: 2px 0 4px 15px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: #0aac23; transition: width .8s var(--ease); }
.meter.warn i { background: #fbb315; }

/* search trigger (sidebar + mobile top bar) */
.side-search {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 34px; padding: 0 7px 0 10px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-3);
  font-size: 13.5px; cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.side-search:hover { border-color: var(--border-strong); background: var(--surface); color: var(--text-2); }
.side-search kbd { margin-left: auto; font-size: 10.5px; }
.top-search { margin-left: auto; }

/* command palette */
.cmdk-scrim { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: rgba(9, 9, 11, .34); backdrop-filter: blur(3px); animation: fadein .12s; }
.cmdk {
  width: min(640px, 100%); max-height: min(560px, 78vh); display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: cmdk-in .2s var(--ease);
}
@keyframes cmdk-in { from { opacity: 0; transform: scale(.97) translateY(-8px); } }
.cmdk-in { display: flex; align-items: center; gap: 10px; padding: 0 14px 0 16px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.cmdk-in input { flex: 1; min-width: 0; height: 54px; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text); }
.cmdk-in input::placeholder { color: var(--text-3); }
.cmdk-list { overflow-y: auto; padding: 6px; scroll-padding: 34px 0 6px; }
.cmdk-g { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.cmdk-it { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 0 10px; border-radius: 9px; cursor: pointer; color: var(--text-2); font-size: 14px; }
.cmdk-it.on { background: var(--surface-3); }
.cmdk-it .ci { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); transition: background .12s, color .12s; }
.cmdk-it.on .ci { background: var(--surface); color: var(--text); }
.cmdk-it .ci img { width: 14px; height: 14px; border-radius: 3px; }
.cmdk-it .cl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 500; }
.cmdk-it .cm { font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cmdk-it mark { background: none; color: var(--accent-text); font-weight: 650; }
.cmdk-empty { padding: 40px 16px; text-align: center; color: var(--text-3); }
.cmdk-foot { display: flex; gap: 18px; padding: 9px 14px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--text-3); }
.cmdk-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* shortcuts sheet */
.sc-list { display: grid; margin-top: 2px; }
.sc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); }
.sc-row:last-child { border-bottom: 0; }
.sc-row span:last-child { display: inline-flex; gap: 4px; }
.sc-row kbd { min-width: 24px; height: 22px; font-size: 11.5px; color: var(--text-2); }

/* home: soft colour glow behind the search box, animated headline, totals line */
.home::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none; left: 50%; top: 250px;
  width: min(940px, 92vw); height: 340px; transform: translateX(-50%);
  background:
    radial-gradient(closest-side at 32% 50%, color-mix(in srgb, var(--series) 15%, transparent), transparent),
    radial-gradient(closest-side at 68% 56%, color-mix(in srgb, var(--i-trans) 11%, transparent), transparent);
  filter: blur(34px); animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translateX(-53%) scale(1); } to { transform: translateX(-47%) scale(1.08); } }
.hero h1 span {
  background: linear-gradient(100deg, var(--text-3) 20%, color-mix(in srgb, var(--series) 75%, var(--text-3)) 50%, var(--text-3) 80%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: sheen 9s ease-in-out infinite;
}
@keyframes sheen { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0% 0; } }
.home-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 0; margin: 24px auto 0; font-size: 13px; color: var(--text-3); }
.home-stats:empty { display: none; }
.home-stats span { display: inline-flex; align-items: center; gap: 5px; }
.home-stats > span + span::before { content: ""; width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); opacity: .6; margin: 0 14px; }
.home-stats [data-count] { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.cmd { transition: border-color .15s, box-shadow .2s, transform .2s var(--ease); }
.cmd.focus { transform: translateY(-1px); }
.btn-go svg { transition: transform .2s var(--ease); }
.btn-go:hover svg { transform: translateX(3px); }

/* entrance: cards rise in sequence, numbers count up, charts draw themselves (once per view) */
.anim > * { animation: rise-in .55s var(--ease) both; }
.anim > :nth-child(2) { animation-delay: .05s; } .anim > :nth-child(3) { animation-delay: .1s; }
.anim > :nth-child(4) { animation-delay: .15s; } .anim > :nth-child(5) { animation-delay: .2s; } .anim > :nth-child(n+6) { animation-delay: .25s; }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } }
.anim .line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s var(--ease) .15s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.anim .area { animation: fadein .8s .45s both; }
.anim .pt, .anim .lbl, .anim .zone, .anim .zone-l { animation: fadein .35s .9s both; }
.anim .bar, .anim .stk { transform-box: fill-box; transform-origin: 50% 100%; animation: grow .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 30ms + .08s); }
@keyframes grow { from { transform: scaleY(0); } }
.anim .dotm { transform-box: fill-box; transform-origin: center; animation: dot-in .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 4ms + .2s); }
@keyframes dot-in { from { transform: scale(0); opacity: 0; } }

/* pointer spotlight on cards */
:is(.kpi, .chart-card, .r-card, .rk-card, .cl-card, .rk-sov):hover {
  background-image: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--accent) 6%, transparent), transparent 65%);
}

/* clickable KPI breakdowns */
.seg button { display: block; height: 100%; border: 0; padding: 0; border-radius: 99px; min-width: 4px; cursor: pointer; transition: opacity .15s, transform .15s var(--ease); }
.seg button:hover { transform: scaleY(1.6); }
.seg.filtering button:not(.on) { opacity: .28; }
.seg-legend button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; font: inherit; color: var(--text-3); cursor: pointer; transition: background .12s, color .12s; }
.seg-legend button::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.seg-legend button:hover:not(:disabled), .seg-legend button.on { background: var(--surface-3); color: var(--text); }
.seg-legend button:disabled { opacity: .5; cursor: default; }
.seg-legend button b { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }
button.bk-row { width: calc(100% + 12px); margin: 0 -6px; padding: 2px 6px; border: 0; border-radius: 6px; background: none; font: inherit; text-align: left; cursor: pointer; transition: background .12s; }
button.bk-row:hover, button.bk-row.on { background: var(--surface-3); }
.kpi .s .link-btn.inline { display: inline; padding: 0; margin: 0; font: inherit; color: var(--text-2); text-align: left; text-decoration: underline dotted color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 3px; border-radius: 3px; }
.kpi .s .link-btn.inline:hover { color: var(--text); background: none; text-decoration-style: solid; }
.kpi .s .link-btn.inline b { color: inherit; font-weight: 600; }
.src b + span { margin-left: auto; color: var(--text-3); font-size: 12px; }
.plot .zone-l { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }

/* keyboard row cursor + drawer stepping */
tbody tr.cur td { background: var(--surface-2); }
tbody tr.cur td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
tbody tr.open td { background: var(--surface-3); }
.dr-nav { display: inline-flex; gap: 2px; margin-left: auto; }
.dr-head .dr-nav .icon-btn, .dr-head .dr-nav ~ .icon-btn { margin-left: 0; }
.drawer .dr-body { animation: fadein .2s; }

/* rank check progress */
.rk-prog { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px 12px; padding: 13px 16px; margin-bottom: 14px; animation: enter .25s var(--ease); }
.rk-prog-ic { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.rk-prog-t { font-size: 13.5px; color: var(--text-2); }
.rk-prog-t b { color: var(--text); font-weight: 600; }
.rk-prog .progress { grid-column: 1 / -1; margin: 0; height: 4px; }
.rk-prog .progress i { background: var(--accent); }
.spin { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; opacity: .85; }

/* toast with a tick for successes; tactile buttons */
.toast { display: flex; align-items: center; gap: 8px; }
.toast .t-ok { color: #53c556; flex: none; }
.btn:active, .side-search:active, .f-chip:active { transform: translateY(1px) scale(.985); }

/* theme switch: circular reveal (View Transitions) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
/* =================================================================== responsive */
@media (max-width: 1500px) { .kd small { display: none; } }
@media (max-width: 1180px) {
  .main { padding: 28px 24px 72px; }
  .run-head { flex-direction: column; align-items: flex-start; }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: 272px; transform: translateX(calc(-100% - 40px)); transition: transform .25s var(--ease); z-index: 45; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(9,9,11,.35); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .topbar { display: flex; align-items: center; gap: 8px; margin: -12px -6px 18px; }
  .main { padding: 18px 16px 72px; }
  .home { padding-top: 2vh; }
  .opt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recent-grid { grid-template-columns: minmax(0, 1fr); }
  .results-head { flex-wrap: wrap; padding-bottom: 10px; }
  .search-sm, .search-sm input { width: 100%; }
  .search-sm kbd { display: none; }
  .cmdk-scrim { padding-top: 7vh; }
  .cmdk-it .cm { display: none; }
  .cmdk-foot { display: none; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .kpi { min-height: 0; }
  .cmd { padding-left: 12px; }
  .btn-go { width: 100%; }
  .run-actions { flex-wrap: wrap; }
  .run-title h1 { font-size: 26px; }
  .search-sm.narrow, .search-sm.narrow input { width: 100%; }
  .tb-sep { display: none; }
  .opt-grid { grid-template-columns: minmax(0, 1fr); }
  .rk-form-grid { grid-template-columns: minmax(0, 1fr); }
  .rk-form .span2 { grid-column: auto; }
  .rk-form .form-foot { flex-direction: column; align-items: stretch; }
  .sov-row { grid-template-columns: minmax(0, 1fr) 70px 48px; }
  .sov-row .sm { display: none; }
  .home-stats { gap: 4px 16px; }
  .home-stats > span + span::before { display: none; }
}
