/* imo — iPad-first shell and the study screens (writing pad, kanji, grammar,
 * quiz). Base tokens and shared components (chips, cards, dictionary rows,
 * kana charts, buttons) live in styles.css.
 *
 * Layout
 *   < 700px     phone / iPad slide-over: sticky top bar + bottom tab bar
 *   ≥ 700px     iPad / desktop: top bar + floating glass dock at the bottom
 */

:root {
  --content-max: 1080px;
  --tap: 44px;
  --wp-guide: rgba(42, 26, 14, 0.16);
  --wp-ghost: rgba(42, 26, 14, 0.1);
  --wp-ghost-next: rgba(215, 119, 113, 0.42);
  --wp-ink: #2a1a0e;
  --wp-live: #ff7100;
  --wp-hint: #d77771;
}
[data-theme="dark"] {
  --wp-guide: rgba(255, 247, 238, 0.16);
  --wp-ghost: rgba(255, 247, 238, 0.1);
  --wp-ghost-next: rgba(232, 138, 130, 0.5);
  --wp-ink: #fff7ee;
  --wp-live: #ff8838;
  --wp-hint: #e88a82;
}

a { color: inherit; }
/* Always reserve the scrollbar's space (desktop browsers with classic
 * scrollbars), so the layout and the centred dock don't shift sideways
 * between short pages (no scrollbar) and long ones. No effect on iPad. */
html { scrollbar-gutter: stable; }
.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 200;
  padding: 0.6rem 1rem;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-weight: 800;
  text-decoration: none;
}
.skip-link:focus { top: calc(env(safe-area-inset-top, 0px) + 0.75rem); }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; min-height: 100svh; }
.main {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0.75rem clamp(1rem, 4vw, 1.75rem) calc(6.25rem + env(safe-area-inset-bottom, 0px));
  outline: none;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.55rem) clamp(1rem, 4vw, 1.75rem) 0.55rem;
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
}
.tb-logo img { display: block; height: 30px; width: auto; }
[data-theme="dark"] .tb-logo img {
  filter: brightness(0) saturate(100%) invert(96%) sepia(34%) saturate(314%) hue-rotate(305deg) brightness(107%) contrast(102%);
}
.tb-level {
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: rgba(215, 119, 113, 0.12);
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.tb-settings { margin-left: auto; }
.sidebar { display: none; }

/* Phone tab bar */
.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
  border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.18s ease, color 0.18s ease;
}
.nav-ico, .nav-glyph {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}
.nav-glyph { font-size: 1.3rem; font-weight: 700; line-height: 1; }
.nav-label-long { display: none; }
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  padding: 0.3rem 0.35rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 -1px 0 var(--border);
}
.tabbar .nav-item {
  flex-direction: column;
  gap: 0.15rem;
  min-height: 52px;
  font-size: 0.66rem;
  border-radius: 12px;
}
.tabbar .nav-item.active { color: var(--accent-3); }
.tabbar .nav-item.active .nav-ico,
.tabbar .nav-item.active .nav-glyph {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #fff;
  border-radius: 9px;
  width: 34px;
}

/* ---------- Glass dock (iPad / desktop) ----------
 * Each icon: a gradient colour tile with a glossy glass layer on top (shine +
 * bevel edge) and the glyph. Hover lifts the tile, the label shows above,
 * and the current section gets a dot underneath. */
:root {
  --gi-size: 60px;
  --gi-gap: 16px;
  --gi-radius: 13px;
  --gi-brand: linear-gradient(135deg, #f0a097, #ff7100);
  --gi-pink: linear-gradient(135deg, hsl(326, 92%, 74%), hsl(314, 70%, 54%));
  --gi-red: linear-gradient(135deg, hsl(354, 95%, 68%), hsl(342, 80%, 52%));
  --gi-green: linear-gradient(135deg, hsl(146, 66%, 54%), hsl(162, 82%, 34%));
  --gi-orange: linear-gradient(135deg, hsl(38, 100%, 62%), hsl(20, 94%, 54%));
  --gi-indigo: linear-gradient(135deg, hsl(236, 90%, 72%), hsl(246, 64%, 54%));
  --gi-graphite: linear-gradient(135deg, hsl(250, 6%, 46%), hsl(250, 8%, 22%));
  --gi-edge: rgba(255, 255, 255, 0.42);
  --gi-drop: rgba(42, 26, 14, 0.28);
  --dock-shelf: rgba(255, 250, 244, 0.72);
  --dock-line: rgba(42, 26, 14, 0.08);
  --dock-fade: rgba(255, 247, 238, 0.55);
}
[data-theme="dark"] {
  --gi-edge: rgba(255, 255, 255, 0.22);
  --gi-drop: rgba(0, 0, 0, 0.5);
  --dock-shelf: rgba(40, 40, 40, 0.7);
  --dock-line: rgba(255, 247, 238, 0.1);
  --dock-fade: rgba(22, 22, 22, 0.55);
}
.dock { display: none; }
.glass-icon {
  position: relative;
  display: block;
  width: var(--gi-size);
  height: var(--gi-size);
  flex-shrink: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  animation: giIn 0.6s cubic-bezier(0.34, 1.4, 0.5, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms + 120ms);
}
@keyframes giIn {
  from { opacity: 0; transform: translateY(14px) scale(0.9); }
  to { opacity: 1; transform: none; }
}
.gi-plate, .gi-glass, .gi-face {
  position: absolute;
  inset: 0;
  border-radius: var(--gi-radius);
}
/* The colour tile, with a glossy glass layer exactly on top of it. */
.gi-plate {
  background: var(--gi-plate, var(--gi-brand));
  box-shadow: 0 10px 22px -12px var(--gi-drop);
}
.gi-glass {
  background:
    radial-gradient(130% 75% at 28% 0%, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.08) 55%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0) 55%, rgba(0, 0, 0, 0.1) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    inset 0 0 0 1px var(--gi-edge);
}
.gi-face {
  display: grid;
  place-items: center;
  color: #fff;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.28));
}
.gi-glyph { font-size: calc(var(--gi-size) * 0.43); font-weight: 700; line-height: 1; }
.gi-face .lucide { width: calc(var(--gi-size) * 0.43); height: calc(var(--gi-size) * 0.43); }
.gi-plate, .gi-glass, .gi-face { transition: transform 0.42s cubic-bezier(0.34, 1.56, 0.64, 1); }
/* Name tooltip: a surface pill like the rest of the app's cards and chips,
 * with a tail pointing at the icon and the Japanese name in the accent colour. */
.gi-label {
  position: absolute;
  bottom: calc(100% + 16px);
  left: 50%;
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--border);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: -0.005em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 6px) scale(0.94);
  transform-origin: 50% 100%;
  transition:
    opacity 0.2s ease,
    transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.gi-label::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 2px;
  background: var(--surface);
  box-shadow: 1px 1px 0 var(--border);
  transform: rotate(45deg);
}
.gi-label-jp { font-size: 0.74rem; font-weight: 700; color: var(--accent); }
.glass-icon.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--text-soft);
}
.glass-icon:focus-visible { outline: none; }
.glass-icon:focus-visible .gi-glass { box-shadow: 0 0 0 3px var(--focus); }
.glass-icon:focus-visible .gi-label { opacity: 1; transform: translate(-50%, 0) scale(1); }
@media (hover: hover) {
  .glass-icon:hover .gi-plate,
  .glass-icon:hover .gi-glass,
  .glass-icon:hover .gi-face { transform: translateY(-8px); }
  .glass-icon:hover .gi-label { opacity: 1; transform: translate(-50%, -8px) scale(1); }
}
.glass-icon:active .gi-plate,
.glass-icon:active .gi-glass,
.glass-icon:active .gi-face { transform: translateY(-5px) scale(0.96); transition-duration: 0.12s; }
/* Settings → Dock size */
html[data-dock="s"] { --gi-size: 48px; --gi-gap: 12px; --gi-radius: 11px; }
html[data-dock="l"] { --gi-size: 72px; --gi-gap: 18px; --gi-radius: 16px; }

/* ---------- iPad / desktop: dock (default) or sidebar (Settings → Navigation) ---------- */
@media (min-width: 700px) {
  .tabbar, .tb-settings { display: none; }
  .topbar {
    position: static;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top, 0px) + 1.1rem) clamp(1.25rem, 3vw, 2.5rem) 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .tb-logo img { height: 34px; }

  /* Dock mode */
  html:not([data-nav="sidebar"]) {
    /* Keep anything scrolled or tabbed into view clear of the floating dock. */
    scroll-padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--gi-size) + 60px);
  }
  html:not([data-nav="sidebar"]) .main {
    padding: 1rem clamp(1.25rem, 3vw, 2.5rem) calc(env(safe-area-inset-bottom, 0px) + var(--gi-size) + 76px);
  }
  html:not([data-nav="sidebar"]) .dock {
    display: flex;
    justify-content: center;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
    z-index: 50;
    pointer-events: none;
  }
  /* Soft frosted band across the bottom of the screen, behind the dock,
   * fading out upwards so content scrolling under the dock blurs away. */
  html:not([data-nav="sidebar"]) .dock::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(-1 * (env(safe-area-inset-bottom, 0px) + 14px));
    height: calc(env(safe-area-inset-bottom, 0px) + var(--gi-size) + 96px);
    background: linear-gradient(to top, var(--dock-fade) 0%, transparent 100%);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    -webkit-mask-image: linear-gradient(to top, #000 0%, #000 45%, transparent 100%);
    mask-image: linear-gradient(to top, #000 0%, #000 45%, transparent 100%);
    pointer-events: none;
  }
  .dock-shelf {
    display: flex;
    align-items: center;
    gap: var(--gi-gap);
    padding: calc(var(--gi-gap) * 0.75) var(--gi-gap) var(--gi-gap);
    border-radius: calc(var(--gi-radius) * 2);
    position: relative;
    background: var(--dock-shelf);
    -webkit-backdrop-filter: blur(28px) saturate(1.7);
    backdrop-filter: blur(28px) saturate(1.7);
    box-shadow: inset 0 0 0 1px var(--dock-line), 0 18px 40px -18px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
  }
  .dock-items { display: flex; gap: var(--gi-gap); }
  .dock-sep { width: 1px; align-self: stretch; margin: 4px 0; background: var(--dock-line); }

  /* Sidebar mode: icon rail on narrower iPads, full sidebar from 1100px */
  html[data-nav="sidebar"] .topbar,
  html[data-nav="sidebar"] .dock { display: none; }
  html[data-nav="sidebar"] .shell { display: grid; grid-template-columns: 92px minmax(0, 1fr); }
  html[data-nav="sidebar"] .sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    padding: calc(env(safe-area-inset-top, 0px) + 1.1rem) 0.55rem calc(env(safe-area-inset-bottom, 0px) + 1rem);
    background: var(--surface-glass);
    box-shadow: 1px 0 0 var(--border);
    z-index: 20;
  }
  html[data-nav="sidebar"] .main { padding: calc(env(safe-area-inset-top, 0px) + 1.6rem) clamp(1.25rem, 3vw, 2.5rem) 3rem; }
  .sb-logo img { display: block; width: 58px; height: auto; }
  [data-theme="dark"] .sb-logo img {
    filter: brightness(0) saturate(100%) invert(96%) sepia(34%) saturate(314%) hue-rotate(305deg) brightness(107%) contrast(102%);
  }
  .sb-level {
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    color: var(--accent);
    background: rgba(215, 119, 113, 0.12);
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
  }
  .sb-nav { display: flex; flex-direction: column; gap: 0.3rem; width: 100%; margin-top: 0.4rem; }
  .sb-nav .nav-item {
    flex-direction: column;
    gap: 0.2rem;
    min-height: 64px;
    font-size: 0.7rem;
    padding: 0.5rem 0.2rem;
  }
  .sb-nav .nav-item.active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    box-shadow: var(--shadow-glow);
  }
  .sb-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; }
  .sb-settings-label { display: none; }
}
@media (min-width: 1100px) {
  html[data-nav="sidebar"] .shell { grid-template-columns: 248px minmax(0, 1fr); }
  html[data-nav="sidebar"] .sidebar { align-items: stretch; padding-inline: 1rem; }
  .sb-logo { padding: 0 0.4rem; }
  .sb-logo img { width: 112px; }
  .sb-level { align-self: flex-start; margin-left: 0.4rem; }
  .sb-nav .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.8rem;
    min-height: 50px;
    padding: 0.55rem 0.85rem;
    font-size: 0.98rem;
  }
  .sb-nav .nav-item:has(.nav-label-long) .nav-label { display: none; }
  .sb-nav .nav-label-long { display: inline; }
  .sb-foot { align-items: stretch; }
  .sb-settings {
    display: flex;
    justify-content: flex-start;
    gap: 0.8rem;
    width: auto;
    height: auto;
    min-height: 50px;
    padding: 0.55rem 0.85rem;
    border-radius: 16px;
    background: none;
    box-shadow: none;
    color: var(--muted);
    font-weight: 800;
    font-size: 0.98rem;
  }
  .sb-settings-label { display: inline; }
}
@media (hover: hover) {
  .nav-item:not(.active):hover,
  .sb-settings:hover { background: var(--surface-muted); color: var(--text); }
}

/* ---------- Settings sheet ---------- */
.settings {
  width: min(560px, calc(100vw - 2rem));
  max-height: min(88vh, 780px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: auto;
  overscroll-behavior: contain;
  /* Rows scrolled into view stop below the sticky header. */
  scroll-padding-top: 76px;
  scroll-padding-bottom: 16px;
}
.settings::backdrop {
  background: rgba(20, 12, 6, 0.38);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.settings[open] { animation: setIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes setIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
.set-sheet { display: flex; flex-direction: column; gap: 1.15rem; padding: 0 1.25rem 1.4rem; }
.set-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 0 0.4rem;
  background: var(--surface);
}
.set-head h2 { font-size: 1.5rem; font-weight: 900; letter-spacing: -0.02em; }
.set-head h2 span { margin-left: 0.3rem; font-size: 0.6em; font-weight: 700; color: var(--accent); }
.set-group { display: flex; flex-direction: column; gap: 0.5rem; }
.set-group .info-h { margin-bottom: 0.1rem; }
.set-group .profile-fields { margin-top: 0; }
.set-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  width: 100%;
  min-height: 54px;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--text);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.set-row-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.set-row-label { font-weight: 800; }
.set-row-desc { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.set-row .seg { box-shadow: none; }
.set-row .seg-btn { min-height: 36px; padding: 0.3rem 0.8rem; }
.switch {
  position: relative;
  flex-shrink: 0;
  width: 50px;
  height: 30px;
  border-radius: 99px;
  background: var(--border-strong);
  transition: background-color 0.2s ease;
}
.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.switch.on { background: linear-gradient(135deg, var(--accent), var(--accent-3)); }
.switch.on span { transform: translateX(20px); }
.set-fold summary {
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  font-weight: 800;
  cursor: pointer;
}
.set-legal { padding: 0.7rem 0.3rem 0; font-size: 0.84rem; font-weight: 600; line-height: 1.6; color: var(--text-soft); }
.set-legal a { color: var(--accent); }
.set-keys-list { list-style: none; display: flex; flex-direction: column; gap: 0.45rem; padding: 0.7rem 0.3rem 0; }
.set-keys-list li { display: flex; align-items: center; gap: 0.75rem; font-size: 0.86rem; font-weight: 700; color: var(--text-soft); }
.set-keys-list kbd { min-width: 4.4rem; text-align: center; }
@media (max-width: 699px) { .set-wide-only { display: none; } }
@media (prefers-reduced-motion: reduce) { .settings[open] { animation: none; } .switch span { transition: none; } }
@media (prefers-reduced-motion: reduce) {
  .glass-icon { animation: none; }
  .gi-plate, .gi-glass, .gi-face, .gi-label { transition: none; }
}

/* ---------- Page scaffolding ---------- */
.page { display: flex; flex-direction: column; gap: var(--stack-gap); }
.main.is-entering .page { animation: pageIn 0.28s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; flex-direction: column; gap: 0.5rem; }
.page-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem 1rem; }
.page-title {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.page-title-jp { font-size: 0.55em; font-weight: 700; color: var(--accent); letter-spacing: 0; margin-left: 0.2rem; }
.page-sub { color: var(--muted); font-weight: 700; font-size: 0.95rem; margin-top: 0.3rem; max-width: 60ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  align-self: flex-start;
  min-height: 36px;
  padding: 0.2rem 0.6rem 0.2rem 0.2rem;
  margin-left: -0.2rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
}
@media (hover: hover) { .back-link:hover { background: rgba(215, 119, 113, 0.1); } }
.info-h {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.7rem;
}
.done-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--success);
  font-weight: 900;
}

.pbar {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-muted);
  overflow: hidden;
  flex: 1;
}
.pbar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  transition: width 0.4s cubic-bezier(0.4, 1.4, 0.4, 1);
}

.seg {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 38px;
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color 0.18s ease, color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.seg-btn.on {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  box-shadow: var(--shadow-glow);
}
@media (hover: hover) { .seg-btn:not(.on):hover { color: var(--text); } }

.icon-btn { text-decoration: none; }
.icon-btn.on { background: linear-gradient(135deg, var(--accent), var(--accent-3)); color: #fff; }

.action-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.75rem;
}
.action-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.action-card:active { transform: scale(0.98); }
@media (hover: hover) { .action-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); } }
.action-ico {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 14px;
  background: var(--surface-muted);
  color: var(--accent);
}
.action-glyph { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.action-card.is-primary .action-ico { background: linear-gradient(135deg, var(--accent), var(--accent-3)); color: #fff; }
.action-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.action-text strong { font-weight: 900; font-size: 1rem; }
.action-text span { font-size: 0.8rem; font-weight: 700; color: var(--muted); }

.toggle-row-start { justify-content: flex-start; }

/* ---------- Home ---------- */
.home-hero { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.3rem 0 0.1rem; }
.home-greet {
  font-size: clamp(2.1rem, 5.5vw, 3.3rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.home-greet .nowrap { display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.home-sub-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.home-sub { color: var(--muted); font-weight: 700; font-size: 1.05rem; }
.home-edit {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
.home-edit:active { background: var(--surface-muted); }
@media (hover: hover) { .home-edit:hover { background: var(--surface-muted); color: var(--text); } }
.home-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-soft);
}
.home-meta-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.home-meta-item .lucide { color: var(--muted); }
.home-meta-item.is-streak .lucide { color: inherit; }
.home-meta-item.is-streak { color: var(--accent-3); }

.home-profile {
  gap: 0.5rem;
  padding: clamp(1.1rem, 3vw, 1.6rem);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.profile-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; margin-top: 0.5rem; }
.profile-field { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; font-weight: 800; color: var(--text-soft); }
.profile-field small { margin-left: 0.25rem; font-weight: 700; color: var(--muted); }
.profile-field input {
  min-height: 50px;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 14px;
  background: var(--bg);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.profile-field input:focus { outline: none; border-color: var(--accent-3); box-shadow: 0 0 0 3px rgba(255, 113, 0, 0.18); }
.profile-hint { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.profile-actions { display: flex; gap: 0.5rem; margin-top: 0.3rem; }
.profile-actions .btn { min-height: var(--tap); min-width: 6.5rem; }
.home-quick { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.home-quick .btn { text-decoration: none; min-height: var(--tap); }
.area-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.9rem;
}
.area-card {
  display: flex;
  gap: 1rem;
  padding: 1.1rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.area-card:active { transform: scale(0.985); }
@media (hover: hover) { .area-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); } }
.area-body { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; flex: 1; }
.area-glyph {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 18px;
  font-size: 2.1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
}
.area-kata .area-glyph { background: linear-gradient(135deg, #4dabf7, #7950f2); }
.area-kanji .area-glyph { background: linear-gradient(135deg, #e03131, #f76707); }
.area-vocab .area-glyph { background: linear-gradient(135deg, #20c997, #12b886); }
.area-grammar .area-glyph { background: linear-gradient(135deg, #f59f00, #e8590c); }
.area-title { font-weight: 900; font-size: 1.1rem; }
.area-jp { font-size: 0.78rem; color: var(--muted); font-weight: 700; margin-left: 0.2rem; }
.area-count { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.area-count strong { color: var(--text); font-size: 1rem; }
.area-cta { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; font-weight: 800; color: var(--accent); }

/* ---------- Home widgets (home-widgets.js) ---------- */
.home-quick { align-items: center; }
.home-customize { margin-left: auto; }
/* Cards in a row share the tallest card's height; balanceHomeGrid() widens a
 * card left alone in a row so the grid never has holes. */
.hw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.9rem; align-items: stretch; }
.hw {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  padding: 1rem 1.1rem 1.1rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.hw-full { grid-column: 1 / -1; }
.hw-bare { padding: 0; background: none; box-shadow: none; }
.hw-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 32px; }
.hw-head-tools { display: flex; align-items: center; gap: 0.35rem; margin-right: -0.4rem; }
.hw-body { flex: 1; display: flex; flex-direction: column; gap: 0.75rem; min-height: 0; }
/* A single block (meter, word of the day…) sits centred in a stretched card;
 * trailing actions and footers sit at the bottom. */
.hw-body > :only-child { margin-block: auto; }
.hw-body > .hw-cta, .hw-body > .hw-foot { margin-top: auto; }
.hw-grip {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: var(--muted);
  opacity: 0.55;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}
.hw-grip:focus-visible, .hw-grip:active { opacity: 1; background: var(--surface-muted); }
@media (hover: hover) { .hw:hover .hw-grip { opacity: 0.9; } .hw-grip:hover { opacity: 1; background: var(--surface-muted); } }
@media (hover: none) { .hw-grip { opacity: 0.75; } }
.hw.is-dragging {
  z-index: 70;
  box-shadow: var(--shadow-lg), 0 0 0 2px rgba(255, 113, 0, 0.35);
  transform: rotate(-0.8deg) scale(1.02);
  cursor: grabbing;
  pointer-events: none;
}
.hw-bare.is-dragging { padding: 1rem; background: var(--surface); border-radius: var(--radius-lg); }
.hw-ph {
  min-height: 120px;
  border-radius: var(--radius-lg);
  border: 2px dashed rgba(255, 113, 0, 0.4);
  background: rgba(255, 113, 0, 0.05);
}
html.is-dragging-widget, html.is-dragging-widget * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }
.hw-head h2 { font-size: 0.72rem; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.hw-head h2 span { margin-left: 0.25rem; letter-spacing: 0.02em; text-transform: none; font-weight: 700; color: var(--accent); }
.hw-head-num { font-size: 0.8rem; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.hw-empty { font-size: 0.88rem; font-weight: 700; line-height: 1.5; color: var(--muted); }
.hw-none { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding: 1rem; }
.hw-foot { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.hw-split { display: flex; align-items: center; gap: 1rem; }
.hw-icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
.hw-icon-btn:disabled { opacity: 0.3; cursor: default; }
@media (hover: hover) { .hw-icon-btn:not(:disabled):hover { color: var(--text); } }
.hw .chip, .hw-cta { text-decoration: none; }

.hw-rows { display: flex; flex-direction: column; gap: 0.45rem; }
.hw-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.hw-row:active { transform: scale(0.99); }
.hw-row > .lucide { margin-left: auto; color: var(--muted); }
.hw-row-glyph {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 700;
}
.hw-row-text { display: flex; flex-direction: column; min-width: 0; }
.hw-row-text strong { font-size: 0.95rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-row-text small { font-size: 0.76rem; font-weight: 700; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.meter {
  --pct: 0;
  display: grid;
  place-items: center;
  width: 108px;
  height: 108px;
  flex-shrink: 0;
  border-radius: 50%;
  background: conic-gradient(var(--accent-3) calc(var(--pct) * 1%), var(--surface-muted) 0);
}
.meter > div { display: grid; place-items: center; align-content: center; width: 84px; height: 84px; border-radius: 50%; background: var(--surface); }
.meter strong { font-size: 1.45rem; font-weight: 900; line-height: 1.1; }
.meter span { font-size: 0.72rem; font-weight: 800; color: var(--muted); }
.meter.is-done { background: var(--success); }
.hw-bars { list-style: none; flex: 1; display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.hw-bars li { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr) auto; align-items: center; gap: 0.5rem; font-size: 0.8rem; font-weight: 800; }
.hw-bar-label { color: var(--text-soft); }
.hw-bar-num { min-width: 2.6rem; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.wk { list-style: none; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.3rem; }
.wk-day { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.wk-dot { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-muted); color: #fff; }
.wk-dot.lvl-1 { background: rgba(255, 113, 0, 0.35); }
.wk-dot.lvl-2 { background: rgba(255, 113, 0, 0.55); }
.wk-dot.lvl-3 { background: rgba(255, 113, 0, 0.78); }
.wk-dot.lvl-4 { background: linear-gradient(135deg, var(--accent), var(--accent-3)); }
.wk-day.is-today .wk-dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent-3); }
.wk-day.is-future { opacity: 0.45; }
.wk-l { font-size: 0.72rem; font-weight: 900; color: var(--text-soft); }
.wk-jp { font-size: 0.66rem; color: var(--muted); }

.hw-goal-text, .hw-day-text { display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; min-width: 0; }
.hw-goal-text strong, .hw-day-text strong { font-size: 1.05rem; font-weight: 900; }
.hw-goal-text small, .hw-day-text small { font-size: 0.8rem; font-weight: 700; line-height: 1.45; color: var(--muted); }

.rv-list { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }
.rv-list a { display: flex; align-items: center; gap: 0.7rem; padding: 0.4rem 0.5rem; border-radius: 12px; color: var(--text); text-decoration: none; }
@media (hover: hover) { .rv-list a:hover { background: var(--surface-muted); } }
.rv-glyph { min-width: 2.6rem; text-align: center; font-size: 1.35rem; font-weight: 700; }
.rv-glyph.is-wide { font-size: 1rem; }
.rv-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.88rem; font-weight: 700; color: var(--text-soft); }
.rv-miss { font-size: 0.74rem; font-weight: 800; color: var(--danger); white-space: nowrap; }
.hw-cta { align-self: flex-start; min-height: var(--tap); }

/* Kana / kanji maps */
.st-new { background: var(--surface-muted); }
.st-seen { background: rgba(255, 113, 0, 0.18); }
.st-learned { background: linear-gradient(135deg, var(--accent), var(--accent-3)); }
.mz-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.mz-title { margin-bottom: 0.4rem; font-size: 0.8rem; font-weight: 900; color: var(--text-soft); }
.mz-kana { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.mz-n { display: flex; justify-content: center; margin-top: 4px; }
.mz-n .mz-cell { width: calc((100% - 36px) / 10); }
.mz-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.mz-cell.st-new { color: var(--muted); }
.mz-cell.st-seen { color: var(--accent-3); }
.mz-cell.st-learned { color: #fff; }
.mz-cell.is-blank { background: none; }
@media (hover: hover) { a.mz-cell:hover { box-shadow: inset 0 0 0 2px var(--accent-3); } }
.mz-kanji { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px; }
.mz-kanji .mz-cell { font-size: 1.15rem; }
.mz-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; font-size: 0.74rem; font-weight: 700; color: var(--muted); }
.mz-legend > span { width: 12px; height: 12px; margin-left: 0.4rem; border-radius: 4px; }
.mz-legend > span:first-child { margin-left: 0; }

.rw-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; }
.rw-item { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; min-width: 0; color: var(--muted); text-decoration: none; }
.rw-glyph { display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 12px; background: var(--surface-muted); color: var(--text); font-size: 1.6rem; font-weight: 700; }
.rw-svg { width: 78%; height: 78%; }
.rw-svg path, .kd-svg path { fill: none; stroke: var(--text); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.rw-item small { font-size: 0.7rem; font-weight: 800; }
.rw-item small.is-clean { color: var(--success); }

.kd-box, .wd-emoji {
  display: grid;
  place-items: center;
  width: 108px;
  height: 108px;
  flex-shrink: 0;
  border-radius: 18px;
  background: var(--surface-muted);
}
.kd-text { font-size: 3.4rem; font-weight: 700; }
.kd-svg { width: 84px; height: 84px; }
/* Drawn by default; .is-playing (playStrokes) draws the strokes in order once. */
.kd-svg path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.kd-svg.is-playing path { animation: kdDraw 0.5s ease both; animation-delay: calc(var(--d) * 0.45s + 0.3s); }
@keyframes kdDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.wd-emoji { font-size: 3.4rem; line-height: 1; }
.hw-day-text .wd-jp { font-size: 1.55rem; }
.wd-en { font-weight: 700; color: var(--text-soft); }

.hm { display: flex; gap: 0.45rem; }
.hm-days { display: grid; grid-template-rows: repeat(7, 15px); gap: 4px; font-size: 0.62rem; font-weight: 800; line-height: 1; color: var(--muted); }
.hm-days span { display: flex; align-items: center; }
.hm-scroll { flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.hm-scroll::-webkit-scrollbar { display: none; }
.hm-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 15px); grid-auto-columns: 15px; gap: 4px; justify-content: end; min-width: 100%; }
.hm-cell { display: block; width: 15px; height: 15px; border-radius: 4px; background: var(--surface-muted); }
.hm-cell.lvl-1 { background: rgba(255, 113, 0, 0.3); }
.hm-cell.lvl-2 { background: rgba(255, 113, 0, 0.5); }
.hm-cell.lvl-3 { background: rgba(255, 113, 0, 0.72); }
.hm-cell.lvl-4 { background: var(--accent-3); }
.hm-cell.is-future { opacity: 0.35; }
.hm-legend .hm-cell { display: inline-block; width: 12px; height: 12px; }

.hw-setup {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(215, 119, 113, 0.16), rgba(255, 113, 0, 0.12));
  box-shadow: inset 0 0 0 1px rgba(255, 113, 0, 0.18);
}
.hw-setup h2 { display: flex; align-items: center; gap: 0.4rem; font-size: 1.15rem; font-weight: 900; }
.hw-setup h2 .lucide { color: var(--accent-3); }
.hw-setup p { max-width: 52ch; margin-top: 0.2rem; font-size: 0.9rem; font-weight: 600; color: var(--text-soft); }
.hw-setup-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.hw-setup-actions .btn { min-height: var(--tap); }

/* Customize sheet */
.set-intro { margin-top: -0.4rem; font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.hw-pick-list { list-style: none; display: flex; flex-direction: column; gap: 0.45rem; }
.hw-pick { display: flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.5rem 0.3rem 0.2rem; border-radius: var(--radius-md); background: var(--surface-muted); }
.hw-pick-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
  min-height: 54px;
  padding: 0.4rem 0.5rem;
  border-radius: 12px;
  color: var(--text);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.hw-pick:not(.is-on) .set-row-label { color: var(--text-soft); }
.hw-pick-jp { margin-left: 0.2rem; font-size: 0.72rem; font-weight: 700; color: var(--accent); }
.hw-pick-move { display: flex; gap: 0.3rem; }
.hw-pick .hw-icon-btn { background: var(--surface); }
.set-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; }
.set-actions .btn { min-height: var(--tap); }
.set-link { cursor: pointer; }
.set-link > .lucide { color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .kd-svg.is-playing path { animation: none; }
}

/* ---------- Kana ---------- */
.kana-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; }
.kana-toolbar-hint { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.kana-page .kana-chart-wrap { display: grid; gap: 1rem; }
@media (min-width: 1100px) {
  .kana-page .kana-chart-wrap { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  .kana-page .kana-chart-basic { grid-column: 1 / -1; }
}
.kana-page .kana-chart { min-width: 0; }
.kana-page .kana-chart-basic .kana-chart { min-width: 520px; }
.kana-page .kana-chart-yoon .kana-chart { min-width: 560px; }
.kana-page .kana-char {
  min-width: var(--tap);
  min-height: var(--tap);
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
  -webkit-tap-highlight-color: transparent;
}
.kana-page .kana-char-wide { font-size: clamp(1.1rem, 2vw, 1.4rem); }
.kana-char:active { background: var(--surface-muted); }
.kana-cell { position: relative; }
.kana-cell.is-learned .kana-char { color: var(--accent); }
.kana-cell.is-learned::after,
.kana-n-row.is-learned .kana-n-char::after {
  content: "";
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.kana-n-row .kana-n-char { position: relative; min-width: var(--tap); min-height: var(--tap); font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
.kana-n-row.is-learned .kana-n-char { color: var(--accent); }
.kana-n-row.is-learned .kana-n-char::after { right: 2px; }
.kana-chart-note { margin-top: 0.75rem; font-size: 0.8rem; font-weight: 700; color: var(--muted); }

.drill-page .kana-learn-section { background: var(--surface); border-radius: var(--radius-xl); padding: clamp(1rem, 3vw, 2rem); box-shadow: var(--shadow-md); }
.drill-page .kana-learn-drill-inner { max-width: 30rem; margin: 0 auto; display: flex; flex-direction: column; gap: 0.9rem; }
.drill-page .kana-learn-input { font-size: 1.4rem; min-height: 56px; text-align: center; }
.drill-page .kana-learn-footer { display: flex; gap: 0.6rem; justify-content: center; }
.drill-page .kana-learn-complete-actions .btn { text-decoration: none; }

/* ---------- Study (writing) ---------- */
.study-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.study-nav { display: flex; align-items: center; gap: 0.5rem; }
.study-pos { min-width: 4.5rem; text-align: center; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.study-grid { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 1000px) {
  .study-grid { grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.88fr); }
  .study-info { position: sticky; top: 1.25rem; }
}
.study-pad-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: clamp(0.85rem, 2vw, 1.25rem);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.pad-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; }
.pad-tools { display: flex; gap: 0.45rem; }
.pad-host {
  position: relative;
  width: 100%;
  max-width: min(600px, 66vh);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  background: var(--bg);
  box-shadow: inset 0 0 0 1.5px var(--border-strong);
  overflow: hidden;
}
.pad-loading { position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; text-align: center; color: var(--muted); font-weight: 700; }
.pad-status {
  min-height: 1.5em;
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-soft);
}
.pad-status[data-tone="ok"] { color: var(--success); }
.pad-status[data-tone="bad"] { color: var(--danger); }
.pad-status[data-tone="done"] { color: var(--accent-3); }
.pad-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem;
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  animation: pageIn 0.3s ease both;
}
.pad-done[hidden] { display: none; }
.pad-done-text { font-weight: 800; text-align: center; }
.pad-done-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.pad-done-actions .btn { text-decoration: none; min-height: var(--tap); }

.wp { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.wp-svg { display: block; width: 100%; height: 100%; touch-action: none; }
.wp[data-mode="trace"] .wp-svg,
.wp[data-mode="write"] .wp-svg { cursor: crosshair; }
.wp-guides line { stroke: var(--wp-guide); stroke-width: 0.6; stroke-dasharray: 2.2 2.2; }
.wp-ghost path,
.wp-done path,
.wp-anim path,
.wp-hint path,
.wp-miss path,
.wp-live {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}
.wp-ghost path { stroke: var(--wp-ghost); }
.wp-ghost path.is-next { stroke: var(--wp-ghost-next); }
.wp[data-mode="watch"] .wp-ghost path { stroke: var(--wp-ghost); }
.wp-done path, .wp-anim path { stroke: var(--wp-ink); }
.wp-anim { transition: opacity 0.4s ease; }
.wp-anim.is-fading { opacity: 0; }
.wp-hint path { stroke: var(--wp-hint); opacity: 0.9; transition: opacity 0.5s ease; }
.wp-hint .is-fading { opacity: 0; transition: opacity 0.5s ease; }
.wp-start { fill: var(--accent-3); stroke: var(--surface); stroke-width: 1.2; }
@media (prefers-reduced-motion: no-preference) {
  .wp-start { animation: wpPulse 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
}
@keyframes wpPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
.wp-nums text {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 7px;
  font-weight: 700;
  fill: var(--accent);
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 2px;
}
.wp-miss path { stroke: var(--danger); opacity: 0.75; }
@media (prefers-reduced-motion: no-preference) {
  .wp-miss path { animation: wpMiss 0.65s ease forwards; }
}
@keyframes wpMiss { 0% { opacity: 0.85; } 60% { opacity: 0.6; } 100% { opacity: 0; } }
.wp-live { stroke: var(--wp-live); stroke-width: 5.5; }
.wp-complete .wp-done path { stroke: var(--success); transition: stroke 0.35s ease; }

.study-info { display: flex; flex-direction: column; gap: 0.9rem; }
.info-card {
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.info-hero { display: flex; align-items: center; gap: 1rem; position: relative; }
.info-glyph {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  flex-shrink: 0;
  border-radius: 20px;
  background: var(--surface-muted);
  font-size: 3.2rem;
  font-weight: 700;
  line-height: 1;
}
.info-hero-text { min-width: 0; }
.info-meaning { font-size: 1.35rem; font-weight: 900; letter-spacing: -0.01em; line-height: 1.2; }
.info-roma { font-size: 2rem; font-style: italic; }
.info-meta { margin-top: 0.25rem; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.info-learned {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  color: #fff;
  background: var(--success);
}
.info-learned[hidden] { display: none; }
.readings { display: grid; gap: 0.6rem; margin-top: 1rem; }
.reading-row { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); align-items: center; gap: 0.6rem; }
.reading-row dt { font-size: 0.78rem; font-weight: 900; color: var(--muted); }
.reading-row dt span { color: var(--accent); margin-left: 0.15rem; }
.reading-row dd { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.reading-chip {
  padding: 0.3rem 0.65rem;
  border-radius: 10px;
  background: var(--surface-muted);
  font-size: 1.05rem;
  font-weight: 700;
}
.okuri { color: var(--muted); }
.reading-none { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.reading-help { margin-top: 0.9rem; font-size: 0.8rem; line-height: 1.5; color: var(--muted); font-weight: 600; }
.ex-list { list-style: none; display: flex; flex-direction: column; }
.ex-row {
  display: grid;
  grid-template-columns: minmax(5.5rem, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--surface-muted);
}
.ex-row:first-child { border-top: 0; }
.ex-jp { font-size: 1.35rem; font-weight: 700; }
.ex-jp rt { font-size: 0.5em; color: var(--muted); font-weight: 700; }
.ex-mid { display: flex; flex-direction: column; min-width: 0; }
.ex-en { font-weight: 800; font-size: 0.92rem; }
.ex-roma { font-size: 0.75rem; font-style: italic; color: var(--muted); font-weight: 700; }
.info-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.info-actions .btn, .info-quiz { text-decoration: none; min-height: var(--tap); }
.speak-btn-lg { width: 44px; height: 44px; }

/* ---------- Kanji index ---------- */
.kanji-group { display: flex; flex-direction: column; gap: 0.7rem; }
.kanji-group-head { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.kanji-group-head h2 { font-size: 1.15rem; font-weight: 900; letter-spacing: -0.01em; }
.kg-jp { font-size: 0.8rem; color: var(--muted); font-weight: 700; margin-left: 0.2rem; }
.kg-count { font-size: 0.85rem; font-weight: 800; color: var(--muted); margin-right: auto; font-variant-numeric: tabular-nums; }
.kanji-group-head .chip { text-decoration: none; }
.kanji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.6rem;
}
.kanji-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  aspect-ratio: 1 / 1.05;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}
.kanji-tile:active { transform: scale(0.96); }
@media (hover: hover) { .kanji-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); } }
.kt-char { font-size: 2.4rem; font-weight: 700; line-height: 1; }
.kt-mean { font-size: 0.72rem; font-weight: 800; color: var(--muted); text-align: center; padding: 0 0.3rem; }
.kanji-tile.is-learned { background: linear-gradient(160deg, var(--surface), rgba(47, 158, 68, 0.09)); }
.kanji-tile.is-written:not(.is-learned) .kt-char { color: var(--accent); }
.kt-check {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
}

/* ---------- Vocabulary ---------- */
.vocab-toolbar { display: flex; flex-direction: column; gap: 0.6rem; }
.vocab-toolbar .toggle-row { justify-content: flex-start; }
.vocab-page .cats-wrap { justify-content: flex-start; margin: 0; }
.vocab-page .cat-btn { min-height: 40px; }
.vocab-cat-progress {
  display: grid;
  grid-template-columns: auto auto minmax(80px, 1fr);
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.vocab-cat-name { font-weight: 900; }
.vocab-cat-count { font-weight: 800; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* ---------- Japanese sentences ---------- */
.jp-sentence { font-size: clamp(1.3rem, 2.6vw, 1.6rem); font-weight: 700; line-height: 2.1; }
.jp-sentence ruby { ruby-position: over; }
.jp-sentence rt { font-size: 0.48em; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
.jp-blank {
  display: inline-block;
  min-width: 3.2em;
  height: 1.3em;
  margin: 0 0.15em;
  vertical-align: -0.2em;
  border-radius: 8px;
  border-bottom: 3px solid var(--accent-3);
  background: rgba(255, 113, 0, 0.08);
}
.jp-blank.is-filled {
  min-width: 0;
  height: auto;
  padding: 0 0.25em;
  color: var(--accent-3);
  vertical-align: baseline;
}

/* ---------- Grammar ---------- */
.gram-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.65rem; }
.gram-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.gram-card > .lucide { color: var(--muted); }
.gram-card:active { transform: scale(0.985); }
@media (hover: hover) { .gram-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); } }
.gram-num {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--surface-muted);
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.gram-card.is-done .gram-num { background: var(--success); color: #fff; }
.gram-card-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.gram-card-title { font-weight: 800; font-size: 1.05rem; }
.gram-card-meaning { font-size: 0.82rem; font-weight: 700; color: var(--muted); }

.lesson-grid { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 1000px) { .lesson-grid { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); } }
.lesson-card {
  padding: clamp(1rem, 2.5vw, 1.4rem);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.gram-pattern {
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(215, 119, 113, 0.12), rgba(255, 113, 0, 0.08));
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.gram-notes { margin: 0.9rem 0 0 1.1rem; display: flex; flex-direction: column; gap: 0.55rem; font-weight: 600; line-height: 1.55; color: var(--text-soft); }
.gram-ex-list { list-style: none; display: flex; flex-direction: column; }
.gram-ex {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--surface-muted);
}
.gram-ex:first-child { border-top: 0; padding-top: 0; }
.gram-ex-main { flex: 1; min-width: 0; }
.gram-ex-roma { font-size: 0.82rem; font-style: italic; font-weight: 700; color: var(--muted); }
.gram-ex-en { font-weight: 700; color: var(--text-soft); margin-top: 0.1rem; }

.gp-list { list-style: none; display: flex; flex-direction: column; gap: 1rem; }
.gp-item { padding: 0.9rem 1rem; border-radius: var(--radius-md); background: var(--surface-muted); }
[data-theme="dark"] .gp-item { background: #3a3a3a; }
.gp-q { display: flex; align-items: center; gap: 0.75rem; }
.gp-q .jp-sentence { flex: 1; min-width: 0; }
.gp-n {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--surface);
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--muted);
}
.gp-en { margin: 0.2rem 0 0.6rem; font-weight: 700; color: var(--muted); font-size: 0.9rem; }
.gp-opts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.gp-opt {
  min-height: var(--tap);
  min-width: 4.5rem;
  padding: 0.45rem 1rem;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 1.15rem;
  font-weight: 700;
  transition: transform 0.12s ease, background-color 0.15s ease;
}
.gp-opt:not(:disabled):active { transform: scale(0.95); }
.gp-opt:disabled { cursor: default; }
.gp-opt.correct { background: var(--success); color: #fff; }
.gp-opt.wrong { background: var(--danger); color: #fff; animation: shake 0.35s ease; }
.gp-item.is-answered .gp-opt:not(.correct):not(.wrong) { opacity: 0.45; }
.gp-feedback { display: flex; flex-direction: column; gap: 0.15rem; margin-top: 0.7rem; font-weight: 700; font-size: 0.9rem; }
.gp-feedback.is-ok strong { color: var(--success); }
.gp-feedback.is-bad strong { color: var(--danger); }
.gp-why { color: var(--text-soft); }
.gp-roma { font-style: italic; color: var(--muted); font-size: 0.82rem; }
.gp-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 113, 0, 0.08);
  font-weight: 800;
}
.gp-summary.is-ok { background: rgba(47, 158, 68, 0.12); }
.gp-summary-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.gp-summary-actions .btn, .lesson-nav .btn, .page-actions .btn { text-decoration: none; min-height: var(--tap); }
.lesson-nav { display: flex; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }

/* ---------- Quiz hub ---------- */
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.8rem; }
.quiz-tile {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}
.quiz-tile:active { transform: scale(0.985); }
@media (hover: hover) { .quiz-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); } }
.quiz-tile-glyph {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 16px;
  background: var(--surface-muted);
  color: var(--accent);
  font-size: 1.7rem;
  font-weight: 700;
}
.quiz-tile.is-primary { background: linear-gradient(135deg, var(--accent), var(--accent-3)); color: #fff; box-shadow: var(--shadow-glow); }
.quiz-tile.is-primary .quiz-tile-glyph { background: rgba(255, 255, 255, 0.22); color: #fff; }
.quiz-tile.is-primary .quiz-tile-desc,
.quiz-tile.is-primary .quiz-tile-stat { color: rgba(255, 255, 255, 0.85); }
.quiz-tile-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.quiz-tile-title { font-weight: 900; font-size: 1.02rem; }
.quiz-tile-title span { font-size: 0.75rem; font-weight: 700; opacity: 0.7; margin-left: 0.15rem; }
.quiz-tile-desc { font-size: 0.82rem; font-weight: 700; color: var(--text-soft); }
.quiz-tile-stat { font-size: 0.72rem; font-weight: 700; color: var(--muted); }
.quiz-groups .chip { text-decoration: none; }

/* ---------- Quiz round ---------- */
.quiz-page { max-width: 760px; width: 100%; margin: 0 auto; }
.qz-top { display: flex; align-items: center; gap: 0.9rem; }
.qz-progress { display: flex; align-items: center; gap: 0.7rem; flex: 1; }
.qz-count { font-weight: 900; font-variant-numeric: tabular-nums; color: var(--text-soft); min-width: 3.5rem; }
.qz-score { display: inline-flex; align-items: center; gap: 0.25rem; font-weight: 900; color: var(--success); font-variant-numeric: tabular-nums; }
.qz-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: clamp(1.4rem, 4vw, 2.4rem) 1.2rem;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(70% 90% at 50% 0%, rgba(255, 113, 0, 0.1), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow-md);
  text-align: center;
}
.qz-label { font-size: 0.75rem; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
.qz-main { font-size: clamp(2.6rem, 8vw, 4.2rem); font-weight: 700; line-height: 1.15; }
.qz-main.is-huge { font-size: clamp(4rem, 13vw, 7rem); }
.qz-main.is-latin { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 900; letter-spacing: -0.01em; }
.qz-sub { font-weight: 700; color: var(--muted); }
.qz-sentence { text-align: center; }
.qz-audio {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  box-shadow: var(--shadow-glow);
  transition: transform 0.15s ease;
}
.qz-audio:active { transform: scale(0.94); }
.qz-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
.qz-opt {
  min-height: 64px;
  font-size: 1.08rem;
  justify-content: flex-start;
  -webkit-tap-highlight-color: transparent;
}
.qz-opt[lang="ja"] { font-size: 1.45rem; font-weight: 700; }
.qz-opt.is-big { font-size: 2rem; }
.qz-opt:disabled { cursor: default; }
.qz-opt:disabled:not(.correct):not(.wrong) { opacity: 0.5; }
@media (max-width: 480px) { .qz-opts { grid-template-columns: 1fr; } }
.qz-feedback {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  animation: pageIn 0.25s ease both;
}
.qz-feedback.is-ok { background: rgba(47, 158, 68, 0.12); }
.qz-feedback.is-ok strong { color: var(--success); }
.qz-feedback.is-bad { background: rgba(224, 49, 49, 0.1); }
.qz-feedback.is-bad strong { color: var(--danger); }
.qz-feedback span { color: var(--text-soft); font-size: 0.9rem; }
.qz-next-row { display: flex; justify-content: flex-end; }
.qz-next-row .btn { min-width: 9rem; min-height: 50px; }
/* After a right answer the quiz moves on by itself: the Next button fills up
   until then (tap it to go straight away). */
.qz-next-row .btn.is-auto { position: relative; overflow: hidden; isolation: isolate; }
.qz-next-row .btn.is-auto::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  /* A bright bar along the bottom edge over a faint fill, so the label stays readable. */
  background: linear-gradient(to top, rgba(255, 255, 255, 0.92) 0 4px, rgba(255, 255, 255, 0.16) 4px);
  transform: scaleX(0);
  transform-origin: left center;
  animation: qzAutoFill var(--auto-total, 1100ms) linear var(--auto-delay, 0ms) both;
}
@keyframes qzAutoFill { to { transform: scaleX(1); } }

.qz-results { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; text-align: center; padding-top: 1rem; }
.qz-ring {
  --pct: 0;
  display: grid;
  place-items: center;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  background: conic-gradient(var(--accent-3) calc(var(--pct) * 1%), var(--surface-muted) 0);
}
.qz-ring > div {
  display: grid;
  place-items: center;
  align-content: center;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: var(--bg);
}
.qz-ring strong { font-size: 2rem; font-weight: 900; }
.qz-ring span { font-weight: 800; color: var(--muted); }
.qz-headline { font-size: 1.6rem; font-weight: 900; }
.qz-result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin: 0.4rem 0 1rem; }
.qz-result-actions .btn { text-decoration: none; min-height: var(--tap); }
.qz-missed {
  list-style: none;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
}
.qz-missed li {
  display: flex;
  flex-direction: column;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
  font-size: 1.05rem;
}
.qz-missed small { font-size: 0.78rem; color: var(--muted); font-weight: 700; }

/* ---------- Touch devices ---------- */
@media (pointer: coarse) {
  .chip { min-height: 40px; padding: 0.5rem 0.9rem; font-size: 0.85rem; }
  .icon-btn { width: 46px; height: 46px; }
  .speak-btn { width: 40px; height: 40px; }
}
/* Touch: hover styles stick after a tap on iPad, so neutralise the lift/scale ones. */
@media (hover: none) {
  .card:hover,
  .chip:hover,
  .cat-btn:hover,
  .icon-btn:hover,
  .answer-btn:hover,
  .speak-btn:hover,
  .kana-char:hover,
  button.kana-n-char:hover,
  .theme-toggle:hover { transform: none; }
  .speak-btn:hover { background: var(--surface-muted); color: var(--text-soft); }
}

@media (prefers-reduced-motion: reduce) {
  .main.is-entering .page { animation: none; }
}
