:root {
  --bg: #F7F3F0;
  --surface: #FFFFFF;
  --surface-muted: #EFE8E4;
  --ink: #241B1D;
  --ink-muted: #6B5C58;
  --border: #E3D9D4;

  --brand: #7A2E3A;
  --brand-strong: #5E212B;
  --brand-tint: #F3E4E6;
  --on-brand: #FFFFFF;

  --success: #2F7A4F;
  --success-tint: #E4F2E8;
  --danger: #C0392B;
  --danger-tint: #FBE7E3;
  --warning: #B8862E;
  --warning-tint: #F7EDDA;

  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "URW Palladio", "Book Antiqua", Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(36,27,29,0.06), 0 1px 1px rgba(36,27,29,0.05);
  --shadow-md: 0 4px 16px rgba(36,27,29,0.08), 0 1px 2px rgba(36,27,29,0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1B1416;
    --surface: #251C1F;
    --surface-muted: #2E2225;
    --ink: #F2E9E6;
    --ink-muted: #B9A8A3;
    --border: #3B2C2F;
    --brand: #C97C8C;
    --brand-strong: #E0A0AE;
    --brand-tint: #3A2328;
    --on-brand: #2A1418;
    --success: #5FBE85;
    --success-tint: #1E3327;
    --danger: #E2735C;
    --danger-tint: #3B211D;
    --warning: #D9A85C;
    --warning-tint: #3A2E1A;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
    --shadow-md: 0 6px 20px rgba(0,0,0,0.4);
  }
}
:root[data-theme="dark"] {
  --bg: #1B1416; --surface: #251C1F; --surface-muted: #2E2225; --ink: #F2E9E6; --ink-muted: #B9A8A3;
  --border: #3B2C2F; --brand: #C97C8C; --brand-strong: #E0A0AE; --brand-tint: #3A2328; --on-brand: #2A1418;
  --success: #5FBE85; --success-tint: #1E3327; --danger: #E2735C; --danger-tint: #3B211D;
  --warning: #D9A85C; --warning-tint: #3A2E1A;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35); --shadow-md: 0 6px 20px rgba(0,0,0,0.4);
}
:root[data-theme="light"] {
  --bg: #F7F3F0; --surface: #FFFFFF; --surface-muted: #EFE8E4; --ink: #241B1D; --ink-muted: #6B5C58;
  --border: #E3D9D4; --brand: #7A2E3A; --brand-strong: #5E212B; --brand-tint: #F3E4E6; --on-brand: #FFFFFF;
  --success: #2F7A4F; --success-tint: #E4F2E8; --danger: #C0392B; --danger-tint: #FBE7E3;
  --warning: #B8862E; --warning-tint: #F7EDDA;
  --shadow-sm: 0 1px 2px rgba(36,27,29,0.06), 0 1px 1px rgba(36,27,29,0.05);
  --shadow-md: 0 4px 16px rgba(36,27,29,0.08), 0 1px 2px rgba(36,27,29,0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

.app-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.app-header-inner {
  max-width: 520px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.wordmark { font-family: var(--font-display); font-size: 1.25rem; }
.wordmark em { font-style: normal; color: var(--brand); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-user { font-size: 0.8125rem; color: var(--ink-muted); }
.header-user button {
  border: none; background: none; color: var(--brand); cursor: pointer; font-size: 0.8125rem;
  text-decoration: underline; padding: 0; margin-left: 6px;
}
.theme-toggle {
  font-size: 0.75rem; padding: 5px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); cursor: pointer;
}

/* Bottom padding just clears the fixed pet-companion-wrap (150px stage +
   breathing room) — the Next button is in normal flow now, so it no longer
   needs its own reserved space here. */
.shell { max-width: 520px; margin: 0 auto; padding: 32px 20px 180px; }

.pet-companion-wrap {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 20px;
  background: var(--bg);
}
.screen { display: none; }
.screen.is-active { display: block; }

/* Sign-in */
.signin-card { margin-top: 14vh; text-align: center; }
.signin-card .wordmark { font-size: 2.5rem; text-wrap: balance; }
.tagline { margin: 10px 0 40px; color: var(--ink-muted); font-size: 1.0625rem; }
#googleSignInDiv { display: flex; justify-content: center; margin-bottom: 14px; }
.dev-login-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px;
  background: var(--surface-muted); border: 1px dashed var(--border); border-radius: var(--radius-sm);
  font-size: 0.8125rem; color: var(--ink-muted); cursor: pointer;
}
.fine-print {
  margin-top: 20px; font-size: 0.8125rem; color: var(--ink-muted);
  max-width: 320px; margin-left: auto; margin-right: auto;
}
.auth-error { margin-top: 16px; font-size: 0.8125rem; color: var(--danger); }

/* Dashboard */
.dash-header { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-strong);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; flex-shrink: 0;
}
.dash-header h1 { margin: 0; font-family: var(--font-display); font-size: 1.375rem; font-weight: normal; }
.dash-header p { margin: 2px 0 0; font-size: 0.875rem; color: var(--ink-muted); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 24px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; }
.stat-tile .n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.75rem; font-weight: 600; line-height: 1.1; }
.stat-tile .l { font-size: 0.75rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.stat-tile.accent .n { color: var(--brand); }
.stat-tile.wide { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; }
.stat-tile.wide .l { margin-top: 0; }

.cta-primary {
  width: 100%; padding: 15px 20px; background: var(--brand); color: var(--on-brand); border: none;
  border-radius: var(--radius-sm); font-size: 1rem; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-sm);
}
.cta-primary:hover { background: var(--brand-strong); }
.cta-primary:disabled { opacity: 0.6; cursor: default; }
.cta-sub { text-align: center; font-size: 0.8125rem; color: var(--ink-muted); margin: 10px 0 32px; }

.section-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); margin-bottom: 10px; }
.word-row {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 8px;
}
.word-row .w { font-family: var(--font-display); font-size: 1.0625rem; }
.pill {
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 3px 10px; border-radius: var(--radius-pill); white-space: nowrap;
}
.pill.new { background: var(--surface-muted); color: var(--ink-muted); }
.pill.learning { background: var(--warning-tint); color: var(--warning); }
.pill.review { background: var(--brand-tint); color: var(--brand-strong); }
.pill.proficient { background: var(--success-tint); color: var(--success); }
.pill.paired { background: var(--surface-muted); color: var(--ink); margin: 2px 4px 2px 0; display: inline-block; }
.empty-note { font-size: 0.875rem; color: var(--ink-muted); }

.paired-words { font-size: 0.8125rem; color: var(--ink-muted); margin: -4px 0 10px; }
.paired-words .paired-words-label { margin-right: 6px; }

/* Practice */
.practice-meta { display: flex; justify-content: space-between; font-size: 0.8125rem; color: var(--ink-muted); margin-bottom: 8px; }
.progress-track { height: 6px; background: var(--surface-muted); border-radius: var(--radius-pill); overflow: hidden; margin-bottom: 20px; }
.progress-fill { height: 100%; background: var(--brand); border-radius: var(--radius-pill); width: 0%; }

.exercise-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); padding: 28px 24px;
}
.word-line { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.word-display { font-family: var(--font-display); font-size: 1.875rem; }
.pos-line {
  font-style: italic; color: var(--ink-muted); font-size: 0.875rem;
  margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.prompt { font-size: 1.0625rem; text-wrap: balance; margin-bottom: 20px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  text-align: left; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 0.9375rem; cursor: pointer;
}
.option:hover:not(:disabled) { border-color: var(--brand); }
.option:disabled { cursor: default; }
.option.is-correct { border-color: var(--success); background: var(--success-tint); color: var(--success); font-weight: 600; }
.option.is-incorrect { border-color: var(--danger); background: var(--danger-tint); color: var(--danger); }

.type-row { display: flex; gap: 8px; }
.type-input { flex: 1; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 1rem; }
.type-input.is-correct { border-color: var(--success); background: var(--success-tint); }
.type-input.is-incorrect { border-color: var(--danger); background: var(--danger-tint); }
.btn-check { padding: 12px 18px; border: none; border-radius: var(--radius-sm); background: var(--ink); color: var(--bg); font-size: 0.9375rem; font-weight: 600; cursor: pointer; }

.feedback { display: none; margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-muted); font-size: 0.875rem; color: var(--ink-muted); }
.feedback.is-visible { display: block; }
.feedback.is-correct { background: var(--success-tint); color: var(--success); }
.feedback.is-incorrect { background: var(--danger-tint); color: var(--danger); }

.sentence-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 1rem;
  resize: vertical; margin-bottom: 10px;
}
.sentence-input:disabled { opacity: 0.75; }

.score-meter { margin-top: 14px; }
.score-meter-track { height: 8px; background: var(--surface-muted); border-radius: var(--radius-pill); overflow: hidden; }
.score-meter-fill { height: 100%; background: var(--success); border-radius: var(--radius-pill); width: 0%; }
#sentenceScorePill { background: var(--surface-muted); color: var(--ink-muted); }
#sentenceScorePill.is-proficient { background: var(--success-tint); color: var(--success); }

.btn-next {
  /* Part of the card's normal flow (not fixed) so it can never overlap
     other content — only the puppy companion is allowed to float over the
     page. A long feedback message just pushes this button further down. */
  width: 100%;
  margin-top: 20px;
  padding: 13px 18px; background: var(--brand); color: var(--on-brand);
  border: none; border-radius: var(--radius-sm); font-size: 0.9375rem; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-md);
  display: none;
}
.btn-next.is-visible { display: block; }

/* Summary */
.summary-hero { text-align: center; margin-bottom: 28px; }
.summary-hero h1 { font-family: var(--font-display); font-weight: normal; font-size: 1.75rem; margin: 0 0 6px; }
.summary-hero p { color: var(--ink-muted); margin: 0; }
.newly-proficient { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 30px; }
