/* Compact dictionary rows keep all three columns readable on phones. */
.word-library { margin-top: 16px; }
.library-set-filters > summary { cursor: pointer; padding: 4px 0; font-weight: 600; }
.library-set-filters[open] > summary { margin-bottom: 12px; }
.word-set { padding: 14px; content-visibility: auto; contain-intrinsic-size: auto 90px; }
.word-set summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
.word-set summary small { display: block; font-weight: 400; margin: 6px 0 0 18px; }
.word-columns { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 12px; text-align: left; }
.word-columns > span { min-width: 0; overflow-wrap: anywhere; }
.word-column-head { font-size: .78rem; opacity: .75; padding: 12px; }
.word-row { display: block; width: 100%; padding: 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; border-radius: 8px; }
.word-row:hover, .word-row:focus-visible { background: var(--surface-2); }
.word-row small { display: block; text-align: left; margin-top: 6px; opacity: .75; }
.elo-history-graph { margin: 18px 0; }
.elo-history-graph svg { display: block; width: 100%; height: 170px; }
.elo-graph-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .8rem; }
.elo-graph-line { fill: none; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.elo-graph-grid { stroke: currentColor; opacity: .13; }
.word-set[open] { contain-intrinsic-size: auto 600px; }
@media (max-width: 620px) {
  .word-columns { gap: 8px; font-size: .86rem; }
  .word-row { padding: 10px 4px; }
  .activity-day { grid-template-columns: 40px minmax(60px, 1fr) 62px !important; }
}

:root {
  color-scheme: light;
  --bg: #f4f0e7;
  --surface: #fffdf7;
  --surface-2: #e9eee6;
  --surface-3: #dfe8de;
  --ink: #17211d;
  --muted: #66726c;
  --line: #d6ddd5;
  --primary: #1f6b50;
  --primary-ink: #f3fff8;
  --primary-soft: #d5eddf;
  --secondary: #a5503e;
  --error: #a33c3c;
  --error-soft: #f7d8d3;
  --shadow: 0 12px 38px rgb(31 48 40 / 9%);
  --radius: 24px;
  --rail: 220px;
  --rank-unranked: #6f7c76;
  --rank-beginner: #596b62;
  --rank-bronze: #a85f39;
  --rank-silver: #687f91;
  --rank-gold: #a87300;
  --rank-platinum: #447f8c;
  --rank-diamond: #5369d1;
  --rank-master: #8f4db5;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-jp: "Noto Serif JP", "Yu Mincho", "Hiragino Mincho ProN", serif;
}

.curriculum-set-list {
  display: grid;
  gap: 7px;
  max-height: 360px;
  padding: 0 12px 10px;
  overflow: auto;
}

.curriculum-set-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
}

.curriculum-set-option span {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.curriculum-set-option small,
.curriculum-set-option > b {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.curriculum-set-option.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.curriculum-set-option.active strong,
.curriculum-set-option.active > b {
  color: var(--primary);
}

.library-curriculum-picker {
  display: grid;
  gap: 4px;
}

.library-curriculum-picker > div:first-child {
  display: grid;
  gap: 3px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1713;
  --surface: #15221c;
  --surface-2: #1c2c25;
  --surface-3: #263a31;
  --ink: #edf6f0;
  --muted: #aab9b1;
  --line: #31483d;
  --primary: #83d3a9;
  --primary-ink: #082216;
  --primary-soft: #234636;
  --secondary: #f0aa91;
  --error: #ffb3aa;
  --error-soft: #542e2d;
  --shadow: 0 16px 46px rgb(0 0 0 / 26%);
  --rank-beginner: #a4b2ab;
  --rank-bronze: #e2a17a;
  --rank-silver: #cad7e1;
  --rank-gold: #f0ca73;
  --rank-platinum: #9bd0dc;
  --rank-diamond: #bdc5ff;
  --rank-master: #e2b2ff;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% -10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 34rem),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

button,
select,
input {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent);
  outline-offset: 2px;
}

.boot-card {
  width: min(420px, calc(100% - 40px));
  margin: 18vh auto;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.boot-mark {
  font: 700 68px/1 var(--font-jp);
  color: var(--primary);
}

.boot-card h1 {
  margin: 12px 0 4px;
}

.boot-card p {
  color: var(--muted);
}

.loader {
  height: 5px;
  margin-top: 24px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--surface-2);
}

.loader span {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  animation: loading 1.1s ease-in-out infinite alternate;
}

@keyframes loading {
  to { transform: translateX(125%); }
}

.shell {
  min-height: 100vh;
}

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: var(--rail);
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 26px;
}

.brand-mark {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border-radius: 15px;
  background: var(--primary);
  color: var(--primary-ink);
  font: 700 27px/1 var(--font-jp);
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand small {
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-button.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 750;
}

.nav-glyph {
  width: 27px;
  font: 600 21px/1 var(--font-jp);
  text-align: center;
}

.rail-foot {
  position: absolute;
  inset: auto 20px 22px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.content {
  width: min(1120px, calc(100% - var(--rail)));
  min-height: 100vh;
  margin-left: var(--rail);
  padding: 30px clamp(22px, 5vw, 72px) 72px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 46px);
  letter-spacing: -.045em;
}

h2 {
  letter-spacing: -.025em;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgb(255 255 255 / 3%);
}

.card-pad {
  padding: 22px;
}

.hero {
  grid-column: span 8;
  min-height: 260px;
  padding: clamp(24px, 4vw, 42px);
  overflow: hidden;
  background:
    linear-gradient(125deg, color-mix(in srgb, var(--primary-soft) 94%, var(--surface)), var(--surface));
}

.hero h2 {
  max-width: 620px;
  margin: 8px 0 12px;
  font-size: clamp(29px, 4vw, 46px);
}

.hero p {
  max-width: 600px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.quick-stat {
  grid-column: span 4;
  padding: 26px;
}

.quick-stat strong {
  display: block;
  margin-top: 10px;
  color: var(--primary);
  font-size: 42px;
  letter-spacing: -.05em;
}

.path-card {
  grid-column: span 6;
  display: flex;
  min-height: 150px;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-align: left;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.path-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--primary) 48%, var(--line));
  box-shadow: var(--shadow);
}

.path-glyph {
  display: grid;
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 22px;
  background: var(--primary-soft);
  color: var(--primary);
  font: 650 43px/1 var(--font-jp);
}

.path-card h3 {
  margin: 0 0 6px;
  font-size: 21px;
}

.path-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.arrow {
  margin-left: auto;
  color: var(--primary);
  font-size: 28px;
}

.panel {
  padding: clamp(18px, 3vw, 28px);
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.review-schedule {
  display: grid;
  gap: 11px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
}

.review-schedule > div:first-child {
  display: grid;
  gap: 2px;
}

.schedule-buckets {
  display: flex;
  gap: 7px;
  padding-bottom: 3px;
  overflow-x: auto;
}

.schedule-bucket {
  display: grid;
  min-width: 72px;
  gap: 1px;
  justify-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.schedule-bucket.due {
  border-color: color-mix(in srgb, var(--primary) 48%, var(--line));
  background: var(--primary-soft);
  color: var(--primary);
}

.schedule-bucket strong {
  font-size: 18px;
}

.schedule-bucket small {
  white-space: nowrap;
}

.review-schedule [data-review-ahead] {
  justify-self: start;
}

.review-schedule p {
  margin: 0;
  font-size: 13px;
}

.field {
  display: grid;
  align-content: start;
  gap: 8px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 13px;
  font-weight: 760;
}

.segmented,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

.chip:hover {
  border-color: var(--primary);
  color: var(--ink);
}

.chip.active {
  border-color: color-mix(in srgb, var(--primary) 50%, transparent);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 750;
}

select,
input[type="search"],
input[type="number"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-radius: 18px;
  background: var(--primary-soft);
}

.summary strong {
  display: block;
  color: var(--primary);
  font-size: 21px;
}

.button {
  min-height: 46px;
  padding: 10px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: var(--primary-ink);
  font-weight: 780;
}

.button:hover {
  filter: brightness(1.05);
}

.button.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.danger {
  border: 1px solid color-mix(in srgb, var(--error) 35%, var(--line));
  background: transparent;
  color: var(--error);
}

.button:disabled {
  cursor: not-allowed;
  filter: none;
  opacity: .45;
}

.session {
  display: grid;
  min-height: calc(100vh - 62px);
  grid-template-rows: auto 4px minmax(0, 1fr) auto auto;
  gap: 9px;
}

.session-head {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.session-head .eyebrow {
  min-width: 0;
  flex: 1;
  margin: 0;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
}

.review-session-stats {
  display: grid;
  min-width: 78px;
  justify-items: end;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
}

.review-timer {
  max-width: 112px;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  overflow-wrap: anywhere;
  text-align: right;
  white-space: normal;
}

.text-button {
  padding: 7px 8px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 740;
}

.progress {
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width .25s ease;
}

.flashcard {
  display: grid;
  min-height: 360px;
  place-items: center;
  padding: clamp(24px, 5vw, 54px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.study-navigation-hint {
  display: flex;
  min-height: 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.keyboard-hint {
  text-align: right;
}

.jp {
  font-family: var(--font-jp);
}

.furigana-word {
  ruby-position: over;
  ruby-align: center;
}

.furigana-word rt {
  color: var(--primary);
  font-family: var(--font-jp);
  font-size: .3em;
  font-weight: 620;
  line-height: 1;
}

.prompt-jp {
  margin: 8px 0 18px;
  font-size: clamp(48px, 9vw, 92px);
  line-height: 1.1;
}

.prompt-en {
  max-width: 800px;
  margin: 8px auto 22px;
  font-size: clamp(26px, 5vw, 48px);
}

.reading {
  margin: 0 0 18px;
  color: var(--primary);
  font-size: clamp(22px, 4vw, 34px);
}

.meanings {
  max-width: 780px;
  font-size: clamp(18px, 2.5vw, 25px);
  line-height: 1.55;
}

.meta {
  margin-top: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.session-actions {
  display: flex;
  gap: 9px;
}

.session-actions .button {
  flex: 1;
}

.session-actions .neutral-next {
  flex-basis: 100%;
}

.review-session {
  display: grid;
  min-height: calc(100vh - 62px);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 7px;
}

.review-prompt {
  padding: 12px 18px;
  border-radius: 18px;
  background: var(--primary-soft);
  text-align: center;
  overflow: visible;
}

.review-prompt .jp {
  font-size: clamp(42px, 7vw, 66px);
  line-height: 1.12;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.review-prompt.context-prompt .jp { font-size: clamp(26px, 5vw, 42px); line-height: 1.25; }

.review-prompt .english {
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 720;
}

.review-prompt .review-hint {
  margin-top: 3px;
  color: var(--primary);
  font-size: clamp(19px, 3vw, 26px);
}

.review-hint-button {
  margin-top: 4px;
}

.option-grid {
  display: grid;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(54px, auto);
  gap: 7px;
}

.option {
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: clamp(11px, 1.5vw, 14px);
  line-height: 1.25;
  overflow-wrap: anywhere;
  overflow: visible;
  white-space: normal;
}

.option.jp {
  font-size: clamp(17px, 3vw, 27px);
}

.option .furigana-word rt {
  color: currentColor;
  font-size: .34em;
}

.option:hover:not(:disabled) {
  border-color: var(--primary);
}

.option.unknown {
  grid-column: 1 / -1;
}

.option.correct {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.option.wrong {
  border-color: var(--error);
  background: var(--error-soft);
}

.review-bottom {
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--line));
  border-radius: 17px;
  background: var(--primary-soft);
}

.review-bottom.wrong {
  border-color: color-mix(in srgb, var(--error) 45%, var(--line));
  background: var(--error-soft);
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-row strong {
  font-size: 18px;
}

.result-ratings {
  display: grid;
  gap: 1px;
  min-width: 0;
  font-size: 13px;
}

.result-ratings span {
  overflow-wrap: anywhere;
}

.result-detail {
  margin: 5px 0 9px;
  line-height: 1.35;
}

.result-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 6px 0 9px;
}

.result-comparison > div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 11px;
}

.result-comparison strong {
  font-size: 12px;
}

.result-comparison span {
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.result-examples {
  margin: -3px 0 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.library-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.library-tab {
  padding: 12px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 760;
}

.library-tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 11px;
}

.library-item {
  contain: content;
  content-visibility: auto;
  contain-intrinsic-size: auto 170px;
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
}

.library-item .literal {
  margin-bottom: 9px;
  color: var(--primary);
  font: 650 38px/1.15 var(--font-jp);
}

.library-item .literal.word {
  font-size: 27px;
}

.library-item p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.library-item .curriculum-preview {
  margin-top: 8px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.rank {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.setting-card {
  padding: 22px;
}

.setting-card h2 {
  margin-bottom: 7px;
}

.setting-card .button {
  margin-top: 10px;
}

.toast {
  position: fixed;
  z-index: 40;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100% - 44px));
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.empty {
  padding: 36px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.bottom-nav {
  display: none;
}

.set-picker,
.mistake-summary {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
}

.set-picker-head,
.mistake-summary > div:first-child,
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.set-picker-head > div:first-child,
.mistake-summary > div:first-child {
  display: grid;
  gap: 3px;
}

.level-set-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.level-set-row {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.level-set-row summary {
  display: flex;
  justify-content: space-between;
  padding: 11px 13px;
  cursor: pointer;
}

.set-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 5px;
  max-height: 220px;
  padding: 0 12px 10px;
  overflow: auto;
}

.set-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
}

.set-chip.active,
.mode-chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.set-row-actions {
  display: flex;
  gap: 8px;
  padding: 0 12px 10px;
}

.recommended {
  border-color: var(--primary) !important;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 7px;
}

.mode-chip {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: left;
}

.range-field,
.puzzle-scale {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.mistake-summary p {
  margin: 9px 0;
}

.typed-answer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: min(620px, 100%);
  margin: 0 auto 10px;
}

.typed-answer label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.typed-answer input {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 20px;
}

.review-unknown {
  display: block;
  width: min(620px, 100%);
  margin: 8px auto 0;
}

.distractor-source {
  display: block;
  width: min(760px, 100%);
  margin: 7px auto 0;
  color: var(--muted);
  text-align: center;
}

.drawing-answer {
  width: min(520px, 100%);
  margin: 0 auto;
}

#drawing-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  touch-action: none;
}

.drawing-actions,
.puzzle-complete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.feedback-score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.elo-delta,
.combo-delta,
.combo-reduced,
.solution-box,
.drawing-result {
  display: grid;
  gap: 3px;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
  border-radius: 14px;
  background: var(--surface);
}

.elo-delta {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.elo-delta strong {
  font-size: 21px;
}

.elo-delta .elo-total { font-size: clamp(27px, 4vw, 36px); }

.elo-breakdown {
  display: grid;
  gap: 5px;
  margin-top: 7px;
  padding-top: 9px;
  border-top: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  color: var(--ink);
}

.elo-breakdown > span { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.elo-breakdown b { font-size: 13px; }
.elo-breakdown b.positive { color: var(--primary); }
.elo-breakdown b.negative { color: var(--error); }

.elo-delta strong small {
  color: var(--muted);
  font-size: 13px;
}

.elo-delta em {
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.elo-delta.rank-unranked { --rank-color: var(--rank-unranked); }
.elo-delta.rank-beginner { --rank-color: var(--rank-beginner); }
.elo-delta.rank-bronze { --rank-color: var(--rank-bronze); }
.elo-delta.rank-silver { --rank-color: var(--rank-silver); }
.elo-delta.rank-gold { --rank-color: var(--rank-gold); }
.elo-delta.rank-platinum { --rank-color: var(--rank-platinum); }
.elo-delta.rank-diamond { --rank-color: var(--rank-diamond); }
.elo-delta.rank-master { --rank-color: var(--rank-master); }

.rank-badge {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--rank-color) 70%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--rank-color) 13%, var(--surface));
  color: var(--rank-color);
}
.rank-badge > b { display: grid; min-width: 24px; place-items: center; font-size: 21px; line-height: 1; }
.rank-badge > span { display: grid; line-height: 1.15; }
.rank-badge strong { color: var(--rank-color); font-size: 14px; }
.rank-badge small { color: var(--muted); font-size: 11px; }
.rank-transition { color: var(--rank-color); letter-spacing: .035em; }

.elo-delta.positive,
.combo-delta { color: var(--primary); }
.elo-delta.negative,
.combo-reduced { color: var(--error); }

.confusion-penalty {
  display: block;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--error) 35%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--error) 9%, var(--surface));
  color: var(--error);
  line-height: 1.55;
}

.rank-up { border-color: color-mix(in srgb, var(--rank-color) 80%, transparent); animation: rank-up 1.05s cubic-bezier(.2,.9,.25,1.15); }
.rank-down { border-color: color-mix(in srgb, var(--error) 65%, transparent); animation: rank-down .8s ease; }
.rank-up .rank-badge { animation: rank-badge-pop .9s cubic-bezier(.2,.9,.25,1.35); }
.rank-up::after { content: "✦  ✧  ✦"; position: absolute; z-index: 0; top: 7px; right: 10px; color: var(--rank-color); font-size: 19px; pointer-events: none; animation: rank-sparkle 1.05s ease both; }

@keyframes rank-up {
  0% { transform: scale(.84); box-shadow: 0 0 0 0 transparent; filter: brightness(.9); }
  35% { transform: scale(1.035); box-shadow: 0 0 20px 5px color-mix(in srgb, var(--rank-color) 48%, transparent); filter: brightness(1.18); }
  67% { transform: scale(.992); box-shadow: 0 0 10px 2px color-mix(in srgb, var(--rank-color) 25%, transparent); }
  100% { transform: scale(1); box-shadow: 0 0 0 1px color-mix(in srgb, var(--rank-color) 24%, transparent); filter: none; }
}

@keyframes rank-badge-pop {
  0% { transform: scale(.55) rotate(-10deg); opacity: 0; }
  48% { transform: scale(1.14) rotate(3deg); opacity: 1; text-shadow: 0 0 13px var(--rank-color); }
  100% { transform: none; opacity: 1; text-shadow: none; }
}

@keyframes rank-down {
  0% { transform: translateY(-7px); }
  30% { transform: translateY(4px) rotate(-1deg); }
  60% { transform: translateY(-2px) rotate(1deg); }
  100% { transform: none; }
}

.answer-comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin: 9px 0;
}

@keyframes rank-sparkle {
  0% { transform: translateY(8px) scale(.45) rotate(-8deg); opacity: 0; }
  38% { transform: translateY(0) scale(1.18) rotate(3deg); opacity: 1; text-shadow: 0 0 12px var(--rank-color); }
  100% { transform: translateY(-3px) scale(1); opacity: .38; text-shadow: none; }
}

.answer-comparison > div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid currentColor;
  border-radius: 17px;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .rank-up, .rank-down, .rank-up .rank-badge, .rank-up::after { animation-duration: .01ms; }
}

.answer-comparison > div > strong {
  font-size: clamp(44px, 8vw, 74px);
}

.answer-comparison > div > small {
  line-height: 1.5;
}

.solution-box { margin-bottom: 8px; }
.solution-box strong { font-size: 18px; }
.result-details,
.similar-info,
.contained-kanji { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.result-details summary,
.similar-info summary,
.contained-kanji summary { cursor: pointer; font-weight: 800; }
.result-details > div { padding-top: 7px; line-height: 1.55; }

.lookalike-pair,
.contained-kanji > div {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.lookalike-pair > div,
.contained-kanji > div > span {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.lookalike-pair b,
.contained-kanji b { font-size: 31px; }
.similar-inline { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 7px; }
.similar-inline span { padding: 5px 8px; border-radius: 9px; background: var(--surface); }

.library-item {
  color: inherit;
  font: inherit;
  text-align: left;
}

.library-item:hover { border-color: var(--primary); transform: translateY(-1px); }
.mini-rings { display: flex; gap: 5px; margin-top: 9px; }
.mini-ring {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle, var(--surface) 55%, transparent 57%), conic-gradient(var(--primary) var(--ring), var(--line) 0);
  font-size: 10px;
}

.detail-back { margin-bottom: 12px; }
.detail-hero { display: grid; grid-template-columns: 170px 1fr; gap: 20px; padding: 22px; }
.detail-literal { display: grid; place-items: center; color: var(--primary); font-size: 130px; }
.detail-word { display: grid; align-content: center; gap: 8px; color: var(--primary); font-size: clamp(38px, 6vw, 68px); }
.detail-word small { color: var(--muted); font: 16px/1.5 var(--font-ui); }
.elo-ring-grid { display: grid; grid-template-columns: repeat(4, minmax(105px, 1fr)); gap: 10px; }
.elo-ring-grid.three { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
.elo-ring {
  display: grid;
  gap: 6px;
  place-items: center;
  padding: 13px 7px;
  border: 0;
  border-radius: 18px;
  background: var(--surface-2);
}
.elo-ring > span { display: grid; width: 92px; height: 92px; place-items: center; align-content: center; border-radius: 50%; background: radial-gradient(circle, var(--surface) 60%, transparent 62%), conic-gradient(var(--primary) var(--ring), var(--line) 0); }
.elo-ring strong { font-size: 23px; }
.elo-ring small,
.elo-ring em { color: var(--muted); font-size: 11px; font-style: normal; }
.ring-explanation { grid-column: 1 / -1; display: grid; gap: 4px; padding: 12px; border-radius: 13px; background: var(--primary-soft); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.detail-card { padding: 19px; }
.detail-wide { margin-top: 12px; }
.stroke-panel { color: inherit; text-align: left; }
.stroke-diagram { display: block; width: min(240px, 100%); margin: auto; overflow: visible; }
.stroke-diagram path { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.stroke-diagram.playing path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw-stroke .62s ease forwards; animation-delay: calc(var(--stroke-index) * .42s); }
@keyframes draw-stroke { to { stroke-dashoffset: 0; } }
.similar-list,
.word-example-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 7px; }
.similar-list button,
.word-example-grid button { display: grid; gap: 3px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: inherit; text-align: left; }
.similar-list b { font-size: 28px; }
.history-list { display: grid; gap: 6px; margin-top: 12px; }
.history-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px; border-bottom: 1px solid var(--line); font-size: 13px; }
.history-list em { padding: 2px 5px; border-radius: 7px; background: var(--primary-soft); color: var(--primary); font-style: normal; }
.history-list small { display: block; margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.account-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 18px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; }
.account-banner small { color: var(--muted); overflow-wrap: anywhere; }
.account-form { margin: 16px 0; }
.account-form input { width: 100%; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; }
.account-form [role=status] { margin: 0; overflow-wrap: anywhere; }
.setting-card summary { cursor: pointer; margin-top: 12px; }
.source-credits { margin-top: 16px; font-size: 14px; line-height: 1.6; }
.source-credits summary { cursor: pointer; font-weight: 600; }
.source-credits a { color: var(--primary); text-underline-offset: 3px; overflow-wrap: anywhere; }

.puzzle-layout { display: grid; gap: 12px; width: min(840px, 100%); margin: 18px auto 0; }
.puzzle-prompt { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px 18px; text-align: left; }
.puzzle-prompt h2 { margin: 3px 0; }
.puzzle-target-kanji { color: var(--primary); font-size: clamp(58px, 10vw, 84px); line-height: 1; }
.puzzle-board { width: min(430px, 90vw); aspect-ratio: 1; margin: auto; border: 3px dashed var(--line); border-radius: 24px; background: var(--surface); }
.puzzle-board.placement { width: min(340px, 78vw); }
.puzzle-board.complete { border-color: var(--primary); box-shadow: 0 0 0 8px var(--primary-soft); }
.puzzle-board svg { width: 100%; height: 100%; }
.puzzle-grid-line { fill: none; stroke: var(--line); stroke-width: .7; stroke-dasharray: 3 3; }
.puzzle-guide { fill: var(--ink); font-size: 72px; opacity: .075; }
.placed-stroke { fill: none; stroke: var(--ink); stroke-width: 3.3; stroke-linecap: round; stroke-linejoin: round; }
.puzzle-tray { padding: 14px; border-radius: 18px; background: var(--surface-2); }
.stroke-pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 7px; }
.stroke-pieces.supplied { grid-template-columns: 92px; justify-content: center; overflow: visible; }
.stroke-piece { aspect-ratio: 1; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stroke-piece svg { width: 100%; height: 100%; }
.stroke-piece svg { transform: scale(var(--piece-scale, 1)); transition: transform .16s ease; }
.stroke-piece path { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.puzzle-complete { flex-direction: column; }
.puzzle-complete strong { color: var(--primary); font-size: 76px; }
.puzzle-message { padding: 10px; border-radius: 12px; background: var(--surface-2); text-align: center; }

.home-due-summary {
  display: grid;
  width: min(620px, 100%);
  gap: 4px;
  margin: 14px 0;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--line));
  border-radius: 15px;
  background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface));
}
.home-due-summary strong { color: var(--primary); font-size: 18px; }
.home-due-summary span { font-weight: 750; }
.home-due-summary small { color: var(--muted); line-height: 1.4; }

.library-search-fixed {
  position: sticky;
  top: 8px;
  z-index: 5;
  margin-bottom: 12px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.library-filter-scroll {
  padding: 3px 4px 8px 0;
  overflow: visible;
}
.library-filter-scroll.empty { display: none; }

.drawing-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.drawing-comparison figure { display: grid; gap: 5px; margin: 0; text-align: center; }
.drawing-comparison figcaption { color: var(--muted); font-size: 12px; font-weight: 800; }
.drawing-replay { padding: 2px 4px; font-size: inherit; }
.drawing-comparison .stroke-diagram { width: min(300px, 100%); }
.user-drawing-diagram { border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.stroke-diagram .drawing-grid { stroke: var(--line); stroke-width: .7; stroke-dasharray: 3 3; }
.stroke-diagram .user-stroke {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stroke-diagram .user-stroke.good { stroke: #2e7d32; }
.stroke-diagram .user-stroke.close { stroke: #f9a825; }
.stroke-diagram .user-stroke.incorrect,
.stroke-diagram .user-stroke.extra { stroke: #c62828; }
.stroke-score-list { display: grid; gap: 5px; margin-top: 8px; }
.stroke-score { display: flex; justify-content: space-between; gap: 10px; padding: 7px 9px; border-radius: 10px; }
.stroke-score.good { background: rgb(46 125 50 / 12%); color: #2e7d32; }
.stroke-score.close { background: rgb(249 168 37 / 14%); color: #9a6500; }
.stroke-score.incorrect,
.stroke-score.missing,
.stroke-score.extra { background: rgb(198 40 40 / 11%); color: #c62828; }

@media (max-width: 840px) {
  :root {
    --rail: 0px;
  }

  .rail {
    display: none;
  }

  .content {
    width: 100%;
    margin: 0;
    padding: 18px 16px 94px;
  }

  .hero,
  .quick-stat,
  .path-card {
    grid-column: 1 / -1;
  }

  .hero {
    min-height: 0;
  }

  .bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px max(7px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: var(--surface);
  }

  .bottom-nav .nav-button {
    display: grid;
    min-width: 0;
    gap: 3px;
    justify-items: center;
    padding: 7px 2px;
    font-size: 10px;
    text-align: center;
  }

  .bottom-nav .nav-glyph {
    font-size: 20px;
  }

  .session,
  .review-session {
    min-height: calc(100vh - 118px);
  }
}

@media (max-width: 620px) {
  .controls,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .field.wide {
    grid-column: auto;
  }

  .page-head {
    align-items: start;
  }

  .summary {
    align-items: stretch;
    flex-direction: column;
  }

  .review-schedule [data-review-ahead] {
    width: 100%;
  }

  .flashcard {
    min-height: 330px;
    padding: 23px;
  }

  .keyboard-hint {
    display: none;
  }

  .option-grid {
    gap: 5px;
  }

  .option {
    padding: 6px 8px;
    font-size: 12px;
  }

  .session-actions {
    flex-wrap: wrap;
  }

  .set-picker-head,
  .history-head { align-items: stretch; flex-direction: column; }

  .detail-hero { grid-template-columns: 1fr; }
  .detail-literal { font-size: 90px; }
  .elo-ring-grid,
  .elo-ring-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .history-list > div { flex-direction: column; gap: 4px; }
  .typed-answer { grid-template-columns: 1fr; }
  .drawing-comparison { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
.elo-combo {
  display: block;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  color: var(--primary);
  font-size: 13px;
  font-weight: 850;
}

.review-activity-card {
  grid-column: 1 / -1;
  padding: 22px;
}

.review-activity-card h2 {
  margin: 5px 0;
}

.activity-chart {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.activity-day {
  display: grid;
  grid-template-columns: 40px minmax(100px, 1fr) 30px minmax(100px, auto);
  align-items: center;
  gap: 9px;
}

.activity-label {
  font-weight: 750;
}

.activity-bar {
  display: flex;
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.activity-bar i,
.activity-legend i {
  display: block;
  height: 100%;
}

.activity-bar i.kanji,
.activity-legend i.kanji {
  background: var(--primary);
}

.activity-bar i.words,
.activity-legend i.words {
  background: var(--secondary);
}

.activity-day small {
  color: var(--muted);
  text-align: right;
}

.activity-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.activity-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.activity-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.similar-study-prompt {
  padding: 22px;
  text-align: center;
}

@media (max-width: 620px) {
  .activity-day {
    grid-template-columns: 34px minmax(70px, 1fr) 24px;
  }

  .activity-day small {
    grid-column: 2 / -1;
  }
}
