:root {
  --bg: #f6f1ea;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #57534e;
  --border: #d6d3d1;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --talk: #1d4ed8;
  --movies: #7c2d12;
  --danger: #b91c1c;
  --radius: 22px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12100e;
    --surface: #1f1c19;
    --text: #f5f5f4;
    --muted: #a8a29e;
    --border: #44403c;
    --accent: #f97316;
    --accent-text: #1c1917;
    --talk: #3b82f6;
    --movies: #c2410c;
    --danger: #ef4444;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

/* ---------- Home ---------- */

.home {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  gap: 24px;
}

.home h1 {
  margin: 8px 0 0;
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  text-align: center;
}

.choices {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 640px) {
  .choices { grid-template-columns: 1fr; }
}

.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  border-radius: 32px;
  text-decoration: none;
  color: #fff;
  font-size: clamp(40px, 7vw, 80px);
  font-weight: 700;
  min-height: 240px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease;
}

.choice:active { transform: scale(0.98); }
.choice:focus-visible { outline: 6px solid var(--accent); outline-offset: 6px; }
.choice svg { width: clamp(96px, 16vw, 180px); height: auto; }
.choice small { font-size: 0.35em; font-weight: 500; opacity: 0.9; }
.choice.talk { background: var(--talk); }
.choice.movies { background: var(--movies); }

/* ---------- Talk ---------- */

.talk-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom));
  max-width: 1400px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar .spacer { flex: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 20px;
  font-weight: 600;
  text-decoration: none;
}

.pill svg { width: 24px; height: 24px; }

.status {
  font-size: 20px;
  color: var(--muted);
  font-weight: 600;
}

.status.speaking { color: var(--accent); }

.composer {
  position: relative;
  background: var(--surface);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease;
}

.composer:focus-within { border-color: var(--talk); }
.composer.speaking { border-color: var(--accent); }

#text {
  display: block;
  width: 100%;
  min-height: 30vh;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 24px 28px;
  font: inherit;
  font-size: var(--text-size, 44px);
  line-height: 1.3;
  font-weight: 500;
}

#text::placeholder { color: var(--muted); opacity: 0.7; }

.actions {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
}

.big {
  border: 0;
  border-radius: var(--radius);
  padding: 22px 16px;
  font-size: 30px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.big svg { width: 34px; height: 34px; flex: none; }
.big:active { transform: scale(0.98); }
.big:disabled { opacity: 0.45; }

.speak { background: var(--accent); color: var(--accent-text); }
.stop { background: var(--danger); color: #fff; }
.secondary { background: var(--surface); border: 3px solid var(--border); }

.hint {
  margin: -4px 4px 0;
  color: var(--muted);
  font-size: 18px;
}

.hint kbd {
  font: inherit;
  font-weight: 700;
  padding: 1px 8px;
  border: 2px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 8px;
  background: var(--surface);
}

section h2 {
  margin: 8px 4px 10px;
  font-size: 22px;
  color: var(--muted);
  font-weight: 700;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.chip > button {
  border: 0;
  background: transparent;
  padding: 14px 20px;
  font-size: 24px;
  font-weight: 600;
  text-align: left;
}

.chip > button.say:active { background: var(--border); }

.chip > button.icon {
  padding: 14px 14px;
  color: var(--muted);
  border-left: 2px solid var(--border);
}

.chip > button.icon svg { width: 22px; height: 22px; display: block; }

.recent .chip { width: 100%; }
.recent .chip > button.say { flex: 1; }

.empty {
  color: var(--muted);
  font-size: 20px;
  margin: 0 4px;
}

/* ---------- Settings dialog ---------- */

dialog {
  border: 0;
  border-radius: 28px;
  padding: 28px;
  width: min(560px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.5); }

dialog h2 { margin: 0 0 20px; font-size: 30px; }

dialog label {
  display: block;
  font-size: 20px;
  font-weight: 600;
  margin: 18px 0 8px;
}

dialog select,
dialog input[type="range"] {
  width: 100%;
  font-size: 20px;
}

dialog select {
  padding: 12px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

dialog .row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

dialog .row .big { flex: 1; font-size: 22px; padding: 16px; }

.value { color: var(--muted); font-weight: 500; }

@media (max-width: 640px) {
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .speak, .actions .stop { grid-column: 1 / -1; }
  #text { font-size: min(var(--text-size, 44px), 32px); }
}
