/* Palette from the Edge mark: deep ink, teal-green and blue. Dark is the default. */
:root {
  --bg: #0e1525;
  --bg-soft: #121b2e;
  --surface: #162036;
  --surface-2: #1c2841;
  --line: #26324d;
  --line-strong: #34436a;
  --text: #e8edf6;
  --muted: #94a1b9;
  --faint: #5d6a85;
  --accent: #34c79c;
  --accent-2: #3b8cf6;
  --accent-ink: #062018;
  --mark: rgba(52, 199, 156, .22);
  --danger: #ff8a7a;
  --code-bg: #0b1120;
  --code-line: #1f2a44;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 12px 32px -18px rgba(0, 0, 0, .6);
  --radius-lg: 16px;
  --radius: 10px;
  --radius-sm: 7px;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-soft: #eef2f9;
  --surface: #ffffff;
  --surface-2: #f2f5fb;
  --line: #dde3ee;
  --line-strong: #c6cfdf;
  --text: #121a2c;
  --muted: #56627a;
  --faint: #9aa5ba;
  --accent: #0d9a72;
  --accent-2: #2563eb;
  --accent-ink: #ffffff;
  --mark: rgba(13, 154, 114, .16);
  --danger: #c2321f;
  --code-bg: #0f1729;
  --code-line: #1f2a44;
  --shadow: 0 1px 2px rgba(18, 26, 44, .05), 0 12px 32px -20px rgba(18, 26, 44, .25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 96px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: var(--mono); font-size: .86em; }
p code, small code, .hint code, li code {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-size: .82em;
}
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.muted { color: var(--muted); }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--muted); font-size: 14px; padding: 6px 10px; border-radius: var(--radius-sm); white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
  color: var(--muted); background: transparent; border: 1px solid transparent; cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface); text-decoration: none; }
@media (max-width: 900px) { .nav { display: none; } .topbar-actions { margin-left: auto; } }

/* ---------- buttons and fields */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  font: 500 15px var(--font); color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #fff); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 6px; }

label { display: block; font-size: 14px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
label output { color: var(--text); font-family: var(--mono); font-size: 13px; margin-left: 4px; }
input, select, textarea {
  width: 100%; font: 15px var(--font); color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px;
}
select { cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 25%, transparent); }
textarea { resize: vertical; line-height: 1.55; }
input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--accent); box-shadow: none; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.field { margin-bottom: 16px; }
.field small { display: block; margin-top: 6px; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--text); white-space: nowrap; }

/* ---------- hero */
.hero { padding: 72px 0 64px; border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center; }
@media (max-width: 960px) { .hero-grid { grid-template-columns: 1fr; gap: 40px; } .hero { padding-top: 48px; } }
h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.08; letter-spacing: -.025em; font-weight: 700; margin: 0 0 20px; max-width: 16ch; }
.lead { font-size: 18px; color: var(--muted); max-width: 52ch; margin: 0 0 24px; }
.hero-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 18px; }
.fineprint { font-size: 14px; color: var(--muted); margin: 0; }

.readalong {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 22px 24px 20px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 500 13px var(--font); color: var(--muted); background: transparent; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip[aria-checked="true"] { color: var(--text); background: var(--surface-2); border-color: var(--accent); }
.readalong-text {
  font-size: clamp(24px, 3vw, 32px); line-height: 1.32; letter-spacing: -.015em; font-weight: 600;
  margin: 26px 0 28px; min-height: 3.96em; color: var(--text);
}
.readalong-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 14px; }

/* Words: dim until spoken, bright once spoken, accent while being spoken. */
.reading span { transition: color .12s; }
.reading.active, .reading.active span { color: var(--faint); }
.reading.active span.done { color: var(--text); }
.reading.active span.on { color: var(--accent); }

/* ---------- sections */
.section { padding: 80px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 640px) { .section { padding: 56px 0; } }
.section-head { max-width: 760px; margin-bottom: 28px; }
h2 { font-size: clamp(26px, 3vw, 32px); letter-spacing: -.02em; line-height: 1.15; margin: 0 0 12px; }
.section-head p { color: var(--muted); margin: 0; }
.split { display: grid; grid-template-columns: 1fr 1.1fr; gap: 48px; align-items: start; }
.split > * { min-width: 0; }
.split > .code { margin-top: 0; position: sticky; top: 84px; }
@media (max-width: 960px) { .split { grid-template-columns: 1fr; gap: 24px; } .split > .code { position: static; } }
.hint { color: var(--muted); font-size: 14px; max-width: 760px; }
.badge {
  display: inline-block; font-size: 14px; padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.playground { display: grid; grid-template-columns: 1.2fr 1fr; }
.pg-text { padding: 24px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.pg-text .grow { flex: 1; display: flex; flex-direction: column; margin-bottom: 0; }
.pg-text textarea { flex: 1; min-height: 220px; }
.pg-voice { padding: 24px; }
.sliders { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
@media (max-width: 860px) {
  .playground { grid-template-columns: 1fr; }
  .pg-text { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 480px) { .sliders { grid-template-columns: 1fr; } }

.alert {
  margin: 16px 0 0; padding: 12px 14px; border-radius: var(--radius);
  color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); white-space: pre-wrap;
}
.result { margin-top: 16px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); }
.stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; }
.stats.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 18px 0; }
.stats.tiles:empty { display: none; }
.stats.tiles div { background: var(--surface); padding: 12px 14px; }
.stats.tiles dd { font-size: 18px; margin-top: 2px; }
@media (max-width: 560px) { .stats.tiles { grid-template-columns: repeat(2, 1fr); } }
.downloads { margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; font-size: 14px; }
.downloads a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); font-family: var(--mono); font-size: 13px; }
.downloads a:hover { border-color: var(--accent); text-decoration: none; }

/* ---------- read-along of the playground */
.karaoke {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 28px 30px; font-size: clamp(20px, 2.4vw, 26px); line-height: 1.55; letter-spacing: -.01em;
  white-space: pre-wrap; font-weight: 500;
}
.karaoke.empty { color: var(--muted); font-size: 17px; font-weight: 400; }
.karaoke span { cursor: pointer; border-radius: 4px; }
.karaoke span:hover { background: var(--mark); }

/* ---------- tabs and panels */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 24px; }
.tabs button {
  font: 500 14px var(--font); color: var(--muted); background: transparent; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 6px 12px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); background: var(--surface); border-color: var(--line); }
.panel { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.panel.empty { padding: 18px; color: var(--muted); }
.panel pre { margin: 0; padding: 16px 18px; max-height: 380px; overflow: auto; white-space: pre-wrap; font-size: 13px; }
.panel .table-wrap { border: 0; border-radius: 0; max-height: 380px; }

/* ---------- tables */
.table-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td.num { text-align: right; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
tr.current td { background: var(--mark) !important; }
.voice-name { font-weight: 600; }
.voice-id { display: block; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.tag { display: inline-block; font-size: 12px; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 999px; padding: 0 7px; margin-left: 6px; vertical-align: 1px; }
.row-btn {
  font: 500 13px var(--font); color: var(--text); background: var(--bg-soft); cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 10px;
}
.row-btn:hover:not(:disabled) { border-color: var(--accent); }
.row-btn:disabled { opacity: .5; }
.filters { display: grid; grid-template-columns: 2fr 1.3fr 1fr auto; gap: 10px; align-items: center; margin-bottom: 14px; }
@media (max-width: 860px) { .filters { grid-template-columns: 1fr 1fr; } .filters input[type="search"] { grid-column: 1 / -1; } }
#voiceShown { display: block; margin-top: 10px; font-size: 13px; }

/* ---------- formats and errors */
.format-list, .error-list { display: grid; gap: 10px; }
.format-item, .error-item {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 14px 16px;
}
.format-item header { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.format-item code { font-size: 13px; }
.format-item .stats { margin-top: 8px; }
.format-item audio { width: 100%; height: 36px; margin-top: 10px; }
.error-list { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.error-item { display: flex; flex-direction: column; gap: 8px; }
.error-item header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.error-item h3 { font-size: 15px; margin: 0; }
.error-item .req { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; }
.error-item .out { font-size: 14px; border-top: 1px solid var(--line); padding-top: 8px; min-height: 2.6em; color: var(--muted); }
.error-item .out b { color: var(--danger); font-family: var(--mono); font-weight: 500; font-size: 13px; }
.error-item .out .meta { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }
.error-item .node { font-size: 12px; color: var(--muted); }
.error-item .node code { color: var(--text); }

.log {
  background: var(--code-bg); color: #c9d3e6; border: 1px solid var(--code-line); border-radius: var(--radius);
  padding: 12px 14px; max-height: 280px; overflow: auto; margin: 12px 0 0; white-space: pre-wrap; font-size: 12.5px;
}

/* ---------- code blocks: always dark, like an editor */
.code { margin-top: 28px; border: 1px solid var(--code-line); border-radius: var(--radius); background: var(--code-bg); overflow: hidden; }
.code-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--code-line); padding: 0 8px 0 4px; }
.code .langs { display: flex; }
.code .langs button {
  font: 500 13px var(--font); color: #8693ad; background: none; border: 0; cursor: pointer;
  padding: 10px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.code .langs button:hover { color: #e8edf6; }
.code .langs button.active { color: #e8edf6; border-bottom-color: var(--accent); }
.code .copy {
  font: 500 12px var(--font); color: #8693ad; background: none; cursor: pointer;
  border: 1px solid var(--code-line); border-radius: 6px; padding: 3px 9px;
}
.code .copy:hover { color: #e8edf6; border-color: #34436a; }
.code pre { scrollbar-color: #34436a var(--code-bg); tab-size: 4; margin: 0; padding: 16px 18px; overflow-x: auto; font-size: 13px; line-height: 1.65; color: #d6deec; }
.code pre code { font-size: inherit; background: none; border: 0; padding: 0; }
.code.compact { margin-top: 0; max-width: 560px; }
.code.compact pre { padding: 12px 16px; }

/* highlight.js tokens */
.hljs-keyword, .hljs-built_in, .hljs-meta .hljs-keyword { color: #c7a2ff; }
.hljs-string, .hljs-meta .hljs-string { color: #7ee2b8; }
.hljs-number, .hljs-literal { color: #f6b26b; }
.hljs-comment { color: #63708b; font-style: italic; }
.hljs-variable, .hljs-template-variable { color: #8cc4ff; }
.hljs-title, .hljs-title.function_, .hljs-title.class_ { color: #7fb6ff; }
.hljs-attr, .hljs-property, .hljs-params { color: #e8edf6; }
.hljs-meta, .hljs-tag, .hljs-name { color: #8cc4ff; }
.hljs-subst { color: #d6deec; }

/* ---------- footer */
.footer { padding: 36px 0; color: var(--muted); font-size: 14px; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.footer-inner a { margin-left: 14px; }
.footer-inner span:first-child a { margin-left: 0; }

/* ---------- player */
.player-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg-soft) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.player-bar[hidden] { display: none; }
.player-inner { max-width: 1160px; margin: 0 auto; padding: 10px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
.player-label { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 0; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-bar audio { height: 38px; flex: 1 1 300px; max-width: 460px; }
.caption { flex: 1 1 240px; font-weight: 500; font-size: 15px; }
@media (max-width: 640px) { .player-inner { padding: 8px 16px; } .caption { display: none; } }
