:root {
  --bg: #f6f7f3;
  --side: rgba(253, 253, 249, .78);
  --card: rgba(255, 255, 255, .76);
  --soft: rgba(251, 250, 245, .74);
  --ink: #20231f;
  --muted: #687066;
  --line: rgba(220, 223, 214, .78);
  --green: #2f7657;
  --green-soft: rgba(228, 242, 235, .8);
  --blue: #2d5b86;
  --red: #b93a3a;
  --amber: #b66d12;
  --amber-soft: #fff1d8;
  --combo-color: var(--green);
  --combo-gradient: linear-gradient(135deg, #2f7657, #8bd8b2);
  --combo-aura: rgba(47, 118, 87, .16);
  --combo-aura-strong: rgba(47, 118, 87, .28);
  --shadow: 0 14px 34px rgba(34, 61, 102, 0.08);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-theme="dark"] {
  --bg: #07100c;
  --side: rgba(15, 23, 18, .76);
  --card: rgba(17, 26, 21, .72);
  --soft: rgba(13, 22, 17, .72);
  --ink: #eef6f0;
  --muted: #9aa89e;
  --line: rgba(38, 56, 46, .82);
  --green: #69d39a;
  --green-soft: rgba(32, 55, 43, .74);
  --blue: #8abaff;
  --red: #e07171;
  --amber: #fbbf24;
  --amber-soft: #332714;
  --combo-color: var(--green);
  --combo-gradient: linear-gradient(135deg, #2fd67b, #8ef7c7);
  --combo-aura: rgba(105, 211, 154, .14);
  --combo-aura-strong: rgba(105, 211, 154, .26);
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 28% 18%, var(--combo-aura), transparent 28%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--combo-color) 9%, transparent), transparent 32%),
    var(--bg);
}
body.combo-active::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 10%, var(--combo-aura-strong), transparent 34%),
    radial-gradient(circle at 0% 50%, var(--combo-aura), transparent 36%),
    radial-gradient(circle at 100% 62%, var(--combo-aura), transparent 38%);
  animation: ambientBreath 2.8s ease-in-out infinite alternate;
  content: "";
}
@keyframes ambientBreath {
  from { opacity: .45; filter: blur(0); }
  to { opacity: 1; filter: blur(3px); }
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 246px 1fr;
  min-height: 100vh;
  transition: grid-template-columns .2s ease;
}

body.side-collapsed .app { grid-template-columns: 74px 1fr; }

.side {
  position: relative;
  padding: 26px 18px;
  border-right: 1px solid var(--line);
  background: var(--side);
}

.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 30px; }
.brand span { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
.logoMark {
  position: relative;
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--green) 34%, var(--line));
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--green) 24%, transparent), transparent 62%),
    color-mix(in srgb, var(--card) 82%, var(--green-soft));
  box-shadow: 0 10px 26px var(--combo-aura);
}
.logoMark img {
  position: relative;
  z-index: 2;
  display: none;
  width: 88%;
  height: 88%;
  object-fit: contain;
}
.logoMark img[src=""],
.logoMark img:not([src]),
.logoMark img[hidden] {
  display: none;
}
.logoMark span {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  margin: 0;
  color: #fff;
  background: var(--green);
  font-size: 22px;
  font-weight: 850;
}
.logoMark img + span {
  opacity: 1;
}
body.side-collapsed .logoMark {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
}
.sideToggle {
  position: absolute;
  top: 28px;
  right: -13px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--card);
  z-index: 3;
}

body.side-collapsed .brand strong,
body.side-collapsed .brand span,
body.side-collapsed .nav {
  font-size: 0;
}

body.side-collapsed .brand { justify-content: center; }
body.side-collapsed .side { padding: 26px 12px; }
body.side-collapsed .sideToggle { transform: rotate(180deg); }

.nav {
  display: block;
  width: 100%;
  min-height: 42px;
  margin-bottom: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 700;
}
.nav.active, .nav:hover { color: var(--ink); border-color: var(--line); background: var(--card); }
body.side-collapsed .nav::first-letter { font-size: 17px; }

.main { padding: 28px 30px; min-width: 0; }
.head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
h1 { margin: 0; font-size: 29px; letter-spacing: 0; }
h2 { margin: 4px 0 0; font-size: 22px; }
p { color: var(--muted); }
.head p { margin-bottom: 0; }
.headTools { display: flex; align-items: flex-start; gap: 10px; }
.themeToggle {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--card);
  backdrop-filter: blur(16px);
  font-weight: 760;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 66px);
  gap: 6px;
}
.stat {
  min-height: 54px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}
.stat strong { display: block; font-size: 18px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 11px; }

.view, .treeMode { display: none; }
.view.active, .treeMode.active { display: block; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.toolActions { display: flex; align-items: center; gap: 10px; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.seg button { min-height: 34px; padding: 0 14px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-weight: 760; }
.seg button.on { color: var(--ink); background: var(--green-soft); }
.modeTitle {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: var(--green-soft);
  box-shadow: 0 0 22px var(--combo-aura);
  font-weight: 850;
}
.learningToolbar {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--green) 8%, transparent), transparent 42%),
    color-mix(in srgb, var(--card) 90%, transparent);
  box-shadow: var(--shadow), 0 0 22px var(--combo-aura);
  backdrop-filter: blur(18px);
}
.toolbarLead {
  display: flex;
  align-items: end;
  min-width: 170px;
}
.learningToolbar .seg,
.learningToolbar .modeTitle {
  width: 100%;
  min-height: 40px;
}
.learningToolbar .seg {
  align-items: center;
  background: var(--soft);
}
.learningToolbar .seg button {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}
.learningToolbar .modeTitle {
  justify-content: center;
  padding: 0 16px;
  font-size: 16px;
  white-space: nowrap;
}
.controlGroup {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(160px, .8fr) minmax(132px, .62fr) minmax(120px, .55fr);
  gap: 10px;
  align-items: end;
  min-width: 0;
}
.controlGroup.cardControls {
  grid-template-columns: minmax(220px, 1.25fr) minmax(170px, .85fr) minmax(126px, .6fr);
}
.fieldShell {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0;
}
.fieldShell span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fieldShell select,
.fieldShell input {
  width: 100% !important;
  min-height: 38px;
  padding: 0 12px;
  background: var(--soft);
  font-size: 14px;
  font-weight: 800;
}
.fieldShell.wide { min-width: 210px; }
.fieldShell.small { min-width: 120px; }
.actionGroup {
  display: flex;
  grid-column: 1 / -1;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 2px;
}
.compactAction {
  min-height: 38px;
  padding: 0 14px;
  font-size: 15px;
  white-space: nowrap;
}
.actionGroup .primary {
  padding: 0 18px;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--green) 20%, transparent);
}
.dangerAction {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 45%, var(--line));
}

.grid { display: grid; grid-template-columns: minmax(0, 1.16fr) minmax(300px, .84fr); gap: 14px; }
.treegrid { grid-template-columns: 340px minmax(0, 1fr); }
.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow), 0 0 24px var(--combo-aura);
  backdrop-filter: blur(18px);
}
.kicker { margin-bottom: 12px; color: var(--green); font-size: 12px; font-weight: 850; text-transform: uppercase; }

.card {
  position: relative;
  overflow: hidden;
  display: grid;
  width: 100%;
  min-height: 300px;
  padding: 24px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: center;
}
.quizbox.reward-success {
  animation: cardPop .42s cubic-bezier(.2, 1.5, .3, 1);
  border-color: color-mix(in srgb, var(--green) 62%, var(--line));
}
.quizbox.reward-success::after {
  position: absolute;
  inset: 0;
  transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 22%, color-mix(in srgb, var(--green) 15%, transparent), transparent 64%);
  content: "";
  pointer-events: none;
  animation: rewardSweep .72s ease-out;
}
.quizbox.reward-strong {
  animation: strongPulse .64s cubic-bezier(.2, 1.5, .3, 1);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--combo-color) 56%, transparent), 0 22px 70px var(--combo-aura-strong);
}
.quizbox.reward-wrong { animation: shake .28s ease; }
@keyframes rewardSweep { to { transform: translateX(120%); } }
@keyframes cardPop {
  0% { transform: scale(.994); }
  55% { transform: scale(1.01); }
  100% { transform: scale(1); }
}
@keyframes strongPulse {
  0% { transform: scale(.992); }
  42% { transform: scale(1.018); }
  100% { transform: scale(1); }
}
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.big { display: block; overflow-wrap: anywhere; font-size: 46px; line-height: 1.15; font-weight: 850; letter-spacing: 0; }
.meaningBlocks {
  display: grid;
  gap: 10px;
  margin: 8px 0 4px;
  text-align: left;
}
.meaningBlock {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--soft) 86%, transparent);
}
.meaningBlock span {
  min-width: 34px;
  color: var(--blue);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.35;
}
.meaningBlock div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.meaningBlock b {
  padding: 2px 0;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.28;
  font-weight: 850;
}
.meaningBlock b + b::before {
  color: var(--muted);
  content: "；";
  margin-right: 8px;
}
.cardMeaningPrompt {
  max-width: 760px;
  margin-inline: auto;
}
.cardMeaningPrompt .meaningBlock b,
.quizMeaningPrompt .meaningBlock b {
  font-size: clamp(22px, 3vw, 34px);
}
.quizMeaningPrompt {
  width: 100%;
  align-content: start;
}
.quizMeaningPrompt .meaningBlock {
  grid-template-columns: 48px minmax(0, 1fr);
  min-height: 76px;
  padding: 12px 16px;
  border-color: color-mix(in srgb, var(--green) 38%, var(--line));
  background: color-mix(in srgb, var(--card) 72%, var(--bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 4%, transparent);
}
.quizMeaningPrompt .meaningBlock span {
  overflow-wrap: anywhere;
  font-size: 18px;
}
.quizMeaningPrompt .meaningBlock b {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(28px, 2.1vw, 38px);
}
.posBadge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-bottom: 12px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue);
  background: var(--soft);
  font-size: 22px;
  font-weight: 850;
}
.hint { display: block; margin-top: 14px; color: var(--muted); }
.answer { min-height: 348px; line-height: 1.8; background: var(--soft); }
.word { display: block; margin-bottom: 10px; font-size: 30px; font-weight: 850; }
.meaningList { display: grid; gap: 6px; margin-top: 10px; }
.meaningLine span {
  color: var(--blue);
  font-weight: 900;
  margin-right: 6px;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.primary, .ok, .bad, .plain {
  min-height: 38px;
  padding: 0 15px;
  border-radius: 8px;
  font-weight: 760;
}
.primary, .ok { border: 1px solid var(--green); color: #fff; background: var(--combo-gradient); box-shadow: 0 10px 28px var(--combo-aura); }
.bad { border: 1px solid var(--red); color: #fff; background: var(--red); }
.plain { border: 1px solid var(--line); color: var(--ink); background: var(--card); }
button:disabled { cursor: not-allowed; opacity: .48; }
.hide { display: none !important; }

.quizGrid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .72fr);
  gap: 18px;
  align-items: stretch;
}
.quizbox {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: clamp(680px, calc(100vh - 290px), 860px);
  max-width: none;
  border-color: color-mix(in srgb, var(--green) 34%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--green) 7%, transparent), transparent 28%),
    color-mix(in srgb, var(--card) 78%, var(--bg));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--green) 18%, transparent),
    var(--shadow),
    0 0 34px var(--combo-aura);
}
.timer { display: flex; justify-content: space-between; align-items: center; }
.timer span { color: var(--green); font-size: 12px; font-weight: 850; text-transform: uppercase; }
.timer strong { color: var(--green); font-size: 26px; }
.bar { height: 7px; margin: 12px 0 20px; overflow: hidden; border-radius: 99px; background: color-mix(in srgb, var(--line) 78%, transparent); }
.bar i { display: block; width: 100%; height: 100%; border-radius: 99px; background: var(--green); transition: width .25s ease; }
.prompt {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 320px;
  max-height: 560px;
  margin-bottom: 18px;
  padding: 28px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--green) 42%, var(--line));
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 22%, transparent), transparent),
    color-mix(in srgb, var(--bg) 38%, var(--soft));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--ink) 8%, transparent),
    0 18px 46px rgba(0, 0, 0, .16);
}
.prompt strong { display: block; font-size: 34px; overflow-wrap: anywhere; }
.prompt .quizPos { display: inline-block; margin-bottom: 8px; color: var(--blue); font-size: 22px; font-weight: 850; }
.quizMeaningHead {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-bottom: 12px;
}
.quizMeaningScroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 286px;
  overflow-y: auto;
  padding-right: 4px;
}
.quizMeaningScroll::-webkit-scrollbar {
  width: 8px;
}
.quizMeaningScroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 42%, var(--line));
}
.quizHintLine {
  flex: 0 0 auto;
  margin: 18px 0 0;
}
.firstHint {
  display: inline-grid;
  min-width: 40px;
  height: 40px;
  margin-left: 8px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green);
  background: var(--card);
  font-size: 22px;
  font-weight: 900;
  text-transform: lowercase;
}
.letterSlots { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.letterSlot {
  display: grid;
  width: 32px;
  height: 42px;
  place-items: center;
  border-bottom: 3px solid var(--muted);
  font-size: 24px;
  font-weight: 850;
  text-transform: lowercase;
}
label { display: block; margin: 14px 0 8px; color: var(--muted); font-size: 13px; font-weight: 760; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--card); outline: none; }
input, select { min-height: 42px; padding: 0 12px; }
#quizInput {
  min-height: 72px;
  font-size: 28px;
  font-weight: 850;
  letter-spacing: 0;
}
.quizFormActions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.inlineChallengeActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}
#wordbookSelect, #quizWordbookSelect, #challengeSize, #customChallengeSize, #cardPickMode, #quizPickMode, #cardPickCount { width: 160px; }
#recordSearch { width: 260px; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.feedback { margin-top: 14px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); line-height: 1.7; }
.feedback.okay { border-color: color-mix(in srgb, var(--green) 36%, transparent); background: var(--green-soft); }
.feedback.warn { border-color: color-mix(in srgb, var(--amber) 36%, transparent); background: var(--amber-soft); }
.feedback.fail { border-color: color-mix(in srgb, var(--red) 36%, transparent); background: color-mix(in srgb, var(--red) 14%, var(--card)); }

#quizForm {
  margin-top: auto;
}
.recordPanel {
  display: flex;
  flex-direction: column;
  height: clamp(680px, calc(100vh - 290px), 860px);
  overflow: hidden;
}
.recordHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
#sessionLabel {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.recordStats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.comboPill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin: -2px 0 14px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--combo-color) 48%, transparent);
  border-radius: 999px;
  color: var(--ink);
  background: color-mix(in srgb, var(--card) 82%, transparent);
  box-shadow: 0 0 24px var(--combo-aura);
  font-weight: 900;
  backdrop-filter: blur(16px);
}
.streakMeter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: -4px 0 14px;
}
.streakBox {
  position: relative;
  overflow: hidden;
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--green) 8%, var(--soft)), var(--soft));
}
.streakBox strong {
  display: block;
  font-size: 26px;
  line-height: 1;
}
.streakBox span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}
.streakBox.bump strong { animation: streakBump .44s cubic-bezier(.2, 1.5, .3, 1); }
@keyframes streakBump { 50% { transform: scale(1.16); color: var(--green); } }
.recordStat {
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.recordStat strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}
.recordStat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}
.chartWrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
#progressChart {
  display: block;
  width: 100%;
  height: 190px;
}
.chartLabel { fill: var(--muted); font-size: 11px; font-weight: 700; }
.barBg { fill: color-mix(in srgb, var(--line) 68%, transparent); }
.barCorrect { fill: var(--green); }
.barWrong { fill: var(--red); }
.barRemain { fill: var(--blue); }
.barInput { fill: var(--amber); }
.barValue { fill: var(--ink); font-size: 13px; font-weight: 850; }
.recordLegend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 12px;
}
.legendDot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 999px;
}
.recordTableWrap {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.recordTableWrap::-webkit-scrollbar,
.wordMemoryList::-webkit-scrollbar {
  width: 8px;
}
.recordTableWrap::-webkit-scrollbar-thumb,
.wordMemoryList::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 42%, var(--line));
}
.recordTableWrap::-webkit-scrollbar-track,
.wordMemoryList::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--bg) 45%, transparent);
}
.recordPanel .recordTableWrap {
  flex: 0 0 clamp(170px, 22vh, 260px);
  min-height: 0;
  max-height: clamp(170px, 22vh, 260px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.recordTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.recordTable th,
.recordTable td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.recordTable th {
  position: sticky;
  top: 0;
  color: var(--muted);
  background: var(--card);
  font-size: 12px;
}
.recordTable tbody tr { cursor: pointer; }
.recordTable tbody tr:hover { background: var(--green-soft); }
.reportTableWrap { max-height: 520px; }
.reportMeta p { margin: 8px 0 0; }
.resultOk { color: var(--green); font-weight: 850; }
.resultBad { color: var(--red); font-weight: 850; }
.memoryLookupPanel { margin-bottom: 14px; }
.memoryFilters {
  display: grid;
  grid-template-columns: minmax(180px, .9fr) minmax(130px, .45fr) minmax(220px, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.wordMemoryList {
  display: grid;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.memoryWordRow {
  display: grid;
  grid-template-columns: 28px minmax(110px, .35fr) 76px minmax(180px, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.memoryWordRow:last-child { border-bottom: 0; }
.memoryState {
  justify-self: start;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.memoryState.learned, .memoryState.due { color: var(--green); border-color: color-mix(in srgb, var(--green) 44%, var(--line)); }
.memoryState.weak { color: var(--red); border-color: color-mix(in srgb, var(--red) 44%, var(--line)); }
.emptyState { padding: 18px; color: var(--muted); }

.selectionPanel {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.selectionHead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.selectionSummary {
  margin: 10px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}
.wordPickList {
  display: grid;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.pickRow {
  display: grid;
  grid-template-columns: 24px 30px minmax(90px, .42fr) minmax(140px, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 42px;
  margin: 0;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
}
.pickRow:last-child { border-bottom: 0; }
.pickRow input { width: 18px; min-height: 18px; padding: 0; }
.pickWord { font-weight: 850; overflow-wrap: anywhere; }
.pickMeaning { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memoryMark {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--card);
  font-size: 14px;
  font-weight: 950;
}
.memoryMark.good { color: var(--green); border-color: color-mix(in srgb, var(--green) 42%, var(--line)); }
.memoryMark.badmark { color: var(--red); border-color: color-mix(in srgb, var(--red) 42%, var(--line)); }

.rewardToast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 30;
  min-width: 250px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 20px 26px;
  border: 1px solid color-mix(in srgb, var(--green) 36%, transparent);
  border-radius: 18px;
  color: var(--ink);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -44%) scale(.9);
  backdrop-filter: blur(14px);
}
.rewardToast.show-low { animation: rewardToast .86s cubic-bezier(.2, 1.3, .3, 1) forwards; }
.rewardToast.show-mid { animation: rewardToast 1.05s cubic-bezier(.2, 1.35, .3, 1) forwards; border-color: color-mix(in srgb, var(--blue) 46%, transparent); }
.rewardToast.show-high {
  animation: rewardToastHigh 1.28s cubic-bezier(.2, 1.45, .3, 1) forwards;
  border-color: color-mix(in srgb, var(--combo-color) 62%, transparent);
  box-shadow: 0 28px 100px var(--combo-aura-strong);
}
.rewardTitle { font-size: 34px; font-weight: 950; line-height: 1.1; }
.rewardText { margin-top: 7px; color: var(--muted); font-weight: 760; }
@keyframes rewardToast {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(.9); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.03); }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -55%) scale(.98); }
}
@keyframes rewardToastHigh {
  0% { opacity: 0; transform: translate(-50%, -38%) scale(.82) rotate(-1deg); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(.6deg); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(.96) rotate(0deg); }
}
.rewardParticle {
  position: fixed;
  z-index: 35;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  pointer-events: none;
  animation: rewardParticle .75s ease-out forwards;
}
@keyframes rewardParticle {
  to {
    transform: translate(var(--x), var(--y)) scale(.25);
    opacity: 0;
  }
}
.screenFlash {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: radial-gradient(circle at 50% 45%, var(--combo-aura-strong), transparent 44%);
  pointer-events: none;
  animation: screenFlash .7s ease-out forwards;
}
@keyframes screenFlash {
  0% { opacity: 0; }
  24% { opacity: 1; }
  100% { opacity: 0; }
}

.familyDirectory {
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.familyGroup { border-bottom: 1px solid var(--line); }
.familyGroup:last-child { border-bottom: 0; }
.familyGroup summary {
  min-height: 34px;
  padding: 8px 11px;
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}
.familyLinks { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 10px 10px; }
.familyLinks button,
.chips button {
  min-height: 29px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--card);
}
.familyLinks button:hover,
.chips button:hover { color: var(--ink); border-color: var(--green); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

#treeView, #examTree { overflow: auto; padding: 4px 0 12px; }
.tree,
.tree ul {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 26px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tree ul {
  flex-direction: column;
  gap: 10px;
  margin-left: 26px;
}
.tree li {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0;
}
.tree li > ul::before {
  position: absolute;
  top: 50%;
  left: -26px;
  width: 26px;
  height: 1px;
  background: var(--line);
  content: "";
}
.tree li > ul > li::before {
  position: absolute;
  top: 50%;
  left: -26px;
  width: 26px;
  height: 1px;
  background: var(--line);
  content: "";
}
.node {
  display: inline-grid;
  width: 210px;
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.node.hit { border-color: var(--amber); background: var(--amber-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 18%, transparent); }
.nodeHead { display: flex; justify-content: space-between; gap: 12px; }
.nodeWord { font-size: 18px; font-weight: 850; }
.pos { color: var(--blue); font-size: 12px; font-weight: 850; }
.meaning { margin-top: 6px; color: var(--muted); line-height: 1.55; }
.rel { margin-top: 8px; color: var(--green); font-size: 12px; font-weight: 850; }
.wordLookupCard {
  max-width: 520px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.wordLookupCard .nodeWord { font-size: 28px; }
.bookTags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.bookTags span {
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green);
  background: var(--card);
  font-size: 12px;
  font-weight: 850;
}
.examHead { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 18px; }
.examInput { width: 180px; min-height: 34px; margin-top: 8px; }
.examInput.good { border-color: var(--green); background: var(--green-soft); }
.examInput.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 14%, var(--card)); }

@media (max-width: 920px) {
  .app, body.side-collapsed .app { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 12px; }
  .brand, .sideToggle { display: none; }
  .nav { text-align: center; margin: 0; }
  .head, .toolbar, .examHead, .toolActions, .headTools { flex-direction: column; align-items: stretch; }
  .learningToolbar { grid-template-columns: 1fr; }
  .toolbarLead { min-width: 0; }
  .controlGroup, .controlGroup.cardControls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fieldShell.wide, .fieldShell.small { min-width: 0; }
  .actionGroup { justify-content: flex-start; flex-wrap: wrap; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .grid, .treegrid, .quizGrid { grid-template-columns: 1fr; }
  .quizbox, .recordPanel { height: auto; min-height: auto; }
  .prompt { min-height: 260px; }
}

@media (max-width: 560px) {
  body { overflow-x: hidden; }
  .main {
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }
  .side {
    overflow-x: auto;
    grid-template-columns: repeat(4, minmax(86px, 1fr));
    scrollbar-width: none;
  }
  .side::-webkit-scrollbar { display: none; }
  .nav { min-height: 42px; padding: 9px 10px; white-space: nowrap; }
  h1 { font-size: 24px; }
  .head { gap: 12px; margin-bottom: 16px; }
  .headTools { gap: 8px; }
  .themeToggle { min-height: 38px; }
  .toolbar { gap: 10px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  #wordbookSelect, #quizWordbookSelect, #challengeSize, #customChallengeSize, #cardPickMode, #quizPickMode, #cardPickCount, #recordSearch { width: 100%; }
  .recordStats { grid-template-columns: repeat(2, 1fr); }
  .memoryFilters, .memoryWordRow { grid-template-columns: 1fr; }
  .pickRow { grid-template-columns: 24px 28px 1fr; }
  .pickMeaning { grid-column: 3; white-space: normal; }
  .seg { display: grid; grid-template-columns: 1fr; }
  .learningToolbar .seg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controlGroup, .controlGroup.cardControls { grid-template-columns: 1fr; }
  .actionGroup { display: grid; grid-template-columns: 1fr; }
  .quizFormActions { align-items: stretch; flex-direction: column; }
  .inlineChallengeActions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin-left: 0; }
  .card { min-height: 220px; }
  .big { font-size: 32px; }
  .prompt { min-height: 220px; padding: 18px; }
  .prompt strong { font-size: 26px; }
  .quizMeaningPrompt .meaningBlock b { font-size: 24px; }
  .letterSlot { width: 26px; height: 34px; font-size: 22px; }
  .tree, .tree ul { gap: 16px; }
  .tree ul { margin-left: 16px; }
  .node { width: 190px; }
}
