/* Errare — dark theme (2026-10-01)
   Ari's call: full dark, no cream backgrounds. Near-black teal surfaces,
   cream text, seafoam/lagoon accents. Fraunces (display serif) + Inter (body/UI).
   Purely visual — class names and structure are unchanged (JS depends on them). */

:root {
  --cream: #FCF4EE;
  --cream-dim: #e8d9c6;
  --bg: #00171b;
  --bg-deep: #000f12;
  --surface: #03262b;
  --surface-2: #063038;
  --teal: #004A54;
  --teal-deep: #013a42;
  --lagoon: #2A7070;
  --seafoam: #60A090;
  --seafoam-bright: #7fc4a8;
  --ink: #FCF4EE;
  --muted: #9fb8b2;
  --line: rgba(96, 160, 144, 0.18);
  --line-soft: rgba(96, 160, 144, 0.1);
  --cta: #1e7a4f;
  --cta-dark: #155c3b;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --shadow-card: 0 2px 6px rgba(0, 0, 0, 0.35), 0 14px 34px rgba(0, 0, 0, 0.28);
  --shadow-cta: 0 6px 18px rgba(21, 92, 59, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  --shadow-glow: 0 0 0 1px rgba(96, 160, 144, 0.12), 0 8px 28px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(96, 160, 144, 0.4); }

.hidden { display: none !important; }

/* ---------- Welcome ---------- */
.screen.welcome {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 28px;
  text-align: center;
  background:
    radial-gradient(130% 85% at 50% -10%, #0b5f6d 0%, var(--teal) 45%, var(--bg-deep) 100%);
  color: var(--cream);
}
.emblem {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(96, 160, 144, 0.5);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 10px rgba(96, 160, 144, 0.08);
}
.tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  color: var(--seafoam);
  margin: 10px 0 0;
  font-size: 20px;
  letter-spacing: 0.01em;
}
.screen.welcome h1 {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: 0.015em;
  margin: 6px 0 26px;
  color: #fff;
}

.cta {
  font-family: var(--font-body);
  background: linear-gradient(180deg, #238a56, var(--cta-dark));
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 16px 38px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: var(--shadow-cta);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.cta:hover { filter: brightness(1.08); }
.cta:active { transform: translateY(1px) scale(0.99); box-shadow: 0 2px 8px rgba(21, 92, 59, 0.4); }
.cta:disabled { opacity: 0.55; cursor: default; transform: none; }

.ghost {
  font-family: var(--font-body);
  background: transparent;
  color: var(--seafoam);
  border: 1.5px solid var(--lagoon);
  border-radius: 999px;
  padding: 11px 26px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
  transition: background 0.12s ease;
}
.ghost:active { background: rgba(96, 160, 144, 0.14); }

/* ---------- Home ---------- */
.screen.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 84px;
  background:
    radial-gradient(120% 60% at 50% -8%, rgba(11, 95, 109, 0.28) 0%, transparent 60%),
    var(--bg);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(180deg, #02333b 0%, var(--bg-deep) 100%);
  color: var(--cream);
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
  border-bottom: 1px solid var(--line-soft);
}
.mark { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.wordmark {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #fff;
}

main { padding: 26px 20px; max-width: 580px; margin: 0 auto; width: 100%; }

.tab h2 {
  font-family: var(--font-display);
  color: #fff;
  margin: 0 0 8px;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.prompt {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: #fff;
  margin: 0 0 6px;
}
.subtitle {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--seafoam);
  font-size: 17px;
  margin: 0 0 18px;
}
.lede { color: var(--muted); margin: 0 0 20px; font-size: 16px; }
.section-title {
  font-family: var(--font-display);
  color: var(--seafoam);
  font-size: 19px;
  font-weight: 600;
  margin: 30px 0 10px;
  letter-spacing: 0.01em;
}

textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 16px;
  line-height: 1.6;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--cream);
  resize: vertical;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea::placeholder { color: #6e8b86; }
textarea:focus {
  outline: none;
  border-color: var(--seafoam);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(96, 160, 144, 0.22);
}

.result {
  margin-top: 16px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--seafoam);
  color: var(--cream);
  font-size: 16px;
  line-height: 1.6;
  box-shadow: var(--shadow-glow);
}
.result .sub { font-size: 13px; color: var(--muted); margin-top: 10px; }

/* Brain feedback: speaking corrections + tap-to-hear */
.result .heard { font-style: italic; margin-bottom: 10px; color: var(--cream-dim); }
.result .correction { margin: 10px 0; }
.result strong { color: #fff; }
.hear-btn {
  font-family: var(--font-body);
  margin-top: 10px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--seafoam);
  background: rgba(96, 160, 144, 0.12);
  color: var(--seafoam-bright);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}
.hear-btn:active { background: rgba(96, 160, 144, 0.28); transform: scale(0.98); }

/* Brain feedback: writing revision */
.rev-block { margin: 12px 0; }
.rev-cap {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 6px;
}
.rev-orig { font-style: italic; color: var(--cream-dim); }
.rev-fixed { font-weight: 600; color: #fff; }
.rev-fixes { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.rev-fixes li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.rev-from { text-decoration: line-through; color: var(--muted); }
.rev-to { font-weight: 700; color: var(--seafoam-bright); }
.rev-why { font-size: 14px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.rev-cheer { margin-top: 12px; font-style: italic; color: var(--seafoam); }

.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.history li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.55;
  box-shadow: var(--shadow-card);
  color: var(--cream);
}
.history li.empty {
  color: var(--muted);
  font-style: italic;
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}
.history .meta { display: block; font-size: 12.5px; color: var(--muted); margin-top: 8px; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-glow);
}
.card .num {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  color: var(--seafoam-bright);
  line-height: 1;
}
.card .lbl { font-size: 13px; color: var(--muted); line-height: 1.4; }

.stat-line { font-size: 16px; margin: 16px 0 20px; color: var(--cream); }
.stat-line strong { color: var(--seafoam-bright); }

/* ---------- Speaking ---------- */
.mic {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, #358585, var(--lagoon));
  font-size: 48px;
  cursor: pointer;
  display: block;
  margin: 22px auto 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.18), 0 0 24px rgba(42, 112, 112, 0.35);
  transition: transform 0.12s ease;
  color: #fff;
}
.mic:active { transform: scale(0.95); }
.mic.recording { background: #b3402e; animation: pulse 1.2s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(179, 64, 46, 0.5); }
  50% { box-shadow: 0 0 0 18px rgba(179, 64, 46, 0); }
}
.hint { text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.65; max-width: 300px; margin: 0 auto; }
.live {
  text-align: center;
  color: var(--seafoam-bright);
  font-size: 17px;
  font-style: italic;
  line-height: 1.55;
  min-height: 1.5em;
  margin: 10px 0 0;
}

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 2px;
  background: rgba(0, 15, 18, 0.98);
  border-top: 1px solid var(--line-soft);
  padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
  z-index: 10;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}
.tabbar button {
  flex: 1;
  background: none;
  border: none;
  color: #8fa9a4;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 10px 2px;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.12s ease, color 0.12s ease;
}
.tabbar button.active { color: #fff; background: rgba(96, 160, 144, 0.22); }

@media (min-width: 480px) {
  .screen.welcome h1 { font-size: 52px; }
  .emblem { width: 200px; height: 200px; }
}
