:root {
  --bg: #0a0e14;
  --bg-soft: #0e141d;
  --panel: #111821;
  --panel-2: #151f2b;
  --border: #1e2a38;
  --border-soft: #18222e;
  --text: #e6edf3;
  --text-dim: #8b98a9;
  --text-faint: #5b6a7d;
  --cyan: #8b5cf6;
  --emerald: #34d399;
  --violet: #a78bfa;
  --amber: #fbbf24;
  --rose: #fb7185;
  --orange: #fb923c;
  --slate: #94a3b8;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
}

html[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-soft: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f2f5f9;
  --border: #d8e0ea;
  --border-soft: #e6ebf1;
  --text: #1c2733;
  --text-dim: #5a6b7d;
  --text-faint: #8a99a9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
}

body {
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(139, 92, 246, 0.10), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(167, 139, 250, 0.07), transparent 55%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { color: var(--cyan); font-size: 18px; }
.brand-name { font-size: 18px; letter-spacing: 0.5px; }
.brand-tag { color: var(--text-faint); font-size: 11px; font-weight: 500; }
.brand-name { color: var(--text); }
.brand-name:hover { color: var(--cyan); text-decoration: none; }
.nav { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.nav-link { color: var(--text-dim); font-size: 13px; }
.nav-link.active, .nav-link:hover { color: var(--text); text-decoration: none; }
.nav-dropdown { position: relative; }
button.nav-dropdown-toggle {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--mono);
  cursor: pointer;
  line-height: 1.5;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.nav-caret { font-size: 10px; transition: transform 0.15s ease; }
.nav-dropdown.open .nav-caret { transform: rotate(180deg); }
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 170px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: none;
  flex-direction: column;
  gap: 2px;
}
.nav-dropdown.open .nav-dropdown-menu { display: flex; }
.nav-dropdown-link {
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  display: block;
  white-space: nowrap;
}
.nav-dropdown-link:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav-dropdown-link.active { color: var(--cyan); }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: var(--mono);
  min-width: 32px;
}
.icon-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.icon-btn.active { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 12px rgba(139, 92, 246, 0.3); }

/* ---- Layout ---- */
.page {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  width: 100%;
  max-width: 1600px;
  align-self: center;
  padding: 32px 28px 80px;
}
.route { display: none; }
.route.active { display: block; }

/* ---- Hero ---- */
.hero { margin-bottom: 32px; }
.hero-title {
  font-size: clamp(1.75rem, 5.4vw, 34px);
  margin: 0 0 12px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--text);
}
.hero-title .accent { color: var(--cyan); }
.hero-subtitle { color: var(--text-dim); margin: 0 0 24px; max-width: 820px; }
.hero-subtitle strong { color: var(--cyan); font-weight: 600; }

/* ---- Lens strip ---- */
.lens-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.lens {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
}
.lens:hover { color: var(--text); border-color: var(--text-faint); }
.lens.active { color: #0a0614; background: var(--cyan); border-color: var(--cyan); font-weight: 600; }

/* ---- Workspace ---- */
.workspace {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

/* Prompt panel (API key) */
.prompt-panel textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 12px;
  resize: vertical;
}
.prompt-panel textarea:focus { outline: none; border-color: var(--cyan); }
.examples { margin: 12px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.examples-label { color: var(--text-faint); font-size: 11px; }
.chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.chip:hover { border-color: var(--cyan); color: var(--cyan); }
.chip.active { border-color: var(--cyan); color: var(--cyan); background: color-mix(in srgb, var(--cyan) 14%, transparent); }
.run-btn {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  color: #0a0614;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.run-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.prompt-panel .status-line { margin: 6px 0 0; min-height: 0; }
/* Viewer panel (terminal) */
.viewer-panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.viewer-meta { min-width: 0; }
.viewer-kicker { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--cyan); }
.viewer-title { font-size: 16px; margin: 2px 0 0; }
.viewer-controls { display: flex; gap: 8px; }
.viewer-body { flex: 1; position: relative; min-height: 520px; background: var(--bg-soft); }
.viewer-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.viewer-body .terminal-root { position: absolute; inset: 0; }
.viewer-panel.maximized { position: fixed; inset: 0; z-index: 60; border-radius: 0; border: none; }

/* Share panel */
.share-panel { display: flex; flex-direction: column; gap: 18px; }
.share-block { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.share-title { font-size: 13px; font-weight: 700; margin: 0; color: var(--text); }
.share-desc { color: var(--text-dim); font-size: 12px; margin: 0; }

.share-row { display: flex; gap: 8px; align-items: stretch; }
.share-row .embed-box { flex: 1; }
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  color: #0a0614;
  cursor: pointer;
}
.copy-btn:hover { filter: brightness(1.08); }
.copy-btn svg { width: 16px; height: 16px; }

/* Left column (prompt + share stacked) */
.side-col { display: flex; flex-direction: column; gap: 18px; }

/* Emerald dot */
.dot-emerald { background: var(--emerald); box-shadow: 0 0 10px var(--emerald); }

/* Trace panel */
.trace-list { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.ns-group { margin-top: 2px; }
.ns-group:first-child { margin-top: 0; }
.ns-group-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  padding: 4px 2px 6px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  cursor: pointer;
}
.ns-group-toggle:hover { color: var(--text); }
.ns-group-label { flex: 1; text-align: left; }
.ns-group-count { font-size: 10px; color: var(--text-faint); }
.ns-group-items { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.ns-group.collapsed .ns-group-items { display: none; }
.ns-item {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ns-item-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.ns-chevron { color: var(--text-faint); font-size: 10px; width: 10px; text-align: center; flex: none; }
.ns-name { color: var(--text); font-weight: 600; }
.ns-type {
  margin-left: auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--cyan);
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0 5px;
  white-space: nowrap;
}
.ns-value { color: var(--text-dim); word-break: break-word; white-space: pre-wrap; display: none; }
.ns-item.open .ns-value { display: block; }
.ns-item.new {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 8%, var(--panel-2));
  animation: nsPulse 1.6s ease;
}
@keyframes nsPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--cyan) 45%, transparent); }
  70% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--cyan) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--cyan) 0%, transparent); }
}
.trace-item {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12px;
}
.trace-item .row { display: flex; align-items: center; gap: 8px; }
.trace-item .tool-name { font-weight: 600; }
.trace-item .tool-args { color: var(--text-faint); font-size: 11px; margin-top: 2px; word-break: break-word; }
.trace-item .tool-result { color: var(--text-dim); margin-top: 4px; word-break: break-word; }
.status-item { color: var(--text-faint); font-size: 11px; padding: 2px 0; }
.answer-box { margin-top: 12px; padding: 10px 12px; border-left: 2px solid var(--violet); color: var(--text); font-size: 12px; display: none; }
.answer-box.visible { display: block; }

.embed-box {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  padding: 9px 12px;
}
.embed-box:focus { outline: none; border-color: var(--cyan); }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
}

/* ---- Sections ---- */
.section {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  scroll-margin-top: 80px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.panel-head-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin: 0;
}
.receipt-badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--panel-2);
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-cyan { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.dot-violet { background: var(--violet); box-shadow: 0 0 10px var(--violet); }
.dot.on { animation: pulse 2s ease-in-out infinite; }
.dot.err { background: var(--rose); box-shadow: 0 0 10px var(--rose); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.section-note { color: var(--text-dim); font-size: 12px; margin: 0 0 16px; }
.status-line { margin: 10px 0; font-size: 12px; color: var(--text-faint); min-height: 16px; }
.empty-note { color: var(--text-faint); padding: 18px 4px; font-size: 13px; text-align: center; }
.dim { color: var(--text-faint); }

/* ---- Tabs ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tab {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  cursor: pointer;
}
.tab:hover { color: var(--text); border-color: var(--text-faint); }
.tab.active { color: #04121a; background: var(--cyan); border-color: var(--cyan); font-weight: 600; }

/* ---- Trending list ---- */
.list { display: flex; flex-direction: column; gap: 8px; }
.trend-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  transition: border-color 0.15s, transform 0.15s;
}
.trend-row:hover { border-color: var(--cyan); transform: translateX(2px); }
.trend-rank { width: 26px; flex: none; color: var(--text-faint); font-size: 12px; text-align: right; }
.trend-avatar {
  width: 34px; height: 34px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover;
  background: var(--bg-soft);
}
.trend-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 14px;
}
.trend-main { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; }
.trend-name {
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trend-name:hover { color: var(--cyan); text-decoration: none; }
.trend-sub { color: var(--text-faint); font-size: 11px; }
.trend-badges { display: flex; gap: 6px; flex-wrap: wrap; flex: 0 1 auto; }
.trend-metrics { display: flex; align-items: center; gap: 12px; flex: none; }
.trend-bar {
  width: 90px;
  height: 6px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
}
.trend-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  transition: width 0.6s ease;
}
.trend-dl, .trend-likes { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.trend-likes { color: var(--rose); }

/* ---- Badges ---- */
.badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge-violet { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 45%, transparent); }
.badge-rose { color: var(--rose); border-color: color-mix(in srgb, var(--rose) 45%, transparent); }

/* ---- Controls ---- */
.controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.search {
  flex: 1 1 240px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 9px 12px;
}
.search:focus { outline: none; border-color: var(--cyan); }
.sort-label { color: var(--text-dim); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.sort-label select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 10px;
  cursor: pointer;
}
.sort-label select:focus { outline: none; border-color: var(--cyan); }

/* ---- Filters / toggles ---- */
.filters { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); cursor: pointer; }
.toggle input { accent-color: var(--cyan); cursor: pointer; }

/* ---- Leaderboard table ---- */
.table-wrap { overflow-x: auto; }
.leader-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.leader-table thead th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.leader-table th.num, .leader-table td.num { text-align: right; }
.leader-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.lb-row { cursor: pointer; transition: background 0.12s; }
.lb-row:hover { background: var(--panel-2); }
.lb-name { font-weight: 600; color: var(--text); }
.lb-name-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.intel-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 700;
  color: #04121a;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
}

/* ---- Benchmark bars ---- */
.bars { display: flex; flex-direction: column; }
.bar-row {
  display: grid;
  grid-template-columns: 26px minmax(140px, 300px) 1fr 44px;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s;
}
.bar-row:hover { background: var(--panel-2); }
.bar-rank { color: var(--text-faint); font-size: 11px; text-align: right; }
.bar-name {
  color: var(--text);
  font-weight: 600;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track { height: 6px; border-radius: 999px; background: var(--border-soft); overflow: hidden; }
.bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  transition: width 0.6s ease;
}
.bar-val { color: var(--text-dim); font-size: 12px; text-align: right; }

/* ---- Repos grid ---- */
.repos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.repo-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.repo-card:hover { border-color: var(--cyan); transform: translateY(-2px); text-decoration: none; }
.repo-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.repo-icon { color: var(--cyan); }
.repo-name { font-weight: 700; color: var(--cyan); font-size: 14px; }
.repo-desc { margin: 0; color: var(--text-dim); font-size: 12px; }
.repo-topics { display: flex; flex-wrap: wrap; gap: 6px; }
.repo-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text-faint);
  font-size: 11px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}
.repo-lang { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); }
.lang-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.repo-meta { color: var(--text-dim); }

/* ---- Footer ---- */
.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 20px 28px;
  color: var(--text-faint);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--bg);
}
.footer-links a { color: var(--text-dim); }

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; z-index: 50; display: none; }
.modal.open { display: block; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 12, 0.72);
  backdrop-filter: blur(4px);
}
.modal-dialog {
  position: relative;
  margin: 6vh auto;
  width: min(680px, calc(100vw - 32px));
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-family: var(--mono);
}
.modal-close:hover { color: var(--rose); border-color: var(--rose); }
.modal-title { font-size: 18px; margin: 0 0 2px; padding-right: 30px; }
.modal-sub { color: var(--text-faint); font-size: 12px; margin-bottom: 12px; }
.modal-desc { color: var(--text-dim); font-size: 12.5px; margin: 0 0 16px; }
.modal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-bottom: 16px; }
.kv {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kv span { color: var(--text-faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.kv b { color: var(--text); font-size: 13px; font-weight: 600; }
.modal-section { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip.static {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
}
.modal-links { display: flex; gap: 10px; }
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  color: #04121a;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.link { color: var(--cyan); font-weight: 600; }

/* ---- Docs ---- */
.docs p { color: var(--text-dim); max-width: 880px; margin: 0 0 8px; }
.docs strong { color: var(--cyan); font-weight: 600; }
.docs h3 { font-size: 14px; color: var(--text); margin: 22px 0 8px; font-weight: 600; }
.docs code {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--cyan);
}
.doc-code {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre;
  margin: 8px 0 16px;
}
.doc-code code {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.docs .doc-table { border-collapse: collapse; margin: 8px 0 16px; font-size: 12.5px; }
.docs .doc-table th, .docs .doc-table td { text-align: left; padding: 7px 12px; border: 1px solid var(--border-soft); }
.docs .doc-table th { color: var(--text-faint); font-weight: 600; background: var(--panel-2); }
.docs .doc-table td { color: var(--text-dim); }

/* ---- Docs: examples, buttons, admonitions, toast ---- */

.doc-example { margin: 10px 0 18px; }
.doc-example .doc-code { margin: 0 0 14px; }
.doc-example-actions { display: flex; gap: 8px; }
.doc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 5px 12px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.doc-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.doc-btn.run { color: var(--emerald); }
.doc-btn.run:hover { border-color: var(--emerald); color: var(--emerald); }

.doc-note, .doc-warning, .doc-info {
  border-left: 3px solid var(--cyan);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0 16px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.doc-warning { border-left-color: var(--amber); }
.doc-info { border-left-color: var(--emerald); }
.doc-note strong, .doc-warning strong, .doc-info strong { color: var(--text); }

.doc-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--panel);
  border: 1px solid var(--cyan);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}
.doc-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.docs .panel-head h2 { font-size: 16px; }

/* ---- Docs multi-page layout ---- */
.docs-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 200px;
  gap: 32px;
  align-items: start;
}
.docs-sidebar {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
}
.docs-nav-group { margin-bottom: 18px; }
.docs-nav-group-title {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.docs-nav-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.docs-nav-links a {
  display: block;
  padding: 3px 0;
  color: var(--text-dim);
  font-size: 13px;
}
.docs-nav-links a:hover { color: var(--text); text-decoration: none; }
.docs-nav-links li.active a { color: var(--cyan); }

.docs-sidebar-right {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 4px;
}
.doc-page-actions { display: flex; align-items: center; gap: 6px; }
.doc-more { position: relative; }
.doc-more-toggle { padding: 5px 9px; }
.doc-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 170px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  z-index: 30;
}
.doc-more.open .doc-more-menu { display: flex; }
.doc-more-item {
  background: none;
  border: 0;
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.doc-more-item:hover { color: var(--cyan); background: var(--panel-2); }
.doc-toc { display: flex; flex-direction: column; gap: 6px; }
.doc-toc-list { list-style: disc; margin: 0; padding: 0 0 0 18px; }
.doc-toc-list li { margin: 0 0 4px; }
.doc-toc-list a { color: var(--text-dim); font-size: 12px; }
.doc-toc-list a:hover { color: var(--cyan); text-decoration: none; }

.docs-content { min-width: 0; max-width: 860px; }
.docs-content h1 { font-size: 26px; margin: 0 0 8px; color: var(--text); }
.docs-lead { color: var(--text-dim); font-size: 14px; margin: 0 0 8px; max-width: 760px; }
.leaderboard-title { font-size: 26px; margin: 0 0 8px; color: var(--text); font-weight: 700; }
.docs-content h3 { margin-top: 26px; }

.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 20px; }

/* Tabs */
.doc-tabs {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 10px 0 18px;
}
.doc-tabs-header {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  overflow-x: auto;
}
.doc-tab-btn {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.doc-tab-btn:hover { color: var(--text); }
.doc-tab-btn.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.doc-tab-panel { display: none; padding: 14px; }
.doc-tab-panel.active { display: block; }

/* Animated flow diagram */
.doc-flow { margin: 16px 0; overflow-x: auto; }
.doc-flow svg { width: 100%; min-width: 720px; height: auto; }
.doc-flow-node rect { fill: var(--panel-2); stroke: var(--border); }
.doc-flow-node text { fill: var(--text); font-family: var(--mono); font-size: 12px; }
.doc-flow-node text.doc-flow-sub { fill: var(--text-faint); font-size: 10px; }
.doc-flow-arrow { stroke: var(--cyan); stroke-width: 2; fill: none; stroke-dasharray: 6 6; animation: docDash 1s linear infinite; }
@keyframes docDash { to { stroke-dashoffset: -12; } }
.doc-flow-node { animation: docPulse 3s ease-in-out infinite; }
.doc-flow-node:nth-of-type(2) { animation-delay: 0.4s; }
.doc-flow-node:nth-of-type(3) { animation-delay: 0.8s; }
.doc-flow-node:nth-of-type(4) { animation-delay: 1.2s; }
.doc-flow-node:nth-of-type(5) { animation-delay: 1.6s; }
@keyframes docPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

/* Print */
@media print {
  .topbar, .footer, .docs-sidebar, .doc-actions, .doc-example-actions, .doc-toc, .doc-toast, .controls, .filters, .status-line, .modal { display: none !important; }
  body { background: #fff !important; }
  .page { max-width: none !important; padding: 0 !important; }
  .docs-layout { display: block !important; }
  .docs-content { max-width: none !important; }
  .doc-code, .doc-note, .doc-warning, .doc-info, .doc-tabs { break-inside: avoid; }
}

@media (max-width: 1200px) {
  .docs-layout { grid-template-columns: 200px minmax(0, 1fr); }
  .docs-sidebar-right { display: none; }
}
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-sidebar { position: static; }
}

/* ---- Responsive ---- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 12px; }
  .nav { order: 3; width: 100%; gap: 14px; }
  .trend-row { flex-wrap: wrap; }
  .trend-metrics { width: 100%; justify-content: flex-end; }
  .trend-bar { flex: 1; }
  .bar-row { grid-template-columns: 22px 1fr 44px; }
  .bar-track { grid-column: 1 / -1; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
