:root {
  --bg: #0b0f17;
  --bg-gradient: radial-gradient(circle at 18% 0%, rgba(245, 158, 11, 0.08) 0%, transparent 45%), radial-gradient(circle at 85% 10%, rgba(6, 182, 212, 0.06) 0%, transparent 40%);
  --panel: #111827;
  --panel-2: #162032;
  --panel-3: #1f2c42;
  --panel-glass: rgba(17, 24, 39, 0.82);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: #1e293b;
  --line-strong: #334155;
  --accent: #f59e0b;
  --accent-strong: #fbbf24;
  --accent-bg: rgba(245, 158, 11, 0.12);
  --accent-glow: rgba(245, 158, 11, 0.28);
  --cyan: #06b6d4;
  --cyan-bg: rgba(6, 182, 212, 0.12);
  --ok: #10b981;
  --ok-bg: rgba(16, 185, 129, 0.12);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.14);
  --err: #ef4444;
  --err-bg: rgba(239, 68, 68, 0.14);
  --term-bg: #070a0f;
  --term-text: #e2e8f0;
  --focus: #38bdf8;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 36px -4px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Inter", Ubuntu, "Noto Sans", sans-serif;

  /* terminal ANSI palette */
  --a-black: #475569; --a-red: #f87171; --a-green: #34d399; --a-yellow: #fbbf24;
  --a-blue: #60a5fa; --a-magenta: #c084fc; --a-cyan: #38bdf8; --a-white: #cbd5e1;
  --a-bright-black: #64748b; --a-bright-red: #fca5a5; --a-bright-green: #6ee7b7;
  --a-bright-yellow: #fde047; --a-bright-blue: #93c5fd; --a-bright-magenta: #e9d5ff;
  --a-bright-cyan: #67e8f9; --a-bright-white: #f8fafc;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f8fafc;
  --bg-gradient: radial-gradient(circle at 18% 0%, rgba(217, 119, 6, 0.05) 0%, transparent 45%), radial-gradient(circle at 85% 10%, rgba(2, 132, 199, 0.04) 0%, transparent 40%);
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --panel-3: #e2e8f0;
  --panel-glass: rgba(255, 255, 255, 0.88);
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #d97706;
  --accent-strong: #b45309;
  --accent-bg: #fef3c7;
  --accent-glow: rgba(217, 119, 6, 0.22);
  --cyan: #0284c7;
  --cyan-bg: #e0f2fe;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --term-bg: #0f172a;
  --term-text: #f8fafc;
  --focus: #0284c7;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 18px -2px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06);
  --a-black: #1e293b; --a-red: #ef4444; --a-green: #10b981; --a-yellow: #f59e0b;
  --a-blue: #3b82f6; --a-magenta: #a855f7; --a-cyan: #06b6d4; --a-white: #94a3b8;
  --a-bright-black: #475569; --a-bright-red: #dc2626; --a-bright-green: #059669;
  --a-bright-yellow: #d97706; --a-bright-blue: #2563eb; --a-bright-magenta: #9333ea;
  --a-bright-cyan: #0891b2; --a-bright-white: #f1f5f9;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg: #f8fafc;
    --bg-gradient: radial-gradient(circle at 18% 0%, rgba(217, 119, 6, 0.05) 0%, transparent 45%), radial-gradient(circle at 85% 10%, rgba(2, 132, 199, 0.04) 0%, transparent 40%);
    --panel: #ffffff;
    --panel-2: #f1f5f9;
    --panel-3: #e2e8f0;
    --panel-glass: rgba(255, 255, 255, 0.88);
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --accent: #d97706;
    --accent-strong: #b45309;
    --accent-bg: #fef3c7;
    --accent-glow: rgba(217, 119, 6, 0.22);
    --cyan: #0284c7;
    --cyan-bg: #e0f2fe;
    --ok: #059669;
    --ok-bg: #ecfdf5;
    --warn: #d97706;
    --warn-bg: #fffbeb;
    --err: #dc2626;
    --err-bg: #fef2f2;
    --term-bg: #0f172a;
    --term-text: #f8fafc;
    --focus: #0284c7;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 18px -2px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06);
    --a-black: #1e293b; --a-red: #ef4444; --a-green: #10b981; --a-yellow: #f59e0b;
    --a-blue: #3b82f6; --a-magenta: #a855f7; --a-cyan: #06b6d4; --a-white: #94a3b8;
    --a-bright-black: #475569; --a-bright-red: #dc2626; --a-bright-green: #059669;
    --a-bright-yellow: #d97706; --a-bright-blue: #2563eb; --a-bright-magenta: #9333ea;
    --a-bright-cyan: #0891b2; --a-bright-white: #f1f5f9;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  scrollbar-color: var(--line-strong) var(--bg);
}
body {
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  font: 14.5px/1.55 var(--sans);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- header */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 22px;
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.brand {
  font-weight: 750; font-size: 19px;
  color: var(--text); text-decoration: none;
  letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 7px;
  transition: opacity 0.15s ease;
}
.brand:hover { text-decoration: none; opacity: 0.9; }
.bolt {
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent));
  animation: pulseBolt 3s infinite ease-in-out;
}
@keyframes pulseBolt {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px var(--accent)); }
  50% { transform: scale(1.12); filter: drop-shadow(0 0 12px var(--accent-strong)); }
}
.brand-sub {
  font-weight: 600; font-size: 12px;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.top-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

select, input, button, textarea { font: inherit; color: inherit; }
select, input[type="text"], input[type="number"], input[type="search"] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-width: 0;
  color: var(--text);
  transition: all 0.15s ease;
}
input:focus, select:focus {
  border-color: var(--focus);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
  background: var(--panel);
}
#lang {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  padding: 6px 10px;
}
.icon-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; line-height: 1;
  color: var(--text);
  transition: all 0.15s ease;
}
.icon-btn:hover {
  background: var(--panel-3);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.icon-btn:active { transform: translateY(0); }
.menu-btn { display: none; }
.github-btn { color: var(--muted); }
.github-btn:hover { color: var(--text); }

/* ---------------------------------------------------------------- layout */
.layout { display: grid; grid-template-columns: 290px 1fr; min-height: 0; }
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  scrollbar-color: var(--line-strong) var(--panel);
  scrollbar-width: thin;
  position: sticky; top: 57px;
  height: calc(100vh - 57px);
  padding-bottom: 32px;
}
.search-wrap {
  position: sticky; top: 0;
  background: var(--panel);
  padding: 14px 14px 10px;
  z-index: 5;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
}
.search-box {
  position: relative;
  display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 11px;
  font-size: 13px; color: var(--muted);
  pointer-events: none; opacity: 0.8;
}
.search-wrap input {
  width: 100%;
  padding-left: 32px;
  padding-right: 32px;
  font-size: 13px;
  background: var(--panel-2);
}
.search-kbd {
  position: absolute; right: 9px;
  font-family: var(--mono); font-size: 11px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 1px 6px; border-radius: 4px;
  pointer-events: none;
}

/* Nav Toolbar (Folder Controls) */
.nav-toolbar {
  display: flex; gap: 6px; padding: 6px 14px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 40%, transparent);
}
.nav-tool-btn {
  background: none; border: 1px solid var(--line);
  color: var(--muted); font-size: 11.5px; font-weight: 500;
  padding: 3px 8px; border-radius: 6px; cursor: pointer;
  transition: all 0.15s ease;
}
.nav-tool-btn:hover {
  background: var(--panel-2); color: var(--text); border-color: var(--line-strong);
}

/* ---------------------------------------------------------------- Folder Structure */
.nav-group { padding: 4px 10px 4px; }
.nav-folder {
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.nav-folder summary { list-style: none; }
.nav-folder summary::-webkit-details-marker { display: none; }
.nav-folder-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  cursor: pointer; user-select: none;
  border-radius: 7px;
  transition: all 0.15s ease;
  color: var(--text);
}
.nav-folder-head:hover {
  background: var(--panel-2);
}
.nav-folder[open] > .nav-folder-head {
  color: var(--text);
  font-weight: 600;
}
.nav-folder.has-active > .nav-folder-head {
  color: var(--accent-strong);
}
.nav-folder-icon { font-size: 14px; line-height: 1; flex-shrink: 0; }
.nav-folder-title, .nav-group h2 {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-folder-badge {
  font-size: 10.5px; font-family: var(--mono);
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 999px;
  line-height: 1.3;
}
.nav-folder-chevron {
  font-size: 10px; color: var(--muted);
  transition: transform 0.2s ease;
  line-height: 1;
}
.nav-folder:not([open]) .nav-folder-chevron {
  transform: rotate(-90deg);
}
.nav-folder-items {
  margin-left: 12px;
  padding-left: 8px;
  border-left: 1.5px solid color-mix(in srgb, var(--line) 75%, transparent);
  margin-top: 2px;
  margin-bottom: 6px;
  display: flex; flex-direction: column; gap: 2px;
}

/* Nav Items (Commands) */
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 6px 9px; border-radius: 7px; color: var(--text);
  transition: all 0.15s ease;
  position: relative;
}
.nav-item-body { flex: 1; min-width: 0; }
.nav-item:hover {
  background: var(--panel-2);
  transform: translateX(2px);
}
.nav-item[aria-current="page"], .nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-strong);
  font-weight: 600;
}
.nav-item[aria-current="page"]::before, .nav-item.active::before {
  content: "";
  position: absolute; left: -9px; top: 4px; bottom: 4px;
  width: 3px; background: var(--accent); border-radius: 2px;
}
.nav-item .cmd {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  display: block; letter-spacing: -0.01em;
}
.nav-item .desc {
  display: block; font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.nav-tag {
  font-size: 10px;
  background: var(--cyan-bg); color: var(--cyan);
  border: 1px solid color-mix(in srgb, var(--cyan) 35%, transparent);
  border-radius: 4px; padding: 1px 5px;
  text-transform: uppercase; font-weight: 600;
}
.nav-empty { color: var(--muted); padding: 16px 20px; font-size: 13.5px; text-align: center; }

/* ---------------------------------------------------------------- main content */
main {
  padding: 24px clamp(16px, 4vw, 44px) 160px;
  min-width: 0; outline: none;
}
#view { max-width: 980px; }

/* ---------------------------------------------------------------- loading */
.loading {
  max-width: 480px; margin: 12vh auto 0; text-align: center;
  padding: 32px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.spinner {
  width: 42px; height: 42px; margin: 0 auto 20px; border-radius: 50%;
  border: 3.5px solid var(--line);
  border-top-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.steps {
  list-style: none; padding: 0; margin: 0 0 16px;
  text-align: left; display: inline-block; font-size: 14px;
}
.steps li { color: var(--muted); padding: 4px 0; display: flex; align-items: center; gap: 8px; }
.steps li.done { color: var(--ok); font-weight: 500; }
.steps li.done::before { content: "✓"; font-weight: 700; color: var(--ok); }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active::before { content: "›"; color: var(--accent); font-weight: 700; font-size: 16px; }
.steps li.todo::before { content: "·"; font-size: 18px; line-height: 0; }
.loading-note { color: var(--muted); font-size: 13px; margin: 0; }
.loading.failed .spinner { display: none; }

/* ---------------------------------------------------------------- command view */
.crumb {
  color: var(--muted); font-size: 13px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.crumb-icon { font-size: 14px; }
.crumb-sep { opacity: 0.6; }
.crumb-current, .crumb strong { color: var(--accent); font-weight: 600; }
.cmd-title {
  font-family: var(--mono); font-size: 28px; font-weight: 700;
  margin: 0 0 8px; letter-spacing: -0.02em; color: var(--text);
}
.lead { font-size: 16px; margin: 0 0 10px; color: var(--text); opacity: 0.95; }
.help-text { white-space: pre-line; color: var(--muted); margin: 0 0 16px; font-size: 14px; line-height: 1.6; }
.group-help {
  white-space: pre-line; color: var(--muted); font-size: 13.5px;
  border-left: 3px solid var(--accent); padding-left: 12px; margin: 0 0 16px;
  background: var(--panel-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 12px;
}

.examples {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 8px 0 20px;
}
.examples .label {
  color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; margin-right: 4px;
}
.chip {
  font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px; padding: 5px 12px;
  cursor: pointer; color: var(--text);
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.chip:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-strong);
  transform: translateY(-1px);
}
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-strong);
  font-weight: 600;
  box-shadow: 0 0 10px var(--accent-glow);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
form.card { padding: 22px; }
.fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px 20px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label {
  font-weight: 600; font-size: 13.5px;
  display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap;
  color: var(--text);
}
.field .opt {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted); font-weight: 500;
}
.field .req { color: var(--err); font-weight: 700; }
.field .hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.field.invalid input, .field.invalid select {
  border-color: var(--err) !important;
  box-shadow: 0 0 0 3px var(--err-bg);
}
.check { flex-direction: row; align-items: center; gap: 10px; }
.check label { font-weight: 600; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.no-params { color: var(--muted); margin: 0; font-style: italic; }

.cli {
  display: flex; align-items: center; gap: 10px; margin-top: 20px;
  padding: 10px 12px;
  background: var(--term-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 13px; overflow: hidden;
}
.cli code {
  flex: 1; overflow-x: auto; white-space: nowrap;
  color: var(--cyan);
}
.cli .prompt { color: var(--muted); user-select: none; font-weight: 700; }
.small-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 6px; padding: 4px 10px;
  font-size: 12.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap; font-family: var(--sans);
  color: var(--text);
  transition: all 0.15s ease;
}
.small-btn:hover {
  background: var(--panel-3);
  border-color: var(--line-strong);
}

.actions { display: flex; gap: 12px; align-items: center; margin-top: 20px; flex-wrap: wrap; }
.run-btn {
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 80%, black) 100%);
  color: #0b0f17; border: 0; border-radius: var(--radius-sm);
  padding: 10px 26px; font-weight: 700; cursor: pointer; font-size: 15px;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 10px var(--accent-glow);
  transition: all 0.15s ease;
}
.run-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.run-btn:active { transform: translateY(1px); }
.run-btn:disabled { opacity: 0.55; cursor: progress; transform: none; box-shadow: none; }
.kbd-hint { color: var(--muted); font-size: 12.5px; }
.ghost-btn {
  background: none; border: 0; color: var(--muted);
  cursor: pointer; text-decoration: underline; font-size: 13px;
  padding: 6px 10px; border-radius: 6px;
  transition: color 0.15s ease;
}
.ghost-btn:hover { color: var(--text); }

/* ---------------------------------------------------------------- results */
.result { margin-top: 26px; }
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  background: var(--panel-2);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.tab {
  border: 0; background: none; padding: 11px 16px;
  cursor: pointer; color: var(--muted);
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
  font-weight: 600; font-size: 13.5px;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
}
.tab-panel { padding: 20px; }

/* Terminal Console */
.term {
  margin: 0; padding: 16px 18px;
  background: var(--term-bg); color: var(--term-text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: 13px/1.42 var(--mono); overflow-x: auto;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}
.plots { display: grid; gap: 16px; margin-top: 16px; }
.plot {
  background: #ffffff;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; margin: 0;
  box-shadow: var(--shadow-sm);
}
.plot img { width: 100%; height: auto; display: block; }
.plot-bar { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 2px 0; }

.msg {
  border-radius: var(--radius-sm);
  padding: 12px 16px; margin-bottom: 14px;
  white-space: pre-wrap; font-size: 14px; line-height: 1.5;
}
.msg.err {
  background: var(--err-bg); color: var(--err);
  border: 1px solid color-mix(in srgb, var(--err) 40%, transparent);
}
.msg.warn {
  background: var(--warn-bg); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
}

.values { width: 100%; border-collapse: collapse; font-size: 14px; }
.values th, .values td {
  text-align: left; padding: 8px 12px;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
.values th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.values td.num { font-family: var(--mono); white-space: nowrap; color: var(--text); }
.values td.raw { font-family: var(--mono); color: var(--muted); font-size: 12.5px; }
.values-wrap { overflow-x: auto; }
.values-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 8px; }
.json {
  margin: 0; font: 12.5px/1.45 var(--mono); white-space: pre; overflow-x: auto;
  background: var(--term-bg); padding: 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); color: var(--term-text);
}
.panel-bar { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* ANSI to HTML */
.a-bold { font-weight: 700; } .a-dim { opacity: 0.7; } .a-italic { font-style: italic; } .a-underline { text-decoration: underline; }
.a-fg-black { color: var(--a-black); } .a-fg-red { color: var(--a-red); } .a-fg-green { color: var(--a-green); }
.a-fg-yellow { color: var(--a-yellow); } .a-fg-blue { color: var(--a-blue); } .a-fg-magenta { color: var(--a-magenta); }
.a-fg-cyan { color: var(--a-cyan); } .a-fg-white { color: var(--a-white); }
.a-fg-bright-black { color: var(--a-bright-black); } .a-fg-bright-red { color: var(--a-bright-red); }
.a-fg-bright-green { color: var(--a-bright-green); } .a-fg-bright-yellow { color: var(--a-bright-yellow); }
.a-fg-bright-blue { color: var(--a-bright-blue); } .a-fg-bright-magenta { color: var(--a-bright-magenta); }
.a-fg-bright-cyan { color: var(--a-bright-cyan); } .a-fg-bright-white { color: var(--a-bright-white); }
.a-bg-black { background: var(--a-black); } .a-bg-red { background: var(--a-red); } .a-bg-green { background: var(--a-green); }
.a-bg-yellow { background: var(--a-yellow); } .a-bg-blue { background: var(--a-blue); } .a-bg-magenta { background: var(--a-magenta); }
.a-bg-cyan { background: var(--a-cyan); } .a-bg-white { background: var(--a-white); }
.a-bg-bright-black { background: var(--a-bright-black); } .a-bg-bright-red { background: var(--a-bright-red); }
.a-bg-bright-green { background: var(--a-bright-green); } .a-bg-bright-yellow { background: var(--a-bright-yellow); }
.a-bg-bright-blue { background: var(--a-bright-blue); } .a-bg-bright-magenta { background: var(--a-bright-magenta); }
.a-bg-bright-cyan { background: var(--a-bright-cyan); } .a-bg-bright-white { background: var(--a-bright-white); }
.a-fg-default-bg { color: var(--term-bg); } .a-bg-default-fg { background: var(--term-text); }
.a-fg-white[class*="a-bg-"], .a-fg-white[style*="background"],
.a-fg-bright-white[class*="a-bg-"], .a-fg-bright-white[style*="background"] { color: #fff; }

/* ---------------------------------------------------------------- circuit simulator */
.sim-examples { margin: 6px 0 10px; }
.sim-examples > .label { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.sim-examples .examples { display: grid; grid-template-columns: 110px 1fr; align-items: baseline; margin: 0 0 6px; }
.sim-examples .chips { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 600px) {
  .sim-examples .examples { grid-template-columns: 1fr; gap: 4px; margin-bottom: 10px; }
}
.sim-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 4px 0 16px; }
.sim-tools .hint, .netlist .hint { font-size: 12.5px; color: var(--muted); }
.file-btn { cursor: pointer; padding: 6px 12px; font-size: 13.5px; }
.file-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.sim-card { padding: 18px; }
.sim-card h2 { font-size: 15px; margin: 18px 0 8px; }
.sim-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sim-head h2 { margin-top: 0; }
.sim-name { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.term.schematic { line-height: 1.18; font-size: 13px; width: max-content; max-width: 100%; }
.parts { max-width: 640px; }
.parts th[scope="row"] { font-family: var(--mono); color: var(--text); font-size: 13.5px; }
.parts td { vertical-align: middle; }
.parts td.kind { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.parts input { width: 100%; min-width: 120px; font-family: var(--mono); font-size: 13.5px; padding: 5px 8px; }
.parts tr.invalid input { border-color: var(--err); background: var(--err-bg); }
.sim-fields { margin-top: 16px; }
.sim-fields input { font-family: var(--mono); }
.netlist { margin-top: 14px; padding: 4px 18px; }
.netlist summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
.netlist[open] { padding-bottom: 16px; }
.netlist textarea {
  width: 100%; font: 13px/1.45 var(--mono); background: var(--term-bg); color: var(--term-text);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; resize: vertical;
}
.file-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.home-sim {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--accent-bg);
}

/* ---------------------------------------------------------------- schematic editor */
:root { --ed-wire: #3d4450; --ed-grid: #c3c8d0; --ed-bg: #fdfdfe; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ed-wire: #c9d1d9; --ed-grid: #39414c; --ed-bg: #0b0e12; } }
:root[data-theme="dark"] { --ed-wire: #c9d1d9; --ed-grid: #39414c; --ed-bg: #0b0e12; }
.sim-head .seg { margin-left: auto; display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn { border: 0; background: var(--panel); padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn[aria-selected="true"] { background: var(--accent-bg); color: var(--text); font-weight: 600; }
#sim-editor, .ed { margin-top: 10px; scroll-margin-top: 72px; }
.ed-bar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 8px; }
.ed-palette, .ed-tools { display: flex; flex-wrap: wrap; gap: 4px; }
.ed-pal, .ed-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px; min-width: 44px; padding: 3px 5px 2px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 7px; cursor: pointer; font-size: 11px; color: var(--text);
  transition: all 0.15s ease;
}
.ed-pal { cursor: grab; touch-action: none; user-select: none; }
.ed-pal:hover, .ed-btn:hover { border-color: var(--accent); background: var(--accent-bg); }
.ed-pal[aria-pressed="true"], .ed-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-bg); font-weight: 600; }
.ed-btn { flex-direction: row; gap: 5px; min-width: 34px; height: 40px; justify-content: center; font-size: 15px; padding: 0 9px; }
.ed-btn span { font-size: 12.5px; }
.ed-new { font-size: 12.5px; }
.ed-icon { width: 34px; height: 22px; display: block; }
.ed-canvas { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--ed-bg); overflow: hidden; }
.ed-svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; cursor: crosshair; }
.ed-svg:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.ed-svg[data-mode="probe"] { cursor: help; }
.ed-dragging, .ed-dragging * { cursor: grabbing !important; }
.ed-svg .grid { stroke: var(--ed-grid); stroke-width: 2.2; stroke-linecap: round; }
.ed-svg .heads text { font: 9.5px var(--mono); fill: var(--muted); }
.ed-svg .wire { stroke: var(--ed-wire); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ed-svg .wire.on { stroke: var(--accent); stroke-width: 3.5; }
.ed-svg .wire.preview { stroke: var(--accent); stroke-dasharray: 5 4; }
.ed-svg .comp { fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ed-svg .comp .lead, .ed-svg .comp .sign { stroke: var(--ed-wire); }
.ed-svg .comp .fill { fill: currentColor; stroke: none; }
.ed-svg .comp text { stroke: none; fill: currentColor; font: 600 11px var(--mono); }
.ed-svg .comp text .val, .ed-svg .comp text.val { font-weight: 500; fill: var(--muted); }
.ed-svg .k-part { color: var(--a-cyan); stroke: var(--a-cyan); }
.ed-svg .k-src { color: var(--a-yellow); stroke: var(--a-yellow); }
.ed-svg .k-dev { color: var(--a-green); stroke: var(--a-green); }
.ed-svg .k-lbl { color: var(--a-magenta); stroke: var(--a-magenta); }
.ed-svg .k-gnd { color: var(--a-green); stroke: var(--a-green); }
.ed-svg .comp .tag { fill: var(--ed-bg); stroke: currentColor; stroke-width: 1.4; }
.ed-svg .comp .lbl-text { font: 600 10.5px var(--mono); fill: currentColor; }
.ed-svg .comp.probed text.ref, .ed-svg .comp.probed .ref { fill: var(--a-magenta); text-decoration: underline; }
.ed-svg .comp.ghost { opacity: 0.55; pointer-events: none; }
.ed-svg .sel { fill: color-mix(in srgb, var(--accent) 16%, transparent); stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 4 3; }
.ed-svg .dot { fill: var(--ed-wire); }
.ed-svg .open { fill: var(--ed-bg); stroke: var(--err); stroke-width: 1.6; }
.ed-svg .probe { fill: none; stroke: var(--a-magenta); stroke-width: 2.2; }
.ed-svg .volt { font: 600 10.5px var(--mono); fill: var(--a-magenta); paint-order: stroke; stroke: var(--ed-bg); stroke-width: 3px; }
.ed-svg .hover { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.ed-icon .comp, .ed-icon { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ed-icon .lead, .ed-icon .sign { stroke: var(--ed-wire); }
.ed-icon .fill { fill: currentColor; stroke: none; }
.ed-icon .tag { fill: none; stroke: currentColor; }
.ed-icon text { fill: currentColor; stroke: none; font: 700 10px var(--mono); }
.ed-icon.k-part { color: var(--a-cyan); stroke: var(--a-cyan); } .ed-icon.k-src { color: var(--a-yellow); stroke: var(--a-yellow); }
.ed-icon.k-dev { color: var(--a-green); stroke: var(--a-green); } .ed-icon.k-lbl { color: var(--a-magenta); stroke: var(--a-magenta); }
.ed-icon.k-gnd { color: var(--a-green); stroke: var(--a-green); }
.ed-status { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); padding: 6px 2px 0; min-height: 24px; }
.ed-where { font-family: var(--mono); color: var(--text); }
.ed-props { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; min-height: 0; }
.ed-props:not(:empty) { padding: 12px 14px; background: var(--panel-2); border-radius: var(--radius-sm); border: 1px solid var(--line); }
.ed-sel-title { font-weight: 600; font-family: var(--mono); font-size: 13.5px; }
.ed-props .ed-value { font-family: var(--mono); min-width: 160px; flex: 0 1 260px; }
.ed-props .ed-value.bad { border-color: var(--err); }
.ed-props .ed-hint { flex-basis: 100%; font-size: 12.5px; color: var(--muted); order: 9; }
.result.stale > .card { opacity: 0.55; }

/* ---------------------------------------------------------------- modern home */
.home { display: flex; flex-direction: column; gap: 28px; }
.home-hero {
  padding: 8px 0 4px;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 4px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  margin-bottom: 12px;
}
.home h1 {
  font-size: clamp(26px, 3.5vw, 36px); font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  color: var(--text);
  line-height: 1.25;
}
.home .lead { color: var(--muted); max-width: 760px; font-size: 16px; margin: 0 0 16px; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.badge {
  font-size: 12px; color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 12px;
  font-weight: 500;
}

/* Simulator Spotlight Card */
.home-sim-spotlight {
  padding: 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, var(--panel)) 0%, var(--panel) 100%);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  cursor: pointer;
  transition: all 0.2s ease;
}
.home-sim-spotlight:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 28px var(--accent-glow);
  transform: translateY(-2px);
}
.spotlight-pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--accent-strong); background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px; padding: 2px 10px; display: inline-block; margin-bottom: 6px;
}
.home-sim-spotlight h2 { margin: 4px 0 6px; font-size: 20px; color: var(--text); }
.home-sim-spotlight p { margin: 0 0 12px; color: var(--muted); font-size: 14px; max-width: 640px; }
.spotlight-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.spotlight-btn { flex-shrink: 0; padding: 12px 28px; }

/* Sections */
.home-section { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.section-head h2 { font-size: 19px; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.section-desc { font-size: 13.5px; color: var(--muted); margin: 0; }

/* Category Folder Cards */
.home-folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.home-folder-card {
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--panel);
  transition: all 0.15s ease;
}
.home-folder-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.home-folder-head {
  display: flex; align-items: center; gap: 10px;
}
.home-folder-icon { font-size: 22px; flex-shrink: 0; line-height: 1; }
.home-folder-info { flex: 1; min-width: 0; }
.home-folder-title {
  font-size: 14.5px; font-weight: 700; margin: 0;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.home-folder-meta { font-size: 12px; color: var(--muted); }
.home-folder-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.home-folder-chips .chip { font-size: 11.5px; padding: 3px 9px; }

/* Home Grid (Featured Tools) */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.home-card {
  padding: 16px 18px; cursor: pointer; text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  transition: all 0.15s ease;
}
.home-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.home-card .cmd { font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--text); }
.home-card .desc { color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.4; }

/* ---------------------------------------------------------------- footer */
.foot {
  color: var(--muted); font-size: 13px; padding: 16px 24px;
  border-top: 1px solid var(--line); background: var(--panel);
  text-align: center;
}
.foot a { color: var(--text); font-weight: 500; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 820px) {
  .menu-btn { display: inline-flex; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 57px; left: 0; bottom: 0;
    width: min(320px, 86vw); z-index: 40;
    transform: translateX(-100%); transition: transform 0.25s ease;
    height: auto; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .top { padding: 8px 12px; gap: 8px; }
  .top-right { gap: 6px; }
  .github-btn { display: none; }
  .brand { font-size: 17px; }
  .brand-sub { display: none; }
  main { padding-top: 18px; }
  .cmd-title { font-size: 22px; }
  .home-sim-spotlight { flex-direction: column; align-items: flex-start; }
}
