:root {
  --bg: #06121f;
  --surface: #0b1d30;
  --surface-2: #122a44;
  --border: rgba(165, 220, 245, 0.20);
  --text: #f8fafc;
  --muted: #b0cde6;
  --accent: #38bdf8;
  --gold: #fbbf24;
  --green: #34d399;
  --purple: #a78bfa;
  --red: #fb7185;
  --fk-w: clamp(70px, 19.5vw, 82px);
  --fk-h: clamp(44px, calc(var(--fk-w) * 0.60), 50px);
  --fk-gap: 6px;
  --fk-grid-w: calc(var(--fk-w) * 3 + var(--fk-gap) * 2);
  --fk-grid-h: calc(var(--fk-h) * 4 + var(--fk-gap) * 3);
  --write-chrome-h: 0px;
  --write-dock-h: var(--fk-grid-h);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: #0d2b42;
  background-image: radial-gradient(circle at 50% 22%, #113654 0%, #0d2b42 78%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
  touch-action: manipulation;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: max(8px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  gap: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-right: 0;
  min-height: 36px;
}

.icon-pill {
  border: 1px solid rgba(165, 220, 245, 0.22);
  background: linear-gradient(180deg, rgba(16, 40, 68, 0.72), rgba(9, 23, 42, 0.84));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.16);
  color: #cbd5e1;
  border-radius: 10px;
  width: 36px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.icon-pill:active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.input-switch {
  display: flex;
  min-width: 0;
  max-width: 100%;
  background: rgba(18, 22, 34, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.sw-pill {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.sw-pill.active {
  background: var(--accent);
  color: #05111d;
  font-weight: 800;
}

.tool-pill {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

/* Open Typographic Stage */
.stage-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 4px 8px;
}

.word-stage {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 120ms ease;
}
.word-stage.complete-pop { filter: drop-shadow(0 0 12px rgba(52, 211, 153, 0.28)); }
.word-stage.phase-transition { animation: mixedPhaseIn 180ms ease-out; }
@keyframes mixedPhaseIn {
  0% { opacity: 0.78; }
  100% { opacity: 1; }
}

.wc-meta {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 22px;
}

.stage-pill,
.mixed-step-pill {
  display: none !important;
}
.stage-pill {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 3px 9px;
  border-radius: 999px;
  opacity: 0.85;
}
.stage-pill.s1 { background: #38bdf81c; color: var(--accent); }
.stage-pill.s2 { background: #a78bfa1e; color: var(--purple); }
.stage-pill.s3 { background: #fbbf241e; color: var(--gold); }
.stage-pill.s4 { background: #34d3991e; color: var(--green); }

.mixed-step-pill {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.mixed-step-pill.step-write {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--accent);
}
.mixed-step-pill.step-flick {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--green);
}

.srs-toast {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: #34d39920;
  color: var(--green);
}

.conj-badge {
  min-height: 21px;
  line-height: 1.2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 11px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: var(--purple);
}
.conj-badge.badge-reading {
  background: rgba(56, 189, 248, 0.13);
  border-color: rgba(56, 189, 248, 0.34);
  color: var(--accent);
}
.conj-badge.badge-vocab {
  background: rgba(52, 211, 153, 0.13);
  border-color: rgba(52, 211, 153, 0.34);
  color: var(--green);
}

.word-kanji {
  position: relative;
  isolation: isolate;
  overflow: visible;
  font-size: clamp(54px, min(16vw, 9.5dvh), 82px);
  font-weight: 400;
  line-height: 1.08;
  color: #ffffff;
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-shadow: 0 4px 20px rgba(2, 16, 34, 0.55);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  max-width: 100%;
  gap: 8px;
}
.kj-phrase-group {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  isolation: isolate;
}
.word-kanji.len-sm { font-size: clamp(44px, min(13vw, 8.2dvh), 70px); gap: 7px; }
.word-kanji.len-md { font-size: clamp(38px, min(11.2vw, 7.6dvh), 58px); gap: 6px; }
.word-kanji.len-lg { font-size: clamp(32px, min(9.8vw, 7.2dvh), 48px); gap: 5px; letter-spacing: 0.02em; }
.word-kanji.len-xl { font-size: clamp(28px, min(8.6vw, 6.6dvh), 42px); gap: 6px 5px; letter-spacing: 0.01em; }
.word-kanji.len-wrap {
  font-size: clamp(30px, min(9.2vw, 6.6dvh), 42px);
  gap: 7px 6px;
  justify-content: center;
  max-width: min(100%, calc(var(--kj-row-max, 6) * 1.24em + (var(--kj-row-max, 6) - 1) * 5px + 18px));
}
/* 9+ chars: a phrase longer than half the word (a pure-kana greeting) wraps inside itself instead of running off-screen; shorter words keep their one-row phrases. */
.word-kanji.len-split .kj-phrase-group { flex-wrap: wrap; max-width: 100%; }

.kj-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 1.24em;
  block-size: 1.24em;
  padding: 0;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  border-radius: 0.24em;
  border: 1.5px solid transparent;
  transition: opacity 150ms ease, background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease;
}
/* Compensate CJK font baseline offset inside square CSS boxes while keeping [?] SVG centered */
.kj-char:not(.concealed-write) {
  padding-bottom: 0.065em;
}
.kj-svg-glyph {
  width: 0.92em;
  height: 0.92em;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 6.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.kj-char.kj-kana {
  inline-size: auto;
  min-inline-size: 0.90em;
  padding-inline: 0.06em;
  color: #e2e8f0;
}
.kj-char.kj-placeholder {
  inline-size: auto;
  min-inline-size: 0.56em;
  padding-inline: 0.04em;
  color: rgba(186, 214, 240, 0.72);
  font-weight: 400;
}
.kj-char.kj-slot.kj-kana-slot {
  inline-size: 1.24em;
  block-size: 1.24em;
  color: #ffffff;
}
.kj-char.kj-slot {
  position: relative;
  overflow: visible;
  background: linear-gradient(155deg, rgba(16, 40, 68, 0.62), rgba(9, 24, 44, 0.78));
  border-color: rgba(165, 220, 245, 0.26);
  box-shadow: inset 0 1px 0 rgba(224, 244, 255, 0.20), 0 8px 20px rgba(2, 10, 22, 0.34);
}
.kj-char.kj-slot.active-write {
  background: linear-gradient(155deg, rgba(32, 92, 146, 0.56), rgba(14, 42, 76, 0.76));
  border-color: rgba(125, 211, 252, 0.78);
  box-shadow: inset 0 1px 0 rgba(224, 244, 255, 0.30), inset 0 0 16px rgba(56, 189, 248, 0.22), 0 0 20px rgba(56, 189, 248, 0.25);
}
.kj-char.kj-slot.upcoming-write {
  opacity: 0.56;
}
.kj-char.kj-slot.done-write {
  color: #d1fae5;
  background: linear-gradient(155deg, rgba(20, 83, 75, 0.52), rgba(10, 42, 46, 0.74));
  border-color: rgba(110, 231, 183, 0.54);
  box-shadow: inset 0 1px 0 rgba(209, 250, 229, 0.26), 0 0 18px rgba(52, 211, 153, 0.18);
}
.kj-char.kj-slot.flick-slot {
  color: #ffffff;
  background: linear-gradient(155deg, rgba(18, 44, 74, 0.62), rgba(10, 25, 46, 0.78));
  border-color: rgba(165, 220, 245, 0.28);
}
.kj-char.kj-slot.silver-reward {
  color: #f1f5f9;
  text-shadow: 0 1px 3px rgba(15, 23, 42, 0.88);
  background: linear-gradient(135deg, #344050 0%, #5b6d82 26%, #aebdcc 48%, #c2cfdc 53%, #697b90 74%, #2b3644 100%);
  border-color: rgba(203, 213, 225, 0.78);
  box-shadow: inset 0 1px 0 rgba(241, 245, 249, 0.48), inset 0 -1px 0 rgba(15, 23, 42, 0.65), 0 4px 12px rgba(15, 23, 42, 0.42);
}
.kj-char.kj-slot.gold-reward {
  color: #fffef5;
  text-shadow: 0 1px 4px rgba(69, 26, 3, 0.88);
  background: linear-gradient(135deg, #6e4105 0%, #c48414 24%, #fde047 46%, #fef9c3 52%, #d99316 70%, #5c3304 100%);
  border-color: #fde047;
  box-shadow: inset 0 1px 0 rgba(255, 251, 235, 0.82), inset 0 -1px 0 rgba(120, 53, 15, 0.65), 0 0 16px rgba(251, 191, 36, 0.34);
}
.kj-char.kj-slot.platinum-reward {
  color: #0b192c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
  background: linear-gradient(135deg, #8ea8c2 0%, #d8e8f8 24%, #ffffff 47%, #e0f2fe 56%, #b2cbe3 76%, #7d98b5 100%);
  border-color: #ffffff;
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.96), inset 0 -1.5px 0 rgba(71, 85, 105, 0.52), 0 0 16px rgba(224, 242, 254, 0.38);
}
.kj-char.kj-slot.gold-reward::after,
.kj-char.kj-slot.platinum-reward::after {
  content: '';
  position: absolute;
  top: -6px;
  right: -6px;
  width: 14px;
  height: 14px;
  pointer-events: none;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fef3c7' stroke='%23fbbf24' stroke-width='1.2' d='M12 1.5L14.4 9.6L22.5 12L14.4 14.4L12 22.5L9.6 14.4L1.5 12L9.6 9.6Z'/%3E%3C/svg%3E");
  animation: goldSparkle 2.4s ease-in-out infinite;
}
.kj-char.kj-slot.platinum-reward::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' stroke='%23bae6fd' stroke-width='1.2' d='M12 1.5L14.4 9.6L22.5 12L14.4 14.4L12 22.5L9.6 14.4L1.5 12L9.6 9.6Z'/%3E%3C/svg%3E");
}
.kj-char.concealed-write {
  color: #7ea3c8;
  text-align: center;
}
.kj-char.active-write.concealed-write {
  color: #bae6fd;
}

.word-kw {
  font-size: clamp(16px, 4.2vw, 19px);
  font-weight: 760;
  line-height: 1.24;
  color: #f8fafc;
  text-align: center;
  max-width: 100%;
  padding: 0 10px 2px;
  letter-spacing: -0.01em;
}
.word-kw.hidden { display: none; }

.word-en {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.32;
  color: var(--muted);
  text-align: center;
  max-width: 100%;
  min-height: 22px;
  padding: 0 8px;
}
.word-en.concealed { color: #475569; letter-spacing: 0.14em; }

.mixed-ctx-hint {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--muted);
  opacity: 0.85;
  text-align: center;
  max-width: calc(100% - 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 2;
}
.mixed-ctx-hint [lang="ja"] {
  font-family: var(--font-ja);
}

.kana-display {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  max-width: 100%;
  gap: 6px;
  min-height: 44px;
  font-size: clamp(23px, 6.2vw, 30px);
  font-weight: 800;
  white-space: nowrap;
}
.kana-display.klen-lg { font-size: clamp(19px, 5.2vw, 26px); gap: 5px; }
.kana-display.klen-xl { font-size: clamp(16px, 4.4vw, 22px); gap: 4px; }

.alt-readings {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  opacity: 0.72;
  letter-spacing: 0.04em;
  min-height: 18px;
  text-align: center;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.k-char {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.32em;
  height: 1.42em;
  padding: 0 0.16em;
  border-radius: 0.28em;
  background: rgba(14, 34, 58, 0.50);
  border: 1px solid rgba(165, 220, 245, 0.24);
  border-bottom: 2px solid rgba(148, 163, 184, 0.42);
  box-shadow: inset 0 1px 0 rgba(224, 244, 255, 0.14);
  transition: transform 80ms ease, color 80ms ease, background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.k-char.done {
  color: var(--green);
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.44);
  border-bottom-color: var(--green);
}
.kana-display {
  position: relative;
  isolation: isolate;
  overflow: visible;
}
.k-char.done.silver-reward {
  color: #f1f5f9;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.88);
  background: linear-gradient(135deg, #344050 0%, #5b6d82 26%, #aebdcc 48%, #c2cfdc 53%, #697b90 74%, #2b3644 100%);
  border-color: rgba(203, 213, 225, 0.78);
  border-bottom-color: #94a3b8;
  box-shadow: inset 0 1px 0 rgba(241, 245, 249, 0.48), 0 3px 8px rgba(15, 23, 42, 0.36);
}
.k-char.done.gold-reward {
  color: #fffef5;
  text-shadow: 0 1px 3px rgba(69, 26, 3, 0.88);
  background: linear-gradient(135deg, #6e4105 0%, #c48414 24%, #fde047 46%, #fef9c3 52%, #d99316 70%, #5c3304 100%);
  border-color: #fde047;
  border-bottom-color: #fbbf24;
  box-shadow: inset 0 1px 0 rgba(255, 251, 235, 0.82), 0 0 12px rgba(251, 191, 36, 0.30);
}
.k-char.done.platinum-reward {
  color: #0b192c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
  background: linear-gradient(135deg, #8ea8c2 0%, #d8e8f8 24%, #ffffff 47%, #e0f2fe 56%, #b2cbe3 76%, #7d98b5 100%);
  border-color: #ffffff;
  border-bottom-color: #cbd5e1;
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.96), 0 0 12px rgba(224, 242, 254, 0.34);
}
.k-char.done.gold-reward::after,
.k-char.done.platinum-reward::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 11px;
  height: 11px;
  pointer-events: none;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fef3c7' stroke='%23fbbf24' stroke-width='1.2' d='M12 1.5L14.4 9.6L22.5 12L14.4 14.4L12 22.5L9.6 14.4L1.5 12L9.6 9.6Z'/%3E%3C/svg%3E");
  animation: goldSparkle 2.4s ease-in-out infinite;
}
.k-char.done.platinum-reward::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' stroke='%23bae6fd' stroke-width='1.2' d='M12 1.5L14.4 9.6L22.5 12L14.4 14.4L12 22.5L9.6 14.4L1.5 12L9.6 9.6Z'/%3E%3C/svg%3E");
}
@keyframes goldSparkle {
  0%, 100% { transform: scale(0.88); opacity: 0.78; }
  50% { transform: scale(1.12); opacity: 1; }
}
.medal-burst-layer {
  position: absolute;
  inset: -4px;
  z-index: -1;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.medal-burst-layer .mb-ring {
  position: absolute;
  inset: 2px;
  border-radius: 999px;
  border: 2px solid currentColor;
  opacity: 0;
  animation: mbRingOut 640ms cubic-bezier(0.16, 1, 0.3, 1) var(--mb-delay, 0ms) forwards;
}
.medal-burst-layer .mb-spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  box-shadow: 0 0 8px currentColor;
  animation: mbSparkOut 760ms cubic-bezier(0.22, 1, 0.36, 1) calc(var(--mb-delay, 0ms) + var(--si, 0) * 24ms) forwards;
}
.medal-burst-layer.tier-silver { color: rgba(148, 163, 184, 0.72); }
.medal-burst-layer.tier-silver .mb-ring { box-shadow: 0 0 8px rgba(148, 163, 184, 0.24); }
.medal-burst-layer.tier-gold { color: rgba(253, 224, 71, 0.96); }
.medal-burst-layer.tier-gold .mb-ring { box-shadow: 0 0 18px rgba(251, 191, 36, 0.56); }
.medal-burst-layer.tier-platinum { color: rgba(240, 249, 255, 0.98); }
.medal-burst-layer.tier-platinum .mb-ring {
  border-width: 2.5px;
  box-shadow: 0 0 22px rgba(224, 242, 254, 0.72), 0 0 8px rgba(186, 230, 253, 0.55);
}
.medal-burst-layer.tier-platinum .mb-spark {
  border-radius: 1px;
  transform: rotate(45deg);
}
@keyframes mbRingOut {
  0% { transform: scale(0.76); opacity: 0.85; }
  70% { opacity: 0.35; }
  100% { transform: scale(1.62); opacity: 0; }
}
@keyframes mbSparkOut {
  0% { transform: translate(0, 0) scale(0.5); opacity: 0.95; }
  65% { opacity: 0.82; }
  100% { transform: translate(var(--sx, 0px), var(--sy, -18px)) scale(0.15); opacity: 0; }
}
@property --rp-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}
/* Rainbow Platinum = unmistakable opaque mirror-Platinum tiles + rotating rainbow aura behind the boxes */
.kj-char.kj-slot.combined-platinum,
.k-char.done.combined-platinum {
  color: #0b192c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.74);
  border-color: #ffffff;
  background: linear-gradient(135deg, #8ea8c2 0%, #d8e8f8 24%, #ffffff 47%, #e0f2fe 56%, #b2cbe3 76%, #7d98b5 100%);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, 0.96),
    inset 0 -1.5px 0 rgba(71, 85, 105, 0.52),
    0 2px 10px rgba(2, 10, 22, 0.40);
}
.k-char.done.combined-platinum {
  border-bottom-color: #cbd5e1;
}
.kj-char.kj-slot.combined-platinum::before,
.k-char.done.combined-platinum::before {
  content: '';
  position: absolute;
  inset: -7px;
  z-index: -1;
  border-radius: calc(0.24em + 5px);
  pointer-events: none;
  background: conic-gradient(
    from var(--rp-angle),
    #38bdf8 0deg,
    #818cf8 60deg,
    #f472b6 120deg,
    #fb923c 180deg,
    #facc15 240deg,
    #34d399 300deg,
    #38bdf8 360deg
  );
  filter: blur(7px);
  opacity: 0.90;
  animation: rpAuraSpin 3.2s linear infinite;
}
.k-char.done.combined-platinum::before {
  inset: -5px;
  filter: blur(5px);
  opacity: 0.86;
}
.kj-char.kj-slot.combined-platinum::after,
.k-char.done.combined-platinum::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' stroke='%23bae6fd' stroke-width='1.3' d='M12 1.5L14.4 9.6L22.5 12L14.4 14.4L12 22.5L9.6 14.4L1.5 12L9.6 9.6Z'/%3E%3C/svg%3E");
}
@keyframes rpAuraSpin {
  0% { --rp-angle: 0deg; }
  100% { --rp-angle: 360deg; }
}
.medal-burst-layer.tier-rainbow { color: #e0f2fe; }
.medal-burst-layer.tier-rainbow .mb-ring {
  border-width: 2.5px;
  border-color: #f9a8d4 #a5f3fc #fde68a #c4b5fd;
  box-shadow: 0 0 24px rgba(244, 182, 234, 0.62), 0 0 12px rgba(125, 211, 252, 0.56);
}
.medal-burst-layer.tier-rainbow .mb-spark {
  border-radius: 1px;
  transform: rotate(45deg);
}
.medal-burst-layer.tier-rainbow .mb-spark:nth-of-type(odd) { color: #a5f3fc; }
.medal-burst-layer.tier-rainbow .mb-spark:nth-of-type(even) { color: #f9a8d4; }
.medal-burst-layer.tier-rainbow .mb-spark:nth-of-type(3n) { color: #fde68a; }
body.reduced-fx .kj-char.kj-slot.combined-platinum::before,
body.reduced-fx .k-char.done.combined-platinum::before,
body.reduced-fx .joyo-seen::after {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .kj-char.kj-slot.combined-platinum::before,
  .k-char.done.combined-platinum::before { animation: none !important; opacity: 0.56; }
}
body.reduced-fx .medal-burst-layer,
body.reduced-fx .kj-char.kj-slot.gold-reward::after,
body.reduced-fx .kj-char.kj-slot.platinum-reward::after,
body.reduced-fx .k-char.done.gold-reward::after,
body.reduced-fx .k-char.done.platinum-reward::after {
  animation: none !important;
}
body.reduced-fx .medal-burst-layer { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  .kj-char.kj-slot.gold-reward::after,
  .kj-char.kj-slot.platinum-reward::after,
  .k-char.done.gold-reward::after,
  .k-char.done.platinum-reward::after { animation: none !important; opacity: 0.92; }
  .medal-burst-layer { display: none !important; }
}
.k-char.pending-mod {
  color: var(--gold);
  background: rgba(251, 191, 36, 0.18);
  border-color: rgba(251, 191, 36, 0.56);
  border-bottom-color: var(--gold);
}
.k-char.current {
  color: #ffffff;
  background: rgba(56, 189, 248, 0.24);
  border-color: rgba(125, 211, 252, 0.80);
  border-bottom-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(224, 244, 255, 0.22), 0 0 12px rgba(56, 189, 248, 0.26);
}
.k-char.upcoming { color: #cbd5e1; }
.k-char.guided-reading,
.kana-display.minna-reading { color: #f1f5f9; }
.k-char.hidden-slot {
  color: #64748b;
  background: rgba(12, 28, 48, 0.42);
  border-color: rgba(148, 163, 184, 0.22);
  border-bottom-color: rgba(100, 116, 139, 0.50);
}
.k-char.hidden-slot.current {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(125, 211, 252, 0.72);
  border-bottom-color: var(--accent);
}
.k-char.shake { color: var(--red); animation: kshake 160ms ease; }

@keyframes kshake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  70% { transform: translateX(4px); }
}

/* 12-Key Japanese Flick Keyboard (borderless floating dock unified with WritePad height) */
.flick-keyboard {
  position: relative;
  align-self: stretch;
  width: 100%;
  height: var(--fk-grid-h);
  flex: 0 0 var(--fk-grid-h);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  padding: 0;
  touch-action: none;
  box-shadow: none;
}

.flick-stage {
  position: relative;
  width: var(--fk-grid-w);
  max-width: 100%;
  margin: 0;
}

.flick-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--fk-gap);
}

.flick-key {
  position: relative;
  height: var(--fk-h);
  border: 1px solid rgba(165, 220, 245, 0.22);
  border-bottom: 3px solid #050810;
  border-radius: 11px;
  background: linear-gradient(180deg, #24304d 0%, #161d30 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10), 0 4px 12px rgba(2, 10, 22, 0.45);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
  cursor: pointer;
  touch-action: none;
  transition: border-color 70ms ease, transform 60ms ease, box-shadow 70ms ease;
}

.flick-key.is-mod,
.flick-key.is-kana-toggle { background: linear-gradient(180deg, #181f32 0%, #111624 100%); }
.flick-key.is-kana-toggle.is-kata-active {
  border-color: rgba(167, 139, 250, 0.55);
  background: linear-gradient(180deg, #252242 0%, #18172e 100%);
}
.flick-key.is-kana-toggle.is-kata-active .fk-main { color: var(--purple); }
.flick-key.pressed { background: linear-gradient(180deg, #2c3b5c 0%, #1d2842 100%); transform: translateY(1px); }
.flick-key.target-key {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px #38bdf877, 0 0 14px #38bdf844;
  background: linear-gradient(180deg, #1d3254 0%, #14233d 100%);
}
.flick-key.flash-ok { background: #14493b; border-color: var(--green); }
.flick-key.flash-err { background: #4c1724; border-color: var(--red); }

.fk-hint { position: absolute; top: 3px; right: 5px; font-size: 10px; font-weight: 800; color: var(--gold); line-height: 1; }
.fk-main { font-size: 22px; font-weight: 700; line-height: 1; }
.flick-key.is-mod .fk-main { font-size: 14px; font-weight: 800; }
.flick-key.is-kana-toggle .fk-main { font-size: 18px; }

/* Cross Flick Popover */
.flick-popover {
  position: absolute;
  width: 138px;
  height: 138px;
  transform: translate(-50%, -50%) translateZ(0);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  pointer-events: none;
  z-index: 25;
}
.flick-popover.hidden {
  display: none !important;
  visibility: hidden !important;
  left: -9999px !important;
  top: -9999px !important;
}
.fp-cell {
  border-radius: 10px;
  background: #1e293bf2;
  border: 1px solid #ffffff38;
  color: #cbd5e1;
  font-size: 19px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px #00000090;
}
.fp-cell:empty { visibility: hidden; }
.fp-cell.active { background: var(--accent); color: #04111f; border-color: #fff; transform: scale(1.1); }
.fp-up     { grid-column: 2; grid-row: 1; }
.fp-left   { grid-column: 1; grid-row: 2; }
.fp-center { grid-column: 2; grid-row: 2; }
.fp-right  { grid-column: 3; grid-row: 2; }
.fp-down   { grid-column: 2; grid-row: 3; }

/* KanjiVG Stroke-Order Writing Pad */
.write-pad {
  position: relative;
  z-index: 25;
  height: var(--write-dock-h);
  flex: 0 0 var(--write-dock-h);
  display: flex;
  flex-direction: column;
}

.write-wrap {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}
.write-wrap.align-center { align-items: center; }
.write-wrap.align-left { align-items: flex-start; }
.write-wrap.align-right { align-items: flex-end; }
.write-wrap.in-word-review .write-toolbar { grid-template-columns: auto minmax(0, 1fr); }
.write-wrap.in-word-review .write-align-bar { display: none; }

.write-toolbar {
  width: min(100%, var(--fk-grid-w));
  align-self: center;
  display: none;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 4px;
  height: 22px;
  min-height: 22px;
  flex: 0 0 22px;
}

.write-align-bar {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.wa-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  width: 24px;
  height: 18px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
}
.wa-btn svg { pointer-events: none; }
.wa-btn.active {
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent);
}
.wa-btn:active {
  background: rgba(255, 255, 255, 0.10);
}

.write-progress {
  justify-self: start;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.write-head-right {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
}

.write-guide-btn {
  appearance: none;
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 6;
  border: 1px solid rgba(165, 220, 245, 0.34);
  background: rgba(11, 27, 46, 0.72);
  color: #bae6fd;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
}
#app[data-input-align="right"] .write-guide-btn {
  right: auto;
  left: 8px;
}
.write-guide-btn[aria-pressed="true"] {
  background: rgba(56, 189, 248, 0.24);
  border-color: rgba(125, 211, 252, 0.72);
  color: #ffffff;
}
.write-guide-btn.hidden { display: none !important; }

.write-hint-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--muted);
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.write-skip-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 6;
  appearance: none;
  border: 1px solid rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.08);
  color: rgba(253, 230, 138, 0.88);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.35;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 80ms ease, background 120ms ease, border-color 120ms ease;
}
.write-skip-pill:active {
  transform: scale(0.95);
  background: rgba(251, 191, 36, 0.18);
}

.write-canvas-box.memory-cue {
  animation: memoryCanvasCue 660ms cubic-bezier(0.22, 1, 0.36, 1);
}
.write-canvas-box.error-cue {
  animation: errorCanvasCue 360ms ease-out;
}
@keyframes errorCanvasCue {
  0% {
    border-color: rgba(251, 113, 133, 0.85);
    box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.36), inset 0 0 18px rgba(251, 113, 133, 0.22);
  }
  100% {
    border-color: rgba(165, 220, 245, 0.28);
    box-shadow: none;
  }
}
@keyframes memoryCanvasCue {
  0% {
    border-color: rgba(253, 224, 71, 0.78);
    box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.42), inset 0 0 22px rgba(251, 191, 36, 0.20);
  }
  55% {
    border-color: rgba(56, 189, 248, 0.65);
    box-shadow: 0 0 0 8px rgba(56, 189, 248, 0.0), inset 0 0 18px rgba(56, 189, 248, 0.16);
  }
  100% {
    border-color: rgba(165, 220, 245, 0.28);
    box-shadow: none;
  }
}

.write-mark {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 68px;
  height: 68px;
  pointer-events: none;
  opacity: 0;
  transform: scale(1.16) rotate(-8deg);
}
.write-mark.stamped {
  opacity: 0.96;
  transform: scale(1) rotate(-5deg);
  animation: markPop 300ms cubic-bezier(0.22, 1, 0.36, 1);
}
.write-mark .wm-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.write-mark.tier-gold {
  color: #fbbf24;
  filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.45));
}
.write-mark.tier-silver {
  color: #94a3b8;
  filter: drop-shadow(0 0 5px rgba(148, 163, 184, 0.24));
}
.write-mark.tier-green {
  color: #34d399;
  filter: drop-shadow(0 0 7px rgba(52, 211, 153, 0.36));
}
@keyframes markPop {
  0%   { opacity: 0; transform: scale(1.24) rotate(-10deg); }
  65%  { opacity: 1; transform: scale(0.96) rotate(-4deg); }
  100% { opacity: 0.96; transform: scale(1) rotate(-5deg); }
}

.write-grade-bar {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: min(362px, 95vw);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 7px;
  background: linear-gradient(168deg, rgba(11, 27, 46, 0.92), rgba(7, 19, 34, 0.96));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(165, 220, 245, 0.26);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.16), 0 10px 28px rgba(2, 10, 22, 0.65);
  z-index: 30;
  touch-action: manipulation;
  pointer-events: auto;
  animation: gradePopIn 140ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes gradePopIn {
  from { opacity: 0; transform: translate(-50%, 6px) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.wg-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 13px;
  height: 48px;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 80ms ease, background 120ms ease, border-color 120ms ease;
}
.wg-btn svg,
.wg-btn span,
.wg-btn small {
  pointer-events: none;
}
.wg-int {
  font-size: 10.5px;
  font-weight: 700;
  opacity: 0.85;
}
.wg-btn svg {
  flex-shrink: 0;
}
.wg-btn:active { transform: scale(0.97); }
.wg-redraw {
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font-size: 12.5px;
}
.wg-review {
  background: rgba(251, 113, 133, 0.15);
  border-color: rgba(251, 113, 133, 0.42);
  color: var(--red);
}
.wg-pass {
  background: rgba(52, 211, 153, 0.17);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--green);
}
.wg-known {
  grid-column: 1 / -1;
  height: 36px;
  border-radius: 11px;
  font-size: 12.5px;
  background: rgba(56, 189, 248, 0.10);
  border-color: rgba(56, 189, 248, 0.30);
  color: var(--accent);
}
.wg-pass.is-guided {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.32);
  color: #cbd5e1;
}

/* 2-Button Anki Self-Grade Floating Bar above Flick Keyboard (matches Write Grade Bar) */
.flick-keyboard.awaiting-flick-grade .flick-stage {
  opacity: 0.42;
  pointer-events: none;
}
.flick-grade-bar {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: min(362px, 95vw);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px;
  background: linear-gradient(168deg, rgba(11, 27, 46, 0.92), rgba(7, 19, 34, 0.96));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(165, 220, 245, 0.26);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.16), 0 10px 28px rgba(2, 10, 22, 0.65);
  z-index: 30;
  touch-action: manipulation;
  pointer-events: auto;
  animation: gradePopIn 140ms cubic-bezier(0.22, 1, 0.36, 1);
}
.fg-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.fg-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 13px;
  height: 48px;
  padding: 0 4px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  touch-action: manipulation;
  white-space: normal;
  text-align: center;
  overflow: hidden;
  transition: transform 80ms ease, background 120ms ease;
}
.fg-btn svg,
.fg-btn span {
  pointer-events: none;
}
.fg-btn svg {
  flex-shrink: 0;
}
.fg-btn:active { transform: scale(0.97); }
.fg-label {
  font-size: clamp(10px, 2.75vw, 12.5px);
  font-weight: 700;
  line-height: 1.15;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fg-int { font-size: 10.5px; font-weight: 700; opacity: 0.85; }
.fg-int:empty,
.wg-int:empty { display: none; }
.fg-retry {
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font-size: 12.5px;
}
.fg-bad {
  background: rgba(251, 113, 133, 0.15);
  border-color: rgba(251, 113, 133, 0.42);
  color: var(--red);
}
.fg-good {
  background: rgba(52, 211, 153, 0.17);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--green);
}
.fg-btn:disabled,
.fg-btn.is-disabled,
.wg-btn:disabled,
.wg-btn.is-disabled {
  opacity: 0.34;
  cursor: not-allowed;
  pointer-events: none;
  filter: saturate(0.45);
  transform: none;
}
.fg-btn:disabled:active,
.wg-btn:disabled:active {
  transform: none;
}
.fg-known {
  height: 36px;
  flex-direction: row;
  gap: 6px;
  border-radius: 11px;
  background: rgba(56, 189, 248, 0.10);
  border-color: rgba(56, 189, 248, 0.30);
  color: var(--accent);
}
.fg-known .fg-label { font-size: 12.5px; font-weight: 700; }

.write-canvas-box {
  --canvas-side: min(calc(var(--write-dock-h) - var(--write-chrome-h)), var(--fk-grid-w), calc(100vw - 44px));
  position: relative;
  width: var(--canvas-side);
  height: var(--canvas-side);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 42%, rgba(11, 27, 46, 0.92) 0%, rgba(5, 14, 27, 0.97) 100%);
  border: 1.5px solid rgba(165, 220, 245, 0.28);
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.14), inset 0 0 24px rgba(2, 10, 22, 0.42), 0 6px 18px rgba(2, 10, 22, 0.35);
  overflow: hidden;
  touch-action: none;
}

.write-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.write-badge-hint {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  pointer-events: none;
}
.write-unavailable-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: rgba(6, 13, 25, 0.94);
  backdrop-filter: blur(8px);
}
.write-unavailable-overlay.hidden {
  display: none;
}
.write-unavail-msg {
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--ink);
  max-width: 240px;
}
.write-unavail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.write-canvas-box.is-unavailable .write-canvas,
.write-canvas-box.is-unavailable .write-mark {
  opacity: 0;
  pointer-events: none;
}

/* Complete-Word Handwriting Self-Review */
.write-word-review {
  width: min(100%, var(--fk-grid-w));
  height: calc(var(--write-dock-h) - var(--write-chrome-h));
  align-self: center;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 50%, #161d2f 0%, #0f1422 100%);
  border: 1px solid #ffffff22;
  animation: reviewFadeIn 180ms ease-out;
}
@keyframes reviewFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wwr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.wwr-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.85;
}
.wwr-divider {
  height: 1px;
  width: 88%;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.09);
}
.wwr-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  flex-wrap: nowrap;
}
.wwr-tile,
.wwr-ref-tile {
  width: var(--wwr-tile, clamp(44px, calc((var(--write-dock-h) - var(--write-chrome-h) - 82px) / 2), 68px));
  height: var(--wwr-tile, clamp(44px, calc((var(--write-dock-h) - var(--write-chrome-h) - 82px) / 2), 68px));
  flex: 0 0 auto;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wwr-row.len-3 { --wwr-tile: min(62px, calc((var(--fk-grid-w) - 34px) / 3), calc((var(--write-dock-h) - var(--write-chrome-h) - 82px) / 2)); gap: 5px; }
.wwr-row.len-4 { --wwr-tile: min(48px, calc((var(--fk-grid-w) - 36px) / 4), calc((var(--write-dock-h) - var(--write-chrome-h) - 82px) / 2)); gap: 4px; }
.wwr-tile {
  background: rgba(9, 11, 16, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.wwr-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.wwr-ref-tile {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.11);
  color: #f8fafc;
  font-size: calc(var(--wwr-tile, 78px) * 0.62);
  font-weight: 300;
  line-height: 1;
  font-family: var(--font-ja) !important;
}
.wwr-okuri {
  flex: 0 0 auto;
  min-width: 18px;
  text-align: center;
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 400;
  color: var(--muted);
  font-family: var(--font-ja) !important;
}
@media (max-width: 360px) {
  .write-grade-bar { gap: 5px; padding: 4px 2px 2px; width: min(348px, 100%); grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wg-btn { font-size: 11px; height: 46px; gap: 3px; padding: 0 5px; }
  .wg-btn svg { display: none; }
  .flick-grade-bar { width: min(352px, 97vw); gap: 5px; padding: 6px; }
  .fg-row { gap: 5px; }
  .fg-btn { height: 46px; gap: 3px; padding: 0 4px; }
  .fg-btn svg { width: 12px; height: 12px; }
}

/* Obsidian Decks, Progress & Settings Sheet */
.cd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
}
.cd-head small { color: var(--muted); font-weight: 600; margin-left: 4px; }
.cd-hint { font-size: 11px; color: var(--muted); }
#custom-deck-input {
  width: 100%;
  background: rgba(9, 11, 16, 0.85);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.45;
  font-family: inherit;
  resize: vertical;
  user-select: text;
  -webkit-user-select: text;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 31, 49, 0.80);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  z-index: 40;
}
@media (min-width: 520px) {
  .modal { align-items: center; padding: 18px; }
}
.modal-card {
  width: 100%;
  max-width: 460px;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  background: rgba(12, 15, 24, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: max(56px, calc(env(safe-area-inset-top) + 46px)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@media (min-width: 520px) {
  .modal-card {
    height: auto;
    max-height: 86dvh;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 22px;
    padding: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  }
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sheet-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sheet-emblem {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 400;
  color: #f8fafc;
}
.sheet-title h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.sheet-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.done-pill {
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.modal-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 8px;
}
.m-tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 6px 10px;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.m-tab.active {
  color: #ffffff;
  border-bottom-color: var(--accent);
  font-weight: 700;
}
.m-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Serene Hairline Menu Lists & Accordions */
.menu-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.78;
  padding: 6px 4px 0;
}
.menu-list {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.menu-list > *:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.menu-row,
.acc-head {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  min-height: 48px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: background 110ms ease;
}
.menu-row:active,
.acc-head:active {
  background: rgba(255, 255, 255, 0.04);
}
.menu-row.active {
  background: rgba(56, 189, 248, 0.07);
}
.row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.row-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.menu-row.active .row-title {
  color: var(--accent);
}
.row-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.row-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.row-check {
  color: var(--accent);
  opacity: 0;
  transition: opacity 120ms ease;
}
.menu-row.active .row-check,
.sub-row.active .row-check {
  opacity: 1;
}

.acc-chev {
  color: var(--muted);
  transition: transform 150ms ease;
}
.acc-group.open .acc-chev {
  transform: rotate(90deg);
}
.acc-body {
  background: rgba(0, 0, 0, 0.22);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  max-height: 290px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.modal-card::-webkit-scrollbar,
.acc-body::-webkit-scrollbar {
  display: none;
}
.acc-body-pad {
  padding: 12px 14px;
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sub-list {
  display: flex;
  flex-direction: column;
}
.sub-row {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  padding: 10px 14px 10px 22px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}
.sub-row:last-child { border-bottom: 0; }
.sub-row.active {
  background: rgba(56, 189, 248, 0.09);
  color: var(--accent);
  font-weight: 700;
}
.sub-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.sub-label-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.sub-bar {
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.sub-bar i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 999px;
}

.custom-inline-editor {
  padding: 10px 14px 12px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.custom-tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.custom-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  text-align: right;
}
.custom-status.err {
  color: var(--red);
}
.accent-pill {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.38);
  color: var(--accent);
}

.focus-acc-head {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.focus-acc-group:last-child .focus-acc-head {
  border-bottom: 0;
}
.focus-acc-head .focus-toggle-main {
  flex: 1;
  min-width: 0;
  border-bottom: 0;
}
.focus-expand-btn {
  appearance: none;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  background: transparent;
  width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.focus-expand-btn:active {
  background: rgba(255, 255, 255, 0.05);
}
/* Unified Conjugations Matrix */
.conj-cat-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(9, 11, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.conj-cat-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  padding: 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.conj-cat-tab em {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.78;
}
.conj-cat-tab.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.36);
  color: #f8fafc;
}
.conj-cat-tab.active em {
  color: var(--accent);
  opacity: 1;
}
.conj-cat-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.conj-preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.tier-pill.mini-act {
  padding: 4px 9px;
  font-size: 10.5px;
}
.conj-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 224px;
  overflow-y: auto;
  scrollbar-width: none;
}
.conj-form-grid::-webkit-scrollbar {
  display: none;
}
.conj-form-item {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
  color: #94a3b8;
  min-height: 38px;
  padding: 6px 9px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.conj-form-item .cf-label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.conj-form-item .cf-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid rgba(148, 163, 184, 0.45);
  background: transparent;
  flex-shrink: 0;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.conj-form-item.active {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.50);
  color: #f8fafc;
  font-weight: 700;
}
.conj-form-item.active .cf-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.75);
}

/* Manual Kanji Familiarity Selector */
.fam-hint {
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}
.fam-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.fam-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  font-size: 10.5px;
  color: var(--muted);
}
.fam-leg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.fam-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
}
.fam-leg.leg-fam .fam-dot {
  background: var(--accent);
  border-color: var(--accent);
}
.fam-leg.leg-mas .fam-dot {
  background: var(--green);
  border-color: var(--green);
}
.fam-actions {
  display: inline-flex;
  gap: 5px;
}
#kanji-browser { box-sizing:border-box; width:min(96vw, 660px); max-height:90dvh; padding:clamp(14px,4vw,26px); border:1px solid #384257; border-radius:18px; background:#131824; color:#edf2fa; overflow:auto; overscroll-behavior:contain; margin:auto; }
#kanji-browser::backdrop { background:rgba(4,7,13,.84); }
#kanji-browser header { position:sticky; top:-1px; z-index:1; background:#131824; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:6px 0; }
#kanji-browser header h2 { order:-1; font-size:1.15rem; }
#kanji-browser p { margin:12px 0; line-height:1.5; }
.browser-actions,.curriculum-row { display:flex; align-items:center; gap:8px; }
.browser-actions { flex-wrap:wrap; margin:16px 0; }
.curriculum-row .sub-row { flex:1; min-width:0; }
.browse,#kanji-browser .tier-pill { min-height:44px; padding:6px 12px; }
.fam-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(48px,1fr)); gap:10px; }
.fam-grid .fam-tile { width:100%; min-height:48px; }
.fam-tile.is-mastered::after { content:"★"; position:absolute; bottom:2px; right:4px; color:var(--green); font-size:12px; }
.fam-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(22, 27, 42, 0.68);
  color: #cbd5e1;
  font-family: var(--font-ja) !important;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 110ms ease, border-color 110ms ease, color 110ms ease, transform 70ms ease;
}
.fam-tile:active {
  transform: scale(0.95);
}
.fam-tile.is-studied {
  border-color: rgba(52, 211, 153, 0.35);
}
.fam-tile.is-studied::after {
  content: "";
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
}
.fam-tile.is-mastered {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.52);
  color: #ecfdf5;
}
.fam-tile.is-familiar {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.72);
  color: #ffffff;
}
.fam-tile.is-familiar::before {
  content: "✓";
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 9px;
  font-weight: 800;
  color: var(--accent);
}
.fam-tile.is-familiar.is-mastered {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.55);
}
.tier-pill {
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.tier-pill.active {
  background: rgba(167, 139, 250, 0.16);
  border-color: rgba(167, 139, 250, 0.45);
  color: var(--purple);
  font-weight: 700;
}

.pref-toggle {
  font-size: 13px;
  font-weight: 600;
}

/* Progress Tab */
.session-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(22, 27, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 14px;
}
.ss-item { display: flex; flex-direction: column; gap: 2px; }
.ss-item.center { text-align: center; }
.ss-item.right { text-align: right; }
.ss-label { font-size: 9px; font-weight: 700; letter-spacing: 0.09em; color: var(--muted); }
.ss-val { font-size: 14px; font-weight: 800; color: var(--text); }
.ss-val.gold { color: var(--gold); }
.ss-val.green { color: var(--green); }

.srs-card {
  background: rgba(22, 27, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.srs-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.srs-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.srs-box strong { font-size: 18px; color: var(--text); font-weight: 700; }
.srs-box span { font-size: 10px; color: var(--muted); }
.mastery-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  display: flex;
}
.mastery-track i { display: block; height: 100%; width: 0%; transition: width 200ms ease; }
.mt-master { background: var(--green); }
.mt-recall { background: var(--gold); }
.mt-learn { background: var(--accent); }
.prog-sub-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.ps-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ps-item strong { font-size: 15px; font-weight: 800; color: var(--accent); }
.ps-item span { font-size: 10px; color: var(--muted); text-align: center; }

.heatmap-legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--muted); align-items: center; }
.leg { padding: 2px 6px; border-radius: 6px; font-weight: 700; }
.leg.fast { background: #34d39920; color: var(--green); }
.leg.mid  { background: #fbbf2420; color: var(--gold); }
.leg.slow { background: #fb718520; color: var(--red); }
.kana-heatmap { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.hm-cell {
  background: rgba(22, 27, 42, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 9px;
  padding: 6px 2px;
  text-align: center;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  font-weight: 700;
}
.hm-cell small { font-size: 9px; color: var(--muted); font-weight: 600; }
.hm-cell.fast { background: #34d3991e; border-color: #34d39944; }
.hm-cell.mid  { background: #fbbf241e; border-color: #fbbf2444; }
.hm-cell.slow { background: #fb71851e; border-color: #fb718544; }

.pref-danger-wrap {
  padding-top: 4px;
}

.ios-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
}
.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.ios-switch input:focus-visible + .ios-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ios-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 150ms ease;
  cursor: pointer;
}
.ios-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 150ms ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.ios-switch input:checked + .ios-slider {
  background: var(--accent);
}
.ios-switch input:checked + .ios-slider::before {
  transform: translateX(18px);
}

.lang-seg {
  display: flex;
  flex-wrap: wrap;
  background: rgba(9, 11, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  padding: 4px;
  gap: 4px;
}
.lang-seg-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.pref-row-col {
  flex-direction: column;
  align-items: flex-start;
  padding: 10px 0 12px;
  gap: 8px;
}
.lang-pill {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
}
.lang-pill.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-weight: 700;
}

/* Startup 1: Language Picker */
#lang-boot-modal {
  align-items: center;
  padding: 20px;
}
.lang-boot-card-wrap {
  width: 100%;
  max-width: 416px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(56, 189, 248, 0.14), transparent 58%),
    linear-gradient(165deg, rgba(20, 28, 48, 0.96), rgba(10, 15, 27, 0.98));
  border: 1.5px solid rgba(212, 175, 106, 0.36);
  border-radius: 24px;
  padding: 24px 18px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 244, 214, 0.18), 0 24px 60px rgba(0, 0, 0, 0.72);
}
.lang-boot-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: center;
}
.lang-boot-sub {
  margin: -4px 0 2px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}
.lang-boot-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.lang-boot-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(25, 31, 48, 0.76);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 10px;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 80ms ease;
}
.lang-boot-btn .lang-native {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
}
.lang-boot-btn .lang-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.25;
}
@media (hover: hover) {
  .lang-boot-btn:hover {
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(56, 189, 248, 0.10);
  }
}
.lang-boot-btn:active {
  transform: scale(0.97);
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.18);
}

/* Startup 2: Web Testing Information Notice */
#web-test-notice-modal {
  align-items: center;
  padding: 16px;
}
.notice-card-wrap {
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 32px);
  background: rgba(14, 18, 29, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  padding: 20px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72);
}
.notice-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.notice-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}
.notice-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 10px 12px;
  background: rgba(9, 11, 16, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(241, 245, 249, 0.90);
}
.notice-body p {
  margin: 0;
  overflow-wrap: anywhere;
}
.notice-btn {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 14.5px;
  font-weight: 700;
  background: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  color: #08101c;
  cursor: pointer;
  line-height: 1.4;
  box-shadow: 0 8px 22px rgba(56, 189, 248, 0.28);
  transition: transform 80ms ease, filter 120ms ease;
}
.notice-btn:active {
  transform: scale(0.98);
  filter: brightness(1.06);
}

/* Study Web Test Scope Banner */
.web-test-banner {
  background: rgba(56, 189, 248, 0.10);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 12px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.web-test-banner strong {
  font-size: 12.5px;
  color: var(--accent);
  line-height: 1.4;
}
.web-test-banner span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

/* Incoming Shared Custom List Modal */
#import-list-modal {
  align-items: center;
  padding: 20px;
}
.import-card-wrap {
  width: 100%;
  max-width: 390px;
  background: rgba(14, 18, 29, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}
.import-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.import-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.import-sub {
  font-size: 12px;
  color: var(--muted);
}
.import-preview-list {
  background: rgba(9, 11, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px 10px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.import-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.import-preview-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.import-preview-row strong {
  color: var(--text);
  font-weight: 700;
}
.import-preview-row span {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.import-preview-more {
  font-size: 11px;
  color: var(--accent);
  text-align: center;
  padding-top: 2px;
}
.import-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.import-cancel {
  color: var(--muted);
}

.pref-danger-wrap {
  padding-top: 4px;
}
.danger-row {
  width: 100%;
  border: 1px solid rgba(251, 113, 133, 0.25);
  background: rgba(251, 113, 133, 0.08);
  color: var(--red);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.danger-row.confirming {
  background: rgba(251, 113, 133, 0.24);
  border-color: var(--red);
  font-weight: 800;
}
/* Typography per Interface Language + Japanese Glyph Preservation */
:root {
  --font-ja: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", "Noto Sans JP", sans-serif;
  --font-ui-en: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-ui-si: "Sinhala Sangam MN", "Sinhala MN", "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", sans-serif;
  --font-ui-ko: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --font-ui-zh: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-ui-my: "Noto Sans Myanmar", "Myanmar Text", "Padauk", "Pyidaungsu", sans-serif;
  --font-ui-bn: "Noto Sans Bengali", "Vrinda", "SolaimanLipi", "Nirmala UI", sans-serif;
  --font-ui-vi: var(--font-ui-en);
}
body[data-ui-lang="en"], body[data-ui-lang="es-419"], body[data-ui-lang="fr"] { font-family: var(--font-ui-en), var(--font-ja); }
body[data-ui-lang="si"] { font-family: var(--font-ui-si), var(--font-ja); }
body[data-ui-lang="ko"] { font-family: var(--font-ui-ko), var(--font-ja); }
body[data-ui-lang="zh"] { font-family: var(--font-ui-zh), var(--font-ja); }
body[data-ui-lang="my"] { font-family: var(--font-ui-my), var(--font-ja); }
body[data-ui-lang="bn"] { font-family: var(--font-ui-bn), var(--font-ja); }
body[data-ui-lang="vi"] { font-family: var(--font-ui-vi), var(--font-ja); }

[lang="ja"],
#word-kanji, .word-kanji,
#kana-display, .kana-display,
#alt-readings, .alt-readings,
.flick-key .fk-main, .fp-cell,
.write-canvas,
#kana-heatmap .hm-cell span,
.import-preview-row strong {
  font-family: var(--font-ja) !important;
}

/* Sinhala / CJK Mobile Wrapping & Diacritic Headroom */
body[data-ui-lang="si"] .notice-body,
body[data-ui-lang="my"] .notice-body,
body[data-ui-lang="bn"] .notice-body {
  font-size: 13px;
  line-height: 1.72;
}
body[data-ui-lang="si"] #word-en,
body[data-ui-lang="my"] #word-en,
body[data-ui-lang="bn"] #word-en,
body[data-ui-lang="vi"] #word-en {
  line-height: 1.52;
  padding-top: 2px;
  padding-bottom: 2px;
}
body[data-ui-lang="si"] .write-toolbar,
body[data-ui-lang="my"] .write-toolbar,
body[data-ui-lang="bn"] .write-toolbar {
  font-size: 11px;
}
body[data-ui-lang="si"] .write-progress,
body[data-ui-lang="si"] .write-hint-tag,
body[data-ui-lang="my"] .write-progress,
body[data-ui-lang="my"] .write-hint-tag,
body[data-ui-lang="bn"] .write-progress,
body[data-ui-lang="bn"] .write-hint-tag {
  font-size: 10.5px;
  line-height: 1.45;
}
body[data-ui-lang="si"] .conj-badge,
body[data-ui-lang="ko"] .conj-badge,
body[data-ui-lang="zh"] .conj-badge,
body[data-ui-lang="my"] .conj-badge,
body[data-ui-lang="bn"] .conj-badge,
body[data-ui-lang="vi"] .conj-badge {
  line-height: 1.4;
  max-width: 100%;
  white-space: normal;
  text-align: center;
}
body[data-ui-lang="si"] .m-tab,
body[data-ui-lang="si"] .seg-btn,
body[data-ui-lang="si"] .sw-pill,
body[data-ui-lang="si"] .lang-pill,
body[data-ui-lang="si"] .conj-cat-tab,
body[data-ui-lang="si"] .conj-form-item,
body[data-ui-lang="si"] .fam-hint,
body[data-ui-lang="si"] .fam-leg,
body[data-ui-lang="si"] .mixed-step-pill,
body[data-ui-lang="si"] .mixed-ctx-hint,
body[data-ui-lang="si"] .wwr-label,
body[data-ui-lang="si"] .wg-btn,
body[data-ui-lang="my"] .m-tab,
body[data-ui-lang="my"] .seg-btn,
body[data-ui-lang="my"] .sw-pill,
body[data-ui-lang="my"] .lang-pill,
body[data-ui-lang="bn"] .m-tab,
body[data-ui-lang="bn"] .seg-btn,
body[data-ui-lang="bn"] .sw-pill,
body[data-ui-lang="bn"] .lang-pill {
  line-height: 1.48;
}
body[data-ui-lang="si"] .m-tab,
body[data-ui-lang="si"] .seg-btn,
body[data-ui-lang="si"] .sw-pill,
body[data-ui-lang="si"] .lang-pill {
  padding-top: 6px;
  padding-bottom: 6px;
}

.hidden { display: none !important; }
.conj-badge.hidden,
.alt-readings.hidden {
  display: block !important;
  visibility: hidden;
  pointer-events: none;
}

#function-test { margin:auto; width:min(440px, 94vw); color:inherit; }
#function-test:not([open]) { display:none; }
#function-test::backdrop { background:rgba(4,7,13,.9); }

/* Learned Words Library in Stats */
.ps-btn {
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  border-radius: 10px;
  padding: 4px 6px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
@media (hover: hover) {
  .ps-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
  }
}
.ps-btn:active {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}
.lib-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.lib-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.lib-filter {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.lib-filter.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.42);
  color: var(--accent);
}
.lib-search {
  width: 100%;
  background: rgba(9, 11, 16, 0.85);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 16px;
  font-family: inherit;
  user-select: text;
  -webkit-user-select: text;
}
.learned-lib-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.lib-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.lib-row-left { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.lib-ja { font-family: var(--font-ja); font-size: 17px; font-weight: 500; color: #fff; flex-shrink: 0; }
.lib-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lib-en { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 155px; }
.lib-skills { font-size: 10px; color: #94a3b8; }
.lib-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.lib-badge { font-size: 9.5px; font-weight: 800; padding: 2px 7px; border-radius: 999px; letter-spacing: 0.04em; text-transform: uppercase; }
.lib-badge.mastered { background: #34d39920; color: var(--green); }
.lib-badge.recall { background: #fbbf2420; color: var(--gold); }
.lib-badge.learning { background: #a78bfa20; color: var(--purple); }
.lib-badge.known { background: #38bdf820; color: var(--accent); }
.lib-due { font-size: 10px; color: var(--muted); }
.lib-empty { text-align: center; padding: 14px 8px; font-size: 12px; color: var(--muted); }

.topbar { position:relative; padding-right:0; }
.top-sound { position:absolute; right:0; width:40px; height:36px; cursor:pointer; }
.top-sound input, .top-sound .sound-label { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
.sound-icon { display:grid; place-items:center; width:100%; height:100%; border-radius:10px; border:1px solid rgba(255,255,255,.12); }
.sound-icon::before { content:"🔇"; }
.top-sound input:checked + .sound-icon::before { content:"🔊"; }
.top-sound input:focus-visible + .sound-icon { outline:2px solid #38bdf8; }
:where(button, [role="option"], [role="button"], .modal, .notice-sheet, .curriculum-sheet, .picker-list, .joyo-row):focus {
  outline: none;
}
:where(button, [role="option"], [role="button"], .joyo-row):focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

@media (max-height: 640px) {
  #app { gap: 5px; }
  .word-stage { gap: 3px; }
  .kana-display { min-height: 36px; }
  .mixed-ctx-hint { bottom: 20px; }
}
@media (max-width: 390px) {
  .topbar { gap: 6px; padding-right: 0; }
  .sw-pill { padding: 5px 9px; font-size: 10.5px; }
  .top-sound { width: 36px; }
}
@media (max-width: 340px) {
  .topbar { gap: 5px; padding-right: 0; }
  .icon-pill { width: 32px; flex-shrink: 0; }
  .top-sound { width: 34px; }
  .sw-pill { padding: 4px 6.5px; font-size: 10px; letter-spacing: 0; }
}

#notice-body { max-height: 62dvh; overflow-y: auto; }
#focus-decks .sub-row[disabled], #drill-practice .sub-row[disabled], #notice-body button:disabled { opacity: .45; }
#deck-overlap .menu-row { font-variant-numeric: tabular-nums; min-height: 38px; }

#notice-body { display: flex; flex-direction: column; }
#notice-body .lang-boot-btn { flex: none; width: 100%; }
#function-test .notice-body p:last-child { margin-top: 1em; font-weight: 650; }

.startup-warning {
  text-align: left;
  padding: 12px 14px;
  border: 1px solid #cca554;
  border-radius: 12px;
  background: rgba(204, 165, 84, .1);
}
.startup-warning strong, .core-experimental, #notice-body small {
  color: #efd093;
}
.startup-warning p, .startup-requirements {
  margin: 4px 0;
  line-height: 1.45;
}
#notice-body small {
  display: block;
  margin-top: 4px;
  font-weight: 500;
}
.core-experimental {
  margin: 0;
  padding: 6px 12px;
  font-size: .8rem;
}


.skip-current-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #f0f9ff;
  background: linear-gradient(180deg, rgba(42, 92, 144, 0.94), rgba(22, 54, 92, 0.98));
  border: 1px solid rgba(147, 213, 255, 0.56);
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 rgba(224, 245, 255, 0.34),
    0 3px 0 rgba(7, 20, 38, 0.88),
    0 6px 14px rgba(2, 10, 22, 0.44);
  min-height: 40px;
  margin: 6px auto 0;
  padding: 6px 14px;
  font-size: 0.84rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 90ms ease, box-shadow 90ms ease, filter 120ms ease;
}
.skip-current-card:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.28),
    0 1px 0 rgba(7, 20, 38, 0.88),
    0 2px 6px rgba(2, 10, 22, 0.36);
}
.skip-current-card svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: #7dd3fc;
}
.fg-known, .wg-known { display: none; }

.study-badge-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 auto 6px;
}
.study-card-type {
  color: #cfe3fa;
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0;
  padding: 4px 12px;
  border: 1px solid rgba(150, 181, 228, 0.40);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(100, 135, 177, 0.22), rgba(32, 48, 74, 0.36));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.card-mastered-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 4px 11px;
  border: 1px solid rgba(52, 211, 153, 0.56);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.24), rgba(6, 78, 59, 0.42));
  box-shadow: inset 0 1px 0 rgba(167, 243, 208, 0.24);
  color: #a7f3d0;
  font-size: .76rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.card-mastered-badge.hidden { display: none; }
.card-mastered-badge svg { width: 13px; height: 13px; flex-shrink: 0; }
.study-card-type[data-card-type="kanji"] {
  color: #ffe6b3;
  border-color: rgba(245, 188, 99, 0.50);
  background: linear-gradient(180deg, rgba(180, 126, 48, 0.24), rgba(58, 40, 22, 0.42));
}
.study-card-type[data-card-type="hira"] {
  color: #b8f7e4;
  border-color: rgba(52, 211, 153, 0.52);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.24), rgba(6, 78, 59, 0.42));
}
.study-card-type[data-card-type="kata"] {
  color: #dbeafe;
  border-color: rgba(96, 165, 250, 0.54);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.26), rgba(30, 58, 138, 0.44));
}
.study-card-type[data-card-type="irregular"] {
  color: #f3e8ff;
  border-color: rgba(192, 132, 252, 0.56);
  background: linear-gradient(180deg, rgba(147, 51, 234, 0.28), rgba(88, 28, 135, 0.46));
}
.study-card-type[data-card-type="radical"] {
  color: #ccfbf1;
  border-color: rgba(45, 212, 191, 0.56);
  background: linear-gradient(180deg, rgba(13, 148, 136, 0.28), rgba(17, 94, 89, 0.46));
}
.study-card-type[data-card-type="component"] {
  color: #e0e7ff;
  border-color: rgba(129, 140, 248, 0.56);
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.28), rgba(49, 46, 129, 0.46));
}
#kana-display.minna-reading { letter-spacing: normal; opacity: .84; }

/* Jōyō lesson picker & Native DS Zen Glass Overhaul (PT-23, PT-24, PT-25, PT-30) */
body.thor-dual-active #notice-body .joyo-seen { display: none; }
#web-test-notice-modal .notice-card-wrap {
  position: relative;
  overflow: hidden;
  max-width: 540px;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(56, 189, 248, 0.16), transparent 54%),
    radial-gradient(ellipse at 86% 100%, rgba(45, 212, 191, 0.12), transparent 52%),
    linear-gradient(170deg, rgba(12, 31, 52, 0.90) 0%, rgba(7, 19, 34, 0.95) 100%);
  border: 1px solid rgba(165, 220, 245, 0.30);
  border-radius: 22px;
  padding: 12px 12px 10px;
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.20), 0 24px 60px rgba(2, 10, 22, 0.72);
}
#web-test-notice-modal.ds-menu-mode {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
  align-items: stretch;
  justify-content: center;
  height: auto;
  overflow: hidden;
}
#web-test-notice-modal.ds-menu-mode .notice-card-wrap {
  width: 100%;
  max-width: 680px;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  gap: 8px;
}
#web-test-notice-modal.ds-menu-mode #notice-body {
  flex: 1 1 auto;
  max-height: none;
}
#web-test-notice-modal .notice-title {
  font-size: clamp(20px, 5vw, 27px);
  letter-spacing: -0.025em;
}
#notice-body.joyo-picker {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 6px 2px 12px;
  margin: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 8px, #000 calc(100% - 12px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 8px, #000 calc(100% - 12px), transparent 100%);
}
.joyo-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
}
.joyo-grade {
  min-width: 0;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(165, 220, 245, 0.24);
  border-radius: 16px;
  background: linear-gradient(155deg, rgba(15, 38, 64, 0.74) 0%, rgba(9, 24, 44, 0.86) 100%);
  box-shadow: inset 0 1px rgba(216, 243, 255, 0.14), 0 8px 18px rgba(2, 10, 22, 0.28);
}
.joyo-grade.joyo-grade-flat {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.joyo-grade.joyo-grade-flat > .joyo-grade-header {
  padding: 5px 12px;
  border-radius: 13px;
  border: 1px solid rgba(165, 220, 245, 0.22);
  background: linear-gradient(155deg, rgba(16, 40, 68, 0.74), rgba(9, 24, 44, 0.86));
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.16), 0 6px 16px rgba(2, 10, 22, 0.26);
}
.joyo-grade.joyo-grade-flat .joyo-toggle {
  min-height: 30px;
  padding-inline: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.92rem;
}
.joyo-grade.joyo-grade-flat .joyo-toggle small {
  display: inline;
  padding-inline-start: 0;
  opacity: 0.82;
}
.joyo-grade.joyo-grade-flat > .joyo-meter {
  width: calc(100% - 6px);
  margin: 7px 3px 8px;
}
.joyo-grade-header, .joyo-lesson {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 8px;
  padding: 4px 8px;
}
.joyo-grade-header {
  padding: 0 12px;
  height: 50px;
  min-height: 50px;
  box-sizing: border-box;
}
.joyo-toggle, .joyo-start, .joyo-action, .joyo-review {
  font: inherit;
  color: inherit;
  min-height: 44px;
  cursor: pointer;
}
.joyo-toggle, .joyo-start {
  border: 0;
  text-align: left;
  background: transparent;
  font-weight: 650;
}
.joyo-toggle {
  font-size: clamp(0.82rem, 3.6vw, 0.95rem);
  color: #ffe3b1;
  height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.15;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.joyo-toggle small {
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.80;
  flex-shrink: 0;
}
.joyo-start { font-size: .82rem; }
.joyo-start:disabled { opacity: .65; cursor: default; }
.joyo-percent { font-variant-numeric: tabular-nums; color: #ffe0a8; font-size: .84rem; }
.joyo-action {
  padding: 5px 9px;
  border-radius: 11px;
  border: 1px solid #edc78248;
  background: #12192590;
  font-size: .73rem;
}
@media (hover: hover) {
  .joyo-action:hover, .joyo-review:hover { border-color: #edc782bb; }
}
.joyo-meter {
  appearance: none;
  display: block;
  border: 0;
  width: calc(100% - 24px);
  height: 4px;
  margin: 0 12px 9px;
  background: rgba(6, 16, 30, 0.85);
  border-radius: 99px;
  overflow: hidden;
}
.joyo-meter::-webkit-progress-bar { background: rgba(6, 16, 30, 0.85); }
.joyo-meter::-webkit-progress-value { background: linear-gradient(90deg, #38bdf8, #fde68a); border-radius: 99px; }
.joyo-meter::-moz-progress-bar { background: #eac386; }
.joyo-lessons {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 6px;
  background: transparent;
  animation: joyo-open .18s ease-out;
}
.joyo-grade.joyo-grade-flat > .joyo-lessons {
  padding: 0;
}
.joyo-lesson + .joyo-lesson { border-top: 1px solid rgba(255, 255, 255, 0.06); }
@keyframes joyo-open { from { opacity: 0; } }
.joyo-review, .joyo-pending, .joyo-all-done {
  padding: 12px 14px;
  background: rgba(20, 30, 48, 0.84);
  border: 1px solid rgba(148, 179, 214, 0.34);
  border-radius: 14px;
}
.joyo-all-done {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.joyo-all-done p { margin: 0; font-size: 0.9rem; font-weight: 700; color: #ffe3b1; }
.joyo-review:disabled, .joyo-pending { color: #a3acb9; opacity: .69; cursor: default; }
.joyo-pending {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: .8rem;
}
.joyo-pending small { text-align: right; }
#srs-modal [hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  .joyo-lessons,
  .joyo-seen::after { animation: none !important; }
}
.joyo-toggle small { display: block; padding-inline-start: 16px; color: #d1c1a6; font-size: .68rem; font-weight: 500; }
.joyo-picker { grid-auto-rows: max-content; align-content: start; min-height: 0; }
#notice-body.joyo-picker > * { flex-shrink: 0; }
#notice-body .joyo-pending small { color: inherit; }

/* Standalone / Safe Area */
#app[hidden] { display: none; }
#app {
  padding-inline-start: max(10px, env(safe-area-inset-left));
  padding-inline-end: max(10px, env(safe-area-inset-right));
}
#lang-boot-modal, #web-test-notice-modal {
  padding-block-start: max(14px, env(safe-area-inset-top));
  padding-block-end: max(14px, env(safe-area-inset-bottom));
  padding-inline-start: max(14px, env(safe-area-inset-left));
  padding-inline-end: max(14px, env(safe-area-inset-right));
}
#lang-boot-modal .lang-boot-card-wrap, #web-test-notice-modal .notice-card-wrap,
#function-test {
  max-height: calc(100dvh - max(24px, env(safe-area-inset-top)) - max(24px, env(safe-area-inset-bottom)));
}
#lang-boot-modal .lang-boot-card-wrap { overflow-y: auto; }
@media (max-height: 540px) {
  .lang-boot-card-wrap { padding: 12px 14px; gap: 6px; border-radius: 18px; }
  .lang-boot-title { font-size: 16px; }
  .lang-boot-sub { font-size: 11.5px; margin: -2px 0 0; }
  .lang-boot-grid { gap: 7px; }
  .lang-boot-btn { min-height: 44px; padding: 6px 8px; border-radius: 11px; }
  .lang-boot-btn .lang-native { font-size: 13.5px; line-height: 1.25; }
  .lang-boot-btn .lang-note { font-size: 10px; }
}

.joyo-lesson-pair {
  position: relative;
  padding: 9px 10px 9px 16px;
  border-radius: 15px;
  border: 1px solid rgba(165, 220, 245, 0.20);
  background: linear-gradient(155deg, rgba(14, 34, 58, 0.72), rgba(9, 22, 40, 0.86));
  box-shadow: inset 0 1px 0 rgba(224, 244, 255, 0.16), 0 6px 16px rgba(2, 10, 22, 0.34);
  transition: transform 90ms ease, border-color 140ms ease, background 140ms ease;
}
.joyo-lesson-pair:active { transform: scale(0.988); }
.joyo-lesson-pair[data-state="cleared"] {
  border-color: rgba(251, 191, 36, 0.34);
  background: linear-gradient(155deg, rgba(46, 38, 28, 0.66), rgba(14, 26, 42, 0.86));
}
.joyo-lesson-pair[data-state="platinum"] {
  border-color: rgba(186, 230, 253, 0.42);
  background: linear-gradient(155deg, rgba(34, 52, 74, 0.72), rgba(14, 28, 46, 0.88));
}
.joyo-lesson-pair[data-state="active"] {
  border-color: rgba(56, 189, 248, 0.36);
}
.joyo-lesson-pair[data-state="bronze"] {
  border-color: rgba(217, 138, 78, 0.46);
  background: linear-gradient(155deg, rgba(54, 34, 24, 0.72), rgba(18, 22, 36, 0.88));
}
.joyo-lesson-pair[data-state="bronze"]::before {
  background: #d98a4e;
  box-shadow: 0 0 8px rgba(217, 138, 78, 0.46);
}
.joyo-lesson-pair[data-state="bronze"] .joyo-percent,
.joyo-percent[data-status="bronze"] {
  color: #fdba74;
}
.joyo-lesson-pair::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: rgba(148, 179, 214, 0.28);
}
.joyo-lesson-pair[data-state="active"]::before {
  background: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.45);
}
.joyo-lesson-pair[data-state="cleared"]::before {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.42);
}
.joyo-lesson-pair[data-state="platinum"]::before {
  background: #e2e8f0;
  box-shadow: 0 0 10px rgba(186, 230, 253, 0.65);
}
.joyo-lesson-pair + .joyo-lesson-pair { border-top: 1px solid rgba(165, 220, 245, 0.20); }
.joyo-lesson-pair[data-state="cleared"] + .joyo-lesson-pair[data-state="cleared"] { border-top-color: rgba(251, 191, 36, 0.34); }
.joyo-lesson-pair[data-state="platinum"] + .joyo-lesson-pair[data-state="platinum"] { border-top-color: rgba(186, 230, 253, 0.42); }
.joyo-lesson-pair h3 { margin: 0 0 7px; font-size: .82rem; color: #e4d5bb; }
.joyo-tracks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.joyo-track { min-width: 0; border: 1px solid #e1b87938; border-radius: 11px; background: #172131; }
.joyo-track .joyo-start {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-content: center;
  align-items: center;
  column-gap: 5px;
  width: 100%;
  padding: 5px 8px;
  line-height: 1.25;
}
.joyo-track .joyo-meter { margin-bottom: 4px; }
.joyo-track .joyo-action {
  display: block;
  width: 100%;
  border-width: 1px 0 0;
  border-radius: 0 0 10px 10px;
}

:root { color-scheme: dark; background-color: #0d2b42; }
.joyo-both {
  width: 100%;
  min-height: 44px;
  margin: 0 0 7px;
  border: 1px solid #e1b87987;
  border-radius: 11px;
  color: #ffe3b1;
  background: linear-gradient(110deg, #3c3428, #222d39);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.joyo-both:disabled { opacity: .5; cursor: default; }
@media (display-mode: standalone) {
  #app {
    position: fixed;
    inset: 0;
    height: auto;
    margin: 0 auto;
    padding-block-start: max(8px, env(safe-area-inset-top));
  }
  .modal-card {
    padding-block-start: max(24px, calc(12px + env(safe-area-inset-top)));
    padding-inline-start: max(16px, env(safe-area-inset-left));
    padding-inline-end: max(16px, env(safe-area-inset-right));
  }
}

.joyo-completed-badge { color: #ffcf69; text-shadow: 0 1px 8px #f0b85f70; font-size: 1rem; line-height: 1; }
.joyo-completed-badge[data-status="silver"] { color: #c0c8d6; text-shadow: 0 1px 8px #a3b1c270; }
.joyo-completed-badge[data-status="platinum"] { color: #f0f9ff; text-shadow: 0 0 10px rgba(125, 211, 252, 0.85), 0 0 4px rgba(255, 255, 255, 0.65); }
.joyo-track .joyo-start:disabled:has(.joyo-completed-badge) { opacity: 1; }
.lang-boot-btn:disabled, .lang-pill:disabled, .joyo-language-options button:disabled {
  color: #9aa5b9;
  opacity: .55;
  cursor: default;
}
.joyo-language-options { margin-top: 8px; }
.joyo-language-options summary { padding: 10px 14px; cursor: pointer; }
.joyo-language-options button { display: block; width: 100%; margin-top: 4px; text-align: left; }

#web-test-notice-modal .notice-head { flex-direction: column; align-items: flex-start; gap: 8px; }
#picker-options { min-height: 44px; }
#notice-body { min-height: 0; }
.picker-footer {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 2px 2px;
  border-top: 1px solid rgba(165, 220, 245, 0.20);
}
#web-test-notice-modal.ds-menu-mode .picker-footer {
  margin-inline: 0;
  padding: 6px 2px max(10px, env(safe-area-inset-bottom));
  border-top: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}
.picker-footer[hidden], #picker-options[hidden] { display: none; }
.picker-footer button {
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(16, 40, 68, 0.82), rgba(9, 23, 42, 0.94));
  border: 1px solid rgba(165, 220, 245, 0.26);
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.16);
  font-size: clamp(11px, 2.9vw, 12.5px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.picker-footer button:active { transform: translateY(1px); }
.picker-footer button[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(36, 98, 148, 0.92), rgba(18, 56, 92, 0.98));
  border-color: rgba(125, 211, 252, 0.88);
  color: #f0f9ff;
  box-shadow: inset 0 1px 0 rgba(224, 242, 254, 0.28), 0 0 14px rgba(56, 189, 248, 0.30);
}
.picker-language-pill { height: 42px; min-height: 42px; border-radius: 999px; padding-inline: 10px; }
.picker-footer .joyo-ui-toggle { width: 100%; }
.joyo-custom-study { border-color: rgba(165, 220, 245, 0.34); color: #e0f2fe; }

/* Options Menu Overhaul (PT-09) */
#srs-modal .modal-card {
  padding-block-start: max(18px, calc(12px + env(safe-area-inset-top)));
  background:
    radial-gradient(ellipse at 50% 0%, rgba(56, 189, 248, 0.14), transparent 52%),
    linear-gradient(172deg, rgba(12, 31, 52, 0.94) 0%, rgba(7, 19, 34, 0.98) 100%);
  border: 1.5px solid rgba(165, 220, 245, 0.30);
}
.options-panel { gap: 12px; }
.options-build-stamp {
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: rgba(186, 230, 253, 0.78);
  padding: 2px 6px 0;
  font-variant-numeric: tabular-nums;
}
.review-selector-section {
  padding: 10px 12px;
}
.review-period-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.review-period-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
}
.review-selector-empty {
  margin: 10px 0 2px;
  text-align: center;
  font-size: 0.86rem;
  color: rgba(203, 213, 225, 0.82);
}
.options-card,
.options-panel-card {
  background: linear-gradient(160deg, rgba(15, 38, 64, 0.72), rgba(9, 24, 44, 0.88));
  border: 1px solid rgba(165, 220, 245, 0.22);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.14);
}
.options-panel-card {
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.options-panel-card .menu-section-label {
  padding: 0;
  color: #ffe3b1;
  opacity: 0.9;
}
.pref-label-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.opt-icon { font-size: 15px; line-height: 1; }
#custom-list-options { margin-top: 0; }
#custom-list-options .custom-inline-editor { padding: 2px 0 0; gap: 6px; }
.custom-pass-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.custom-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.custom-input-row input {
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 179, 214, 0.26);
  background: rgba(8, 12, 22, 0.88);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  user-select: text;
  -webkit-user-select: text;
}
.custom-input-row button { height: 40px; padding-inline: 16px; }
.saved-list-name { margin: 4px 0 0; font-size: 12.5px; font-weight: 650; color: #dbeafe; }
.custom-removals { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
#custom-access-status { margin: 2px 0 0; font-size: 11.5px; min-height: 0; }
.save-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  background: transparent;
  border: 0;
  overflow: visible;
}
.save-grid > *:not(:last-child) { border-bottom: 0; }
.save-tile {
  appearance: none;
  border: 1px solid rgba(148, 179, 214, 0.24);
  background: linear-gradient(180deg, rgba(30, 42, 68, 0.85), rgba(18, 26, 44, 0.94));
  color: var(--text);
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 650;
  text-align: center;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 120ms ease, transform 70ms ease;
}
.save-tile:active { transform: translateY(1px); }
.save-tile:disabled { opacity: 0.45; cursor: default; }
.options-credits {
  padding: 10px 13px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.options-credits summary { cursor: pointer; font-weight: 650; color: #cbd5e1; }
.options-credits p { margin: 8px 0 4px; line-height: 1.45; }
.options-credits a { color: var(--accent); }

/* Metallic Jōyō Achievement Plate (PT-21, NEXT6-11 Frosted->Bronze->Silver->Gold->Platinum) */
.joyo-seen,
.joyo-seen[data-tier="frosted"] {
  --plate-accent: #93c5fd;
  --plate-bright: #e0f2fe;
  --plate-ring-track: rgba(186, 230, 253, 0.14);
  --plate-text: #f0f9ff;
  --plate-sub: #cbd5e1;
  isolation: isolate;
  position: relative;
  overflow: hidden;
  margin-bottom: 2px;
  padding: clamp(12px, 3.6vw, 20px) clamp(14px, 4vw, 22px);
  border: 1.5px solid rgba(165, 220, 245, 0.28);
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 86% 6%, rgba(148, 210, 250, 0.16), transparent 58%),
    linear-gradient(148deg, rgba(16, 40, 66, 0.62) 0%, rgba(10, 24, 44, 0.72) 56%, rgba(7, 17, 32, 0.78) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    inset 0 1px 0 rgba(224, 244, 255, 0.24),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 12px 28px rgba(2, 10, 22, 0.48);
  color: var(--plate-text);
}
.joyo-seen[data-tier="bronze"] {
  --plate-accent: #d99b56;
  --plate-bright: #ffe6bd;
  --plate-ring-track: rgba(255, 224, 178, 0.16);
  --plate-text: #fff3dc;
  --plate-sub: #e7c9a6;
  border-color: rgba(214, 152, 82, 0.78);
  background:
    radial-gradient(ellipse at 86% 6%, rgba(196, 128, 58, 0.45), transparent 58%),
    repeating-linear-gradient(125deg, rgba(255, 232, 194, 0.03) 0 2px, transparent 2px 10px),
    linear-gradient(142deg, #4b3322 0%, #2a222b 54%, #161d2e 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 236, 198, 0.42),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45),
    inset 0 0 0 2px rgba(255, 218, 160, 0.09),
    0 10px 24px rgba(5, 8, 16, 0.56);
}
.joyo-seen::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(126deg, transparent 0 14px, rgba(255, 228, 178, 0.06) 14px 15px);
  mask-image: linear-gradient(90deg, transparent 20%, #000);
}
.joyo-seen::after {
  content: '';
  position: absolute;
  z-index: 0;
  inset: -40% -60%;
  pointer-events: none;
  background: linear-gradient(112deg, transparent 42%, rgba(255, 245, 220, 0.14) 50%, transparent 58%);
  transform: translateX(-65%);
  animation: plateSheen 6.5s ease-in-out infinite;
}
@keyframes plateSheen {
  0%, 58% { transform: translateX(-65%); opacity: 0; }
  74% { opacity: 1; }
  92%, 100% { transform: translateX(65%); opacity: 0; }
}

.joyo-seen[data-tier="silver"] {
  --plate-accent: #94a3b8;
  --plate-bright: #cbd5e1;
  --plate-ring-track: rgba(148, 163, 184, 0.14);
  --plate-text: #e2e8f0;
  --plate-sub: #94a3b8;
  border-color: rgba(148, 163, 184, 0.56);
  background:
    radial-gradient(ellipse at 86% 6%, rgba(100, 116, 139, 0.28), transparent 60%),
    repeating-linear-gradient(125deg, rgba(203, 213, 225, 0.025) 0 2px, transparent 2px 10px),
    linear-gradient(142deg, #333c4b 0%, #1f2636 54%, #101624 100%);
}
.joyo-seen[data-tier="gold"] {
  --plate-accent: #fbbf24;
  --plate-bright: #fef3c7;
  --plate-ring-track: rgba(253, 230, 138, 0.18);
  --plate-text: #fffbeb;
  --plate-sub: #fde68a;
  border-color: rgba(251, 191, 36, 0.85);
  background:
    radial-gradient(ellipse at 86% 6%, rgba(245, 158, 11, 0.48), transparent 60%),
    repeating-linear-gradient(125deg, rgba(254, 243, 199, 0.04) 0 2px, transparent 2px 10px),
    linear-gradient(142deg, #634618 0%, #342921 54%, #181c2c 100%);
}
.joyo-seen[data-tier="platinum"] {
  --plate-accent: #bae6fd;
  --plate-bright: #ffffff;
  --plate-ring-track: rgba(186, 230, 253, 0.20);
  --plate-text: #f0f9ff;
  --plate-sub: #bae6fd;
  border-color: rgba(186, 230, 253, 0.90);
  background:
    radial-gradient(ellipse at 84% 6%, rgba(125, 211, 252, 0.42), transparent 60%),
    linear-gradient(142deg, #2d4b6e 0%, #1e2a46 56%, #12182b 100%);
}

.joyo-seen-header {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(8px, 3vw, 18px);
  align-items: center;
}
.joyo-seen-details {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}
.joyo-seen-counter-btn {
  padding: 2px 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 90ms ease, background 120ms ease;
}
.joyo-seen-counter-btn:active { transform: scale(0.985); }
.joyo-seen-meta-row {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}
.joyo-seen-subpill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(9, 13, 24, 0.36);
  color: var(--plate-sub);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.joyo-stars {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 1px;
}
.joyo-star {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 14, 26, 0.56);
  color: rgba(203, 213, 225, 0.32);
  font-size: 12px;
  line-height: 1;
}
.joyo-star.earned {
  border-color: rgba(253, 224, 71, 0.85);
  background: linear-gradient(145deg, #fbbf24, #b45309);
  color: #fffbeb;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.joyo-seen-seal-btn {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform 90ms ease;
}
.joyo-seen-seal-btn:active { transform: scale(0.94); }
.joyo-meter-mastery {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  pointer-events: none;
  background: linear-gradient(90deg, #bae6fd, #ffffff);
  box-shadow: 0 0 8px rgba(186, 230, 253, 0.65);
  transition: width 280ms ease;
}
.joyo-seen-count {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 6px;
  margin: 0;
  color: var(--plate-sub);
  font-variant-numeric: tabular-nums;
}
.joyo-seen-count strong {
  font-size: clamp(1.65rem, 6.2vw, 2.35rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--plate-bright);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.42);
}
.joyo-seen-sep {
  font-size: clamp(1.05rem, 4vw, 1.35rem);
  opacity: 0.72;
  font-weight: 600;
}
.joyo-seen-max {
  white-space: nowrap;
  font-size: clamp(1.05rem, 4vw, 1.35rem);
  font-weight: 650;
  color: var(--plate-sub);
}
.joyo-seen-pct {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(9, 13, 24, 0.42);
  color: var(--plate-bright);
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.joyo-seen-seal {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(60px, 16vw, 78px);
  height: clamp(60px, 16vw, 78px);
}
.joyo-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.joyo-ring-track {
  fill: none;
  stroke: var(--plate-ring-track);
  stroke-width: 4.5;
}
.joyo-ring-arc {
  fill: none;
  stroke: var(--plate-bright);
  stroke-width: 4.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 5px var(--plate-accent));
  transition: stroke-dashoffset 280ms ease;
}
.joyo-seal-glyph {
  display: grid;
  width: 72%;
  height: 72%;
  place-items: center;
  border: 1px solid rgba(255, 232, 186, 0.46);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 18%, rgba(130, 86, 46, 0.92), rgba(34, 24, 30, 0.96) 82%);
  color: var(--plate-bright);
  font-family: 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif CJK JP', serif;
  font-size: clamp(1.25rem, 5vw, 1.85rem);
  line-height: 1;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.65);
}
.joyo-seen[data-tier="silver"] .joyo-seal-glyph {
  background: radial-gradient(circle at 35% 18%, #64748b, #1e293b 82%);
  border-color: rgba(226, 232, 240, 0.56);
}
.joyo-seen[data-tier="gold"] .joyo-seal-glyph {
  background: radial-gradient(circle at 35% 18%, #b45309, #29201b 82%);
  border-color: rgba(253, 224, 71, 0.68);
}
.joyo-seen[data-tier="platinum"] .joyo-seal-glyph {
  background: radial-gradient(circle at 35% 18%, #38bdf8, #172542 82%);
  border-color: rgba(224, 242, 254, 0.78);
}

.joyo-seen-rail {
  position: relative;
  z-index: 1;
  margin-top: clamp(10px, 3vw, 14px);
}
.joyo-seen-rail::after {
  content: '';
  position: absolute;
  inset: 1px 0;
  border-radius: 999px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent calc(100% - 1px), rgba(255, 240, 210, 0.35) 0) 0 0 / 25% 100% repeat-x;
}
.joyo-seen .joyo-meter {
  width: 100%;
  height: 8px;
  margin: 0;
  border: 1px solid rgba(255, 225, 175, 0.32);
  background: rgba(11, 14, 24, 0.85);
}
.joyo-seen .joyo-meter::-webkit-progress-bar { background: rgba(11, 14, 24, 0.85); }
.joyo-seen .joyo-meter::-webkit-progress-value { background: linear-gradient(90deg, var(--plate-accent), var(--plate-bright)); }
.joyo-seen .joyo-meter::-moz-progress-bar { background: linear-gradient(90deg, var(--plate-accent), var(--plate-bright)); }

.joyo-seen-complete {
  box-shadow: inset 0 0 0 2px rgba(224, 242, 254, 0.24), 0 10px 26px rgba(56, 189, 248, 0.25);
}

#boot-japanese-ui:not([hidden]) {
  display: grid;
  gap: 4px;
  width: 100%;
  margin-top: 14px;
  border-color: #d9b47692;
}
#boot-japanese-ui .lang-native { color: #ffe2ad; }
#boot-japanese-ui[hidden] { display: none; }

/* Custom In-Game Curriculum Selector & Controls Bar (PT-18, PT-20) */
.picker-title-hidden { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
#web-test-notice-modal .notice-head:has(.picker-title-hidden) { height:0; }
.picker-list-controls { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:7px; padding:2px 0; }
.picker-list-controls .tool-pill { padding:0 11px; font-size:12.5px; white-space:nowrap; }
@media (max-width: 340px) {
  .picker-list-controls { grid-template-columns: minmax(0, 1fr); }
}
.picker-list-controls > * { height:42px; min-height:42px; border-radius:13px; box-sizing:border-box; }
.curriculum-trigger {
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(165, 220, 245, 0.30);
  background: linear-gradient(180deg, rgba(16, 40, 68, 0.84), rgba(9, 24, 44, 0.94));
  color: #f0f9ff;
  font: inherit;
  font-size: 0.90rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.20), 0 6px 16px rgba(2, 10, 22, 0.30);
}
.curr-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.curr-chev {
  display: inline-flex;
  color: #bae6fd;
  flex-shrink: 0;
}
.hide-completed-btn {
  width: 132px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: 10px;
  line-height: 1;
  font-size: clamp(11px, 2.7vw, 12px);
  border: 1px solid rgba(165, 220, 245, 0.28);
  background: linear-gradient(180deg, rgba(16, 40, 68, 0.82), rgba(9, 24, 44, 0.94));
  color: #dbeafe;
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.16), 0 6px 16px rgba(2, 10, 22, 0.28);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hide-completed-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(36, 98, 148, 0.94), rgba(18, 56, 92, 0.98));
  border-color: rgba(125, 211, 252, 0.88);
  color: #f0f9ff;
  box-shadow: inset 0 1px 0 rgba(224, 242, 254, 0.28), 0 0 14px rgba(56, 189, 248, 0.28);
}

.curriculum-overlay {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(4, 13, 24, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.curriculum-sheet {
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  border: 1.5px solid rgba(165, 220, 245, 0.34);
  background: linear-gradient(168deg, rgba(14, 36, 62, 0.94) 0%, rgba(7, 19, 34, 0.98) 100%);
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.20), 0 18px 42px rgba(2, 10, 22, 0.72);
  animation: joyo-open .16s ease-out;
}
.curriculum-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.curriculum-sheet-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
  color: #f0f9ff;
}
.curriculum-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 55dvh;
}
.curriculum-option {
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border-radius: 13px;
  border: 1px solid rgba(165, 220, 245, 0.24);
  background: rgba(12, 31, 52, 0.84);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.curriculum-option.active {
  border-color: rgba(125, 211, 252, 0.78);
  background: linear-gradient(135deg, rgba(36, 78, 118, 0.75), rgba(20, 38, 66, 0.92));
  box-shadow: inset 0 1px 0 rgba(224, 242, 254, 0.20), 0 0 14px rgba(56, 189, 248, 0.18);
}
.curriculum-option.disabled,
.curriculum-option:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
.joyo-group-play-btn {
  min-width: 84px;
  height: 32px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 750;
  white-space: nowrap;
  border: 1px solid rgba(165, 220, 245, 0.34);
  background: linear-gradient(180deg, rgba(22, 54, 88, 0.90), rgba(11, 29, 52, 0.96));
  color: #e0f2fe;
}
.joyo-group-play-btn[data-state="active"] {
  border-color: rgba(125, 211, 252, 0.72);
  color: #f0f9ff;
}
.joyo-group-play-btn[data-state="platinum"],
.joyo-group-play-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.curr-opt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.curr-opt-title { font-size: 0.94rem; font-weight: 700; color: #f8fafc; }
.curr-opt-meta { font-size: 0.74rem; color: #a5b4cf; }
.curr-opt-mark { color: #7dd3fc; display: inline-flex; flex-shrink: 0; }

/* Aligned Level-Select Rows (PT-08) */
.joyo-lesson-pair > summary { cursor:pointer; display:grid; grid-template-columns:minmax(0,1fr) 3em; min-height:38px; align-items:center; color:#e4d5bb; list-style:none; }
.joyo-lesson-pair > summary > strong, .joyo-track .joyo-percent { text-align:right; }
.joyo-lesson-pair[open] > summary { margin-bottom:6px; }
.lesson-track-actions > summary { cursor:pointer; list-style:none; text-align:center; min-height:28px; color:#d1c1a6; }
.joyo-track .joyo-start { display:grid; grid-template-columns:minmax(0,1fr) auto; text-align:left; }

.lesson-run-row {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 96px;
  gap: 10px;
  align-items: center;
  height: 58px;
  min-height: 58px;
  padding: 0 10px 0 16px;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.lesson-run-row::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: calc(var(--charge-pct, 0) * 100%);
  background: linear-gradient(90deg, #38bdf8, #67e8f9 65%, #fde047);
  opacity: 0;
  pointer-events: none;
  transition: opacity 80ms ease;
}
.lesson-run-row.long-pressing::before { opacity: 0.95; }
.lesson-run-row.long-pressing {
  transform: scale(0.985);
  border-color: rgba(103, 232, 249, 0.72);
  box-shadow: 0 0 0 1px rgba(103, 232, 249, 0.35), 0 0 18px rgba(56, 189, 248, 0.24);
}
.lesson-run-row.long-pressing[data-charge-phase="mid"] {
  border-color: rgba(165, 243, 252, 0.88);
  box-shadow: 0 0 0 1.5px rgba(103, 232, 249, 0.55), 0 0 24px rgba(56, 189, 248, 0.38);
}
.lesson-run-row.long-pressing[data-charge-phase="peak"] {
  border-color: rgba(253, 224, 71, 0.96);
  box-shadow: 0 0 0 2px rgba(253, 224, 71, 0.65), 0 0 28px rgba(251, 191, 36, 0.48);
}
.buster-charge-hud {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 4;
  display: grid;
  place-items: center;
}
.buster-ring { width: 44px; height: 44px; overflow: visible; }
.buster-ring .br-track {
  fill: rgba(6, 18, 34, 0.58);
  stroke: rgba(186, 230, 253, 0.24);
  stroke-width: 3;
}
.buster-ring .br-fill {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 3.4;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.72));
}
.lesson-run-row[data-charge-phase="mid"] .br-fill {
  stroke: #67e8f9;
  filter: drop-shadow(0 0 9px rgba(103, 232, 249, 0.88));
}
.lesson-run-row[data-charge-phase="peak"] .br-fill {
  stroke: #fde047;
  filter: drop-shadow(0 0 12px rgba(253, 224, 71, 0.96));
}
.buster-charge-hud.fx-on .bc-orb {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7dd3fc;
  box-shadow: 0 0 8px #38bdf8;
  animation: busterGather 560ms ease-in infinite;
}
.lesson-run-row[data-charge-phase="peak"] .bc-orb { background: #fef08a; box-shadow: 0 0 10px #fde047; }
.buster-charge-hud.fx-on .bc-orb.o1 { --bx: -26px; --by: -18px; animation-delay: 0ms; }
.buster-charge-hud.fx-on .bc-orb.o2 { --bx: 26px; --by: -18px; animation-delay: 140ms; }
.buster-charge-hud.fx-on .bc-orb.o3 { --bx: -24px; --by: 18px; animation-delay: 280ms; }
.buster-charge-hud.fx-on .bc-orb.o4 { --bx: 24px; --by: 18px; animation-delay: 420ms; }
@keyframes busterGather {
  0% { transform: translate(var(--bx), var(--by)) scale(0.95); opacity: 0.9; }
  100% { transform: translate(0, 0) scale(0.25); opacity: 0.1; }
}
.lesson-run-row > span {
  min-width: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lesson-run-row > strong {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.lesson-run-start {
  width: 96px;
  height: 38px;
  min-height: 38px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 10px;
  font-size: clamp(10.5px, 2.7vw, 12px);
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(165, 220, 245, 0.30);
  background: linear-gradient(180deg, rgba(22, 54, 88, 0.90), rgba(11, 29, 52, 0.96));
  color: #e0f2fe;
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.18);
  transition: transform 80ms ease;
}
.lesson-run-start:active { transform: scale(0.96); }
.lesson-run-start[data-state="active"] {
  border-color: rgba(56, 189, 248, 0.72);
  background: linear-gradient(180deg, rgba(38, 96, 146, 0.95), rgba(22, 58, 94, 0.98));
  color: #f0f9ff;
}
.lesson-run-start[data-state="bronze"] {
  border-color: rgba(217, 138, 78, 0.72);
  background: linear-gradient(180deg, rgba(96, 54, 28, 0.92), rgba(46, 28, 18, 0.96));
  color: #ffedd5;
}
.lesson-run-start[data-state="cleared"] {
  border-color: rgba(251, 191, 36, 0.65);
  background: linear-gradient(180deg, rgba(78, 58, 26, 0.9), rgba(40, 32, 22, 0.96));
  color: #fef3c7;
}
.lesson-run-start[data-state="platinum"] {
  border-color: rgba(186, 230, 253, 0.56);
  background: linear-gradient(180deg, rgba(44, 66, 92, 0.88), rgba(20, 36, 56, 0.94));
  color: #f0f9ff;
}
.lesson-run-start[data-state="platinum"]:disabled {
  opacity: 0.72;
  cursor: default;
  transform: none;
}
.joyo-lesson-pair[data-state="locked"] {
  opacity: 0.62;
  border-color: rgba(148, 163, 184, 0.22);
}
.lesson-run-start[data-state="locked"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.lesson-run-active .fg-int, .lesson-run-active .wg-int,
.lesson-run-active [data-fgrade="known"], .lesson-run-active .wg-known { display:none !important; }

.write-question { display:block; width:.68em; height:.68em; }

/* Hide redundant flat summary header & meter on dual-screen Thor (summary sits beneath top plaque, PT-43) */
body.thor-dual-active .joyo-grade.joyo-grade-flat > .joyo-grade-header,
body.thor-dual-active .joyo-grade.joyo-grade-flat > .joyo-meter {
  display: none;
}

/* Dedicated Main Menu Review button & modal (PT-33, geometry locked PT-53) */
.picker-review-btn {
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 0 14px;
  line-height: 1;
  box-sizing: border-box;
  border-radius: 13px;
  border: 1px solid rgba(165, 220, 245, 0.28);
  background: linear-gradient(155deg, rgba(28, 52, 82, 0.80), rgba(14, 30, 52, 0.90));
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.16), 0 6px 14px rgba(2, 10, 22, 0.26);
  color: #f0f9ff;
  font: inherit;
  font-size: 0.90rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}
.picker-review-btn:active { transform: translateY(1px); }
.picker-review-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  min-width: 34px;
  padding: 0 10px;
  line-height: 1;
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  color: #ffe3b1;
  background: rgba(251, 191, 36, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.34);
}
.review-filter-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.review-filter-tab {
  min-height: 34px;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1px solid rgba(165, 220, 245, 0.24);
  background: rgba(12, 31, 52, 0.82);
  color: #cbd5e1;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 650;
  cursor: pointer;
}
.review-filter-tab[aria-pressed="true"] {
  border-color: rgba(125, 211, 252, 0.84);
  background: linear-gradient(180deg, rgba(34, 88, 136, 0.92), rgba(18, 52, 86, 0.96));
  color: #f0f9ff;
}
.review-card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 46dvh;
}
.review-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 11px;
  border: 1px solid rgba(165, 220, 245, 0.18);
  background: rgba(10, 26, 46, 0.76);
}
.review-card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.review-card-term {
  font-family: var(--font-ja);
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
}
.review-card-clue {
  font-size: 0.74rem;
  color: #a5b4cf;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.review-card-tags {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.review-skill-tag {
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.28);
}
.review-empty-msg {
  margin: 0;
  padding: 18px 8px;
  text-align: center;
  font-size: 0.86rem;
  color: #94a3b8;
}
.review-start-btn {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(125, 211, 252, 0.75);
  background: linear-gradient(180deg, rgba(36, 98, 148, 0.94), rgba(18, 56, 92, 0.98));
  color: #f0f9ff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
.review-start-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Three Independent Save Slots (PT-58) & One-Time Mastered Confirmation (PT-57) */
.save-slots-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.save-slot-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(165, 220, 245, 0.22);
  background: rgba(12, 31, 52, 0.76);
  color: var(--text);
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.save-slot-btn.active {
  border-color: rgba(125, 211, 252, 0.80);
  background: linear-gradient(135deg, rgba(32, 74, 114, 0.72), rgba(16, 36, 62, 0.92));
  box-shadow: inset 0 1px 0 rgba(224, 242, 254, 0.22);
}
.save-slot-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.save-slot-title {
  font-size: 0.88rem;
  font-weight: 750;
  color: #f8fafc;
}
.save-slot-meta {
  font-size: 0.72rem;
  color: #a8c5e2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.save-slot-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.save-slot-lang {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #dbeafe;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(165, 220, 245, 0.28);
}
.mastered-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(4, 13, 24, 0.76);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mastered-confirm-sheet {
  width: 100%;
  max-width: 400px;
  padding: 18px;
  border-radius: 18px;
  border: 1.5px solid rgba(165, 220, 245, 0.36);
  background: linear-gradient(168deg, rgba(14, 36, 62, 0.96) 0%, rgba(7, 19, 34, 0.98) 100%);
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.22), 0 20px 48px rgba(2, 10, 22, 0.78);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mastered-confirm-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
  color: #f0f9ff;
}
.mastered-confirm-body {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #cbd5e1;
}
.mastered-confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.mastered-confirm-actions button {
  min-height: 40px;
}

/* Birthday setting (PT-69), Custom Dropdowns (PT-03), Water Quality (PT-08) & Voice Clips */
.water-quality-seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(7, 20, 36, 0.72);
  border: 1px solid rgba(165, 220, 245, 0.18);
}
.wq-btn {
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: #9dc0df;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.wq-btn.active {
  color: #f0f9ff;
  background: linear-gradient(180deg, rgba(44, 102, 152, 0.88), rgba(22, 58, 96, 0.96));
  border-color: rgba(125, 211, 252, 0.56);
  box-shadow: inset 0 1px 0 rgba(224, 245, 255, 0.25), 0 2px 6px rgba(2, 10, 22, 0.35);
}
.birthday-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.birthday-trigger {
  flex: 1 1 110px;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(165, 220, 245, 0.28);
  background: rgba(12, 31, 52, 0.86);
  color: #e2eefc;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}
.birthday-trigger:disabled {
  opacity: 0.45;
  cursor: default;
}
.birthday-trigger-chev {
  color: #7dd3fc;
  font-size: 0.78rem;
}
.birthday-picker-sheet {
  max-width: 390px;
}
.birthday-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding: 2px;
}
.birthday-picker-grid.months {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.birthday-opt-btn {
  min-height: 38px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(165, 220, 245, 0.22);
  background: rgba(12, 31, 52, 0.82);
  color: #dbeafe;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}
.birthday-opt-btn.selected {
  color: #f0f9ff;
  border-color: rgba(125, 211, 252, 0.85);
  background: linear-gradient(135deg, rgba(36, 98, 148, 0.88), rgba(18, 52, 88, 0.96));
  box-shadow: inset 0 1px 0 rgba(224, 245, 255, 0.25);
}
.about-row-btn {
  width: 100%;
  min-height: 36px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: #e2eefc;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.about-row-btn svg {
  color: #7dd3fc;
}
.voice-test-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.voice-test-header .menu-section-label {
  margin: 0;
}
.voice-test-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
@media (max-width: 390px) {
  .voice-test-list {
    grid-template-columns: minmax(0, 1fr);
  }
}
.voice-clip-btn {
  width: 100%;
  padding: 8px 10px;
  border-radius: 11px;
  border: 1px solid rgba(165, 220, 245, 0.22);
  background: rgba(12, 31, 52, 0.76);
  color: var(--text);
  font: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 80ms ease;
}
.voice-clip-btn.voice-clip-mystery {
  grid-column: 1 / -1;
  align-items: center;
  text-align: center;
  letter-spacing: 0.14em;
}
.voice-clip-btn:active {
  transform: scale(0.98);
}
.voice-clip-btn.playing {
  border-color: rgba(125, 211, 252, 0.88);
  background: linear-gradient(135deg, rgba(32, 74, 114, 0.78), rgba(16, 36, 62, 0.94));
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.22);
}
.voice-clip-ja {
  font-size: 0.86rem;
  font-weight: 750;
  color: #f8fafc;
}
.voice-clip-sub {
  font-size: 0.7rem;
  color: #9dc0df;
}

/* Joyo Kanji Collection Drawer & Platinum Inspector (NEXT-09) */
/* Circular Starbucks-Inspired Jōyō Medal Gallery (NEXT6-15) */
.joyo-collection-modal-wrap:has(.joyo-collection-shell) {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.joyo-collection-modal-wrap,
.joyo-collection-shell,
.medal-gallery-shell {
  width: min(96vw, 880px);
  height: min(90dvh, 760px);
  max-height: 92dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 20px;
  border: 1px solid rgba(165, 220, 245, 0.28);
  background: linear-gradient(160deg, rgba(11, 28, 48, 0.96), rgba(6, 17, 32, 0.98));
  box-shadow: 0 24px 60px rgba(2, 8, 20, 0.72);
  color: #f0f9ff;
  box-sizing: border-box;
  overflow: hidden;
}
.thor-collection-stage .joyo-collection-shell {
  width: 100%;
  max-height: none;
  height: 100%;
  padding: 10px 12px;
  gap: 6px;
}
.joyo-col-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  flex: none;
}
.joyo-col-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
  color: #f8fafc;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.joyo-gal-count {
  font-size: 0.76rem;
  font-weight: 700;
  color: #bae6fd;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(165, 220, 245, 0.24);
  background: rgba(14, 34, 58, 0.78);
  flex: none;
}
.joyo-gal-gear-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(165, 220, 245, 0.30);
  background: rgba(15, 39, 66, 0.85);
  color: #e0f2fe;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.joyo-gal-gear-btn.active {
  border-color: rgba(125, 211, 252, 0.90);
  background: rgba(36, 98, 148, 0.92);
}
.joyo-gal-gear-pop {
  position: absolute;
  top: 52px;
  right: 12px;
  left: 12px;
  max-width: 420px;
  margin-left: auto;
  z-index: 25;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(165, 220, 245, 0.36);
  background: rgba(8, 22, 40, 0.97);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 40px rgba(2, 8, 20, 0.78);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 68dvh;
  overflow-y: auto;
}
.joyo-gal-gear-pop.hidden { display: none !important; }
.gal-pop-sec { display: flex; flex-direction: column; gap: 4px; }
.gal-pop-lbl { font-size: 0.72rem; font-weight: 700; color: #ffe3b1; letter-spacing: 0.03em; }
.gal-pop-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.gal-chip {
  min-height: 26px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(165, 220, 245, 0.24);
  background: rgba(14, 34, 58, 0.76);
  color: #cbd5e1;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.gal-chip.active {
  border-color: rgba(125, 211, 252, 0.90);
  background: linear-gradient(180deg, rgba(36, 98, 148, 0.92), rgba(18, 52, 88, 0.98));
  color: #ffffff;
}
.joyo-medal-viewport {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4px;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  -webkit-overflow-scrolling: touch;
}
.joyo-medal-viewport.size-all {
  overflow: hidden;
  align-items: center;
}
.joyo-medal-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 8px;
  width: 100%;
}
.joyo-medal-grid.size-all {
  gap: var(--medal-gap, 2px);
}
.joyo-medal-grid.size-small .medal-tile { width: 34px; height: 34px; font-size: 0.95rem; }
.joyo-medal-grid.size-medium .medal-tile { width: 48px; height: 48px; font-size: 1.32rem; }
.joyo-medal-grid.size-large .medal-tile { width: 66px; height: 66px; font-size: 1.85rem; }
.joyo-medal-grid.size-all .medal-tile {
  width: var(--medal-d, 10px);
  height: var(--medal-d, 10px);
  font-size: calc(var(--medal-d, 10px) * 0.54);
}
.joyo-medal-grid.micro-discs .medal-glyph {
  opacity: 0;
  font-size: 1px;
}
/* Starbucks oatomi.com/medals/ inspired circular discs + arrival-ring */
.medal-tile {
  position: relative;
  isolation: isolate;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.medal-art {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.20);
  background: radial-gradient(circle at 32% 28%, rgba(30, 54, 84, 0.65), rgba(8, 20, 36, 0.88));
  color: rgba(148, 163, 184, 0.44);
  font-family: var(--font-ja);
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 3px 8px rgba(0, 0, 0, 0.34);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s ease;
}
.medal-tile:hover .medal-art { transform: translateY(-2px) scale(1.06); }
.medal-tile.bronze .medal-art {
  border-color: rgba(217, 155, 86, 0.84);
  background: radial-gradient(circle at 30% 28%, #e5a967, #9c5d26 55%, #3d210f 100%);
  color: #fff3dc;
  box-shadow: inset 0 1px 0 rgba(255, 232, 194, 0.62), 0 2px 8px rgba(180, 108, 42, 0.28);
}
.medal-tile.silver .medal-art {
  border-color: rgba(226, 232, 240, 0.90);
  background: radial-gradient(circle at 30% 28%, #f8fafc, #94a3b8 55%, #334155 100%);
  color: #0b1524;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78), 0 2px 8px rgba(148, 163, 184, 0.30);
}
.medal-tile.gold .medal-art {
  border-color: rgba(253, 224, 71, 0.94);
  background: radial-gradient(circle at 30% 28%, #fef08a, #d97706 58%, #6b3b09 100%);
  color: #1f1204;
  text-shadow: 0 1px 0 rgba(254, 243, 199, 0.60);
  box-shadow: inset 0 1px 0 rgba(255, 251, 235, 0.84), 0 2px 10px rgba(245, 158, 11, 0.36);
}
.medal-tile.platinum .medal-art {
  border-color: rgba(240, 249, 255, 0.96);
  background: radial-gradient(circle at 30% 28%, #ffffff, #bae6fd 48%, #4b7399 100%);
  color: #08182a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.90), 0 2px 12px rgba(186, 230, 253, 0.44);
}
.medal-tile.selected .medal-art {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}
.joyo-gal-empty {
  padding: 28px 14px;
  color: #94a3b8;
  font-size: 0.88rem;
  text-align: center;
}
.joyo-medal-tooltip {
  position: relative;
  flex: none;
  border-radius: 14px;
  border: 1px solid rgba(165, 220, 245, 0.32);
  background: rgba(7, 20, 36, 0.95);
  box-shadow: 0 -8px 26px rgba(2, 8, 20, 0.56);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 40dvh;
  overflow-y: auto;
}
.joyo-ins-medal-preview { width: 46px; height: 46px; font-size: 1.5rem; }
body.reduced-fx .medal-tile:hover .medal-art { transform: none; }
.word-card, .notice-card {
  box-shadow: 0 16px 40px rgba(2, 10, 22, 0.42);
}
.joyo-col-close {
  flex: none;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(165, 220, 245, 0.34);
  background: rgba(15, 39, 66, 0.88);
  color: #e0f2fe;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.joyo-col-grades {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.joyo-col-grade-btn {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(165, 220, 245, 0.22);
  background: rgba(10, 27, 46, 0.78);
  color: #cbd5e1;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}
.joyo-col-grade-btn.active {
  border-color: rgba(125, 211, 252, 0.88);
  background: linear-gradient(180deg, rgba(36, 98, 148, 0.92), rgba(18, 52, 88, 0.96));
  color: #ffffff;
}
.joyo-col-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  flex: 1;
}
.joyo-col-body:has(.joyo-col-inspector) {
  grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.95fr);
}
@media (max-width: 600px) {
  .joyo-col-body:has(.joyo-col-inspector) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
}
.joyo-col-sections {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
  min-height: 0;
  align-content: start;
}
.joyo-col-sec {
  border-radius: 12px;
  border: 1px solid rgba(165, 220, 245, 0.22);
  background: rgba(10, 26, 46, 0.78);
  overflow: hidden;
  flex: none;
}
.joyo-col-sec.expanded {
  border-color: rgba(125, 211, 252, 0.50);
  background: rgba(12, 31, 54, 0.86);
}
.joyo-col-sec-head {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: #ffe3b1;
  font: inherit;
  font-size: 0.90rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  cursor: pointer;
}
.joyo-col-sec-chev {
  font-size: 0.85rem;
  color: #93c5fd;
  flex: none;
}
.joyo-col-sec-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.joyo-col-sec .joyo-col-grid {
  padding: 4px 10px 10px;
  overflow: visible;
}
.joyo-ins-close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(165, 220, 245, 0.28);
  background: rgba(15, 39, 66, 0.82);
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  flex: none;
}
.joyo-col-sub {
  font-size: 0.74rem;
  font-weight: 650;
  color: #93c5fd;
}
.joyo-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
  padding: 4px;
  align-content: start;
  min-height: 0;
}
.joyo-col-tile {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(9, 20, 36, 0.62);
  color: rgba(148, 163, 184, 0.38);
  font-family: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Noto Sans JP', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.joyo-col-tile.seen {
  border-color: rgba(147, 197, 253, 0.42);
  background: rgba(20, 48, 78, 0.78);
  color: #f8fafc;
}
.joyo-col-tile.bronze {
  border-color: rgba(217, 155, 86, 0.80);
  background: linear-gradient(145deg, #b87439 0%, #6d3f1e 48%, #2e1d16 100%);
  color: #fff3dc;
  box-shadow: inset 0 1px 0 rgba(255, 232, 194, 0.50);
}
.joyo-col-tile.silver {
  border-color: rgba(203, 213, 225, 0.85);
  background: linear-gradient(145deg, #cbd5e1 0%, #64748b 48%, #273347 100%);
  color: #0b1524;
  text-shadow: 0 1px 0 rgba(248, 250, 252, 0.45);
  box-shadow: inset 0 1px 0 rgba(248, 250, 252, 0.72);
}
.joyo-col-tile.gold {
  border-color: rgba(251, 191, 36, 0.90);
  background: linear-gradient(145deg, #fde68a 0%, #d97706 48%, #5b340e 100%);
  color: #1f1204;
  text-shadow: 0 1px 0 rgba(254, 243, 199, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 251, 235, 0.80), 0 0 8px rgba(245, 158, 11, 0.28);
}
.joyo-col-tile.platinum {
  border-color: rgba(224, 242, 254, 0.92);
  background: linear-gradient(145deg, #e2eef8 0%, #94b3ce 44%, #385878 100%);
  color: #0b192c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 0 10px rgba(186, 230, 253, 0.32);
}
.joyo-col-tile.selected {
  outline: 2px solid #fbbf24;
  outline-offset: 1px;
}
.joyo-col-inspector {
  border-radius: 14px;
  border: 1px solid rgba(165, 220, 245, 0.24);
  background: rgba(8, 21, 38, 0.90);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 55dvh;
}
.joyo-ins-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.joyo-ins-glyph {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  border: 1px solid rgba(165, 220, 245, 0.34);
  background: rgba(16, 40, 68, 0.88);
  color: #f8fafc;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
  flex: none;
}
.joyo-ins-glyph.bronze {
  border-color: rgba(217, 155, 86, 0.88);
  background: linear-gradient(145deg, #ca8446 0%, #6f4020 50%, #301d15 100%);
  color: #fff3dc;
  box-shadow: inset 0 1px 0 rgba(255, 232, 194, 0.55);
}
.joyo-ins-glyph.silver {
  border-color: rgba(203, 213, 225, 0.90);
  background: linear-gradient(145deg, #e2e8f0 0%, #64748b 50%, #273347 100%);
  color: #0b1524;
  box-shadow: inset 0 1px 0 rgba(248, 250, 252, 0.78);
}
.joyo-ins-glyph.gold {
  border-color: rgba(251, 191, 36, 0.95);
  background: linear-gradient(145deg, #fef08a 0%, #d97706 50%, #5c340e 100%);
  color: #1f1204;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.35), inset 0 1px 0 #fffbeb;
}
.joyo-ins-glyph.platinum {
  border-color: rgba(224, 242, 254, 0.95);
  background: linear-gradient(145deg, #f8fafc 0%, #9dc0db 48%, #416282 100%);
  color: #09172a;
  box-shadow: 0 0 16px rgba(186, 230, 253, 0.45), inset 0 1px 0 #ffffff;
}
.joyo-ins-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.joyo-ins-origin { font-size: 0.78rem; color: #93c5fd; font-weight: 700; }
.joyo-ins-status { font-size: 0.82rem; font-weight: 800; color: #e2eefc; }
.joyo-ins-readings {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.joyo-ins-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid rgba(165, 220, 245, 0.14);
  background: rgba(14, 34, 58, 0.72);
}
.joyo-ins-r-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.joyo-ins-r-kana { font-size: 0.84rem; font-weight: 750; color: #f8fafc; }
.joyo-ins-r-clue { font-size: 0.72rem; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.joyo-ins-r-badge {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 750;
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #94a3b8;
}
.joyo-ins-r-badge.mastered { border-color: rgba(186, 230, 253, 0.75); background: rgba(56, 189, 248, 0.18); color: #e0f2fe; }
.joyo-ins-r-badge.learned { border-color: rgba(52, 211, 153, 0.6); background: rgba(16, 185, 129, 0.16); color: #a7f3d0; }
.thor-collection-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(125, 211, 252, 0.45);
  background: rgba(14, 38, 66, 0.86);
  color: #e0f2fe;
  font-size: 0.84rem;
  font-weight: 700;
}

/* Dedicated Vocabulary Collection & iPhone/Smartphone Touch Polish (v1.36) */
.vocab-col-summary {
  margin-left: auto;
  font-size: 0.74rem;
  font-weight: 700;
  color: #93c5fd;
  white-space: nowrap;
}
.vocab-col-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
  min-height: 0;
}
.vocab-col-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.vocab-col-group-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(12, 34, 58, 0.94);
  border: 1px solid rgba(125, 211, 252, 0.24);
  color: #ffe3b1;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.vocab-col-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid rgba(165, 220, 245, 0.16);
  background: rgba(12, 30, 52, 0.78);
}
.vocab-col-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.vocab-col-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}
.vocab-col-word {
  font-size: 1.06rem;
  font-weight: 800;
  color: #f8fafc;
}
.vocab-col-kana {
  font-size: 0.82rem;
  font-weight: 700;
  color: #7dd3fc;
}
.vocab-col-meaning {
  font-size: 0.76rem;
  color: #cbd5e1;
  line-height: 1.32;
  overflow-wrap: anywhere;
}
.vocab-col-empty {
  padding: 24px 14px;
  text-align: center;
  color: #93c5fd;
  font-size: 0.86rem;
  line-height: 1.5;
}
.complete-plaque-wrap {
  width: 100%;
  margin-bottom: 6px;
}
@media (max-width: 480px) {
  .joyo-col-top { flex-wrap: wrap; gap: 8px; }
  .vocab-col-summary { margin-left: 0; flex-basis: 100%; }
  .joyo-collection-modal-wrap, .joyo-collection-shell { width: 96vw; padding: 12px; }
}

/* Text fields stay selectable and editable despite the global user-select: none. */
input, textarea { user-select: text; -webkit-user-select: text; }
#custom-password {
  width: 100%;
  background: rgba(9, 11, 16, 0.85);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 16px;
  font-family: inherit;
}



/* Keep the collection toolbar below the system status bar while grades scroll. */
#joyo-collection-modal {
  padding: max(12px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  align-items: stretch;
}
#joyo-collection-host {
  width: min(100%, 760px);
  max-height: 100%;
  min-height: 0;
  padding: 0;
}
#joyo-collection-host .joyo-collection-shell {
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
}
#joyo-collection-host .joyo-col-top { flex-shrink: 0; }
#joyo-collection-host .joyo-col-close { min-height: 44px; }

/* Standalone PWAs keep inset: 0 edges pinned cleanly to the viewport without 100vh bottom overflow. */

/* Eliminate expensive multi-pass backdrop blur stalls during active typing on touch devices */
@media (pointer: coarse) {
  .modal,
  .curriculum-overlay,
  .mastered-confirm-overlay,
  .icon-pill,
  .input-switch,
  .write-grade-bar,
  .flick-grade-bar,
  #web-test-notice-modal.ds-menu-mode .picker-footer {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.save-backup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.save-backup-btn {
  flex: 1 1 130px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(125, 211, 252, 0.28);
  background: rgba(15, 23, 42, 0.72);
  color: #e2e8f0;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.save-backup-btn:active {
  transform: scale(0.98);
  border-color: var(--accent);
}

.save-code-primary-btn {
  border-color: rgba(125, 211, 252, 0.5);
  background: linear-gradient(180deg, rgba(14, 116, 144, 0.42), rgba(15, 23, 42, 0.84));
  color: #f0f9ff;
}

.save-code-overlay {
  overflow-y: auto;
  align-items: center;
}

.save-code-sheet {
  max-width: 440px;
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
}

.save-code-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 128px;
  max-height: 36vh;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(125, 211, 252, 0.34);
  background: rgba(4, 12, 24, 0.86);
  color: #e0f2fe;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px; /* >=16px prevents iOS Safari auto-zoom on focus */
  line-height: 1.4;
  word-break: break-all;
  resize: vertical;
  -webkit-user-select: text;
  user-select: text;
}

.save-code-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.save-code-feedback {
  margin: -6px 0 0;
  min-height: 1.1em;
  font-size: 0.76rem;
  color: #bae6fd;
}

.save-code-feedback.is-error {
  color: #fda4af;
}

.save-backup-status {
  margin-top: 6px;
  min-height: 1.1em;
  font-size: 0.74rem;
  color: #bae6fd;
}

.save-backup-status.is-error {
  color: #fda4af;
}

.boot-error-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 10, 20, 0.86);
}

.boot-error-card {
  margin: auto;
  width: min(360px, 92vw);
  padding: 20px 18px;
  border-radius: 16px;
  border: 1px solid rgba(251, 113, 133, 0.45);
  background: rgba(7, 19, 34, 0.96);
  color: #f8fafc;
  text-align: center;
  box-shadow: 0 18px 42px rgba(2, 8, 18, 0.7);
}

.boot-error-title {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
}

.boot-error-msg {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.45;
}

.boot-error-retry {
  min-width: 128px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.6);
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.9), rgba(3, 105, 161, 0.9));
  color: #f8fafc;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#app[data-input-align="left"] .flick-keyboard,
#app[data-input-align="left"] .write-wrap { align-items: flex-start; }
#app[data-input-align="center"] .flick-keyboard,
#app[data-input-align="center"] .write-wrap { align-items: center; }
#app[data-input-align="right"] .flick-keyboard,
#app[data-input-align="right"] .write-wrap { align-items: flex-end; }

.input-align-bar {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 999px;
  background: rgba(11, 27, 46, 0.56);
  border: 1px solid rgba(165, 220, 245, 0.16);
}
.input-align-bar .wa-btn {
  width: 28px;
  height: 20px;
}
#app:has(.write-wrap.in-word-review) .input-align-bar {
  visibility: hidden;
  pointer-events: none;
}

@media (max-height: 620px) {
  #app {
    gap: 6px;
    padding-block-end: max(8px, env(safe-area-inset-bottom));
  }
  .stage-wrap {
    min-height: 0;
    padding: 2px 8px;
    overflow-y: auto;
    scrollbar-width: none;
  }
  .stage-wrap::-webkit-scrollbar { display: none; }
  .word-stage { gap: 4px; }
  .wc-meta { min-height: 0; }
  .study-card-type { margin-bottom: 0; }
  .skip-current-card { margin-top: 2px; min-height: 36px; padding: 5px 12px; }
}

/* Rainbow Platinum Run */
.rp-hud-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid rgba(165, 220, 245, 0.22);
  background: linear-gradient(180deg, rgba(16, 40, 68, 0.72), rgba(9, 23, 42, 0.84));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(216, 243, 255, 0.16);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.rp-hud-pill.hidden {
  display: none;
}
.rp-hud-pill.last-try {
  background: linear-gradient(180deg, rgba(136, 19, 55, 0.44), rgba(76, 5, 25, 0.62));
  border-color: rgba(251, 113, 133, 0.56);
  color: #ffe4e6;
}
#word-card.challenge-fail {
  animation: rpFailShake 260ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes rpFailShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-4px); }
  88% { transform: translateX(2px); }
}
body.reduced-fx #word-card.challenge-fail { animation: none; }
@media (prefers-reduced-motion: reduce) { #word-card.challenge-fail { animation: none; } }

.rp-setup-panel,
.rp-results-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 2px 0 8px;
}
.rp-card {
  background: rgba(10, 28, 48, 0.72);
  border: 1px solid rgba(165, 220, 245, 0.18);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rp-resume-card {
  border-color: rgba(56, 189, 248, 0.45);
  background: linear-gradient(180deg, rgba(16, 52, 84, 0.82), rgba(10, 30, 50, 0.88));
}
.rp-resume-text {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #e0f2fe;
}
.rp-btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.rp-elig-bar {
  font-size: 0.86rem;
  font-weight: 700;
  color: #cfe7fa;
  background: rgba(14, 38, 64, 0.76);
  border: 1px solid rgba(125, 211, 252, 0.25);
  border-radius: 12px;
  padding: 9px 12px;
  text-align: center;
}
.rp-length-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.rp-len-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 60px;
  padding: 8px 6px;
  border-radius: 13px;
  border: 1px solid rgba(165, 220, 245, 0.22);
  background: rgba(11, 30, 52, 0.84);
  color: #cbd5e1;
  font: inherit;
  cursor: pointer;
}
.rp-len-btn strong { font-size: 1.25rem; line-height: 1.1; color: #f8fafc; }
.rp-len-btn span { font-size: 0.74rem; font-weight: 700; opacity: 0.9; }
.rp-len-btn.active {
  border-color: rgba(125, 211, 252, 0.92);
  background: linear-gradient(155deg, rgba(34, 96, 146, 0.92), rgba(76, 54, 128, 0.82));
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(186, 230, 253, 0.35), 0 6px 18px rgba(14, 116, 144, 0.32);
}
.rp-len-btn:disabled { opacity: 0.42; cursor: default; }
.rp-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2eef9;
}
.rp-chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.rp-sub-lbl {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-right: 2px;
}
.rp-shortage-msg {
  margin: 0;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid rgba(251, 191, 36, 0.42);
  background: rgba(120, 53, 15, 0.24);
  color: #fde68a;
  font-size: 0.8rem;
  line-height: 1.4;
}
.rp-start-btn {
  width: 100%;
  font-weight: 800;
  border-color: rgba(125, 211, 252, 0.72);
  background: linear-gradient(135deg, rgba(30, 96, 145, 0.94), rgba(88, 60, 148, 0.90));
  color: #ffffff;
}
.rp-start-btn:disabled { opacity: 0.45; }
.rp-card-title {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #ffe3b1;
}
.rp-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.rp-stat-cell {
  background: rgba(7, 20, 36, 0.65);
  border: 1px solid rgba(165, 220, 245, 0.14);
  border-radius: 10px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rp-stat-cell small { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.rp-stat-cell strong { font-size: 0.98rem; color: #f8fafc; font-weight: 800; }
.rp-unlock-prog { font-weight: 800; color: #bae6fd; margin: 2px 0 6px; font-size: 0.95rem; }
.rp-outcome-badge {
  padding: 10px 14px;
  border-radius: 13px;
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  border: 1px solid rgba(186, 230, 253, 0.35);
}
.rp-outcome-badge.tier-perfect {
  background: linear-gradient(125deg, rgba(56, 189, 248, 0.28), rgba(167, 139, 250, 0.30), rgba(251, 191, 36, 0.28));
  border-color: rgba(253, 224, 71, 0.68);
  color: #fef9c3;
}
.rp-outcome-badge.tier-all-succ {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.26), rgba(99, 102, 241, 0.26));
  border-color: rgba(125, 211, 252, 0.65);
  color: #e0f2fe;
}
.rp-outcome-badge.tier-done {
  background: rgba(15, 39, 64, 0.76);
  color: #e2e8f0;
}
.rp-word-group {
  background: rgba(10, 27, 46, 0.74);
  border: 1px solid rgba(165, 220, 245, 0.16);
  border-radius: 12px;
  padding: 10px;
}
.rp-word-group.is-elim { border-color: rgba(251, 113, 133, 0.42); }
.rp-word-group.is-missed { border-color: rgba(251, 191, 36, 0.38); }
.rp-word-group h4 { margin: 0 0 7px; font-size: 0.82rem; font-weight: 800; color: #e2eef9; }
.rp-word-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rp-word-chip {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(7, 20, 36, 0.72);
  border: 1px solid rgba(165, 220, 245, 0.20);
  color: #f8fafc;
}
.rp-practice-btn { border-color: rgba(251, 191, 36, 0.65); color: #fde68a; }
#web-test-notice-modal.rp-menu-fading {
  opacity: 0;
  pointer-events: none;
  transition: opacity 850ms cubic-bezier(0.22, 1, 0.36, 1);
}
#app.rp-countdown-active #word-card { min-height: 210px; }
#app.rp-countdown-active .wc-meta,
#app.rp-countdown-active .study-badge-row,
#app.rp-countdown-active #word-kanji,
#app.rp-countdown-active #word-kw,
#app.rp-countdown-active #word-en,
#app.rp-countdown-active #mixed-ctx-hint,
#app.rp-countdown-active #kana-display,
#app.rp-countdown-active #alt-readings,
#app.rp-countdown-active #skip-current-card,
#app.rp-countdown-active #input-align-bar {
  visibility: hidden;
}
#app.rp-countdown-active #write-pad {
  pointer-events: none;
  opacity: var(--rp-pad-alpha, 0);
  transition: opacity 2800ms cubic-bezier(0.22, 1, 0.36, 1);
}
#app.rp-countdown-active.rp-pad-revealed #write-pad {
  --rp-pad-alpha: 1;
}
#app.rp-countdown-active #write-pad *,
#app.rp-countdown-active .write-guide-btn {
  pointer-events: none !important;
}
#app.rp-countdown-active .write-guide-btn {
  display: none !important;
}
@media (prefers-reduced-motion: reduce) {
  #web-test-notice-modal.rp-menu-fading,
  #app.rp-countdown-active #write-pad {
    transition-duration: 120ms;
  }
  .rp-countdown-num.pop {
    animation: none !important;
    opacity: 1 !important;
    transform: scale(1) !important;
  }
}
.rp-countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 6;
}
.rp-countdown-num {
  font-size: clamp(3.8rem, 15vw, 5.8rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #bae6fd 0%, #c4b5fd 50%, #fde68a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(125, 211, 252, 0.45));
}
.rp-countdown-num.pop {
  animation: rpCountPop 0.92s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes rpCountPop {
  0% { transform: scale(1.38); opacity: 0.15; }
  22% { transform: scale(1); opacity: 1; }
  85% { transform: scale(0.96); opacity: 0.95; }
  100% { transform: scale(0.86); opacity: 0.4; }
}
.voice-rp-details {
  margin-top: 8px;
}
.voice-rp-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 750;
  color: #bae6fd;
  background: rgba(14, 34, 58, 0.56);
  border: 1px solid rgba(125, 211, 252, 0.22);
}
.voice-rp-summary::-webkit-details-marker { display: none; }
.voice-rp-summary::after { content: '▾'; font-size: 0.85em; opacity: 0.8; }
.voice-rp-details[open] .voice-rp-summary { margin-bottom: 7px; }
.voice-rp-details[open] .voice-rp-summary::after { content: '▴'; }


