:root {
  --bg: #0e0c14;
  --surface: #17141f;
  --surface-2: #211c2c;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f7f3ec;
  --muted: #aaa3b9;
  --amber: #ffb547;
  --coral: #ff7a59;
  --magenta: #e2489a;
  --good: #57d6a8;
  --danger: #ff7b7b;
  --spark: linear-gradient(120deg, var(--amber), var(--coral) 55%, var(--magenta));
  --radius: 18px;
  --gutter: 16px;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
}

.screen {
  display: none;
  min-height: 100dvh;
  padding: max(env(safe-area-inset-top), 12px) var(--gutter) max(env(safe-area-inset-bottom), 16px);
  padding-left: max(env(safe-area-inset-left), var(--gutter));
  padding-right: max(env(safe-area-inset-right), var(--gutter));
}

body[data-screen="home"] #home,
body[data-screen="result"] #result {
  display: block;
}

body[data-screen="session"] #session,
body[data-screen="composing"] #composing {
  display: flex;
  flex-direction: column;
}

/* ---------- shared */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe1a1, var(--coral) 55%, var(--magenta));
  box-shadow: 0 0 16px rgba(255, 122, 89, 0.6);
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.icon-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
}

.icon-btn svg circle {
  fill: var(--muted);
  stroke: none;
}

.text-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 600;
  min-height: 44px;
  padding: 0 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 600;
}

.btn.small {
  min-height: 40px;
  padding: 0 14px;
  font-size: 15px;
}

.btn.primary {
  border: 0;
  background: var(--spark);
  color: #1b1020;
}

.btn.big {
  min-height: 60px;
  font-size: 19px;
  padding: 0 28px;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: var(--danger);
}

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

.small {
  font-size: 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.grad {
  background: var(--spark);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.card-title {
  margin: 0 0 2px;
  font-weight: 700;
}

/* ---------- orb */

.orb {
  --level: 0;
  position: relative;
  width: min(60vw, 240px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: transparent;
  padding: 0;
  flex: none;
}

.orb-core,
.orb-ring {
  position: absolute;
  border-radius: 50%;
}

.orb-core {
  inset: 14%;
  background: radial-gradient(circle at 35% 30%, #ffe3a6 0%, var(--amber) 22%, var(--coral) 55%, var(--magenta) 100%);
  box-shadow:
    0 0 60px rgba(255, 122, 89, 0.45),
    inset 0 -10px 30px rgba(120, 20, 80, 0.45);
  transform: scale(calc(0.94 + var(--level) * 0.22));
  transition:
    transform 90ms linear,
    filter 300ms ease;
}

.orb-ring {
  inset: 0;
  border: 2px solid rgba(255, 181, 71, 0.28);
}

.orb[data-state="listening"] .orb-ring {
  border-color: rgba(87, 214, 168, 0.75);
  box-shadow: 0 0 calc(10px + var(--level) * 50px) rgba(87, 214, 168, 0.45);
  transform: scale(calc(1 + var(--level) * 0.08));
  transition: transform 90ms linear;
}

.orb[data-state="speaking"] .orb-core {
  animation: breathe 1.6s ease-in-out infinite;
}

.orb[data-state="thinking"] .orb-ring {
  border: 3px solid transparent;
  border-top-color: var(--amber);
  border-right-color: var(--coral);
  animation: spin 1.1s linear infinite;
}

.orb[data-state="thinking"] .orb-core {
  transform: scale(0.88);
  filter: saturate(0.85) brightness(0.9);
}

.orb[data-state="paused"] .orb-core,
.orb[data-state="idle"] .orb-core {
  transform: scale(0.85);
  filter: grayscale(0.7) brightness(0.7);
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.95);
  }
  50% {
    transform: scale(1.04);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- home */

.hero {
  text-align: center;
  padding: 20px 0 8px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 8.5vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0 auto 26px;
  max-width: 34ch;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.orb-start {
  display: block;
  margin: 0 auto;
}

.orb-start .orb-core {
  animation: breathe 3.2s ease-in-out infinite;
}

.orb-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 800;
  color: #24101e;
  letter-spacing: 0.02em;
}

.topic-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 26px 0 8px;
  padding: 0;
  list-style: none;
}

.topic-list li {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
}

.draft-card {
  display: grid;
  gap: 12px;
  margin: 20px 0 0;
  border-color: rgba(255, 181, 71, 0.35);
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history {
  margin-top: 28px;
}

.history h2,
.remix h2 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.report-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.report-item {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.report-title {
  font-weight: 700;
  font-size: 17px;
}

.report-meta {
  color: var(--muted);
  font-size: 14px;
}

.empty {
  margin: 4px 0 0;
}

.road-note {
  margin: 28px 0 8px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- interview */

.small-brand {
  font-size: 15px;
  color: var(--muted);
}

.small-brand .brand-mark {
  width: 16px;
  height: 16px;
}

.progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.progress li {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.progress li span {
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-2);
  transition: background 400ms ease;
}

.progress li.done {
  color: var(--text);
}

.progress li.done span {
  background: var(--spark);
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 12px 0;
}

.stage .orb {
  margin-bottom: 18px;
}

.status {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.hint {
  margin: 0;
  min-height: 1.3em;
  color: var(--muted);
  font-size: 15px;
}

.question {
  margin: 18px 0 0;
  max-width: 30ch;
  font-size: clamp(20px, 5.6vw, 24px);
  line-height: 1.35;
  font-weight: 600;
}

.heard {
  margin: 12px 0 0;
  max-width: 34ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 10px;
  padding-top: 12px;
}

.controls.single {
  grid-template-columns: 1fr;
}

.ctl {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  font-size: 17px;
  font-weight: 700;
}

.ctl.primary {
  border: 0;
  background: var(--spark);
  color: #1b1020;
  font-size: 18px;
}

.ctl:active,
.btn:active,
.chip:active {
  transform: scale(0.98);
}

.type-bar {
  display: flex;
  gap: 8px;
  padding-top: 8px;
}

.type-bar input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 17px;
}

body.typing .stage .orb {
  width: min(36vw, 140px);
}

/* Typed answers are sent with the Send button, so "Done talking" has no job. */
body.typing #done-btn {
  display: none;
}

body.typing .controls {
  grid-template-columns: 1fr 1fr;
}

/* ---------- composing */

.compose-error {
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 34ch;
}

/* ---------- result */

.result-head {
  padding: 10px 0 18px;
}

.result-head h1 {
  margin: 0 0 18px;
  font-size: clamp(28px, 7.5vw, 36px);
  line-height: 1.15;
}

.play-btn {
  width: 100%;
}

.play-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.play-btn .stop-icon,
.play-btn[data-playing="true"] .play-icon {
  display: none;
}

.play-btn[data-playing="true"] .stop-icon {
  display: inline;
}

.play-btn[data-listening="true"] {
  box-shadow: 0 0 0 3px var(--good);
}

.take-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

select,
.sheet input[type="text"] {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.take-row select {
  flex: 1;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
  margin-bottom: 14px;
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
}

.tab[aria-selected="true"] {
  background: var(--surface-2);
  color: var(--text);
}

.narration {
  display: block;
  width: 100%;
  min-height: 300px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 19px;
  line-height: 1.6;
  resize: none;
  overflow: hidden;
}

.kept {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(87, 214, 168, 0.1);
  color: #a9ecd2;
  font-size: 14px;
  line-height: 1.45;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.actions .btn {
  flex: 1 1 auto;
}

.scene-list,
.transcript {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.scene {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.scene-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.scene-beat {
  color: var(--amber);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scene-time {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.scene-vo {
  margin: 0 0 10px;
  font-size: 17px;
  line-height: 1.5;
}

.scene-notes {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 0;
  font-size: 14px;
}

.scene-notes dt {
  color: var(--muted);
}

.scene-notes dd {
  margin: 0;
}

.bubble {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface);
  max-width: 90%;
}

.bubble.reporter {
  justify-self: end;
  background: var(--surface-2);
}

.bubble .who {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bubble p {
  margin: 0;
  line-height: 1.45;
}

.remix {
  margin: 26px 0 18px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(255, 181, 71, 0.4);
  border-radius: 999px;
  background: transparent;
  color: var(--amber);
  font-weight: 700;
}

#delete-btn {
  width: 100%;
  margin-bottom: 12px;
}

/* ---------- dialogs */

.sheet {
  width: min(560px, 100vw);
  max-width: 100vw;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0 var(--gutter) max(env(safe-area-inset-bottom), 18px);
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  color: var(--text);
}

.sheet::backdrop {
  background: rgba(5, 4, 9, 0.7);
}

.small-sheet {
  margin: auto;
  border-radius: 22px;
  padding: 20px var(--gutter);
}

.small-sheet form {
  display: grid;
  gap: 12px;
}

.error-text {
  margin: 0;
  color: var(--danger);
  font-size: 15px;
}

.small-sheet h2 {
  margin: 0;
}

.sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 8px;
  background: var(--surface);
  z-index: 1;
}

.sheet-head h2 {
  margin: 0;
  font-size: 20px;
}

.sheet-head .text-btn {
  color: var(--amber);
}

fieldset {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
  display: grid;
  gap: 10px;
}

legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.row {
  display: flex;
  gap: 8px;
}

.row select {
  flex: 1;
  min-width: 0;
}

.range {
  display: grid;
  gap: 6px;
  font-size: 15px;
}

.range input {
  width: 100%;
  accent-color: var(--amber);
}

.radio,
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 15px;
}

.radio input,
.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--amber);
  flex: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 40px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 700;
}

.segmented input:checked + span {
  background: var(--bg);
  color: var(--text);
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--amber);
}

.sheet input[type="text"] {
  width: 100%;
}

#clear-reports {
  width: 100%;
  margin-top: 6px;
}

/* ---------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(max(env(safe-area-inset-bottom), 16px) + 90px);
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: #2c2638;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 200ms ease,
    transform 200ms ease;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
