:root {
  color-scheme: light dark;
  --font-display: Cardo, Georgia, 'Times New Roman', serif;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --paper: #f5f6f2;
  --surface: #fffefa;
  --surface-muted: #ecefe8;
  --ink: #171614;
  --muted: #62675f;
  --line: #d8d9d1;
  --accent: #2f5d50;
  --accent-strong: #20463d;
  --record: #b3261e;
  --warning: #8f3a20;
  --shadow: 0 14px 32px rgba(20, 18, 14, .08);
  --radius: 8px;
  font-family: var(--font-ui);
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  text-rendering: optimizeLegibility;
}

body::before {
  content: '';
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--warning) 52%, #273f58);
}

.app-shell {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px) clamp(14px, 2.4vw, 24px) 56px;
}

.page-header {
  margin: 0 0 18px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: .88rem;
  font-weight: 700;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(2.2rem, 5vw, 3.7rem);
  line-height: .98;
}

h2 {
  margin: 0 0 12px;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  line-height: 1.08;
}

p {
  margin: 0 0 12px;
}

small,
.muted {
  color: var(--muted);
}

.lead {
  max-width: 58ch;
  font-size: clamp(1rem, 1.8vw, 1.14rem);
}

a {
  color: var(--accent-strong);
  text-decoration-color: color-mix(in srgb, var(--accent-strong) 38%, transparent);
  text-underline-offset: 3px;
  font-weight: 650;
}

a:hover {
  text-decoration-color: currentColor;
}

code {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--surface-muted);
  font-family: var(--font-mono);
  font-size: .92em;
}

.panel,
.card {
  margin: 14px 0;
  padding: clamp(14px, 2.2vw, 22px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 16px;
  align-items: start;
}

.guide-console {
  grid-template-columns: minmax(300px, 1.1fr) minmax(220px, .74fr);
}

.guide-console.is-solo {
  grid-template-columns: minmax(0, 620px);
}

.index-grid {
  grid-template-columns: minmax(260px, 1fr) minmax(220px, .75fr);
}

.control-stack {
  max-width: 500px;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: var(--ink);
  font-weight: 650;
}

.mode-switch {
  max-width: 460px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.mode-switch legend {
  margin: 0 0 6px;
  padding: 0;
  color: var(--ink);
  font-weight: 650;
}

.mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 84%, var(--ink));
  border-radius: var(--radius);
  background: var(--surface);
}

.mode-option {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 42px;
  margin: 0;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}

.mode-option + .mode-option {
  border-left: 1px solid var(--line);
}

.mode-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  opacity: 0;
}

.mode-option:has(input:checked) {
  color: var(--surface);
  background: var(--accent-strong);
}

.mode-option:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: -3px;
}

.mode-option:has(input:disabled) {
  cursor: default;
}

.mode-switch.is-locked .mode-option:not(:has(input:checked)) {
  opacity: .52;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  max-width: 460px;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--line) 84%, var(--ink));
  border-radius: 6px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 6px;
}

.check-row input {
  width: auto;
  min-height: 0;
  max-width: none;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 18px 0 12px;
}

.icon-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--line) 78%, var(--ink));
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(20, 18, 14, .08);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.icon-button:hover:not(:disabled) {
  border-color: color-mix(in srgb, currentColor 38%, var(--line));
  box-shadow: 0 10px 24px rgba(20, 18, 14, .12);
  transform: translateY(-1px);
}

.icon-button:active:not(:disabled) {
  transform: translateY(0);
}

.icon-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 3px;
}

.icon-button:disabled {
  opacity: .42;
  cursor: default;
  box-shadow: none;
}

.icon-button::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 30;
  padding: 5px 8px;
  color: var(--surface);
  background: var(--ink);
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -3px);
  transition: opacity .12s ease, transform .12s ease;
}

.icon-button:hover:not(:disabled)::after,
.icon-button:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.record-button {
  color: var(--record);
}

.play-button {
  color: var(--accent);
}

.icon {
  display: inline-block;
  color: currentColor;
}

.icon-record {
  width: 18px;
  height: 18px;
  background: currentColor;
  border-radius: 50%;
}

.icon-stop {
  width: 18px;
  height: 18px;
  background: currentColor;
  border-radius: 3px;
}

.icon-play {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-left: 17px solid currentColor;
}

.icon-pause {
  width: 19px;
  height: 22px;
  display: inline-flex;
  justify-content: space-between;
}

.icon-pause::before,
.icon-pause::after {
  content: '';
  width: 6px;
  height: 22px;
  background: currentColor;
  border-radius: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status {
  margin: 10px 0;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface-muted);
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 6px;
  white-space: pre-wrap;
}

.status.error {
  color: #5f130e;
  background: #fbe3df;
  border-color: #f0b9b0;
}

.qr-panel {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 10px;
  text-align: center;
}

.solo-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.solo-panel h2 {
  margin-bottom: 10px;
}

.qr {
  display: block;
  width: clamp(148px, 28vw, 280px);
  max-width: 100%;
  max-height: min(44vh, 280px);
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  image-rendering: pixelated;
}

.link-row {
  margin: 0;
}

.meter {
  width: 100%;
  height: 14px;
  overflow: hidden;
  background: #dfe5db;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.meter > div {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--warning));
  transition: width .08s linear;
}

.log {
  height: 220px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  color: #f4f0e8;
  background: #171614;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.transcript {
  min-height: 96px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  background: var(--surface-muted);
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 6px;
  white-space: pre-wrap;
}

.cost {
  color: var(--accent-strong);
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 7vw, 3.7rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 3px;
  padding: 3px 10px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 999px;
}

@media (max-width: 700px) {
  .app-shell {
    padding: 16px 12px 40px;
  }

  .grid,
  .guide-console,
  .index-grid {
    grid-template-columns: 1fr;
  }

  .guide-console.is-solo {
    grid-template-columns: 1fr;
  }

  .control-stack,
  .mode-switch,
  input,
  select {
    max-width: none;
  }

  .qr {
    width: min(64vw, 260px);
    max-height: 36vh;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .app-shell {
    width: 100%;
    padding: 10px 14px 22px;
  }

  .page-header {
    margin-bottom: 8px;
    padding-bottom: 8px;
  }

  .eyebrow {
    margin-bottom: 2px;
    font-size: .76rem;
  }

  h1 {
    margin-bottom: 2px;
    font-size: clamp(1.7rem, 5.8vh, 2.2rem);
  }

  h2 {
    margin-bottom: 8px;
    font-size: 1.18rem;
  }

  .lead {
    font-size: .9rem;
  }

  .panel,
  .card {
    margin: 8px 0;
    padding: 10px;
  }

  .guide-console,
  .index-grid {
    grid-template-columns: minmax(290px, 1fr) minmax(170px, .55fr);
    gap: 10px;
  }

  .guide-console.is-solo {
    grid-template-columns: minmax(270px, 520px);
  }

  label {
    margin: 7px 0 4px;
  }

  .mode-switch {
    margin-bottom: 10px;
  }

  .mode-options {
    max-width: 390px;
  }

  .mode-option {
    min-height: 36px;
    padding: 7px 10px;
  }

  input,
  select {
    min-height: 36px;
    padding: 7px 10px;
  }

  .check-row {
    margin: 10px 0 4px;
  }

  .control-row {
    gap: 10px;
    margin: 10px 0;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .icon-record {
    width: 15px;
    height: 15px;
  }

  .icon-stop {
    width: 15px;
    height: 15px;
  }

  .icon-play {
    border-top-width: 9px;
    border-bottom-width: 9px;
    border-left-width: 14px;
  }

  .icon-pause {
    width: 16px;
    height: 18px;
  }

  .icon-pause::before,
  .icon-pause::after {
    width: 5px;
    height: 18px;
  }

  .status {
    max-height: 5.8rem;
    margin: 8px 0;
    padding: 7px 9px;
    overflow: auto;
  }

  .meter {
    height: 12px;
  }

  .solo-panel {
    margin-top: 10px;
    padding-top: 10px;
  }

  .qr-panel {
    grid-template-columns: minmax(112px, 34vh) minmax(0, 1fr);
    align-items: center;
    justify-items: start;
    gap: 8px 10px;
    text-align: left;
  }

  .qr-panel h2 {
    grid-column: 1 / -1;
    margin: 0;
  }

  .qr-panel .qr {
    grid-row: 2 / span 2;
    width: min(34vh, 150px);
    max-height: 34vh;
    padding: 6px;
  }

  .qr-panel .link-row {
    align-self: end;
  }

  .qr-note {
    display: none;
  }

  .cost {
    font-size: 2rem;
  }

  .transcript {
    min-height: 64px;
    max-height: 122px;
  }

  .log {
    height: 100px;
  }

  small {
    font-size: .76rem;
  }
}

@media (orientation: landscape) and (max-height: 380px) {
  .guide-console,
  .index-grid {
    grid-template-columns: minmax(270px, 1fr) minmax(150px, .45fr);
  }

  .guide-console.is-solo {
    grid-template-columns: minmax(260px, 480px);
  }

  .qr-panel .qr {
    width: min(30vh, 128px);
    max-height: 30vh;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111411;
    --surface: #1c1f1b;
    --surface-muted: #262b24;
    --ink: #f5f2ea;
    --muted: #b9b8ae;
    --line: #3b4239;
    --accent: #86b7a5;
    --accent-strong: #b8d9cd;
    --record: #ff8a80;
    --warning: #d49b72;
    --shadow: 0 16px 34px rgba(0, 0, 0, .28);
  }

  input,
  select {
    background: #171a16;
  }

  .status.error {
    color: #ffe9e5;
    background: #4d1e19;
    border-color: #7f352d;
  }

  .qr {
    background: #fff;
  }

  .meter {
    background: #30362d;
  }

  .log {
    color: #f4f0e8;
    background: #0b0c0a;
  }
}
