/* ═══════════════════════════════════════════════════════════════════
   語道 Godō — Stylesheet  v2
   Aesthetic: Edo-era ink & lacquerware — deep blacks, vermillion fire,
              brushed gold, washi warmth. Refined darkness with presence.
   ═══════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────────────── */
:root {
  /* Core palette */
  --ink:        #080809;
  --ink-soft:   #111115;
  --ink-mid:    #1c1c23;
  --ink-light:  #2e2e3a;
  --ink-raise:  #242430;
  --ash:        #52525e;
  --mist:       #8a8a99;
  --paper:      #f2ece0;
  --paper-warm: #e9e0cb;
  --paper-mid:  #c4b89a;

  /* Accents */
  --vermillion: #c93a2e;
  --verm-glow:  #e04a3d;
  --verm-deep:  #8c2920;
  --verm-ember: rgba(201,58,46,0.15);
  --gold:       #c4891e;
  --gold-light: #e8ac3a;
  --gold-pale:  rgba(196,137,30,0.12);
  --sage:       #3d7560;
  --sage-light: #52a07e;
  --sage-pale:  rgba(61,117,96,0.12);

  /* Feedback */
  --correct:    #2d8050;
  --correct-bg: rgba(45,128,80,0.1);
  --wrong:      #b03030;
  --wrong-bg:   rgba(176,48,48,0.1);

  /* Typography */
  --font-jp:    'Shippori Mincho', 'Noto Serif JP', serif;
  --font-jp-ui: 'Noto Sans JP', sans-serif;
  --font-body:  'Crimson Pro', Georgia, serif;
  --font-mono:  'JetBrains Mono', monospace;

  /* Sizing */
  --sidebar-w:  230px;
  --bnav-h:     64px;
  --radius-sm:  5px;
  --radius:     10px;
  --radius-lg:  18px;
  --radius-xl:  28px;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.5);
  --shadow:     0 6px 24px rgba(0,0,0,0.6);
  --shadow-lg:  0 12px 48px rgba(0,0,0,0.75);
  --glow-red:   0 0 32px rgba(201,58,46,0.22);
  --glow-gold:  0 0 24px rgba(196,137,30,0.2);

  /* Transitions */
  --ease:       cubic-bezier(0.22, 0.82, 0.44, 1);
  --ease-out:   cubic-bezier(0.0, 0.0, 0.2, 1);
  --t-fast:     0.14s;
  --t-mid:      0.26s;
  --t-slow:     0.45s;
}

/* ── Reset & Base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background-color: var(--ink);
  color: var(--paper);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse 90% 55% at 15% 8%,  rgba(201,58,46,0.055) 0%, transparent 65%),
    radial-gradient(ellipse 70% 45% at 85% 92%, rgba(196,137,30,0.04) 0%, transparent 65%),
    radial-gradient(ellipse 50% 30% at 50% 50%, rgba(30,28,40,0.8) 0%, transparent 100%);
}

/* Subtle grain overlay on body */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.6;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; font-size: 1rem; }
a { color: var(--gold-light); text-decoration: none; }

/* ── Loading Screen ──────────────────────────────────────────────── */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 0.5rem;
  transition: opacity 0.6s var(--ease);
}

.loading-screen::before {
  content: '';
  position: absolute;
  width: 340px; height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,58,46,0.08) 0%, transparent 70%);
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(0.9); opacity: 0.5; }
  50%       { transform: scale(1.1); opacity: 1; }
}

.loading-kanji {
  font-family: var(--font-jp);
  font-size: 8rem;
  font-weight: 800;
  color: var(--vermillion);
  line-height: 1;
  position: relative;
  text-shadow: 0 0 60px rgba(201,58,46,0.4), 0 0 120px rgba(201,58,46,0.15);
  animation: pulseIn 1.6s var(--ease) infinite alternate;
}

.loading-subtitle {
  font-family: var(--font-body);
  font-size: 1.3rem;
  color: var(--paper-mid);
  letter-spacing: 0.25em;
  font-style: italic;
}

.loading-text {
  font-family: var(--font-jp-ui);
  font-size: 0.75rem;
  color: var(--ash);
  letter-spacing: 0.3em;
  margin-top: 0.75rem;
}

@keyframes pulseIn {
  from { opacity: 0.7; transform: scale(0.96); filter: brightness(0.9); }
  to   { opacity: 1;   transform: scale(1.04); filter: brightness(1.1); }
}

/* ── App Layout ──────────────────────────────────────────────────── */
.hidden { display: none !important; }

.app {
  display: flex;
  min-height: 100dvh;
  position: relative;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100dvh;
  background: var(--ink-soft);
  border-right: 1px solid var(--ink-light);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
}

/* Sidebar accent line */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--vermillion) 0%, transparent 60%);
  opacity: 0.7;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem 1.5rem;
  border-bottom: 1px solid var(--ink-light);
  gap: 0.25rem;
  position: relative;
}

.sidebar-brand::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--vermillion), transparent);
}

.brand-kanji {
  font-family: var(--font-jp);
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--vermillion);
  line-height: 1;
  letter-spacing: 0.06em;
  text-shadow: 0 0 40px rgba(201,58,46,0.3);
}

.brand-latin {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--ash);
  letter-spacing: 0.35em;
  font-style: italic;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
  gap: 0.2rem;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  color: var(--ash);
  font-size: 0.88rem;
  font-family: var(--font-body);
  letter-spacing: 0.03em;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  width: 100%;
  position: relative;
  overflow: hidden;
}

.nav-btn::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--vermillion);
  border-radius: 0 3px 3px 0;
  transform: scaleY(0);
  transition: transform var(--t-fast) var(--ease);
}

.nav-icon {
  font-family: var(--font-jp);
  font-size: 1.15rem;
  width: 1.6rem;
  text-align: center;
  color: var(--ash);
  transition: color var(--t-fast), transform var(--t-fast);
  flex-shrink: 0;
}

.nav-btn:hover {
  background: var(--ink-raise);
  color: var(--paper-warm);
  transform: translateX(2px);
}
.nav-btn:hover .nav-icon { color: var(--gold-light); }

.nav-btn.active {
  background: var(--ink-mid);
  color: var(--paper);
}
.nav-btn.active::before  { transform: scaleY(1); }
.nav-btn.active .nav-icon { color: var(--vermillion); }

.sidebar-stats {
  display: flex;
  justify-content: space-around;
  padding: 1.25rem 0.75rem;
  border-top: 1px solid var(--ink-light);
  background: linear-gradient(0deg, var(--ink) 0%, transparent 100%);
}

.sidebar-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.sstat-icon  { font-size: 1rem; }
.sstat-val   { font-size: 1.05rem; font-weight: 700; color: var(--paper); font-family: var(--font-body); }
.sstat-label { font-size: 0.6rem; color: var(--ash); letter-spacing: 0.08em; font-family: var(--font-jp-ui); }

/* ── Main Content ────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  max-width: calc(var(--sidebar-w) + 800px);
  width: 100%;
  padding: 2.5rem 2.5rem 4rem;
  position: relative;
}

/* ── Screen Base ─────────────────────────────────────────────────── */
.screen {
  display: none;
  animation: fadeUp 0.38s var(--ease) both;
}
.screen.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen-header {
  margin-bottom: 2.5rem;
  position: relative;
  padding-left: 1.25rem;
}

.screen-header::before {
  content: '';
  position: absolute;
  left: 0; top: 5%; bottom: 5%;
  width: 3px;
  background: linear-gradient(180deg, var(--vermillion), var(--verm-deep));
  border-radius: 99px;
}

.screen-title {
  font-family: var(--font-jp);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--paper);
  line-height: 1.1;
  letter-spacing: 0.03em;
}

.screen-subtitle {
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--ash);
  font-style: italic;
  margin-top: 0.3rem;
  letter-spacing: 0.02em;
}

/* ── Section headings ────────────────────────────────────────────── */
.section-heading {
  font-family: var(--font-jp);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--mist);
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--ink-light), transparent);
  max-width: 120px;
}

.subsection-heading {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--paper-mid);
  margin-bottom: 0.5rem;
}

/* ── HOME SCREEN ─────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.3rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
}

.stat-card:hover {
  border-color: var(--ink-raise);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-icon-wrap {
  font-size: 1.6rem;
  width: 2.6rem;
  height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-mid);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.stat-icon-wrap.kanji-icon {
  font-family: var(--font-jp);
  font-size: 1.3rem;
  color: var(--vermillion);
  text-shadow: 0 0 16px rgba(201,58,46,0.3);
}

.stat-value {
  font-family: var(--font-body);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--paper);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-label {
  font-family: var(--font-jp-ui);
  font-size: 0.68rem;
  color: var(--ash);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 0.2rem;
}

.home-section { margin-bottom: 2.25rem; }

.continue-card {
  background: linear-gradient(135deg, var(--ink-soft) 0%, var(--ink-raise) 100%);
  border: 1px solid var(--ink-light);
  border-left: 3px solid var(--vermillion);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--t-mid), transform var(--t-fast);
}

.continue-card::before {
  content: '';
  position: absolute;
  top: -40%; right: -5%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(201,58,46,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.continue-card:hover {
  box-shadow: var(--glow-red), var(--shadow);
  transform: translateY(-1px);
}

.continue-unit-tag {
  font-family: var(--font-jp-ui);
  font-size: 0.65rem;
  background: var(--verm-ember);
  color: var(--verm-glow);
  border-radius: 99px;
  padding: 0.2rem 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: inline-block;
  margin-bottom: 0.4rem;
  border: 1px solid rgba(201,58,46,0.2);
}

.continue-title {
  font-family: var(--font-jp);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--paper);
  line-height: 1.25;
  letter-spacing: 0.02em;
}

.continue-desc {
  font-size: 0.83rem;
  color: var(--ash);
  margin-top: 0.3rem;
  font-style: italic;
}

.continue-cta {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.btn-main { font-family: var(--font-jp); font-size: 1rem; font-weight: 700; }
.btn-sub  { font-size: 0.68rem; letter-spacing: 0.06em; opacity: 0.75; }

.review-due-card {
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  transition: border-color var(--t-fast);
}

.review-due-card:has(.review-due-count:not(:empty)) {
  border-color: rgba(196,137,30,0.25);
}

.review-due-count-wrap { display: flex; align-items: baseline; gap: 0.6rem; }
.review-due-count {
  font-family: var(--font-body);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1;
  letter-spacing: -0.03em;
  text-shadow: 0 0 20px rgba(196,137,30,0.25);
}
.review-due-label { font-size: 0.82rem; color: var(--ash); }

/* Mode Toggle */
.mode-toggle { display: flex; flex-direction: column; gap: 0.65rem; }

.mode-btn {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1rem 1.25rem;
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-lg);
  color: var(--ash);
  text-align: left;
  transition: all var(--t-fast);
}
.mode-btn:hover { border-color: var(--ink-raise); color: var(--paper); background: var(--ink-raise); }
.mode-btn.active {
  border-color: var(--vermillion);
  background: var(--verm-ember);
  color: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(201,58,46,0.15);
}
.mode-icon { font-size: 1.8rem; flex-shrink: 0; }
.mode-name { font-weight: 600; font-family: var(--font-body); font-size: 0.95rem; }
.mode-desc { font-size: 0.78rem; color: var(--ash); margin-top: 0.1rem; }

/* ── LESSON MAP ──────────────────────────────────────────────────── */
.lesson-map { display: flex; flex-direction: column; gap: 1.5rem; }

.unit-block {
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: border-color var(--t-mid);
}

.unit-block:hover { border-color: var(--ink-raise); }

.unit-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(90deg, var(--ink-mid) 0%, var(--ink-raise) 100%);
  border-bottom: 1px solid var(--ink-light);
  position: relative;
}

.unit-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 1.5rem; right: 1.5rem;
  height: 1px;
  background: linear-gradient(90deg, var(--vermillion), transparent);
  opacity: 0.4;
}

.unit-num {
  font-family: var(--font-jp-ui);
  font-size: 0.68rem;
  color: var(--verm-glow);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  background: var(--verm-ember);
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  flex-shrink: 0;
  border: 1px solid rgba(201,58,46,0.18);
}

.unit-title {
  font-family: var(--font-jp);
  font-size: 1rem;
  font-weight: 700;
  color: var(--paper);
  flex: 1;
  letter-spacing: 0.02em;
}

.unit-progress {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ash);
  flex-shrink: 0;
}

.unit-lessons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 0.7rem;
  padding: 1.1rem 1.2rem;
}

.lesson-node {
  border: 1px solid var(--ink-light);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
  background: var(--ink-mid);
  overflow: hidden;
}

.lesson-node::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
}

.lesson-node.available {
  border-color: rgba(196,137,30,0.35);
  background: linear-gradient(135deg, var(--ink-mid) 0%, rgba(196,137,30,0.06) 100%);
}

.lesson-node.available::before {
  background: linear-gradient(90deg, var(--gold), transparent);
  opacity: 0.6;
}

.lesson-node.available:hover {
  background: linear-gradient(135deg, var(--ink-raise), rgba(196,137,30,0.12));
  border-color: var(--gold);
  transform: translateY(-3px);
  box-shadow: var(--shadow), var(--glow-gold);
}

.lesson-node.complete {
  border-color: rgba(61,117,96,0.35);
  background: linear-gradient(135deg, var(--ink-mid), rgba(61,117,96,0.06));
  opacity: 0.9;
}

.lesson-node.complete::before {
  background: linear-gradient(90deg, var(--sage), transparent);
  opacity: 0.5;
}

.lesson-node.locked {
  opacity: 0.3;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.lesson-node-title {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--paper);
  line-height: 1.25;
}

.lesson-node-type {
  font-family: var(--font-jp-ui);
  font-size: 0.65rem;
  color: var(--ash);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-top: 0.35rem;
}

.lesson-node.complete::after {
  content: '✓';
  position: absolute;
  top: 0.5rem; right: 0.65rem;
  font-size: 0.7rem;
  color: var(--sage-light);
  background: var(--sage-pale);
  width: 1.2rem; height: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

/* ── LESSON SCREEN ───────────────────────────────────────────────── */
.screen-lesson,
.screen-exercise {
  padding: 0;
  max-width: 100%;
}

.lesson-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: rgba(17,17,21,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ink-light);
  position: sticky;
  top: 0;
  z-index: 50;
}

.lesson-bar-progress {
  flex: 1;
  height: 7px;
  background: var(--ink-light);
  border-radius: 99px;
  overflow: hidden;
}

.lesson-prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--vermillion), var(--gold-light));
  border-radius: 99px;
  transition: width 0.55s var(--ease);
  position: relative;
  overflow: hidden;
}

/* Shimmer on progress bar */
.lesson-prog-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.25) 50%, transparent 100%);
  animation: shimmer 2.2s infinite;
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(200%); }
}

.hearts-display { font-size: 1.1rem; letter-spacing: 0.08em; }

.exercise-counter {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--mist);
  white-space: nowrap;
  background: var(--ink-mid);
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
}

/* ── Vocab Card ──────────────────────────────────────────────────── */
.lesson-sub {
  padding: 2rem 2rem 7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  min-height: calc(100dvh - 80px);
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.lesson-sub.hidden { display: none !important; }

.lesson-instruction {
  font-family: var(--font-jp-ui);
  font-size: 0.78rem;
  color: var(--ash);
  text-align: center;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.vocab-card {
  width: 100%;
  max-width: 500px;
  min-height: 240px;
  background: linear-gradient(160deg, var(--ink-raise) 0%, var(--ink-mid) 100%);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 2rem;
  gap: 0.5rem;
  cursor: pointer;
  transition: transform var(--t-mid) var(--ease), box-shadow var(--t-mid);
  position: relative;
  overflow: hidden;
}

.vocab-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--vermillion), var(--gold), var(--vermillion));
  background-size: 200%;
  animation: gradientSlide 4s linear infinite;
}

@keyframes gradientSlide {
  from { background-position: 0% 50%; }
  to   { background-position: 200% 50%; }
}

/* Corner ornament */
.vocab-card::after {
  content: '語';
  position: absolute;
  bottom: 1rem; right: 1.25rem;
  font-family: var(--font-jp);
  font-size: 4rem;
  font-weight: 800;
  color: rgba(255,255,255,0.025);
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.vocab-card:hover {
  transform: translateY(-5px) scale(1.005);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(201,58,46,0.1);
}

.vocab-front { text-align: center; }

.vc-kanji {
  font-family: var(--font-jp);
  font-size: 5rem;
  font-weight: 800;
  color: var(--paper);
  line-height: 1;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 20px rgba(0,0,0,0.4);
}

.vc-type-badge {
  font-family: var(--font-jp-ui);
  font-size: 0.65rem;
  color: var(--ash);
  background: var(--ink);
  border-radius: 99px;
  padding: 0.22rem 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 0.6rem;
  border: 1px solid var(--ink-light);
  display: inline-block;
}

.vocab-back {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  animation: revealBack 0.3s var(--ease) both;
  width: 100%;
}

@keyframes revealBack {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.vc-reading {
  font-family: var(--font-jp);
  font-size: 2.1rem;
  font-weight: 600;
  color: var(--gold-light);
  line-height: 1;
  text-shadow: 0 0 20px rgba(196,137,30,0.2);
}

.vc-romaji {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ash);
  font-style: italic;
  letter-spacing: 0.06em;
}

.vc-meaning {
  font-family: var(--font-body);
  font-size: 1.65rem;
  font-weight: 600;
  color: var(--paper);
  margin-top: 0.35rem;
}

.vc-example {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--ink-light);
  width: 100%;
  text-align: center;
  position: relative;
}

.vc-example::before {
  content: '';
  position: absolute;
  top: -1px; left: 25%; right: 25%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ash), transparent);
}

.vc-ex-jp  { font-family: var(--font-jp); font-size: 1.05rem; color: var(--paper-mid); }
.vc-ex-rd  { font-size: 0.75rem; color: var(--ash); font-style: italic; margin-top: 0.2rem; }
.vc-ex-en  { font-size: 0.82rem; color: var(--mist); margin-top: 0.1rem; }

.vc-mnemonic {
  background: linear-gradient(135deg, rgba(196,137,30,0.08), rgba(196,137,30,0.05));
  border: 1px solid rgba(196,137,30,0.22);
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  font-size: 0.8rem;
  color: var(--gold-light);
  margin-top: 0.5rem;
  text-align: left;
}
.mnemonic-label { font-weight: 700; margin-right: 0.4rem; font-size: 0.75rem; }

.vocab-actions {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.vocab-dots {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
}

.vocab-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-light);
  transition: background var(--t-fast), transform var(--t-mid) var(--ease), width var(--t-mid) var(--ease);
}
.vocab-dot.current {
  background: var(--vermillion);
  transform: scale(1.4);
  box-shadow: 0 0 8px rgba(201,58,46,0.4);
}
.vocab-dot.done { background: var(--sage); }

/* ── Grammar Card ────────────────────────────────────────────────── */
.grammar-card {
  width: 100%;
  max-width: 600px;
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.grammar-card-header {
  padding: 1.6rem 2rem;
  background: linear-gradient(135deg, var(--ink-mid) 0%, var(--ink-raise) 100%);
  border-bottom: 1px solid var(--ink-light);
  position: relative;
}

.grammar-card-header::after {
  content: '文';
  position: absolute;
  right: 1.5rem; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-jp);
  font-size: 5rem;
  font-weight: 800;
  color: rgba(255,255,255,0.03);
  line-height: 1;
  pointer-events: none;
}

.grammar-tag {
  font-family: var(--font-jp-ui);
  font-size: 0.65rem;
  color: var(--vermillion);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  background: var(--verm-ember);
  padding: 0.18rem 0.6rem;
  border-radius: 99px;
  display: inline-block;
  border: 1px solid rgba(201,58,46,0.2);
}

.gram-title {
  font-family: var(--font-jp);
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--paper);
  margin-top: 0.4rem;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.gram-pattern {
  font-family: var(--font-jp);
  font-size: 1rem;
  color: var(--gold-light);
  background: rgba(196,137,30,0.1);
  border: 1px solid rgba(196,137,30,0.2);
  border-radius: var(--radius-sm);
  padding: 0.4rem 1rem;
  display: inline-block;
  margin-top: 0.6rem;
}

.gram-explanation {
  padding: 1.3rem 2rem;
  font-size: 0.93rem;
  color: var(--paper-mid);
  line-height: 1.8;
  border-bottom: 1px solid var(--ink-light);
}

.gram-examples {
  padding: 1.1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gram-example-item {
  border-left: 2px solid var(--vermillion);
  padding-left: 1.1rem;
  position: relative;
}

.gram-example-item::before {
  content: '';
  position: absolute;
  left: -2px; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--vermillion), var(--verm-deep));
}

.gram-ex-jp  { font-family: var(--font-jp); font-size: 1.08rem; color: var(--paper); }
.gram-ex-rd  { font-size: 0.75rem; color: var(--ash); font-style: italic; margin-top: 0.15rem; }
.gram-ex-en  { font-size: 0.85rem; color: var(--mist); margin-top: 0.1rem; }

/* ── Lesson Complete ─────────────────────────────────────────────── */
.complete-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 2.5rem 1.5rem 1.5rem;
  text-align: center;
  position: relative;
}

.complete-screen::before {
  content: '';
  position: absolute;
  top: -20%; left: 50%;
  transform: translateX(-50%);
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(201,58,46,0.1) 0%, transparent 70%);
  pointer-events: none;
}

.complete-kanji {
  font-family: var(--font-jp);
  font-size: 7rem;
  font-weight: 800;
  color: var(--vermillion);
  animation: popIn 0.7s var(--ease) both;
  line-height: 1;
  text-shadow: var(--glow-red);
}

@keyframes popIn {
  from { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  60%  { transform: scale(1.08) rotate(2deg); }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

.complete-heading {
  font-family: var(--font-body);
  font-size: 1.85rem;
  font-weight: 600;
  color: var(--paper);
  animation: fadeUp 0.5s 0.2s var(--ease) both;
}

.complete-xp-display {
  font-family: var(--font-body);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--gold-light);
  text-shadow: var(--glow-gold);
  animation: fadeUp 0.5s 0.3s var(--ease) both;
}

.complete-stats-row {
  display: flex;
  gap: 3rem;
  margin-top: 0.5rem;
  animation: fadeUp 0.5s 0.4s var(--ease) both;
}

.complete-stat { text-align: center; }
.cstat-val   { font-family: var(--font-body); font-size: 1.7rem; font-weight: 700; color: var(--paper); }
.cstat-label { font-size: 0.72rem; color: var(--ash); letter-spacing: 0.1em; text-transform: uppercase; }

.complete-actions {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  animation: fadeUp 0.5s 0.5s var(--ease) both;
}

/* ── EXERCISE PANELS ─────────────────────────────────────────────── */
.ex-panel {
  padding: 2rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  animation: fadeUp 0.28s var(--ease) both;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.ex-panel.hidden { display: none !important; }

.ex-prompt {
  font-family: var(--font-jp-ui);
  font-size: 0.75rem;
  color: var(--ash);
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
}

.ex-kanji-hero {
  font-family: var(--font-jp);
  font-size: 5.5rem;
  font-weight: 800;
  color: var(--paper);
  line-height: 1;
  text-align: center;
  text-shadow: 0 4px 30px rgba(0,0,0,0.5);
}

.ex-meaning-hero {
  font-family: var(--font-body);
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--paper);
  text-align: center;
  line-height: 1.2;
}

.ex-reading-hint {
  font-family: var(--font-jp);
  font-size: 1.05rem;
  color: var(--ash);
  background: var(--ink-mid);
  padding: 0.3rem 0.9rem;
  border-radius: 99px;
}

/* Story comp panels */
.ex-story-text {
  font-family: var(--font-jp);
  font-size: 1.1rem;
  line-height: 2;
  color: var(--paper-mid);
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-left: 3px solid var(--vermillion);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  width: 100%;
  max-width: 560px;
}

.ex-story-question {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--paper);
  text-align: center;
  line-height: 1.5;
}

/* ── Choices Grid ────────────────────────────────────────────────── */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  width: 100%;
  max-width: 520px;
}

.choice-btn {
  padding: 1rem 1.1rem;
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius);
  color: var(--paper-mid);
  font-family: var(--font-body);
  font-size: 0.93rem;
  text-align: left;
  transition: all var(--t-fast);
  cursor: pointer;
  line-height: 1.3;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: var(--gold-pale);
  color: var(--paper);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.choice-btn.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: #80c8a0;
  box-shadow: 0 0 16px rgba(45,128,80,0.15);
}

.choice-btn.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
  color: #d08080;
}

.choice-btn:disabled { cursor: default; }

/* ── Word Bank / Tile System ─────────────────────────────────────── */
.wordbank-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  width: 100%;
  max-width: 560px;
}
.wordbank-wrap.hidden { display: none !important; }

.answer-slots {
  min-height: 58px;
  width: 100%;
  background: var(--ink);
  border: 2px dashed var(--ink-light);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  position: relative;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.answer-slots:empty::after {
  content: attr(data-empty);
  font-size: 0.8rem;
  color: var(--ash);
  font-style: italic;
  font-family: var(--font-body);
}

.answer-slots.has-content {
  border-color: var(--gold);
  border-style: solid;
  box-shadow: 0 0 0 1px rgba(196,137,30,0.1);
}

.tile-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-start;
  width: 100%;
}

.tile-bank-centered { justify-content: center; }

.tile {
  background: var(--ink-mid);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.95rem;
  font-family: var(--font-jp);
  font-size: 1rem;
  color: var(--paper);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
}

.tile:hover {
  background: var(--ink-raise);
  border-color: var(--ash);
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}
.tile.selected { opacity: 0.28; pointer-events: none; transform: none; }

.answer-tile {
  background: var(--ink-raise);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.85rem;
  font-family: var(--font-jp);
  font-size: 1rem;
  color: var(--paper);
  cursor: pointer;
  transition: all var(--t-fast);
}
.answer-tile:hover { border-color: var(--wrong); background: var(--wrong-bg); }

/* ── Type Input ──────────────────────────────────────────────────── */
.typein-wrap {
  display: flex;
  gap: 0.7rem;
  width: 100%;
  max-width: 520px;
}
.typein-wrap.hidden { display: none !important; }

.answer-input {
  flex: 1;
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  color: var(--paper);
  font-size: 1rem;
  font-family: var(--font-jp-ui);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.answer-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196,137,30,0.1);
}
.answer-input.correct {
  border-color: var(--correct);
  box-shadow: 0 0 0 3px rgba(45,128,80,0.1);
}
.answer-input.wrong {
  border-color: var(--wrong);
  box-shadow: 0 0 0 3px rgba(176,48,48,0.1);
}

/* ── Fill in the Blank ───────────────────────────────────────────── */
.ex-sentence {
  font-family: var(--font-jp);
  font-size: 1.65rem;
  color: var(--paper);
  text-align: center;
  line-height: 1.7;
  max-width: 560px;
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.8rem;
}

.sentence-blank {
  display: inline-block;
  min-width: 3.5rem;
  border-bottom: 3px solid var(--gold);
  color: var(--gold-light);
  padding: 0 0.4rem;
  font-weight: 700;
  font-family: var(--font-jp);
}

.ex-sentence-en {
  font-size: 0.88rem;
  color: var(--ash);
  font-style: italic;
  text-align: center;
}

/* ── Feedback Bar ────────────────────────────────────────────────── */
.feedback-bar {
  position: fixed;
  bottom: 0;
  /* Align with sidebar so it doesn't span full browser width */
  left: var(--sidebar-w);
  right: 0;
  background: rgba(17,17,21,0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--ink-light);
  padding: 1.1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 200;
  animation: slideUp 0.28s var(--ease) both;
}

.feedback-bar.hidden { display: none !important; }

.feedback-bar.correct-fb {
  border-top-color: var(--correct);
  background: rgba(8,22,14,0.96);
}
.feedback-bar.wrong-fb {
  border-top-color: var(--wrong);
  background: rgba(22,8,8,0.96);
}

/* Top glow line on feedback */
.feedback-bar.correct-fb::before {
  content: '';
  position: absolute;
  top: 0; left: 5%; right: 5%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--correct), transparent);
  opacity: 0.5;
}
.feedback-bar.wrong-fb::before {
  content: '';
  position: absolute;
  top: 0; left: 5%; right: 5%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--wrong), transparent);
  opacity: 0.5;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.feedback-inner { display: flex; align-items: center; gap: 1rem; }

.feedback-ico {
  font-size: 1.8rem;
  width: 2.5rem; height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.correct-fb .feedback-ico { background: var(--correct-bg); color: #80c8a0; }
.wrong-fb   .feedback-ico { background: var(--wrong-bg);   color: #d08080; }

.feedback-title {
  font-family: var(--font-jp);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--paper);
}
.feedback-detail {
  font-size: 0.83rem;
  color: var(--mist);
  margin-top: 0.2rem;
  font-family: var(--font-body);
}

/* ── Stories ─────────────────────────────────────────────────────── */
.story-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}

.story-card {
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.4rem;
  cursor: pointer;
  transition: all var(--t-mid) var(--ease);
  position: relative;
  overflow: hidden;
}

.story-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--vermillion), var(--gold));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-mid) var(--ease);
}

/* Watermark kanji in corner */
.story-card::after {
  content: '話';
  position: absolute;
  bottom: -0.5rem; right: 0.8rem;
  font-family: var(--font-jp);
  font-size: 5.5rem;
  font-weight: 800;
  color: rgba(255,255,255,0.018);
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.story-card:not(.story-locked):hover::before { transform: scaleX(1); }
.story-card:not(.story-locked):hover {
  border-color: var(--ash);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.story-locked { opacity: 0.35; cursor: not-allowed; filter: grayscale(0.3); }

.story-card-level {
  font-family: var(--font-jp-ui);
  font-size: 0.65rem;
  color: var(--vermillion);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 0.5rem;
}

.story-card-title-jp {
  font-family: var(--font-jp);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--paper);
  line-height: 1.2;
}

.story-card-title-en {
  font-family: var(--font-body);
  font-size: 0.83rem;
  color: var(--ash);
  font-style: italic;
  margin-top: 0.2rem;
}

.story-card-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.story-card-tags span {
  font-size: 0.68rem;
  background: var(--ink-mid);
  color: var(--mist);
  border-radius: 99px;
  padding: 0.15rem 0.65rem;
  font-family: var(--font-jp-ui);
  border: 1px solid var(--ink-light);
}

/* Story Reader */
.story-reader { padding-bottom: 4rem; }
.story-reader.hidden { display: none !important; }

.story-content-wrap {
  max-width: 640px;
  margin: 1.5rem auto 0;
}

.story-reader-title-jp {
  font-family: var(--font-jp);
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--paper);
  line-height: 1.2;
  letter-spacing: 0.03em;
}

.story-reader-title-en {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ash);
  font-style: italic;
  margin-top: 0.3rem;
}

.story-body {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

.story-para {
  font-family: var(--font-jp);
  font-size: 1.15rem;
  line-height: 2.4;
  color: var(--paper-mid);
  position: relative;
}

ruby { ruby-align: center; }
rt {
  font-size: 0.5em;
  font-family: var(--font-jp-ui);
  color: var(--ash);
  transition: opacity var(--t-mid);
}

.hide-furigana rt { opacity: 0; pointer-events: none; }

.story-footer-controls {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--ink-light);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  position: relative;
}

.story-footer-controls::before {
  content: '';
  position: absolute;
  top: -1px; left: 0; width: 60px;
  height: 1px;
  background: var(--vermillion);
  opacity: 0.5;
}

/* ── PROGRESS SCREEN ─────────────────────────────────────────────── */
.progress-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 2.25rem;
}

.pstat-card {
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  text-align: center;
  transition: border-color var(--t-fast), transform var(--t-fast);
  position: relative;
  overflow: hidden;
}

.pstat-card:hover { border-color: var(--ink-raise); transform: translateY(-2px); }

.pstat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
}

.pstat-val {
  font-family: var(--font-body);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--paper);
  line-height: 1;
  letter-spacing: -0.02em;
}

.pstat-label {
  font-family: var(--font-jp-ui);
  font-size: 0.65rem;
  color: var(--ash);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.35rem;
}

/* Mastery bars */
.mastery-section { margin-bottom: 2rem; }
.mastery-bars    { display: flex; flex-direction: column; gap: 0.7rem; }

.mastery-row {
  display: grid;
  grid-template-columns: 3.2rem 1fr 4.5rem;
  align-items: center;
  gap: 0.75rem;
}

.mastery-level-label {
  font-family: var(--font-jp-ui);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold-light);
  text-align: center;
  background: var(--gold-pale);
  border-radius: var(--radius-sm);
  padding: 0.22rem 0;
  border: 1px solid rgba(196,137,30,0.2);
}

.mastery-track {
  height: 10px;
  background: var(--ink-mid);
  border-radius: 99px;
  overflow: hidden;
}

.mastery-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--vermillion), var(--gold-light));
  border-radius: 99px;
  transition: width 1.2s var(--ease);
  position: relative;
  overflow: hidden;
}

.mastery-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  animation: shimmer 3s 0.5s infinite;
}

.mastery-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ash);
  text-align: right;
}

/* Hard Save Panel */
.hard-save-panel,
.local-save-panel {
  background: var(--ink-soft);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius-xl);
  padding: 1.6rem 2rem;
  margin-bottom: 1.5rem;
}

.hard-save-panel {
  border-color: rgba(196,137,30,0.25);
  background: linear-gradient(135deg, var(--ink-soft) 0%, rgba(196,137,30,0.03) 100%);
}

.panel-desc {
  font-size: 0.87rem;
  color: var(--mist);
  line-height: 1.7;
  margin-bottom: 1.1rem;
}

.panel-warning {
  font-size: 0.8rem;
  color: var(--gold);
  background: rgba(196,137,30,0.07);
  border: 1px solid rgba(196,137,30,0.18);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  margin-top: 0.5rem;
  line-height: 1.55;
}

.save-generate-area { margin-bottom: 2rem; }

.save-code-area {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.save-code-area.hidden { display: none !important; }

.save-code-label {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--mist);
}

.save-textarea {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--ink-light);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  color: var(--gold-light);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  resize: vertical;
  outline: none;
  line-height: 1.55;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.save-textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196,137,30,0.08);
}

.save-warning {
  font-size: 0.8rem;
  color: var(--vermillion);
  line-height: 1.55;
}

.save-load-area { display: flex; flex-direction: column; gap: 0.75rem; }

.load-result {
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-family: var(--font-body);
}
.load-result.success { background: var(--correct-bg); color: #80c8a0; border: 1px solid rgba(45,128,80,0.3); }
.load-result.error   { background: var(--wrong-bg);   color: #d08080; border: 1px solid rgba(176,48,48,0.3); }
.load-result.hidden  { display: none !important; }

/* ── BUTTONS ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all var(--t-fast);
  cursor: pointer;
  border: none;
  outline: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: rgba(255,255,255,0.12);
  pointer-events: none;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--vermillion), var(--verm-deep));
  color: #fff;
  box-shadow: 0 2px 12px rgba(201,58,46,0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--verm-glow), var(--vermillion));
  box-shadow: 0 4px 20px rgba(201,58,46,0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--ink-mid);
  color: var(--paper-mid);
  border: 1px solid var(--ink-light);
}
.btn-secondary:hover {
  background: var(--ink-raise);
  color: var(--paper);
  border-color: var(--ash);
}

.btn-accent {
  background: linear-gradient(135deg, var(--gold), #a87218);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 2px 12px rgba(196,137,30,0.3);
}
.btn-accent:hover {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  box-shadow: 0 4px 20px rgba(196,137,30,0.4);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--ash);
  border: 1px solid transparent;
}
.btn-ghost:hover {
  background: var(--ink-mid);
  color: var(--paper-mid);
  border-color: var(--ink-light);
}

.btn-danger {
  background: var(--wrong-bg);
  color: #d08080;
  border: 1px solid rgba(176,48,48,0.3);
}
.btn-danger:hover {
  background: rgba(176,48,48,0.25);
  color: #e8a0a0;
  border-color: var(--wrong);
}

.btn-lg  { padding: 1rem 2rem; font-size: 1rem; border-radius: var(--radius); }
.btn-sm  { padding: 0.38rem 0.85rem; font-size: 0.8rem; }
.btn-icon {
  width: 2.4rem; height: 2.4rem; padding: 0;
  border-radius: var(--radius-sm);
}

.full-width { width: 100%; }

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

/* ── TOAST ───────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink-raise);
  color: var(--paper);
  border: 1px solid var(--ink-light);
  border-radius: 99px;
  padding: 0.65rem 1.5rem;
  font-size: 0.85rem;
  font-family: var(--font-body);
  z-index: 999;
  opacity: 0;
  transition: all 0.3s var(--ease);
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── BOTTOM NAV (Mobile) ─────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bnav-h);
  background: rgba(17,17,21,0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--ink-light);
  z-index: 300;
  justify-content: space-around;
  align-items: stretch;
}

.bnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  color: var(--ash);
  font-size: 0.58rem;
  font-family: var(--font-jp-ui);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: color var(--t-fast);
  padding: 0.4rem 0;
  border-radius: 0;
  position: relative;
}

.bnav-btn.active::before {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%;
  height: 2px;
  background: var(--vermillion);
  border-radius: 0 0 99px 99px;
}

.bnav-icon {
  font-family: var(--font-jp);
  font-size: 1.35rem;
  line-height: 1;
  color: var(--ash);
  transition: color var(--t-fast), transform var(--t-fast);
}

.bnav-btn.active,
.bnav-btn.active .bnav-icon {
  color: var(--vermillion);
}

.bnav-btn.active .bnav-icon { transform: scale(1.1); }

.bnav-btn:hover,
.bnav-btn:hover .bnav-icon { color: var(--paper-mid); }

/* Review empty state */
.review-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4rem 1rem;
  gap: 0.8rem;
  text-align: center;
}

.empty-big-kanji {
  font-family: var(--font-jp);
  font-size: 4.5rem;
  font-weight: 800;
  color: var(--sage-light);
  line-height: 1;
  text-shadow: 0 0 30px rgba(82,160,126,0.2);
}

.empty-heading {
  font-family: var(--font-body);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--paper);
}

.empty-body {
  font-size: 0.9rem;
  color: var(--ash);
  line-height: 1.75;
}

/* Review exercise area */
.review-exercise-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ── RESPONSIVE ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }

  .main-content {
    margin-left: 0;
    padding: 1.5rem 1.1rem calc(var(--bnav-h) + 2rem);
    max-width: 100%;
  }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .progress-stat-grid { grid-template-columns: 1fr 1fr; }

  .vc-kanji { font-size: 3.8rem; }
  .ex-kanji-hero { font-size: 3.8rem; }
  .ex-meaning-hero { font-size: 1.9rem; }

  .choices-grid { grid-template-columns: 1fr 1fr; }

  .feedback-bar { left: 0; }

  .continue-card { flex-direction: column; align-items: stretch; }
  .continue-cta  { width: 100%; }

  .review-due-card { flex-direction: column; align-items: flex-start; gap: 0.85rem; }

  .lesson-sub { padding: 1.25rem 1rem 5.5rem; }
  .ex-panel   { padding: 1.25rem 1rem; }

  .story-footer-controls { flex-direction: column; }

  .save-code-area .btn { width: 100%; }
  .typein-wrap { flex-direction: column; }
  .typein-wrap .btn { width: 100%; }

  .mastery-row { grid-template-columns: 2.8rem 1fr 3.8rem; }

  .complete-kanji { font-size: 5rem; }
  .unit-lessons-grid { grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); }

  .hard-save-panel,
  .local-save-panel { padding: 1.2rem 1.2rem; }
}

@media (max-width: 420px) {
  .stat-grid           { grid-template-columns: 1fr 1fr; gap: 0.45rem; }
  .choices-grid        { grid-template-columns: 1fr; }
  .story-list          { grid-template-columns: 1fr; }
  .progress-stat-grid  { grid-template-columns: 1fr 1fr; }
  .lesson-sub          { padding: 1rem 0.75rem 5.5rem; }
  .complete-stats-row  { gap: 2rem; }
}

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--ink-raise); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--ash); }

/* ── Selection ───────────────────────────────────────────────────── */
::selection { background: rgba(201,58,46,0.32); color: var(--paper); }

/* ── Focus ring ──────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
