/* gosuvoice - dark sci-fi theme */
:root {
  --bg: #0b0d12;
  --panel: #151a21;
  --panel-2: #1b222c;
  --line: #263140;
  --text: #e8eef5;
  --muted: #8494a7;
  --cyan: #00ccff;
  --green: #22ff00;
  --red: #ff3333;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app {
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.brand { white-space: nowrap; display: flex; align-items: center; gap: 10px; font-size: 1.05rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.brand strong { color: var(--cyan); font-weight: 700; }
.brand-mark { width: 26px; height: 26px; color: var(--cyan); flex: none; }
.topbar-status { white-space: nowrap; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.topbar-status.on { color: var(--green); }

/* ── Layout ── */
.layout {
  display: grid;
  gap: 12px;
  padding: 12px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "select" "timer" "timeline" "settings";
  max-width: 1280px;
  margin: 0 auto;
}
.select-panel { grid-area: select; }
.timer-panel { grid-area: timer; }
.timeline-panel { grid-area: timeline; }
.settings { grid-area: settings; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid rgba(0, 204, 255, .45);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
}

/* ── Race + strategy ── */
.race-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.race-tab {
  min-height: 52px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.05rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}
.race-tab[aria-pressed="true"] { color: var(--bg); background: var(--cyan); border-color: var(--cyan); }
.race-tab:disabled { opacity: .45; cursor: not-allowed; }

.field-label { display: block; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.select {
  width: 100%;
  min-height: 54px;
  padding: 10px 40px 10px 12px;
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2300ccff' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center / 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.05rem; font-weight: 600;
  appearance: none; -webkit-appearance: none;
  text-overflow: ellipsis;
}
.select:disabled { opacity: .5; }
.select-sm { min-height: 46px; font-size: .95rem; font-weight: 500; }
.select option, .select optgroup { background: var(--panel); color: var(--text); }

/* Strategy picker: current build bar + expandable list */
.build-current {
  width: 100%; min-height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  text-align: left; cursor: pointer;
}
.build-current:disabled { cursor: not-allowed; }
.build-current:disabled .bc-action { visibility: hidden; }
.bc-text { min-width: 0; }
.bc-text .field-label { margin: 0 0 2px; }
.bc-name { display: block; font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.bc-action {
  flex: none; padding: 6px 10px;
  border: 1px solid rgba(0, 204, 255, .5); border-radius: 6px;
  color: var(--cyan); font-size: .8rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
.build-list { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.build-group {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 12px;
  background: rgba(0, 204, 255, .12);
  border-bottom: 1px solid var(--line);
}
.bg-mu { color: var(--cyan); font-weight: 700; letter-spacing: .1em; }
.bg-vs { color: var(--muted); font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; }
.build-row {
  width: 100%; display: block; text-align: left;
  padding: 12px 12px 12px 14px;
  background: transparent; border: 0; border-bottom: 1px solid var(--line);
  border-left: 4px solid transparent;
  cursor: pointer;
}
.build-row:last-child { border-bottom: 0; }
.build-row:hover { background: rgba(0, 204, 255, .06); }
.build-row[aria-selected="true"] { border-left-color: var(--green); background: rgba(34, 255, 0, .09); }
.build-row[aria-selected="true"] .br-name { color: var(--green); }
.br-name { display: block; font-size: 1.08rem; font-weight: 700; line-height: 1.25; }
.br-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: 4px; }
.br-style { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.br-style.macro { color: var(--cyan); }
.br-style.timing { color: #ffb000; }
.br-style.cheese { color: var(--red); }
.br-len { font-size: .8rem; color: var(--muted); }
.br-desc { display: block; margin-top: 4px; font-size: .86rem; line-height: 1.35; color: var(--muted); }
@media (min-width: 900px) { .build-list { max-height: 56vh; overflow-y: auto; } }

/* My builds + paste panel */
.br-style.custom { color: var(--green); }
.my-build { border-bottom: 1px solid var(--line); }
.my-build .build-row { border-bottom: 0; padding-bottom: 6px; }
.my-tools { display: flex; gap: 8px; padding: 0 12px 12px 18px; }
.btn-mini {
  min-height: 40px; padding: 0 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  color: var(--cyan); font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  cursor: pointer;
}
.btn-mini.danger { color: var(--red); }
.build-add {
  width: 100%; min-height: 56px; padding: 10px 14px; text-align: left;
  background: rgba(34, 255, 0, .06); border: 0; border-bottom: 1px solid var(--line);
  color: var(--green); font-size: 1.02rem; font-weight: 700; cursor: pointer;
}
.paste-panel { margin-top: 10px; }
.paste-text {
  display: block; width: 100%; min-height: 220px; resize: vertical;
  padding: 10px 12px;
  background: #080b10; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--mono); font-size: 1rem; line-height: 1.45;
  white-space: pre; overflow: auto;
}
.paste-text::placeholder { color: #55667a; }
.paste-msg { margin: 6px 0 0; font-size: .9rem; min-height: 0; }
.paste-msg.error { color: var(--red); }
.paste-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-top: 10px; }
.about code { font-family: var(--mono); color: var(--text); background: var(--panel-2); padding: 1px 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: .76rem; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.chip.accent { color: var(--cyan); border-color: rgba(0, 204, 255, .5); }
.chip.warn { color: var(--red); border-color: rgba(255, 51, 51, .5); }
a.chip { text-decoration: none; }
.build-desc { margin: 10px 0 0; color: var(--text); font-size: 1rem; }
.lock-note { margin: 8px 0 0; font-size: .82rem; color: var(--muted); }

/* ── Timer ── */
.timer-panel { text-align: center; }
.state-line {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .82rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.timer {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: clamp(4.6rem, 24vw, 9rem);
  line-height: 1;
  letter-spacing: .02em;
  color: #5b6a7c;
  margin: 4px 0 8px;
}
[data-state="running"] .timer { color: var(--green); text-shadow: 0 0 28px rgba(34, 255, 0, .35); }
[data-state="running"] .state-dot { background: var(--green); box-shadow: 0 0 10px var(--green); }
[data-state="running"] .state-line { color: var(--green); }
[data-state="paused"] .timer { color: var(--cyan); }
[data-state="paused"] .state-dot { background: var(--cyan); }
[data-state="countdown"] .timer { color: var(--red); text-shadow: 0 0 28px rgba(255, 51, 51, .4); }
[data-state="countdown"] .state-dot { background: var(--red); }
[data-state="countdown"] .state-line { color: var(--red); }

.next-up {
  display: flex; flex-direction: column; gap: 2px;
  min-height: 78px; justify-content: center;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--cyan);
  border-radius: 8px;
  text-align: left;
}
.next-label { font-family: var(--mono); font-size: .9rem; letter-spacing: .1em; text-transform: uppercase; color: var(--cyan); }
.next-action { font-size: clamp(1.35rem, 5.4vw, 1.9rem); font-weight: 700; line-height: 1.15; }
.next-up.soon { border-left-color: var(--red); }
.next-up.soon .next-label { color: var(--red); }
.next-up.now { border-left-color: var(--green); }
.next-up.now .next-label { color: var(--green); }

.controls { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.btn {
  min-height: 60px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 1.1rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer;
}
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-start { background: var(--green); border-color: var(--green); color: #041100; }
.btn-pause { color: var(--cyan); border-color: rgba(0, 204, 255, .5); }
.btn-reset { color: var(--red); border-color: rgba(255, 51, 51, .5); }
.btn:active:not(:disabled), .btn-small:active, .race-tab:active:not(:disabled) { transform: translateY(1px); filter: brightness(1.15); }

.sync-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.sync-label { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.btn-small {
  min-height: 44px; min-width: 72px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  font-family: var(--mono); font-weight: 700;
  cursor: pointer;
}
.btn-wide { width: 100%; margin-top: 10px; font-family: var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--cyan); border-color: rgba(0, 204, 255, .5); }

/* ── Timeline ── */
.timeline-panel { display: flex; flex-direction: column; padding-bottom: 6px; }
.timeline-head { display: flex; align-items: baseline; justify-content: space-between; }
.timeline-head h2 { margin: 0; font-size: .95rem; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); }
.timeline-head span { font-size: .8rem; color: var(--muted); font-family: var(--mono); }
.timeline-cols, .timeline li {
  display: grid;
  grid-template-columns: 4.8rem 3.4rem minmax(0, 1fr);
  gap: 8px; align-items: center;
}
.timeline-cols { padding: 10px 10px 6px; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.timeline {
  list-style: none; margin: 0; padding: 6px 0;
  position: relative;
  height: 46vh; min-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.timeline li {
  padding: 11px 10px;
  border-left: 4px solid transparent;
  border-radius: 6px;
  font-size: 1.08rem;
}
.timeline .t { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--cyan); font-weight: 700; }
.timeline .sup { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.timeline .act { font-weight: 600; overflow-wrap: anywhere; }
.timeline li.done { opacity: .42; }
.timeline li.done .act { text-decoration: line-through; }
.timeline li.done .t { color: var(--muted); }
.timeline li.next { border-left-color: var(--cyan); background: rgba(0, 204, 255, .07); }
.timeline li.active {
  border-left-color: var(--green);
  background: rgba(34, 255, 0, .1);
  font-size: 1.25rem;
}
.timeline li.active .t, .timeline li.active .act { color: var(--green); }
.timeline .empty { display: block; color: var(--muted); padding: 20px 10px; }

/* ── Settings ── */
.settings summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 10px;
  font-size: .95rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan);
  min-height: 32px;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary::before { content: "+"; font-family: var(--mono); font-size: 1.3rem; width: 1em; text-align: center; }
.settings[open] summary::before { content: "−"; }
.summary-hint { font-size: .72rem; font-weight: 400; letter-spacing: .06em; color: var(--muted); text-transform: none; }
.setting { padding: 14px 0; border-top: 1px solid var(--line); margin-top: 12px; }
.setting + .setting { margin-top: 0; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch-row b { display: block; font-size: 1rem; }
.switch-row small { display: block; color: var(--muted); font-size: .82rem; }
.switch {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 56px; height: 32px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  position: relative; cursor: pointer; margin: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--muted); transition: transform .15s;
}
.switch:checked { background: rgba(34, 255, 0, .18); border-color: var(--green); }
.switch:checked::after { transform: translateX(24px); background: var(--green); }
.slider-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.slider-row input[type="range"] { flex: 1; min-width: 0; height: 32px; accent-color: var(--cyan); }
.slider-row output { font-family: var(--mono); font-weight: 700; color: var(--cyan); min-width: 3.4em; text-align: right; }
.setting .field-label { margin-top: 12px; }
.voice-status { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: .88rem; color: var(--text); }
.hint { margin: 6px 0 0; font-size: .82rem; color: var(--muted); }

/* ── How it works / about ── */
.about {
  max-width: 1280px; margin: 0 auto;
  padding: 8px 16px 28px;
  display: grid; gap: 4px 32px; grid-template-columns: minmax(0, 1fr);
  color: var(--muted); font-size: .88rem; line-height: 1.5;
}
.about h2 { margin: 16px 0 6px; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); }
.about p { margin: 0 0 8px; max-width: 62ch; }
.about ol { margin: 0 0 8px; padding-left: 1.4em; max-width: 62ch; }
.about li { margin-bottom: 2px; }
.about .fine { font-size: .78rem; opacity: .8; }
@media (min-width: 900px) { .about { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px 16px 32px; } }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ── Wide screens: controls left, timeline right ── */
@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
    grid-template-areas: "select timeline" "timer timeline" "settings timeline";
    grid-template-rows: auto auto 1fr;
    align-items: start;
    gap: 16px; padding: 16px;
  }
  .timeline-panel { position: sticky; top: 16px; height: calc(100dvh - 90px); min-height: 480px; }
  .timeline { flex: 1; height: auto; }
  .timeline-cols, .timeline li { grid-template-columns: 7rem 4.5rem minmax(0, 1fr); }
  .timeline-cols { padding-left: 18px; }
  .timeline li { font-size: 1.3rem; padding: 14px 14px; }
  .timeline li.active { font-size: 1.6rem; }
  .timer { font-size: clamp(5rem, 9vw, 8rem); }
}

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