/* ============================================================================
   LinguaNote — "Tịch Dương" theme
   A deep-dusk study surface: twilight plum ground, sunset-amber accent.
   Dark by intent — used at dawn and dusk, calm and low-glare, easy on long
   focus sessions. Each language carries its own hue so the brain tells them apart.
   ========================================================================== */

:root {
  /* --- dusk ground & surfaces (OKLCH) --- */
  --bg: oklch(0.21 0.035 295);
  --bg-deep: oklch(0.17 0.03 295);
  --surface: oklch(0.26 0.04 293);
  --surface-2: oklch(0.31 0.045 292);
  --surface-3: oklch(0.36 0.05 291);
  --line: oklch(0.4 0.04 292 / 0.5);
  --line-soft: oklch(0.5 0.03 292 / 0.22);

  /* --- ink --- */
  --ink: oklch(0.96 0.012 85);
  --ink-soft: oklch(0.82 0.02 290);
  --ink-mute: oklch(0.68 0.025 290);

  /* --- sunset accent --- */
  --sun: oklch(0.78 0.155 60);
  --sun-deep: oklch(0.7 0.16 45);
  --rose: oklch(0.72 0.15 18);
  --sun-glow: oklch(0.78 0.155 60 / 0.18);

  /* --- per-language hues --- */
  --en: oklch(0.74 0.12 235); /* cool dusk blue */
  --ko: oklch(0.74 0.15 12); /* hibiscus rose  */
  --ja: oklch(0.78 0.12 150); /* matcha green   */

  /* --- grading --- */
  --again: oklch(0.66 0.16 22);
  --hard: oklch(0.74 0.13 70);
  --good: oklch(0.76 0.12 150);
  --easy: oklch(0.74 0.12 215);

  /* --- type --- */
  --display: "Spectral", "Iowan Old Style", Georgia, serif;
  --body: "Be Vietnam Pro", system-ui, -apple-system, sans-serif;

  /* --- shape & motion --- */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  /* z-scale */
  --z-sheet: 50;
  --z-toast: 70;

  --maxw: 560px;
}

* {
  box-sizing: border-box;
  margin: 0;
}

/* The `hidden` attribute must always win, even over our display:flex/grid rules
   (equal specificity would otherwise let the later class rule override it). */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100dvh;
}

/* slow drifting aurora — the last light over Tịch Dương Thành */
.aurora {
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 70vh;
  z-index: -1;
  background:
    radial-gradient(60% 60% at 20% 0%, oklch(0.7 0.16 45 / 0.22), transparent 70%),
    radial-gradient(55% 55% at 85% 10%, oklch(0.66 0.15 18 / 0.18), transparent 70%),
    radial-gradient(50% 50% at 50% 40%, oklch(0.5 0.1 300 / 0.2), transparent 75%);
  filter: blur(8px);
  animation: drift 26s var(--ease-soft) infinite alternate;
  pointer-events: none;
}
@keyframes drift {
  from {
    transform: translate3d(-2%, -1%, 0) scale(1.05);
  }
  to {
    transform: translate3d(3%, 2%, 0) scale(1.12);
  }
}

/* ----------------------------------------------------------------- screens */
.screen {
  display: none;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.1rem, 4vw, 1.8rem);
  padding-top: max(1.4rem, env(safe-area-inset-top));
  padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
  min-height: 100dvh;
}
.screen[data-active="true"] {
  display: flex;
  flex-direction: column;
  animation: screen-in 0.45s var(--ease) both;
}
@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ----------------------------------------------------------------- home */
.home-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.brand-mark {
  font-size: 1.9rem;
  color: var(--sun);
  filter: drop-shadow(0 0 12px var(--sun-glow));
  line-height: 1;
}
.brand-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.55rem;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.brand-sub {
  font-size: 0.78rem;
  color: var(--ink-mute);
  font-style: italic;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s var(--ease), border-color 0.2s, transform 0.2s var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-soft);
}
.icon-btn:active {
  transform: scale(0.94);
}

.greeting {
  margin: clamp(1.6rem, 6vw, 2.6rem) 0 1.4rem;
}
.greeting-line {
  font-family: var(--display);
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  font-weight: 500;
  line-height: 1.25;
  text-wrap: balance;
  letter-spacing: -0.015em;
}
.greeting-line .accent {
  color: var(--sun);
}
.streak {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-top: 0.9rem;
  padding: 0.4rem 0.85rem;
  background: var(--sun-glow);
  border: 1px solid oklch(0.78 0.155 60 / 0.35);
  border-radius: 100px;
  font-size: 0.9rem;
}
.streak-flame {
  color: var(--sun);
}
#streak-count {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--sun);
}
.streak-label {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* today card */
.today-card {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(1.2rem, 5vw, 1.7rem);
  box-shadow: 0 20px 50px -28px oklch(0.1 0.05 290 / 0.9);
}
.today-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}
.today-head h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.2rem;
}
.today-date {
  font-size: 0.8rem;
  color: var(--ink-mute);
}
.today-metrics {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.3rem;
}
.metric {
  flex: 1;
  text-align: center;
  padding: 0.7rem 0.4rem;
  background: var(--bg-deep);
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
}
.metric-num {
  display: block;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}
.metric:first-child .metric-num {
  color: var(--sun);
}
.metric-label {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-mute);
  margin-top: 0.35rem;
}

.cta {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--sun), var(--sun-deep));
  color: oklch(0.2 0.04 50);
  font-family: var(--body);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  letter-spacing: 0.01em;
  box-shadow: 0 14px 34px -14px var(--sun-deep);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s;
}
.cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px -16px var(--sun-deep);
  filter: brightness(1.05);
}
.cta:active {
  transform: translateY(0) scale(0.99);
}

.today-empty {
  color: var(--ink-soft);
  font-size: 0.92rem;
  text-align: center;
  margin-top: 0.4rem;
  font-style: italic;
}

/* ---- Viên ngọc của hôm nay (gem hero) ---- */
.gem-hero {
  margin: 1.5rem 0 1.5rem;
  padding: 1.3rem 1.4rem;
  background:
    radial-gradient(120% 100% at 100% 0%, var(--sun-glow), transparent 60%),
    linear-gradient(155deg, var(--surface-2), var(--surface));
  border: 1px solid oklch(0.78 0.155 60 / 0.28);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 44px -26px oklch(0.1 0.05 290 / 0.9);
}
.gem-hero-label {
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--sun);
  font-weight: 600;
}
.gem-hero-front {
  font-family: var(--display);
  font-size: clamp(1.9rem, 8vw, 2.6rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-top: 0.5rem;
  text-wrap: balance;
}
.gem-hero-front.is-long {
  font-size: clamp(1.25rem, 4.6vw, 1.55rem);
  font-style: italic;
  font-weight: 500;
  line-height: 1.35;
}
.gem-hero-phon {
  font-size: 1rem;
  color: var(--sun);
  margin-top: 0.2rem;
}
.gem-hero-title {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin-top: 0.5rem;
  text-wrap: pretty;
}
.gem-hero-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}
.gem-hero-play {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 100px;
  background: linear-gradient(135deg, var(--sun), var(--sun-deep));
  color: oklch(0.2 0.04 50);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.18s var(--ease), filter 0.2s;
}
.gem-hero-play .ghp-icon {
  font-size: 0.72rem;
}
.gem-hero-play:hover {
  filter: brightness(1.06);
}
.gem-hero-play:active {
  transform: scale(0.96);
}
.gem-hero-play.playing {
  filter: brightness(1.12);
}
.gem-hero-more {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-family: var(--body);
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0.4rem 0.3rem;
  transition: color 0.2s;
}
.gem-hero-more:hover {
  color: var(--sun);
}

/* ---- bầu trời Tịch Dương (dusk-sky progress) ---- */
.dusk-sky {
  margin: 0.3rem 0 0.7rem;
}
.dusk-sky svg {
  display: block;
}
.dusk-caption {
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-bottom: 1.2rem;
  text-wrap: balance;
}

/* per-language progress */
.lang-progress {
  margin-top: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.lang-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}
.lang-row .flag {
  font-size: 1.3rem;
}
.lang-row .lang-info {
  flex: 1;
  min-width: 0;
}
.lang-row .lang-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.lvl-chip {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--bg-deep);
  background: var(--en);
  border-radius: 6px;
  vertical-align: middle;
}
.lang-row .lang-meta {
  font-size: 0.78rem;
  color: var(--ink-mute);
}
.lang-bar {
  height: 6px;
  border-radius: 100px;
  background: var(--bg-deep);
  margin-top: 0.45rem;
  overflow: hidden;
}
.lang-bar > span {
  display: block;
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s var(--ease);
}
.lang-row[data-lang="en"] .lang-bar > span {
  background: var(--en);
}
.lang-row[data-lang="ko"] .lang-bar > span {
  background: var(--ko);
}
.lang-row[data-lang="ja"] .lang-bar > span {
  background: var(--ja);
}
.lang-row .lang-due {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sun);
  white-space: nowrap;
}

.home-foot {
  margin-top: auto;
  padding-top: 1.8rem;
  text-align: center;
  color: var(--ink-mute);
  font-size: 0.85rem;
}
.text-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: var(--body);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
}
.text-btn:hover {
  color: var(--sun);
}
.dot-sep {
  margin: 0 0.5rem;
  opacity: 0.5;
}

/* ---- kanji panel on home ---- */
.kanji-card {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(150deg, oklch(0.3 0.05 150 / 0.5), var(--surface));
  border: 1px solid oklch(0.78 0.12 150 / 0.3);
  border-radius: var(--r-md);
}
.kanji-glyphs {
  font-family: var(--display);
  font-size: 1.5rem;
  letter-spacing: 0.15em;
  color: var(--ja);
  opacity: 0.85;
  flex-shrink: 0;
}
.kanji-info {
  flex: 1;
  min-width: 0;
}
.kanji-info h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
}
.kanji-sub {
  font-family: var(--body);
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--ink-mute);
  font-style: italic;
}
.kanji-meta {
  font-size: 0.78rem;
  color: var(--ink-mute);
  margin-top: 0.2rem;
}
.kanji-btn {
  flex-shrink: 0;
  padding: 0.6rem 1rem;
  border: 1px solid var(--ja);
  border-radius: var(--r-sm);
  background: oklch(0.78 0.12 150 / 0.14);
  color: var(--ja);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.18s var(--ease);
}
.kanji-btn:hover {
  background: oklch(0.78 0.12 150 / 0.26);
}
.kanji-btn:active {
  transform: scale(0.96);
}

/* ---- kanji on the study card ---- */
.card-front.is-kanji {
  font-size: clamp(5rem, 26vw, 9rem);
  line-height: 1;
  color: var(--ink);
}
.card-hanviet {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ja);
  text-transform: uppercase;
}
.kanji-detail {
  margin-top: 1.1rem;
  text-align: center;
}
.kanji-detail .khv {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ja);
  text-transform: uppercase;
}
.kreadings {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}
.kr {
  font-size: 0.88rem;
  color: var(--ink-soft);
  padding: 0.3rem 0.7rem;
  background: var(--bg-deep);
  border-radius: 100px;
  border: 1px solid var(--line-soft);
}
.kr b {
  color: var(--ja);
  font-weight: 700;
  margin-right: 0.15rem;
}
.kex-list {
  margin-top: 1rem;
  text-align: left;
  border-top: 1px solid var(--line-soft);
  padding-top: 0.9rem;
}
.kex-head {
  font-size: 0.75rem;
  color: var(--ink-mute);
  margin-bottom: 0.5rem;
  text-align: center;
}
.kex {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 0.5rem 0.7rem;
  padding: 0.4rem 0;
}
.kex + .kex {
  border-top: 1px dashed var(--line-soft);
}
.kex-w {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
}
.kex-read {
  font-size: 0.82rem;
  color: var(--sun);
}
.kex-hv {
  grid-column: 2 / 4;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ja);
  text-transform: uppercase;
}
.kex-vi {
  grid-column: 1 / 4;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* ---- word-power gem panel on home ("Sức mạnh của Ngôn từ") ---- */
.gem-card {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(150deg, var(--sun-glow), var(--surface));
  border: 1px solid oklch(0.78 0.155 60 / 0.32);
  border-radius: var(--r-md);
}
.gem-glyph {
  font-size: 1.7rem;
  filter: drop-shadow(0 0 10px var(--sun-glow));
  flex-shrink: 0;
}
.gem-info {
  flex: 1;
  min-width: 0;
}
.gem-info h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
}
.gem-sub {
  font-family: var(--body);
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--ink-mute);
  font-style: italic;
}
.gem-meta {
  font-size: 0.78rem;
  color: var(--ink-mute);
  margin-top: 0.2rem;
}
.gem-btn {
  flex-shrink: 0;
  padding: 0.6rem 1rem;
  border: 1px solid var(--sun);
  border-radius: var(--r-sm);
  background: var(--sun-glow);
  color: var(--sun);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.18s var(--ease);
}
.gem-btn:hover {
  background: oklch(0.78 0.155 60 / 0.28);
}
.gem-btn:active {
  transform: scale(0.96);
}

/* ---- reading panel on home ("Đọc & Ngẫm", Giai đoạn 2) ---- */
.read-card {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(150deg, oklch(0.34 0.06 235 / 0.45), var(--surface));
  border: 1px solid oklch(0.74 0.12 235 / 0.32);
  border-radius: var(--r-md);
}
.read-glyph {
  font-size: 1.7rem;
  filter: drop-shadow(0 0 9px oklch(0.74 0.12 235 / 0.45));
  flex-shrink: 0;
}
.read-info {
  flex: 1;
  min-width: 0;
}
.read-info h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
}
.read-sub {
  font-family: var(--body);
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--ink-mute);
  font-style: italic;
}
.read-meta {
  font-size: 0.78rem;
  color: var(--ink-mute);
  margin-top: 0.2rem;
}
.read-btn {
  flex-shrink: 0;
  padding: 0.6rem 1rem;
  border: 1px solid var(--en);
  border-radius: var(--r-sm);
  background: oklch(0.74 0.12 235 / 0.14);
  color: var(--en);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.18s var(--ease);
}
.read-btn:hover {
  background: oklch(0.74 0.12 235 / 0.26);
}
.read-btn:active {
  transform: scale(0.96);
}

/* ---- reading screen: list of passages + the reader ---- */
.read-screen {
  margin-top: 0.4rem;
}
/* ---- language filter chips above the reading list ---- */
.read-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.read-filter {
  --tile-hue: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.read-filter[data-lang="en"] {
  --tile-hue: var(--en);
}
.read-filter[data-lang="ko"] {
  --tile-hue: var(--ko);
}
.read-filter[data-lang="ja"] {
  --tile-hue: var(--ja);
}
.read-filter:hover {
  color: var(--ink);
  background: var(--surface-3);
}
.read-filter.active {
  color: var(--tile-hue);
  border-color: color-mix(in oklch, var(--tile-hue) 55%, transparent);
  background: color-mix(in oklch, var(--tile-hue) 16%, transparent);
}
.read-filter-n {
  font-size: 0.74rem;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.read-filter.active .read-filter-n {
  color: inherit;
  opacity: 0.8;
}
.read-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.read-tile {
  --tile-hue: var(--en); /* per-language accent, set by [data-lang] below */
  text-align: left;
  width: 100%;
  display: block;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink); /* buttons don't inherit body color — set it so titles aren't black */
  cursor: pointer;
  transition: border-color 0.2s, transform 0.18s var(--ease), background 0.2s;
}
.read-tile[data-lang="ko"] {
  --tile-hue: var(--ko);
}
.read-tile[data-lang="ja"] {
  --tile-hue: var(--ja);
}
.read-tile:hover {
  border-color: color-mix(in oklch, var(--tile-hue) 45%, transparent);
  background: var(--surface-2);
}
.read-tile:active {
  transform: scale(0.99);
}
.read-tile-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}
.read-topic {
  flex-shrink: 0;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tile-hue);
  background: color-mix(in oklch, var(--tile-hue) 13%, transparent);
  border: 1px solid color-mix(in oklch, var(--tile-hue) 30%, transparent);
  padding: 0.12rem 0.5rem;
  border-radius: 100px;
}
.read-tile-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.2;
  color: var(--ink);
}
.read-tile-vi {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 0.1rem;
}
.read-tile-foot {
  font-size: 0.74rem;
  color: var(--ink-mute);
  margin-top: 0.5rem;
}

/* the reader itself */
.reader {
  --tile-hue: var(--en); /* per-language accent, set by [data-lang] below */
}
.reader[data-lang="ko"] {
  --tile-hue: var(--ko);
}
.reader[data-lang="ja"] {
  --tile-hue: var(--ja);
}
.reader-topic {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tile-hue);
}
.reader-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.18;
  margin-top: 0.3rem;
}
.reader-title-vi {
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 0.2rem;
}
.reader-lore {
  margin-top: 0.9rem;
  padding: 0.85rem 1rem;
  background: var(--sun-glow);
  border: 1px solid oklch(0.78 0.155 60 / 0.28);
  border-radius: var(--r-sm);
  font-size: 0.86rem;
  color: var(--ink-soft);
}
.reader-lore::before {
  content: "✦ Ngẫm";
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sun);
  margin-bottom: 0.3rem;
}
.reader-body {
  margin-top: 1.2rem;
}
.reader-para {
  margin-bottom: 0.9rem;
}
.reader-body p {
  font-size: 1.08rem;
  line-height: 1.85;
  margin-bottom: 0;
  color: var(--ink);
}
/* ---- reader toolbar: listen / mask / translate ---- */
.reader-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.1rem;
}
.rd-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.8rem;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.rd-tool:hover {
  color: var(--ink);
  background: var(--surface-3);
}
/* pressed (active) toggle picks up the passage's language hue */
.rd-tool[aria-pressed="true"] {
  color: var(--tile-hue);
  border-color: color-mix(in oklch, var(--tile-hue) 55%, transparent);
  background: color-mix(in oklch, var(--tile-hue) 16%, transparent);
}
.rd-tool.playing {
  color: var(--sun);
  border-color: color-mix(in oklch, var(--sun) 55%, transparent);
  background: var(--sun-glow);
}
/* ---- Vietnamese translation under each paragraph (toggle) ---- */
.reader-vi {
  display: none;
  margin-top: 0.3rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-soft);
  font-style: italic;
  padding-left: 0.7rem;
  border-left: 2px solid color-mix(in oklch, var(--tile-hue) 45%, transparent);
}
.reader-body.show-vi .reader-vi {
  display: block;
}
/* ---- listen-first: mask the original text until anh reveals it ---- */
.reader-body.is-masked .reader-para > p:first-child {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
  transition: filter 0.2s;
}
.reader-hint {
  margin-top: 0.6rem;
  font-size: 0.76rem;
  color: var(--ink-mute);
  text-align: center;
}
/* a glossary word inside the passage: tappable, gently underlined */
.rd-gloss {
  color: var(--tile-hue);
  border-bottom: 1px dashed color-mix(in oklch, var(--tile-hue) 60%, transparent);
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 3px;
}
.rd-gloss:hover,
.rd-gloss.active {
  background: color-mix(in oklch, var(--tile-hue) 18%, transparent);
}

/* ---- grammar used in the passage (Ngữ pháp trong bài) ---- */
.reader-grammar {
  margin-top: 1.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}
.reader-grammar-head {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tile-hue);
  margin-bottom: 0.7rem;
}
.reader-grammar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.rd-gram {
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.rd-gram-point {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--tile-hue);
}
.rd-gram-vi {
  margin-top: 0.25rem;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.rd-gram-ex {
  margin-top: 0.35rem;
  font-size: 0.84rem;
  font-style: italic;
  color: var(--tile-hue);
}

/* ---- lookup bar: slides up when a glossary word is tapped ---- */
.lookup-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-sheet);
  display: flex;
  justify-content: center;
  padding: 0 0.8rem max(0.8rem, env(safe-area-inset-bottom));
  pointer-events: none;
}
.lookup-card {
  pointer-events: auto;
  position: relative;
  width: 100%;
  max-width: var(--maxw);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: 0 -16px 40px -20px oklch(0.1 0.05 290 / 0.9);
  animation: lookup-in 0.26s var(--ease) both;
}
@keyframes lookup-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}
.lookup-close {
  position: absolute;
  top: 0.55rem;
  right: 0.6rem;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--ink-mute);
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: var(--r-sm);
}
.lookup-close:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.lookup-w {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--en);
  padding-right: 2rem;
}
.lookup-ipa {
  font-size: 0.85rem;
  color: var(--ink-mute);
  margin-top: 0.1rem;
}
.lookup-ipa:empty {
  display: none;
}
.lookup-vi {
  font-size: 1rem;
  color: var(--ink);
  margin-top: 0.5rem;
}
.lookup-note {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 0.35rem;
}
.lookup-note:empty {
  display: none;
}
.lookup-play {
  margin-top: 0.8rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--en);
  border-radius: var(--r-sm);
  background: oklch(0.74 0.12 235 / 0.14);
  color: var(--en);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.lookup-play:hover {
  background: oklch(0.74 0.12 235 / 0.26);
}
.lookup-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}
.lookup-actions .lookup-play {
  margin-top: 0;
}
.lookup-save {
  flex: 1;
  min-width: 9rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--sun);
  border-radius: var(--r-sm);
  background: var(--sun-glow);
  color: var(--sun);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.lookup-save:hover:not(:disabled) {
  background: oklch(0.78 0.155 60 / 0.28);
}
.lookup-save:disabled {
  border-color: var(--line);
  background: transparent;
  color: var(--ink-mute);
  cursor: default;
}

/* ---- prosody panel on home ("Luyện ngữ điệu", Giai đoạn 2) ---- */
.pros-card {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(150deg, oklch(0.34 0.07 18 / 0.45), var(--surface));
  border: 1px solid oklch(0.72 0.15 18 / 0.32);
  border-radius: var(--r-md);
}
.pros-glyph {
  font-size: 1.6rem;
  filter: drop-shadow(0 0 9px oklch(0.72 0.15 18 / 0.45));
  flex-shrink: 0;
}
.pros-info {
  flex: 1;
  min-width: 0;
}
.pros-info h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
}
.pros-sub {
  font-family: var(--body);
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--ink-mute);
  font-style: italic;
}
.pros-meta {
  font-size: 0.78rem;
  color: var(--ink-mute);
  margin-top: 0.2rem;
}
.pros-btn {
  flex-shrink: 0;
  padding: 0.6rem 1rem;
  border: 1px solid var(--rose);
  border-radius: var(--r-sm);
  background: oklch(0.72 0.15 18 / 0.14);
  color: var(--rose);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.18s var(--ease);
}
.pros-btn:hover {
  background: oklch(0.72 0.15 18 / 0.26);
}
.pros-btn:active {
  transform: scale(0.96);
}

/* ---- prosody practice screen ---- */
.pros-stage {
  margin-top: 0.6rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.pros-vi {
  font-size: 0.9rem;
  color: var(--ink-mute);
  font-style: italic;
}
.pros-stress {
  font-family: var(--display);
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  line-height: 1.4;
  margin-top: 0.6rem;
  color: var(--ink-soft);
  text-wrap: balance;
}
/* a stressed word in the target pattern: lifted, bright, weighty */
.pros-stress b {
  color: var(--rose);
  font-weight: 700;
  position: relative;
}
.pros-stress b::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.12em;
  height: 2px;
  background: var(--rose);
  border-radius: 2px;
  opacity: 0.6;
}
.pros-tip {
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: oklch(0.72 0.15 18 / 0.1);
  border: 1px solid oklch(0.72 0.15 18 / 0.22);
  border-radius: var(--r-sm);
  padding: 0.7rem 0.9rem;
}
.pros-model-btn {
  align-self: flex-start;
  margin-top: 1.1rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.18s var(--ease);
}
.pros-model-btn:hover {
  background: var(--surface-3);
}
.pros-model-btn:active {
  transform: scale(0.97);
}
.pros-model-btn.playing {
  border-color: var(--sun);
  color: var(--sun);
}

.pros-wave-wrap {
  position: relative;
  margin-top: 1.2rem;
  background: var(--bg-deep);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  overflow: hidden;
  min-height: 120px;
  display: grid;
  place-items: center;
}
.pros-wave {
  display: block;
  width: 100%;
  height: 120px;
}
.pros-wave-empty {
  position: absolute;
  padding: 0 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-mute);
  pointer-events: none;
}

.pros-rec-row {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.1rem;
}
.pros-rec-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--rose);
  border-radius: var(--r-md);
  background: oklch(0.72 0.15 18 / 0.14);
  color: var(--rose);
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.18s var(--ease);
}
.pros-rec-btn:active {
  transform: scale(0.98);
}
.pros-rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--rose);
}
/* while recording: filled red button and a soft pulse on the dot */
.pros-rec-btn.recording {
  background: var(--rose);
  color: oklch(0.18 0.03 20);
}
.pros-rec-btn.recording .pros-rec-dot {
  background: oklch(0.18 0.03 20);
  animation: pros-pulse 1s var(--ease-soft) infinite;
}
@keyframes pros-pulse {
  50% {
    opacity: 0.3;
  }
}
.pros-play-btn {
  flex: 1;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.18s var(--ease);
}
.pros-play-btn:hover:not(:disabled) {
  background: var(--surface-3);
}
.pros-play-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.pros-status {
  margin-top: 0.7rem;
  font-size: 0.82rem;
  color: var(--ink-mute);
  text-align: center;
  min-height: 1.2em;
}
.pros-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  margin-top: 1.2rem;
}
.pros-nav-btn {
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--body);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.pros-nav-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--line-soft);
}
.pros-nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---- gem on the study card ---- */
.card-front.is-gem {
  font-size: clamp(1.5rem, 5.5vw, 2.15rem);
  line-height: 1.32;
  font-style: italic;
  color: var(--ink);
}
.gem-detail {
  margin-top: 1.2rem;
  text-align: left;
}

/* nuance: a ladder of near-synonyms with an intensity meter */
.gem-spectrum {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.gem-sp {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.2rem 0.7rem;
  padding: 0.5rem 0;
}
.gem-sp + .gem-sp {
  border-top: 1px dashed var(--line-soft);
}
.gem-sp-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.gem-sp-w {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
}
.gem-sp-ipa {
  font-size: 0.78rem;
  color: var(--sun);
}
.gem-sp-meter {
  display: inline-flex;
  gap: 3px;
  align-self: center;
}
.gd-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bg-deep);
  border: 1px solid var(--line);
}
.gd-dot.on {
  background: var(--sun);
  border-color: var(--sun);
}
.gem-sp-vi {
  grid-column: 1 / 3;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

/* register: rungs from formal to casual */
.gem-ladder {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.gem-rung {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-deep);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}
.gem-rung-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--sun);
  text-transform: uppercase;
}
.gem-rung-label::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sun);
}
.gem-rung-w {
  display: block;
  font-family: var(--display);
  font-size: 1.02rem;
  color: var(--ink);
}
.gem-rung-vi {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-mute);
}

/* prosody: same sentence, different stress → different meaning */
.gem-readings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.gem-reading {
  padding: 0.5rem 0.75rem;
  background: var(--bg-deep);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}
.gem-read-stress {
  font-family: var(--display);
  font-size: 0.98rem;
  color: var(--ink-soft);
}
.gem-read-stress b {
  color: var(--sun);
  font-weight: 700;
}
.gem-read-vi {
  font-size: 0.8rem;
  color: var(--ink-mute);
  margin-top: 0.15rem;
}

/* rhetoric / lore: device + attribution chips */
.gem-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.1rem;
  justify-content: center;
}
.gem-device,
.gem-source {
  font-size: 0.76rem;
  padding: 0.3rem 0.7rem;
  border-radius: 100px;
}
.gem-device {
  color: var(--sun);
  background: var(--sun-glow);
  border: 1px solid oklch(0.78 0.155 60 / 0.35);
  font-weight: 600;
}
.gem-source {
  color: var(--ink-mute);
  background: var(--bg-deep);
  border: 1px solid var(--line-soft);
  font-style: italic;
}

/* ----------------------------------------------------------------- study */
.study-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: clamp(1.2rem, 5vw, 2rem);
}
.progress-track {
  flex: 1;
  height: 7px;
  background: var(--surface);
  border-radius: 100px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--sun-deep), var(--sun));
  border-radius: 100px;
  transition: width 0.5s var(--ease);
}
.study-counter {
  font-size: 0.82rem;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  min-width: 3.2rem;
  text-align: right;
}

.card-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0;
}
.flashcard {
  width: 100%;
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: clamp(1.5rem, 6vw, 2.4rem);
  min-height: 56vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 70px -34px oklch(0.1 0.05 290 / 0.95);
  animation: card-in 0.4s var(--ease) both;
}
@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
}
.card-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
}
.lang-badge {
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 0.28rem 0.6rem;
  border-radius: 8px;
  color: var(--bg-deep);
}
.lang-badge[data-lang="en"] {
  background: var(--en);
}
.lang-badge[data-lang="ko"] {
  background: var(--ko);
}
.lang-badge[data-lang="ja"] {
  background: var(--ja);
}
.lang-badge[data-lang="gem"] {
  background: var(--sun);
}
.deck-tag {
  font-size: 0.76rem;
  color: var(--ink-mute);
  padding: 0.25rem 0.55rem;
  background: var(--bg-deep);
  border-radius: 7px;
}
.mode-tag {
  margin-left: auto;
  font-size: 0.74rem;
  color: var(--sun);
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border: 1px solid oklch(0.78 0.155 60 / 0.3);
  border-radius: 100px;
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.7rem;
}
.card-prompt {
  font-size: 0.95rem;
  color: var(--ink-mute);
  font-style: italic;
}
.card-front {
  font-family: var(--display);
  font-size: clamp(1.9rem, 8vw, 3rem);
  font-weight: 500;
  line-height: 1.2;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
.card-front.is-vi {
  color: var(--ink);
}
.card-phon {
  font-size: clamp(1rem, 4vw, 1.2rem);
  color: var(--sun);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.audio-btn {
  margin-top: 0.6rem;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.6rem 1.2rem;
  border-radius: 100px;
  font-family: var(--body);
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.2s;
}
.audio-btn:hover {
  background: oklch(0.4 0.06 291);
}
.audio-btn:active {
  transform: scale(0.95);
}
.audio-btn.playing {
  border-color: var(--sun);
  color: var(--sun);
}

/* ---- dictation (nghe–chép) ---- */
.dictate-box {
  width: 100%;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.dictate-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.05rem;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.dictate-input::placeholder {
  color: var(--ink-mute);
}
.dictate-input:focus {
  outline: none;
  border-color: var(--sun);
  box-shadow: 0 0 0 3px var(--sun-glow);
}
.dictate-input:disabled {
  opacity: 0.65;
}
.dictate-hint {
  font-size: 0.78rem;
  color: var(--ink-mute);
  font-style: italic;
}
.dictate-result {
  margin-top: 0.4rem;
  padding: 0.9rem 1rem;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  animation: answer-in 0.3s var(--ease) both;
}
.dx-score {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}
.dx-praise {
  font-weight: 500;
  font-style: italic;
}
.dictate-result[data-tier="high"] .dx-score {
  color: var(--good);
}
.dictate-result[data-tier="mid"] .dx-score {
  color: var(--hard);
}
.dictate-result[data-tier="low"] .dx-score {
  color: var(--again);
}
.dx-line {
  font-family: var(--display);
  font-size: 1.25rem;
  line-height: 1.45;
  text-wrap: balance;
}
.dx {
  border-radius: 5px;
  padding: 0 0.06em;
}
.dx.hit {
  color: var(--good);
}
.dx.miss {
  color: var(--again);
  background: oklch(0.66 0.16 22 / 0.16);
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.card-answer {
  border-top: 1px solid var(--line);
  margin-top: 1.4rem;
  padding-top: 1.4rem;
  text-align: center;
  animation: answer-in 0.35s var(--ease) both;
}
@keyframes answer-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.card-vi {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--ink);
  text-wrap: balance;
}
.card-note {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-style: italic;
  text-wrap: pretty;
}

/* controls */
.card-controls {
  padding-top: 1.2rem;
}
.reveal-btn {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.18s var(--ease), border-color 0.2s;
}
.reveal-btn:hover {
  background: var(--surface-3);
  border-color: var(--sun);
}
.reveal-btn:active {
  transform: scale(0.99);
}

.known-btn {
  display: block;
  margin: 0.7rem auto 0;
  padding: 0.4rem 0.9rem;
  background: none;
  border: none;
  color: var(--ink-mute);
  font-family: var(--body);
  font-size: 0.82rem;
  cursor: pointer;
  border-radius: 100px;
  transition: color 0.2s, background 0.2s;
}
.known-btn:hover {
  color: var(--good);
  background: oklch(0.76 0.12 150 / 0.12);
}

.grade-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.grade {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.7rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--body);
  transition: transform 0.16s var(--ease), background 0.18s, border-color 0.18s;
}
.grade:active {
  transform: scale(0.95);
}
.grade-label {
  font-weight: 600;
  font-size: 0.92rem;
}
.grade-ivl {
  font-size: 0.72rem;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.grade-again:hover {
  border-color: var(--again);
  background: oklch(0.66 0.16 22 / 0.16);
}
.grade-hard:hover {
  border-color: var(--hard);
  background: oklch(0.74 0.13 70 / 0.16);
}
.grade-good:hover {
  border-color: var(--good);
  background: oklch(0.76 0.12 150 / 0.16);
}
.grade-easy:hover {
  border-color: var(--easy);
  background: oklch(0.74 0.12 215 / 0.16);
}

/* ----------------------------------------------------------------- done */
.done-wrap {
  margin: auto;
  text-align: center;
  max-width: 26rem;
  animation: screen-in 0.5s var(--ease) both;
}
.done-glyph {
  font-size: 3.4rem;
  color: var(--sun);
  filter: drop-shadow(0 0 20px var(--sun-glow));
}
#done-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.5rem, 6vw, 2rem);
  margin: 0.8rem 0 0.5rem;
  text-wrap: balance;
}
.done-sub {
  color: var(--ink-soft);
  font-size: 1rem;
}
.done-stats {
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  margin: 1.8rem 0;
}
.done-stat {
  text-align: center;
}
.done-stat b {
  display: block;
  font-family: var(--display);
  font-size: 1.9rem;
  color: var(--sun);
}
.done-stat span {
  font-size: 0.78rem;
  color: var(--ink-mute);
}
.done-wrap .cta {
  max-width: 18rem;
  margin: 0 auto;
}
.done-quote {
  margin-top: 2.2rem;
  font-style: italic;
  font-family: var(--display);
  color: var(--ink-mute);
  font-size: 0.92rem;
  line-height: 1.6;
  text-wrap: balance;
}

/* ----------------------------------------------------------------- browse */
.browse-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.2rem;
  flex: 1;
  text-align: center;
}
.browse-filter {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.chip {
  padding: 0.4rem 0.85rem;
  border-radius: 100px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.chip[data-active="true"] {
  background: var(--sun);
  color: var(--bg-deep);
  border-color: var(--sun);
  font-weight: 600;
}
.browse-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow-y: auto;
}
.browse-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}
.browse-item .bi-front {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 500;
}
.browse-item .bi-phon {
  font-size: 0.8rem;
  color: var(--sun);
}
.browse-item .bi-vi {
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.browse-item .bi-main {
  flex: 1;
  min-width: 0;
}
.browse-item .bi-play {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}
.browse-item .bi-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.browse-item .bi-known {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-mute);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.9rem;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.16s var(--ease);
}
.browse-item .bi-known:active {
  transform: scale(0.9);
}
.browse-item .bi-known.on {
  background: var(--good);
  border-color: var(--good);
  color: var(--bg-deep);
}
.browse-item[data-known="true"] {
  opacity: 0.55;
}
.browse-item[data-known="true"] .bi-front {
  text-decoration: line-through;
  text-decoration-color: var(--line);
}
.browse-item[data-lang="en"] .bi-dot {
  background: var(--en);
}
.browse-item[data-lang="ko"] .bi-dot {
  background: var(--ko);
}
.browse-item[data-lang="ja"] .bi-dot {
  background: var(--ja);
}

/* ----------------------------------------------------------------- sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  background: oklch(0.1 0.03 290 / 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.25s var(--ease);
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.sheet-panel {
  width: 100%;
  max-width: var(--maxw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 1.4rem clamp(1.1rem, 4vw, 1.6rem) max(1.6rem, env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
  animation: sheet-up 0.4s var(--ease) both;
}
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}
.sheet-head h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.3rem;
}
.setting-block {
  padding: 1rem 0;
  border-top: 1px solid var(--line-soft);
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.setting-row span small {
  color: var(--ink-mute);
  font-weight: 400;
}
.setting-row input[type="number"] {
  width: 70px;
  padding: 0.5rem;
  text-align: center;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
}
.setting-hint {
  font-size: 0.8rem;
  color: var(--ink-mute);
  margin-top: 0.5rem;
  font-style: italic;
}
.level-select {
  padding: 0.5rem 0.7rem;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--body);
  font-size: 0.92rem;
  cursor: pointer;
  min-width: 9.5rem;
}
.level-select:hover {
  border-color: var(--sun);
}
.setting-title {
  display: block;
  font-weight: 600;
  margin-bottom: 0.7rem;
  font-size: 0.95rem;
}
.lang-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--sun);
}
.setting-actions {
  display: flex;
  gap: 0.6rem;
}
.ghost-btn {
  flex: 1;
  text-align: center;
  padding: 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: var(--body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}
.ghost-btn:hover {
  background: var(--surface-3);
}
.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ------------------------------------------------------- account & sync */
.account-box {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.account-box .ghost-btn {
  flex: none;
  width: 100%;
}
.account-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-weight: 600;
}
.account-google .g-mark {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg-deep);
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
}
.account-who {
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.account-who b {
  color: var(--sun);
}

/* ----------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  z-index: var(--z-toast);
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.75rem 1.2rem;
  border-radius: 100px;
  font-size: 0.9rem;
  box-shadow: 0 18px 40px -18px oklch(0.1 0.05 290);
  opacity: 0;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ----------------------------------------------------------------- a11y */
:focus-visible {
  outline: 2px solid var(--sun);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .aurora {
    animation: none;
  }
}

@media (min-width: 600px) {
  .screen {
    padding-top: 2.4rem;
  }
}

/* ---- narrow phones: stack the twin home cards so .kanji-info / .gem-info
   keep room instead of being squeezed by the glyphs + button ---- */
@media (max-width: 420px) {
  .kanji-card,
  .gem-card,
  .read-card,
  .pros-card {
    flex-wrap: wrap;
  }
  .kanji-btn,
  .gem-btn,
  .read-btn,
  .pros-btn {
    flex-basis: 100%;
    margin-top: 0.5rem;
  }
}
