:root {
  --ink: #1b2a2e;
  --ink-dim: #5c6b6e;
  --surface: #ffffff;
  --surface-raised: #f4f7f6;
  --border: #dbe3e1;
  --passage: #2f6f5e;
  --mastery: #2f6f5e;
  --mastery-soft: #e7f2ee;
  --barrier: #b3453f;
  --bg: #fbfaf7;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

h1 { font-size: 22px; margin: 0 0 4px; }
.subtitle { color: var(--ink-dim); font-size: 14px; margin: 0 0 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 10px;
}

.card .prompt { font-weight: 600; font-size: 16px; }
.card .answer-reveal { color: var(--passage); font-size: 18px; font-weight: 600; margin-top: 6px; }
.card .answer-reveal .reading { color: var(--ink-dim); font-weight: 400; font-size: 14px; }
.card .example { color: var(--ink-dim); font-size: 13px; font-style: italic; margin-top: 4px; }

/* Furigana. Small, muted, above the kanji; lines that can carry it get a
   little more leading so the reading never collides with the line above.
   A run whose reading is hidden (known kanji, or already mastered) keeps a
   faint dotted underline — the tap affordance — and one tap reveals it. */
.card .answer-reveal, .card .example, .card .subtitle, .drill-hint, .feedback { line-height: 1.9; }
ruby { ruby-position: over; }
ruby rt { font-size: 0.55em; color: var(--ink-dim); font-weight: 400; font-style: normal; letter-spacing: 0; }
ruby.hid rt { display: none; }
ruby.hid {
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: #aab8b5; /* --border was invisible on the bold green answer line */
  text-underline-offset: 3px;
  cursor: pointer;
}
/* Touch: inline kanji is a small target. Pad the hit area out and pull it
   back with negative margin so nothing moves visually; kill iOS text
   selection / double-tap zoom on the tap; give a soft tap tint. */
ruby {
  padding: 6px 3px;
  margin: -6px -3px;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: rgba(47, 111, 94, 0.15);
  border-radius: 4px;
}
.drill-label-read { color: var(--passage); }

.toolbar { display: flex; justify-content: flex-end; margin: -10px 0 10px; }
.btn-quiet {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 13px;
  padding: 8px 4px; /* comfortable tap height, visually light */
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
button { touch-action: manipulation; -webkit-tap-highlight-color: rgba(47, 111, 94, 0.15); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--passage); outline-offset: 2px; }

button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px;
  cursor: pointer;
}

.btn-primary {
  background: var(--passage);
  color: #fff;
  border: none;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  margin-top: 8px;
}

.mode-row { display: flex; gap: 6px; margin-bottom: 20px; }
.mode-row button { flex: 1; }
.mode-row button[aria-pressed="true"] { background: var(--mastery-soft); border-color: var(--mastery); }

.drill-card { text-align: center; padding: 24px; }
.drill-label { color: var(--ink-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.drill-prompt { font-size: 20px; margin: 8px 0 12px; }
.drill-hint { color: var(--ink-dim); opacity: 0.5; min-height: 20px; margin-bottom: 12px; }

input[type="text"] {
  width: 100%;
  text-align: center;
  font-size: 18px;
  padding: 12px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--surface-raised);
}
input[type="text"].correct { border-color: var(--mastery); }
input[type="text"].wrong { border-color: var(--barrier); }

.feedback { min-height: 20px; margin-top: 8px; font-size: 14px; }
.feedback.correct { color: var(--mastery); }
.feedback.wrong { color: var(--barrier); }

.streak-row { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; font-size: 13px; color: var(--ink-dim); }
.streak-dots { display: flex; gap: 5px; }
.streak-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.streak-dot.filled { background: var(--mastery); }

.self-report-row { display: flex; gap: 8px; margin-top: 12px; }
.self-report-row button { flex: 1; }

.wisdom-card {
  margin-top: auto;
  text-align: center;
  padding: 28px 20px;
  background: var(--mastery-soft);
  border: 1px solid var(--mastery);
  border-radius: 8px;
}
.wisdom-card h2 { color: var(--mastery); margin: 0 0 8px; }

.loading, .locked-out {
  margin: auto;
  text-align: center;
  color: var(--ink-dim);
}
