/* ============================================================================
   LLM Eval Roadmap Notes — dark, clean, readable. No external fonts/CDNs.
   Telegram Mini App themeParams are injected onto :root as --tg-* variables and
   mapped onto the app variables below when running inside Telegram.
   ============================================================================ */

:root {
  /* Base palette (used as the default and as Telegram fallbacks). */
  --bg: #0e1116;
  --bg-elev: #151a21;
  --surface: #1b212b;
  --surface-2: #232b37;
  --border: #2a323e;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-faint: #6b7785;
  --accent: #4dabf7;
  --accent-strong: #74c0fc;
  --accent-contrast: #06121f;
  --danger: #f87171;
  --mark-bg: #fde68a;
  --mark-fg: #1a1205;

  /* Node-type accent colors. */
  --type-root: #fbbf24;
  --type-hub: #a78bfa;
  --type-metric: #38bdf8;
  --type-tool: #34d399;
  --type-proc: #fb923c;
  --type-goal: #f472b6;

  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 56px;
  --sidebar-w: 300px;
  --maxw: 860px;

  /* Safe-area insets (Telegram / iOS notch). */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: none;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--topbar-h) + var(--sat));
  padding: var(--sat) max(12px, var(--sar)) 0 max(12px, var(--sal));
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}
.icon-btn:hover { background: var(--surface); color: var(--text); }

.menu-btn { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand img { width: 26px; height: 26px; display: block; }
.brand .brand-sub {
  font-weight: 500;
  font-size: 12px;
  color: var(--text-faint);
  display: none;
}

.spacer { flex: 1 1 auto; }

.search {
  position: relative;
  flex: 0 1 320px;
  min-width: 0;
}
.search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.search .search-ic {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}
.lang-toggle button {
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}
.lang-toggle button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* --------------------------------------------------------------- progress */
.progress {
  position: sticky;
  top: calc(var(--topbar-h) + var(--sat));
  z-index: 20;
  height: 4px;
  background: var(--surface);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--type-tool), var(--accent));
  transition: width 0.35s ease;
}

/* ----------------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + var(--sat) + 4px);
  height: calc(100dvh - var(--topbar-h) - var(--sat) - 4px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 14px 10px calc(24px + var(--sab));
  background: var(--bg);
}

.nav-heading {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 6px 10px;
}

.stage-group { margin-bottom: 6px; }
.stage-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}
.stage-num {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.node-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px 7px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
}
.node-link:hover { background: var(--surface); text-decoration: none; }
.node-link.active {
  background: var(--surface-2);
  box-shadow: inset 2px 0 0 var(--accent);
}
.node-link .nl-title { flex: 1 1 auto; min-width: 0; }
.node-link.done .nl-title { color: var(--text-dim); }

.type-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot, var(--text-faint));
}
.node-link .check {
  flex: none;
  font-size: 12px;
  color: var(--type-tool);
  width: 14px;
  text-align: center;
}

/* node-type dot colors */
.t-root { --dot: var(--type-root); }
.t-hub { --dot: var(--type-hub); }
.t-metric { --dot: var(--type-metric); }
.t-tool { --dot: var(--type-tool); }
.t-proc { --dot: var(--type-proc); }
.t-goal { --dot: var(--type-goal); }

/* ------------------------------------------------------------------- main */
.main {
  min-height: calc(100dvh - var(--topbar-h) - var(--sat));
  padding: 26px max(18px, var(--sar)) calc(60px + var(--sab)) max(18px, var(--sal));
}
.content { max-width: var(--maxw); margin: 0 auto; }

.muted { color: var(--text-dim); }
.center-note { color: var(--text-dim); padding: 40px 0; text-align: center; }

h1, h2, h3 { line-height: 1.25; }
.page-title { font-size: 1.7rem; margin: 0 0 6px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.chip .type-dot { width: 8px; height: 8px; }
.chip.type-chip { color: var(--text); }

.badge-fallback {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: color-mix(in srgb, var(--type-root) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--type-root) 45%, transparent);
  color: var(--type-root);
}

/* status segmented control */
.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 4px 0 22px;
}
.status-row .status-label { font-size: 13px; color: var(--text-faint); }
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}
.segmented button {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  border-right: 1px solid var(--border);
}
.segmented button:last-child { border-right: none; }
.segmented button[aria-pressed="true"] { color: var(--text); }
.segmented button[data-status="not_started"][aria-pressed="true"] { background: var(--surface-2); }
.segmented button[data-status="in_progress"][aria-pressed="true"] {
  background: color-mix(in srgb, var(--type-root) 28%, var(--surface));
  color: #fff;
}
.segmented button[data-status="done"][aria-pressed="true"] {
  background: color-mix(in srgb, var(--type-tool) 30%, var(--surface));
  color: #fff;
}

/* rendered markdown body */
.md { font-size: 1.02rem; }
.md h2 {
  font-size: 1.18rem;
  margin: 1.6em 0 0.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}
.md h3 { font-size: 1.05rem; margin: 1.3em 0 0.4em; }
.md p { margin: 0.7em 0; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: 0.3em 0; }
.md a { word-break: break-word; }
.md code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.md pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
}
.md pre code { background: none; border: none; padding: 0; }
.md blockquote {
  margin: 0.9em 0;
  padding: 2px 14px;
  border-left: 3px solid var(--accent);
  color: var(--text-dim);
}
.md table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }

/* links list */
.links-block { margin-top: 30px; }
.links-block h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}
.link-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.link-item:hover { border-color: var(--accent); text-decoration: none; }
.link-kind {
  flex: none;
  min-width: 52px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  border-radius: 6px;
}
.kind-DOC { background: color-mix(in srgb, var(--type-metric) 22%, transparent); color: var(--type-metric); }
.kind-ART { background: color-mix(in srgb, var(--type-proc) 22%, transparent); color: var(--type-proc); }
.kind-VID { background: color-mix(in srgb, var(--type-goal) 22%, transparent); color: var(--type-goal); }
.link-item .link-label { flex: 1 1 auto; color: var(--text); min-width: 0; }
.link-item .link-host { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.link-item .ext { color: var(--text-faint); flex: none; }

/* home */
.lead { font-size: 1.08rem; color: var(--text-dim); max-width: 640px; }
.section-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin: 30px 0 12px;
}
.progress-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.progress-card .pc-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.progress-card .pc-num { font-size: 1.6rem; font-weight: 700; }
.progress-card .pc-num small { font-size: 1rem; color: var(--text-faint); font-weight: 500; }
.bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--type-tool), var(--accent));
  transition: width 0.35s ease;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.stage-card {
  display: block;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
}
.stage-card:hover { border-color: var(--accent); text-decoration: none; background: var(--surface-2); }
.stage-card .sc-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}
.stage-card .sc-name { font-weight: 600; }
.stage-card .sc-meta { font-size: 12.5px; color: var(--text-faint); }
.stage-card .sc-bar { height: 6px; margin-top: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.stage-card .sc-bar > span { display: block; height: 100%; background: var(--type-tool); }

/* search results */
.result-item {
  display: block;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.result-item:hover { border-color: var(--accent); text-decoration: none; }
.result-item .ri-title { font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.result-item .ri-snippet { color: var(--text-dim); font-size: 14px; }
.result-item mark, .md mark { background: var(--mark-bg); color: var(--mark-fg); border-radius: 3px; padding: 0 2px; }

/* scrim for mobile drawer */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.5);
}

/* ----------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-grid; }
  .brand .brand-sub { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 26;
    width: min(86vw, var(--sidebar-w));
    height: 100dvh;
    padding-top: calc(var(--topbar-h) + var(--sat) + 10px);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; }
}

@media (min-width: 560px) {
  .brand .brand-sub { display: inline; }
}

@media (max-width: 420px) {
  .search { flex-basis: 150px; }
  .brand .brand-name { display: none; }
}
