/* ── Page shell ── */
.page {
  padding: 1rem;
  max-width: 1440px;
  margin: 0 auto;
}
@media (min-width: 640px)  { .page { padding: 1.5rem; } }
@media (min-width: 768px)  { .page { padding: 2.5rem; } }

.page > * + * { margin-top: 1.5rem; }

/* ── Header ── */
.header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-title { font-size: 1.25rem; font-weight: 900; color: #111827; letter-spacing: -0.01em; margin: 0; }
.page-subtitle { font-size: 0.875rem; color: #6b7280; margin: 0.25rem 0 0; font-weight: 500; }

/* ── Locale switcher ── */
.locale-select {
  font-family: var(--font-jakarta);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-sage-dark);
  background: var(--color-warm-white);
  border: 1px solid #f3f4f6;
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  box-shadow: 0 4px 20px -2px rgba(0,0,0,0.04);
  cursor: pointer;
}

/* ── Tabs ── */
.tabs-scroll { overflow-x: auto; }
.tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--color-warm-white);
  border: 1px solid #f3f4f6;
  box-shadow: 0 4px 20px -2px rgba(0,0,0,0.04);
  padding: 0.375rem;
  border-radius: 16px;
  width: fit-content;
}
.tab-btn {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-jakarta);
}
.tab-btn:hover { color: var(--color-sage-dark); background: var(--color-sage-light); }
.tab-btn.active { background: var(--color-sage); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* ── Tip banner ── */
.tip {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  background: var(--color-sage-light);
  border: 1px solid rgba(91,138,114,0.2);
  border-radius: 16px;
  padding: 0.75rem 1rem;
}
.tip p { margin: 0; font-size: 0.75rem; font-weight: 500; color: var(--color-sage-dark); line-height: 1.5; }
.tip b { font-weight: 900; }
.tip-irregular {
  display: block;
  margin-top: 0.25rem;
  color: #b45309;
  font-weight: 700;
}

/* ── Chart grid ── */
.chart { display: flex; flex-direction: column; gap: 0.375rem; margin-top: 0.5rem; }
.chart-headers, .chart-row {
  display: grid;
  gap: 0.5rem;
  align-items: center;
}
.chart-headers.cols-5, .chart-row.cols-5 { grid-template-columns: 32px repeat(5, 1fr); }
.chart-headers.cols-3, .chart-row.cols-3 { grid-template-columns: 32px repeat(3, 1fr); }
.chart-headers span {
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0;
}
.row-label {
  font-size: 8px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: right;
  padding-right: 0.25rem;
}
.kana-card {
  border-radius: 10px;
  border: 2px solid #f3f4f6;
  background: var(--color-warm-white);
  box-shadow: 0 4px 20px -2px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.125rem;
  gap: 0.125rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-jakarta);
}
.kana-card:hover { border-color: rgba(91,138,114,0.3); box-shadow: 0 10px 40px -4px rgba(91,138,114,0.12); transform: translateY(-1px); }
.kana-card.visited { border-color: var(--color-sage); background: var(--color-sage-light); }
.kana-card .kana { font-size: 1.25rem; font-family: var(--font-klee); font-weight: 600; color: #111827; line-height: 1; }
.kana-card .romaji { font-size: 9px; font-weight: 700; color: var(--color-sage-dark); line-height: 1; }
.kana-card .translit { font-size: 8px; font-weight: 500; color: #9ca3af; line-height: 1; }
.kana-card .hira { font-size: 8px; font-weight: 500; color: #d1d5db; line-height: 1; margin-top: 0.125rem; }

/* Irregular readings — じ/ぢ both "ji", づ "zu", し "shi", ち "cha" — the romaji
   doesn't follow from the row consonant. Amber + dotted rule so learners catch
   the exception instead of skimming past it. Colour only: touching the border
   would fight .kana-card:hover / .visited. */
.kana-card.special .romaji {
  color: #b45309;
  border-bottom: 1px dotted #d9a066;
  padding-bottom: 1px;
}
@media (min-width: 640px) {
  .chart-headers.cols-5, .chart-row.cols-5 { grid-template-columns: 56px repeat(5, 1fr); }
  .chart-headers.cols-3, .chart-row.cols-3 { grid-template-columns: 56px repeat(3, 1fr); }
  .row-label { font-size: 10px; padding-right: 0.5rem; }
  .kana-card { padding: 1rem 0.25rem; border-radius: 14px; }
  .kana-card .kana { font-size: 1.875rem; }
  .kana-card .romaji { font-size: 10px; }
  .kana-card .translit, .kana-card .hira { font-size: 9px; }
}
.kana-card.yoon .kana { font-size: 1.125rem; }
@media (min-width: 640px) { .kana-card.yoon .kana { font-size: 1.5rem; } }

.extra-section { display: flex; flex-direction: column; gap: 1.5rem; }

/* ── Vocab grid ── */
.vocab-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 640px) { .vocab-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .vocab-grid { grid-template-columns: 1fr 1fr 1fr; } }
.vocab-card {
  background: var(--color-warm-white);
  border-radius: 20px;
  border: 1px solid #f3f4f6;
  box-shadow: 0 4px 20px -2px rgba(0,0,0,0.04);
  padding: 1.25rem;
  transition: all 0.2s;
}
.vocab-card:hover { box-shadow: 0 10px 40px -4px rgba(91,138,114,0.12); transform: translateY(-1px); }
.vocab-card .row { display: flex; align-items: flex-start; gap: 0.75rem; }
.vocab-card .emoji { font-size: 1.875rem; line-height: 1; margin-top: 0.125rem; }
.vocab-card .content { flex: 1; min-width: 0; }
.vocab-card .baseline { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.25rem; }
.vocab-card .hira { font-size: 1.5rem; font-family: var(--font-klee); font-weight: 600; color: #111827; }
.vocab-card .romaji { font-size: 0.875rem; font-weight: 700; color: var(--color-sage-dark); }
.vocab-card .meaning { font-size: 0.875rem; font-weight: 700; color: #374151; margin: 0; }
.vocab-card .en { font-size: 0.75rem; color: #9ca3af; font-weight: 500; margin: 0.125rem 0 0; }
.vocab-card .num { font-size: 10px; font-weight: 700; color: #d1d5db; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── CTA ── */
.cta {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--color-sage-light);
  border: 1px solid rgba(91,138,114,0.2);
  border-radius: 20px;
  padding: 1.25rem;
}
@media (min-width: 640px) { .cta { flex-direction: row; align-items: center; justify-content: space-between; } }
.cta .title { font-weight: 900; color: var(--color-sage-dark); font-size: 0.875rem; margin: 0; }
.cta .subtitle { font-size: 0.75rem; color: var(--color-sage-dark); opacity: 0.7; font-weight: 500; margin: 0.125rem 0 0; }
.cta a {
  background: var(--color-sage);
  color: #fff;
  padding: 0.625rem 1.25rem;
  border-radius: 12px;
  font-weight: 900;
  font-size: 0.875rem;
  text-decoration: none;
  text-align: center;
  transition: background 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.cta a:hover { background: var(--color-sage-dark); }

/* ── Dialog ── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 640px) { .dialog-overlay { align-items: center; padding: 1rem; } }
.dialog-overlay[hidden] { display: none; }
.dialog-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); }
.dialog-card {
  position: relative;
  background: var(--color-warm-white);
  border-radius: 28px 28px 0 0;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  padding: 1rem;
  max-height: 92vh;
  overflow-y: auto;
  font-family: var(--font-jakarta);
}
@media (min-width: 640px) { .dialog-card { border-radius: 28px; max-width: 24rem; padding: 1.5rem; } }
.dialog-card > * + * { margin-top: 0.75rem; }
@media (min-width: 640px) { .dialog-card > * + * { margin-top: 1rem; } }

.dialog-drag-handle { width: 2.5rem; height: 4px; background: #e5e7eb; border-radius: 999px; margin: 0 auto; }
@media (min-width: 640px) { .dialog-drag-handle { display: none; } }
.dialog-close-row { display: flex; justify-content: flex-end; }

.dialog-header { display: flex; align-items: flex-start; gap: 0.5rem; }
.nav-btn-group { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; flex-shrink: 0; align-self: center; }
.nav-btn-label { font-size: 10px; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.05em; }
.nav-btn {
  flex-shrink: 0; width: 2.25rem; height: 2.25rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: #f3f4f6; color: #6b7280;
  border: none; cursor: pointer;
  transition: background 0.2s;
  font-size: 1.1rem;
}
.nav-btn:hover { background: #e5e7eb; }
.nav-btn:disabled { opacity: 0.2; cursor: default; }
.dialog-char-info { flex: 1; display: flex; align-items: center; gap: 0.75rem; justify-content: center; min-width: 0; align-self: center; }
.dialog-char-info .big-kana { font-size: 3.75rem; font-family: var(--font-klee); font-weight: 600; line-height: 1; color: #111827; flex-shrink: 0; }
@media (min-width: 640px) { .dialog-char-info .big-kana { font-size: 4.5rem; } }
.dialog-char-info .meta { min-width: 0; }
.dialog-char-info .romaji-row { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.dialog-char-info .romaji { font-size: 1.25rem; font-weight: 900; color: var(--color-sage-dark); margin: 0; }
@media (min-width: 640px) { .dialog-char-info .romaji { font-size: 1.5rem; } }
.audio-btn {
  width: 1.75rem; height: 1.75rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--color-sage-light); color: var(--color-sage-dark);
  border: none; cursor: pointer; flex-shrink: 0;
  transition: all 0.2s;
  font-size: 0.85rem;
}
.audio-btn:hover { background: var(--color-sage); color: #fff; }
.dialog-char-info .translit { font-size: 0.875rem; font-weight: 700; color: #6b7280; margin: 0; }
@media (min-width: 640px) { .dialog-char-info .translit { font-size: 1rem; } }
.dialog-char-info .hira-note { font-size: 0.75rem; color: #d1d5db; font-weight: 500; margin: 0.125rem 0 0; }

.dialog-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.speed-group { display: flex; align-items: center; gap: 0.25rem; background: #f3f4f6; padding: 0.25rem; border-radius: 12px; }
.speed-btn {
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.15s;
}
@media (min-width: 640px) { .speed-btn { padding: 0.25rem 0.75rem; } }
.speed-btn:hover { color: #4b5563; }
.speed-btn.active { background: #fff; color: #111827; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.draw-toggle {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  border: none;
  background: #f3f4f6; color: #6b7280;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.draw-toggle:hover { color: #374151; }
.draw-toggle.active { background: #e0e7ff; color: #4338ca; box-shadow: inset 0 0 0 1px #a5b4fc; }

.dialog-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  background: var(--color-cloud);
  overflow: hidden;
}
.dialog-canvas-wrap svg {
  width: 100%; height: 100%;
  transition: opacity 0.3s;
  --shadow: #d1e0d8;
  --stroke: #5B8A72;
}
.combo-glyph {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.combo-glyph span { font-size: 130px; font-family: var(--font-klee); font-weight: 400; color: rgba(209,213,219,0.5); line-height: 1; user-select: none; }
.draw-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;
  transition: opacity 0.3s;
}
.draw-canvas.active { cursor: crosshair; pointer-events: auto; }
.draw-canvas:not(.active) { pointer-events: none; }
.loading-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.loading-placeholder span { font-size: 120px; font-family: var(--font-klee); font-weight: 600; color: #f3f4f6; line-height: 1; user-select: none; }
.draw-badge {
  position: absolute; top: 0.75rem; left: 0.75rem;
  background: rgba(79,70,229,0.8); color: #fff;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.25rem 0.5rem; border-radius: 8px;
  pointer-events: none;
}

.brush-row { display: flex; align-items: center; gap: 0.75rem; padding: 0 0.25rem; }
.brush-row .label { font-size: 10px; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.05em; flex-shrink: 0; }
.brush-row input[type="range"] { flex: 1; accent-color: #6366f1; height: 6px; }
.brush-preview { flex-shrink: 0; border-radius: 999px; background: #6366f1; transition: all 0.15s; }

.dialog-controls { display: flex; align-items: center; justify-content: space-between; }
.transport { display: flex; align-items: center; gap: 0.25rem; }
.transport .icon-btn { width: 2.25rem; height: 2.25rem; border-radius: 12px; background: transparent; }
.transport .icon-btn:hover { background: #f3f4f6; color: #111827; }
.play-btn {
  width: 2.75rem; height: 2.75rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--color-sage); color: #fff;
  border: none; cursor: pointer;
  transition: background 0.2s;
  font-size: 1rem;
}
.play-btn:hover { background: var(--color-sage-dark); }
.play-btn:disabled { opacity: 0.4; cursor: default; }
.right-controls { display: flex; align-items: center; gap: 0.25rem; margin-left: auto; }
.pill-btn {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem; font-weight: 700;
  border: none; cursor: pointer;
  background: transparent; color: #9ca3af;
  transition: all 0.2s;
}
.pill-btn:hover { background: #f3f4f6; color: #374151; }
.pill-btn.active { background: var(--color-sage); color: #fff; }
.pill-btn .txt { display: none; }
@media (min-width: 640px) { .pill-btn .txt { display: inline; } }
