:root {
  --spell-ink: #21342c;
  --spell-muted: #5e7068;
  --spell-green: #477b62;
  --spell-green-dark: #285943;
  --spell-green-soft: #e8f2ec;
  --spell-red: #a84d4b;
  --spell-cream: #fbfaf5;
  --spell-line: #dbe4de;
}

body[data-learning-portal="spelling"] {
  background: radial-gradient(circle at 8% 0%, #dcebe0 0, transparent 34rem), linear-gradient(160deg, #f7faf8 0%, #eef4f0 58%, #f7f5ef 100%);
}

body[data-learning-portal="spelling"] .learning-portal-shell {
  width: min(100% - 32px, 1480px);
}

body[data-learning-portal="spelling"] [data-view="dashboard"] {
  display: block;
}

body[data-learning-portal="spelling"] [data-view="dashboard"][hidden] {
  display: none;
}

.spelling-workspace {
  display: grid;
  gap: 22px;
  color: var(--spell-ink);
}

.spelling-hero,
.spelling-controls,
.spelling-bank,
.spelling-card,
.spelling-complete-card {
  border: 1px solid rgba(71, 123, 98, .18);
  border-radius: 28px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 20px 50px rgba(34, 67, 52, .09);
}

.spelling-hero {
  min-height: 230px;
  padding: clamp(32px, 5vw, 64px);
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  color: white;
  background:
    linear-gradient(108deg, rgba(25, 71, 50, .97), rgba(59, 112, 84, .87)),
    repeating-linear-gradient(90deg, transparent 0 42px, rgba(255,255,255,.04) 42px 43px);
  position: relative;
}

.spelling-hero::after {
  content: "A  L  I  E  N";
  position: absolute;
  right: -18px;
  bottom: -35px;
  color: rgba(255, 255, 255, .07);
  font: 900 clamp(55px, 9vw, 128px)/1 Georgia, serif;
  letter-spacing: .06em;
  white-space: nowrap;
}

.spelling-hero > * { position: relative; z-index: 1; }
.spelling-eyebrow { margin: 0 0 10px; color: var(--spell-green); font-size: 12px; font-weight: 950; letter-spacing: .16em; }
.spelling-hero .spelling-eyebrow { color: #cfe6d8; }
.spelling-hero h1 { max-width: 820px; margin: 0; font: 800 clamp(38px, 5vw, 70px)/1.06 Georgia, "Noto Serif TC", serif; }
.spelling-hero p:last-child { max-width: 720px; margin: 20px 0 0; color: rgba(255,255,255,.78); font-size: 17px; font-weight: 700; }

.spelling-hero__count {
  min-width: 150px;
  padding: 24px;
  display: grid;
  gap: 4px;
  text-align: center;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 22px;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(10px);
}
.spelling-hero__count strong { font: 800 46px/1 Georgia, serif; }
.spelling-hero__count span { font-size: 12px; font-weight: 900; letter-spacing: .08em; }

.spelling-controls {
  padding: 24px;
  display: grid;
  grid-template-columns: 1.15fr 1fr .9fr .72fr;
  gap: 16px;
}

.spelling-control {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--spell-line);
  border-radius: 20px;
  background: var(--spell-cream);
}
.spelling-control > label,
.spelling-control > span { display: block; margin-bottom: 14px; font-weight: 950; }
.spelling-control small { display: block; margin-top: 12px; color: var(--spell-muted); font-size: 12px; line-height: 1.5; }
.spelling-range-row { display: grid; grid-template-columns: 1fr 76px; align-items: center; gap: 16px; }
.spelling-range-row input { width: 100%; accent-color: var(--spell-green); }
.spelling-range-row output { padding: 9px 10px; text-align: center; border-radius: 11px; color: white; background: var(--spell-green-dark); font-weight: 950; }

.spelling-frequency-row { display: flex; flex-wrap: wrap; gap: 9px; }
.spelling-frequency-row button,
.spelling-frequency-row label,
.spelling-bank__actions button,
.spelling-practice-header button,
.spelling-complete-actions > button:not(.spelling-primary) {
  min-height: 42px;
  border: 1px solid var(--spell-line);
  border-radius: 12px;
  color: var(--spell-ink);
  background: white;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.spelling-frequency-row button { padding: 0 16px; }
.spelling-frequency-row button[aria-pressed="true"] { border-color: var(--spell-green-dark); color: white; background: var(--spell-green-dark); }
.spelling-frequency-row label { padding: 0 10px 0 13px; display: flex; align-items: center; gap: 8px; cursor: text; }
.spelling-frequency-row input { width: 58px; padding: 6px; border: 0; border-bottom: 2px solid var(--spell-green); background: transparent; font: inherit; font-weight: 950; text-align: center; }

.spelling-control--summary { display: grid; align-content: center; text-align: center; }
.spelling-control--summary > strong { color: var(--spell-green-dark); font: 800 46px/1 Georgia, serif; }
.spelling-control--summary > small { margin-bottom: 15px; }
.spelling-mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.spelling-mode-options button,
.spelling-view-tabs button,
.spelling-refresh-history {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--spell-line);
  border-radius: 12px;
  color: var(--spell-ink);
  background: white;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.spelling-mode-options button[aria-pressed="true"],
.spelling-view-tabs button[aria-current="page"] { border-color: var(--spell-green-dark); color: white; background: var(--spell-green-dark); }
.spelling-view-tabs { width: max-content; padding: 5px; display: flex; gap: 4px; border: 1px solid var(--spell-line); border-radius: 15px; background: rgba(255,255,255,.9); }

.spelling-primary {
  min-height: 50px;
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, var(--spell-green), var(--spell-green-dark));
  box-shadow: 0 10px 24px rgba(40, 89, 67, .2);
  font: inherit;
  font-weight: 950;
  cursor: pointer;
}
.spelling-primary svg,
.spelling-sound svg,
.spelling-complete-card__icon svg { width: 22px; height: 22px; }
.spelling-submit kbd { padding: 3px 7px; color: var(--spell-green-dark); border: 1px solid rgba(255,255,255,.65); border-radius: 7px; background: rgba(255,255,255,.9); box-shadow: 0 2px 0 rgba(23, 65, 45, .18); font: 800 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.spelling-primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }

.spelling-bank { padding: clamp(24px, 4vw, 42px); }
.spelling-bank__toolbar { margin-bottom: 22px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.spelling-bank__toolbar h2 { margin: 0; font: 800 clamp(27px, 3vw, 39px)/1.1 Georgia, serif; }
.spelling-bank__title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.spelling-search input { width: min(360px, 46vw); min-height: 44px; padding: 0 16px; border: 1px solid var(--spell-line); border-radius: 999px; color: var(--spell-ink); background: white; font: inherit; font-weight: 750; }
.spelling-search input:focus { outline: 3px solid rgba(71, 123, 98, .2); border-color: var(--spell-green); }
.spelling-bank__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px; }
.spelling-bank__actions span { margin-right: 8px; color: var(--spell-muted); font-size: 13px; font-weight: 900; }
.spelling-bank__actions button { padding: 0 15px; }
.spelling-table-wrap { max-height: min(62vh, 760px); overflow: auto; border: 1px solid var(--spell-line); border-radius: 18px; }
.spelling-table-wrap table { width: 100%; border-collapse: collapse; }
.spelling-table-wrap thead { position: sticky; top: 0; z-index: 2; }
.spelling-table-wrap th { padding: 15px 18px; text-align: left; color: #edf7f1; background: var(--spell-green-dark); font-size: 12px; letter-spacing: .06em; }
.spelling-table-wrap td { padding: 15px 18px; border-top: 1px solid var(--spell-line); }
.spelling-table-wrap tbody tr:nth-child(even) { background: #f8fbf9; }
.spelling-table-wrap tbody tr[data-mastered="true"],
.spelling-table-wrap tbody tr[data-mastered="true"]:nth-child(even) { background: #e9f6ed; }
.spelling-table-wrap tbody tr[data-mastered="true"] td { border-top-color: #c9e6d2; }
.spelling-table-wrap tbody tr:hover { background: var(--spell-green-soft); }
.spelling-table-wrap tbody tr[data-mastered="true"]:hover { background: #dff1e5; }
.spelling-word-row { cursor: pointer; }
.spelling-word-row { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.spelling-word-row:focus-visible { outline: 3px solid rgba(71, 123, 98, .35); outline-offset: -3px; }
.spelling-table-wrap td strong { font: 700 18px/1.3 Georgia, serif; }
.spelling-word-cell { display: inline-flex; align-items: center; gap: 10px; }
.spelling-row-sound { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; border: 1px solid var(--spell-line); border-radius: 50%; color: var(--spell-green-dark); background: white; cursor: pointer; }
.spelling-row-sound:hover { background: var(--spell-green-soft); }
.spelling-row-sound svg { width: 18px; height: 18px; }
.spelling-drag-hint { margin: -8px 0 14px; color: var(--spell-muted); font-size: 12px; font-weight: 750; }

.spelling-dropdown { min-width: 190px; position: relative; color: var(--spell-ink); }
.spelling-dropdown__trigger {
  width: 100%;
  min-height: 44px;
  padding: 0 12px 0 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--spell-ink);
  border: 1px solid #cddbd3;
  border-radius: 13px;
  background: linear-gradient(180deg, #fff, #f8fbf9);
  box-shadow: 0 5px 14px rgba(40, 89, 67, .07);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.spelling-filter .spelling-dropdown { min-width: 170px; }
.spelling-filter .spelling-dropdown__trigger { border-radius: 999px; }
.spelling-dropdown__trigger:hover { border-color: #8fb3a1; background: #fff; }
.spelling-dropdown__trigger:focus-visible { outline: 3px solid rgba(71, 123, 98, .2); outline-offset: 2px; border-color: var(--spell-green); }
.spelling-dropdown__trigger svg { width: 19px; height: 19px; flex: 0 0 auto; transition: transform .18s ease; }
.spelling-dropdown.is-open .spelling-dropdown__trigger { border-color: var(--spell-green); box-shadow: 0 0 0 3px rgba(71, 123, 98, .14), 0 10px 24px rgba(40, 89, 67, .12); }
.spelling-dropdown.is-open .spelling-dropdown__trigger svg { transform: rotate(180deg); }
.spelling-dropdown.is-complete .spelling-dropdown__trigger { border-color: #78ad8d; background: linear-gradient(180deg, #effaf2, #e2f4e8); }
.spelling-dropdown__menu {
  min-width: 100%;
  max-height: 310px;
  padding: 7px;
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  left: 0;
  overflow: auto;
  border: 1px solid #cddbd3;
  border-radius: 16px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 18px 42px rgba(35, 65, 51, .2);
  backdrop-filter: blur(14px);
}
.spelling-dropdown__menu[hidden] { display: none; }
.spelling-filter .spelling-dropdown__menu { right: 0; left: auto; width: 220px; }
.spelling-dropdown__menu button {
  width: 100%;
  min-height: 43px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--spell-ink);
  border: 0;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  font-weight: 780;
  text-align: left;
  cursor: pointer;
}
.spelling-dropdown__menu button:hover,
.spelling-dropdown__menu button:focus-visible { outline: none; background: #f3f7f4; }
.spelling-dropdown__menu button[aria-selected="true"] { color: var(--spell-green-dark); background: #edf5f0; font-weight: 950; }
.spelling-dropdown__menu button.is-complete { background: #e8f6ec; }
.spelling-dropdown__menu button.is-complete:hover,
.spelling-dropdown__menu button.is-complete:focus-visible,
.spelling-dropdown__menu button.is-complete[aria-selected="true"] { background: #d9efdf; }
.spelling-dropdown__check { width: 22px; height: 22px; display: grid; place-items: center; color: white; border: 1px solid transparent; border-radius: 7px; font-size: 12px; }
.spelling-dropdown__menu button[aria-selected="true"] .spelling-dropdown__check,
.spelling-dropdown__menu button.is-complete .spelling-dropdown__check { border-color: var(--spell-green); background: var(--spell-green); }
.spelling-dropdown__menu em { color: var(--spell-green-dark); font-size: 11px; font-style: normal; font-weight: 950; white-space: nowrap; }

.spelling-check { display: inline-grid; place-items: center; cursor: pointer; }
.spelling-check input { position: absolute; opacity: 0; pointer-events: none; }
.spelling-check span[aria-hidden] { width: 24px; height: 24px; display: grid; place-items: center; border: 2px solid #9bb1a6; border-radius: 7px; background: white; }
.spelling-check input:checked + span { border-color: var(--spell-green-dark); background: var(--spell-green-dark); }
.spelling-check input:checked + span::after { content: ""; width: 9px; height: 5px; border: solid white; border-width: 0 0 2px 2px; transform: rotate(-45deg) translateY(-1px); }
.spelling-check input:focus-visible + span { outline: 3px solid rgba(71, 123, 98, .26); outline-offset: 3px; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.spelling-workspace--practice { min-height: calc(100vh - 130px); align-content: start; }
.spelling-practice-header { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--spell-line); border-radius: 18px; background: rgba(255,255,255,.9); }
.spelling-practice-header button { padding: 0 15px; }
.spelling-practice-header__right,
.spelling-practice-metrics { display: flex; align-items: center; gap: 18px; }
.spelling-practice-header span { color: var(--spell-muted); font-size: 12px; font-weight: 900; }
.spelling-practice-header strong { font: 800 25px/1 Georgia, serif; }
.spelling-practice-metrics span { display: inline-flex; align-items: baseline; gap: 7px; }
.spelling-typing-effect-toggle { display: inline-flex; align-items: center; gap: 7px; transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease; }
.spelling-typing-effect-toggle svg { width: 18px; height: 18px; color: var(--spell-green-dark); }
.spelling-typing-effect-toggle strong { min-width: 26px; padding: 3px 7px; border-radius: 999px; color: #7b6750; background: #efeae3; font-family: inherit; font-size: 11px; font-weight: 950; line-height: 1.2; text-align: center; }
.spelling-typing-effect-toggle[aria-pressed="true"] { border-color: #8ec4a7; background: linear-gradient(135deg, #f0faf3, #fff9df); box-shadow: 0 6px 16px rgba(53,109,89,.1); }
.spelling-typing-effect-toggle[aria-pressed="true"] strong { color: white; background: var(--spell-green-dark); }
.spelling-typing-effect-toggle[aria-pressed="true"] svg { animation: spelling-sparkle-breathe 2.8s ease-in-out infinite; }
.spelling-auto-audio-toggle { display: inline-flex; align-items: center; gap: 7px; transition: border-color .18s ease, background .18s ease, box-shadow .18s ease; }
.spelling-auto-audio-toggle svg { width: 18px; height: 18px; color: var(--spell-green-dark); }
.spelling-auto-audio-toggle strong { min-width: 26px; padding: 3px 7px; border-radius: 999px; color: #7b6750; background: #efeae3; font-family: inherit; font-size: 11px; font-weight: 950; line-height: 1.2; text-align: center; }
.spelling-auto-audio-toggle[aria-pressed="true"] { border-color: #7fb8d2; background: linear-gradient(135deg, #eef8fc, #f0faf3); box-shadow: 0 6px 16px rgba(45,104,128,.11); }
.spelling-auto-audio-toggle[aria-pressed="true"] strong { color: #fff; background: #286c80; }
.spelling-touch-only { display: none !important; }
.spelling-workspace[data-touch-device="true"] .spelling-touch-only { display: inline-flex !important; }
.spelling-touch-keyboard-toggle { align-items: center; gap: 7px; transition: border-color .18s ease, background .18s ease, box-shadow .18s ease; }
.spelling-touch-keyboard-toggle strong { min-width: 26px; padding: 3px 7px; border-radius: 999px; color: #81766b; background: #ebe7e1; font-size: 11px; font-weight: 950; line-height: 1.2; text-align: center; }
.spelling-touch-keyboard-toggle[aria-pressed="true"] { color: #fff; border-color: #343537; background: linear-gradient(145deg, #343537, #1b1c1e); box-shadow: 0 7px 17px rgba(20,20,21,.2); }
.spelling-touch-keyboard-toggle[aria-pressed="true"] span { color: #fff; }
.spelling-touch-keyboard-toggle[aria-pressed="true"] strong { color: #fff; background: #e95c10; }
[data-audio-speaking="true"] .spelling-auto-audio-toggle svg,
[data-audio-speaking="true"] .spelling-sound svg { animation: spelling-audio-pulse 1s ease-in-out infinite; }
.spelling-sound.needs-audio-unlock { border-color: #d89c45; box-shadow: 0 0 0 4px rgba(216,156,69,.16); animation: spelling-listen-pulse 1.35s ease-in-out infinite; }
.spelling-audio-unlock { margin: -.4rem 0 .85rem; color: #8a5c1e; font-size: .9rem; font-weight: 750; text-align: right; }

.spelling-auto-advance { position: relative; width: min(100%, 520px); height: 4px; margin: .1rem auto .9rem; overflow: visible; border-radius: 999px; background: rgba(40,61,75,.12); }
.spelling-auto-advance::after { content: ""; position: absolute; inset: -5px 0; z-index: -1; border-radius: inherit; background: linear-gradient(90deg,#ff6b62,#ffc857,#43c97b,#4d93ff); filter: blur(8px); opacity: .26; }
.spelling-auto-advance i { display: block; width: 100%; height: 100%; transform: scaleX(var(--advance-progress, 0)); transform-origin: left center; border-radius: inherit; background: linear-gradient(90deg,#ff6b62 0%,#ffc857 34%,#43c97b 67%,#4d93ff 100%); box-shadow: 0 0 8px rgba(77,147,255,.35); animation: spelling-auto-advance var(--advance-remaining, 2400ms) linear forwards; }
.spelling-card--enter,
.spelling-complete-card { animation: spelling-card-enter .28s cubic-bezier(.2,.8,.2,1) both; }
.spelling-card--exit { pointer-events: none; animation: spelling-card-exit .19s ease-in both; }

@keyframes spelling-auto-advance { from { transform: scaleX(var(--advance-progress, 0)); } to { transform: scaleX(1); filter: brightness(1.15); } }
@keyframes spelling-card-enter { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spelling-card-exit { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(-22px); } }
@keyframes spelling-audio-pulse { 50% { transform: scale(1.12); opacity: .72; } }
@keyframes spelling-listen-pulse { 50% { box-shadow: 0 0 0 8px rgba(216,156,69,.08); } }
.spelling-progress { height: 8px; overflow: hidden; border-radius: 999px; background: #dbe7e0; }
.spelling-progress i { height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--spell-green), #78ac8f); transition: width .45s ease; }

.spelling-card { width: min(100%, 980px); min-height: 560px; margin: 16px auto 0; padding: clamp(30px, 6vw, 72px); display: grid; align-content: center; }
.spelling-meaning-row { display: flex; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.spelling-meaning-row h1 { margin: 0; font: 800 clamp(34px, 6vw, 64px)/1.15 Georgia, "Noto Serif TC", serif; }
.spelling-sound { min-height: 48px; padding: 0 16px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--spell-line); border-radius: 999px; color: var(--spell-green-dark); background: var(--spell-green-soft); font: inherit; font-weight: 950; cursor: pointer; }
.spelling-word-progress { margin: 16px 0 36px; color: var(--spell-muted); text-align: center; font-weight: 800; }
.spelling-slots { min-height: 118px; display: flex; flex-wrap: wrap; align-items: end; justify-content: center; gap: 9px; }
.spelling-token { max-width: 100%; display: inline-flex; flex: 0 0 auto; align-items: end; gap: 7px; white-space: nowrap; break-inside: avoid; }
.spelling-word-gap { width: clamp(12px, 2vw, 24px); height: 1px; flex: 0 0 auto; }
.spelling-slot { width: clamp(32px, 5vw, 52px); height: 70px; display: grid; place-items: end center; padding-bottom: 10px; border-bottom: 4px solid #8fa69a; font: 800 clamp(29px, 5vw, 48px)/1 Georgia, serif; text-transform: lowercase; }
.spelling-slot--given { color: var(--spell-ink); background: linear-gradient(180deg, transparent 62%, var(--spell-green-soft) 62%); }
.spelling-slot--blank { border-color: var(--spell-red); background: #fff5f3; }
.spelling-slot--blank input { width: 100%; height: 100%; padding: 0 0 8px; border: 0; outline: 0; opacity: 1; color: var(--spell-red) !important; -webkit-text-fill-color: var(--spell-red); caret-color: var(--spell-red); background: transparent; appearance: none; -webkit-appearance: none; font: inherit; line-height: 1; text-align: center; text-transform: lowercase; }
.spelling-slot--corrected { color: #8d302e; border-color: var(--spell-red); background: linear-gradient(180deg, transparent 56%, #ffe1dc 56%); }
.spelling-slot--space { width: 20px; border: 0; background: transparent; }
.spelling-feedback { min-height: 27px; margin: 24px 0 14px; text-align: center; font-weight: 900; }
.spelling-feedback[data-state="correct"] { color: var(--spell-green-dark); }
.spelling-feedback[data-state="wrong"] { color: var(--spell-red); }
.spelling-feedback[data-state="warning"] { color: #a06917; }
.spelling-line-answer { width: min(100%, 760px); margin: 20px auto; display: block; }
.spelling-line-answer input { width: 100%; padding: 16px 8px; border: 0; border-bottom: 4px solid var(--spell-green); outline: 0; opacity: 1; color: var(--spell-ink) !important; -webkit-text-fill-color: var(--spell-ink); caret-color: var(--spell-red); background: transparent; appearance: none; -webkit-appearance: none; font: 800 clamp(28px, 5vw, 48px)/1.2 Georgia, serif; text-align: center; }
.spelling-line-answer input:focus { border-color: var(--spell-red); }
.spelling-comparison { width: min(100%, 760px); margin: 22px auto 8px; display: grid; gap: 10px; text-align: left; }
.spelling-comparison > div { padding: 13px 16px; display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: baseline; border-radius: 12px; background: #f7faf8; }
.spelling-comparison span { color: var(--spell-muted); font-size: 12px; }
.spelling-comparison strong { font: 800 clamp(20px, 3vw, 30px)/1.45 Georgia, serif; letter-spacing: .03em; overflow-wrap: anywhere; }
.spelling-comparison mark { padding: 1px 2px; color: inherit; background: transparent; }
.spelling-comparison mark.is-different { border-radius: 4px; color: #6d4a04; background: #ffe27a; box-shadow: 0 0 0 2px #ffe27a; }
.spelling-comparison mark.is-missing { color: #8b5a00; }
.spelling-submit { min-width: 220px; margin: auto; }
.spelling-attempts { margin: 24px 0 0; color: var(--spell-muted); text-align: center; font-size: 12px; font-weight: 800; }

.spelling-touch-keyboard { width: min(100%, 860px); margin: 24px auto 18px; padding: 14px 16px 16px; display: grid; gap: 8px; border: 1px solid #0c0c0d; border-radius: 17px; background: linear-gradient(160deg, #303133 0%, #17181a 58%, #111214 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 16px 30px rgba(18,18,20,.22); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.spelling-touch-keyboard__row { display: flex; justify-content: center; gap: clamp(5px, .8vw, 9px); }
.spelling-touch-keyboard button { width: clamp(44px, 6.6vw, 64px); height: clamp(48px, 6vw, 58px); padding: 0; border: 1px solid #09090a; border-radius: 7px; color: #f7f7f7; background: linear-gradient(180deg, #393a3d, #242527); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 3px 0 #080809, 0 5px 8px rgba(0,0,0,.32); font: 800 clamp(17px, 2.1vw, 23px)/1 system-ui, sans-serif; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color .08s ease, background .08s ease, transform .08s ease, box-shadow .08s ease; }
.spelling-touch-keyboard button:active,
.spelling-touch-keyboard button:focus-visible { color: #fff; border-color: #ff761f; background: linear-gradient(180deg, #f36b14, #d94d00); box-shadow: inset 0 1px 0 rgba(255,255,255,.24), 0 1px 0 #7f2b00, 0 0 14px rgba(244,92,8,.45); transform: translateY(2px); outline: none; }
.spelling-touch-keyboard .spelling-touch-keyboard__delete { width: clamp(58px, 8vw, 82px); color: #ff8a47; font-size: clamp(21px, 2.6vw, 28px); }
.spelling-slot[data-touch-active="true"],
.spelling-line-answer[data-touch-active="true"] { filter: drop-shadow(0 0 8px rgba(233,92,16,.28)); }
.spelling-slot[data-touch-active="true"] { border-color: #e95c10; background: #fff0e7; }
.spelling-line-answer[data-touch-active="true"] input { border-color: #e95c10; }

.spelling-writing-effect { width: 8px; height: 8px; position: fixed; z-index: 9999; pointer-events: none; transform: translate(-50%, -50%); }
.spelling-writing-effect i { position: absolute; display: block; pointer-events: none; }
.spelling-writing-ripple { width: 18px; height: 18px; top: -5px; left: -5px; border: 2px solid rgba(116,173,147,.62); border-radius: 50%; }
.spelling-writing-effect.is-typing .spelling-writing-ripple { border-color: rgba(226,180,71,.64); animation: spelling-soft-ripple 700ms cubic-bezier(.16,.8,.3,1) forwards; }
.spelling-writing-effect.is-erasing .spelling-writing-ripple { animation: spelling-soft-erase 520ms cubic-bezier(.3,.7,.4,1) forwards; }
.spelling-writing-mote { width: 6px; height: 6px; top: 1px; left: 1px; border-radius: 50% 50% 50% 14%; background: linear-gradient(135deg, #f3d98c, #77b597); box-shadow: 0 0 8px rgba(116,173,147,.28); opacity: 0; }
.spelling-writing-effect.is-typing .spelling-writing-mote { animation: spelling-mote-bloom 780ms cubic-bezier(.15,.7,.28,1) calc(var(--mote-index) * 28ms) forwards; }
.spelling-writing-effect.is-erasing .spelling-writing-mote { background: linear-gradient(135deg, #a8d5c0, #e7d8bd); animation: spelling-mote-return 580ms ease-out calc(var(--mote-index) * 25ms) forwards; }

@keyframes spelling-sparkle-breathe { 0%, 100% { transform: rotate(0) scale(1); } 50% { transform: rotate(12deg) scale(1.12); } }
@keyframes spelling-soft-ripple { 0% { opacity: 0; transform: scale(.3); } 28% { opacity: .75; } 100% { opacity: 0; transform: scale(2.8); } }
@keyframes spelling-soft-erase { 0% { opacity: 0; transform: scale(2.2); } 38% { opacity: .68; } 100% { opacity: 0; transform: scale(.25); } }
@keyframes spelling-mote-bloom { 0% { opacity: 0; transform: translate(0, 0) rotate(0) scale(.2); } 24% { opacity: .82; } 100% { opacity: 0; transform: translate(var(--mote-x), var(--mote-y)) rotate(110deg) scale(.15); } }
@keyframes spelling-mote-return { 0% { opacity: 0; transform: translate(var(--mote-x), var(--mote-y)) scale(.2); } 38% { opacity: .62; } 100% { opacity: 0; transform: translate(0, 0) scale(.1); } }

.spelling-workspace--complete { min-height: calc(100vh - 140px); place-items: center; }
.spelling-complete-card { width: min(100%, 840px); padding: clamp(38px, 7vw, 84px); text-align: center; }
.spelling-complete-card__icon { width: 76px; height: 76px; margin: 0 auto 24px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--spell-green-dark); }
.spelling-complete-card__icon svg { width: 36px; height: 36px; }
.spelling-complete-card h1 { margin: 0; font: 800 clamp(35px, 5vw, 56px)/1.1 Georgia, serif; }
.spelling-complete-card > p:not(.spelling-eyebrow) { color: var(--spell-muted); font-weight: 700; }
.spelling-complete-stats { margin: 34px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.spelling-complete-stats div { padding: 20px; display: grid; gap: 6px; border-radius: 16px; background: var(--spell-green-soft); }
.spelling-complete-stats strong { color: var(--spell-green-dark); font: 800 32px/1 Georgia, serif; }
.spelling-complete-stats span { color: var(--spell-muted); font-size: 12px; font-weight: 900; }
.spelling-complete-actions { display: flex; justify-content: center; gap: 12px; }
.spelling-complete-actions > button:not(.spelling-primary) { padding: 0 20px; }

.spelling-history h2 { margin: 0; font: 800 clamp(27px, 3vw, 39px)/1.1 Georgia, serif; }
.spelling-history-empty { min-height: 260px; display: grid; place-content: center; gap: 8px; color: var(--spell-muted); text-align: center; }
.spelling-history-empty strong { color: var(--spell-ink); font: 800 28px/1.2 Georgia, serif; }
.spelling-history-list { display: grid; gap: 10px; }
.spelling-history-row { overflow: hidden; border: 1px solid var(--spell-line); border-radius: 16px; background: #fff; }
.spelling-history-row summary { padding: 17px 20px; display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; cursor: pointer; list-style: none; }
.spelling-history-row summary::-webkit-details-marker { display: none; }
.spelling-history-row summary > span { display: grid; gap: 5px; }
.spelling-history-row summary > span:last-child { text-align: right; }
.spelling-history-row summary strong { font-size: 17px; }
.spelling-history-row summary small { color: var(--spell-muted); font-weight: 750; }
.spelling-history-detail { overflow-x: auto; border-top: 1px solid var(--spell-line); }
.spelling-history-detail table { width: 100%; border-collapse: collapse; }
.spelling-history-detail th, .spelling-history-detail td { padding: 11px 14px; border-bottom: 1px solid var(--spell-line); text-align: left; }
.spelling-history-detail .is-wrong { background: #fff6ce; }
.spelling-history-detail .is-correct { color: var(--spell-green-dark); }

@media (max-width: 900px) {
  .spelling-controls { grid-template-columns: 1fr 1fr; }
  .spelling-control--summary { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  body[data-learning-portal="spelling"] .learning-portal-shell { width: min(100% - 18px, 1480px); padding-top: 14px; }
  .spelling-workspace { gap: 14px; }
  .spelling-hero { min-height: 250px; padding: 28px 24px; align-items: start; flex-direction: column; }
  .spelling-hero__count { min-width: 0; padding: 13px 17px; grid-auto-flow: column; align-items: baseline; }
  .spelling-hero__count strong { font-size: 29px; }
  .spelling-controls { padding: 13px; grid-template-columns: 1fr; }
  .spelling-control--summary { grid-column: auto; }
  .spelling-bank { padding: 19px 13px; }
  .spelling-bank__toolbar { align-items: start; flex-direction: column; }
  .spelling-bank__title-row { align-items: stretch; flex-direction: column; }
  .spelling-search input { width: min(100%, 420px); }
  .spelling-bank__actions { justify-content: flex-start; }
  .spelling-table-wrap { max-height: 65vh; }
  .spelling-table-wrap th, .spelling-table-wrap td { padding: 13px 10px; }
  .spelling-table-wrap th:first-child, .spelling-table-wrap td:first-child { width: 46px; text-align: center; }
  .spelling-card { min-height: 520px; padding: 34px 18px; }
  .spelling-meaning-row { flex-direction: column; }
  .spelling-slots { gap: 6px; }
  .spelling-token { gap: 4px; }
  .spelling-word-gap { width: 12px; }
  .spelling-slot {
    width: min(34px, calc((100vw - 70px - (var(--token-length, 1) - 1) * 4px) / var(--token-length, 1)));
    min-width: 12px;
    height: 59px;
    font-size: min(31px, calc((100vw - 84px) / var(--token-length, 1)));
  }
  .spelling-complete-stats { grid-template-columns: 1fr; }
  .spelling-complete-actions { flex-direction: column; }
  .spelling-practice-header { align-items: flex-start; flex-wrap: wrap; }
  .spelling-practice-header__right { width: 100%; align-items: flex-end; flex-direction: column; gap: 10px; }
  .spelling-practice-metrics { align-items: flex-end !important; flex-direction: column; gap: 7px !important; }
  .spelling-comparison > div { grid-template-columns: 1fr; gap: 5px; }
  .spelling-history-row summary { grid-template-columns: 1fr; }
  .spelling-history-row summary > span:last-child { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .spelling-writing-effect { display: none !important; }
}

/* 2026 storybook journal interface — original ImageGen art, not third-party artwork. */
:root {
  --spell-ink: #24201c;
  --spell-muted: #746b64;
  --spell-green: #74ad93;
  --spell-green-dark: #356d59;
  --spell-green-soft: #edf7f1;
  --spell-red: #b45f20;
  --spell-cream: #fffdf5;
  --spell-line: #ead7a5;
  --spell-gold: #f3d68c;
  --spell-yellow: #fff77b;
  --spell-gray: #c5bab6;
  --spell-mint: #99ddd1;
}

body[data-learning-portal="spelling"] {
  background:
    radial-gradient(circle at 8% 0%, rgba(153, 221, 209, .32) 0, transparent 31rem),
    radial-gradient(circle at 96% 5%, rgba(243, 214, 140, .3) 0, transparent 28rem),
    linear-gradient(160deg, #fffdf5 0%, #f6f0df 100%);
}

.spelling-hero,
.spelling-controls,
.spelling-bank,
.spelling-card,
.spelling-complete-card,
.spelling-library,
.spelling-deck-explorer {
  border-color: rgba(180, 95, 32, .2);
  background: rgba(255, 253, 245, .97);
  box-shadow: 0 22px 54px rgba(84, 64, 37, .11);
}

.spelling-hero {
  min-height: 300px;
  color: var(--spell-ink);
  border: 2px solid var(--spell-gold);
  background:
    linear-gradient(90deg, rgba(255, 253, 245, .99) 0 40%, rgba(255, 253, 245, .86) 56%, rgba(255, 253, 245, .08) 82%),
    url("./spelling-adventure-journal-hero.webp") center / cover no-repeat;
}
.spelling-hero::after { display: none; }
.spelling-hero .spelling-eyebrow { color: var(--spell-red); }
.spelling-hero p:last-child { color: var(--spell-muted); }
.spelling-hero__count {
  color: var(--spell-ink);
  border-color: rgba(180, 95, 32, .26);
  background: rgba(255, 253, 245, .86);
  box-shadow: inset 0 0 0 2px rgba(243, 214, 140, .45);
}

.spelling-primary {
  color: var(--spell-ink);
  border: 2px solid #e2bb3f;
  background: linear-gradient(180deg, #fffca0, var(--spell-yellow));
  box-shadow: 0 7px 0 #d8ae2e, 0 13px 24px rgba(132, 93, 12, .16);
}
.spelling-primary:hover { filter: brightness(1.02); transform: translateY(-1px); }
.spelling-frequency-row button[aria-pressed="true"],
.spelling-mode-options button[aria-pressed="true"],
.spelling-view-tabs button[aria-current="page"] {
  color: var(--spell-ink);
  border-color: #e2bb3f;
  background: var(--spell-yellow);
}

.spelling-library,
.spelling-deck-explorer { padding: clamp(22px, 4vw, 40px); border-radius: 28px; }
.spelling-library__heading,
.spelling-deck-explorer__top { margin-bottom: 20px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.spelling-library__heading h2,
.spelling-deck-explorer__top h2 { margin: 0; font: 800 clamp(27px, 3vw, 39px)/1.1 Georgia, "Noto Serif TC", serif; }
.spelling-library__heading > p { max-width: 560px; margin: 0; color: var(--spell-muted); font-weight: 750; }
.spelling-library__tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.spelling-library-card {
  min-width: 0;
  min-height: 150px;
  padding: 22px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 16px;
  text-align: left;
  color: var(--spell-ink);
  border: 2px solid var(--spell-line);
  border-radius: 22px;
  background: #fffdf5;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.spelling-library-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(84, 64, 37, .11); }
.spelling-library-card[aria-pressed="true"] { border-color: #e2bb3f; background: linear-gradient(145deg, #fffdf5, #fff8c5); box-shadow: inset 0 0 0 3px rgba(255, 247, 123, .55); }
.spelling-library-card--1[aria-pressed="true"] { border-color: var(--spell-mint); background: linear-gradient(145deg, #fffdf5, #e8faf6); }
.spelling-library-card--2[aria-pressed="true"] { border-color: #f0b088; background: linear-gradient(145deg, #fffdf5, #fff1e6); }
.spelling-library-card__number { width: 44px; height: 44px; display: grid; place-items: center; color: var(--spell-red); border: 1px solid var(--spell-gold); border-radius: 14px; background: #fff9df; font-weight: 950; }
.spelling-library-card > span:last-child { min-width: 0; display: grid; gap: 6px; }
.spelling-library-card strong { font-size: 20px; }
.spelling-library-card small { color: var(--spell-red); font-weight: 900; }
.spelling-library-card em { color: var(--spell-muted); font-size: 13px; font-style: normal; line-height: 1.45; }

.spelling-deck-actions,
.spelling-group-tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spelling-deck-actions button,
.spelling-group-tabs button {
  min-height: 40px;
  padding: 0 14px;
  color: var(--spell-ink);
  border: 1px solid var(--spell-line);
  border-radius: 12px;
  background: white;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}
.spelling-group-tabs { margin-bottom: 17px; }
.spelling-group-tabs button[aria-pressed="true"] { border-color: #e2bb3f; background: var(--spell-yellow); }
.spelling-section-list { display: grid; gap: 12px; }
.spelling-section-card { overflow: hidden; border: 1px solid var(--spell-line); border-radius: 18px; background: rgba(255,255,255,.82); }
.spelling-section-card summary { padding: 16px 18px; display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
.spelling-section-card summary::-webkit-details-marker { display: none; }
.spelling-section-card summary strong { font-size: 17px; }
.spelling-section-card summary em { margin-left: auto; color: var(--spell-muted); font-size: 12px; font-style: normal; font-weight: 800; }
.spelling-section-card summary .spelling-section-card__badge { padding: 5px 9px; border-radius: 999px; color: var(--spell-red); background: #fff2cf; font-size: 12px; font-weight: 950; }
.spelling-section-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 4px 0 12px;
}
.spelling-section-choice {
  min-width: 0;
  min-height: 112px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  text-align: left;
  color: var(--spell-ink);
  border: 2px solid var(--spell-line);
  border-radius: 20px;
  background: linear-gradient(145deg, #fffdf5, #fff9df);
  box-shadow: 0 8px 20px rgba(84, 64, 37, .08);
  font: inherit;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.spelling-section-choice:hover,
.spelling-section-choice:focus-visible {
  transform: translateY(-2px);
  border-color: #e2bb3f;
  box-shadow: 0 13px 28px rgba(84, 64, 37, .13);
}
.spelling-section-choice > span:first-child {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--spell-red);
  border: 1px solid var(--spell-gold);
  border-radius: 14px;
  background: #fff;
  font-weight: 950;
}
.spelling-section-choice strong { display: block; font-size: clamp(17px, 2vw, 21px); line-height: 1.2; }
.spelling-section-choice small { display: block; margin-top: 6px; color: var(--spell-muted); font-weight: 750; }
.spelling-section-choice em { color: var(--spell-red); font-style: normal; font-weight: 900; white-space: nowrap; }
.spelling-section-choice b { color: var(--spell-red); font-size: 23px; }
.spelling-section-stage {
  margin-bottom: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--spell-gold);
  border-radius: 18px;
  background: linear-gradient(90deg, #fffdf5, #fff8dc);
}
.spelling-section-stage > span { min-width: 0; display: grid; gap: 4px; }
.spelling-section-stage strong { font-size: 20px; }
.spelling-section-stage small { color: var(--spell-muted); font-weight: 750; }
.spelling-section-back {
  min-height: 42px;
  padding: 0 14px;
  color: var(--spell-ink);
  border: 1px solid var(--spell-line);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.spelling-deck-grid { padding: 0 14px 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.spelling-deck-grid--stage { padding: 0; }
.spelling-deck-grid button {
  min-width: 0;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  color: var(--spell-ink);
  border: 1px solid var(--spell-line);
  border-radius: 14px;
  background: #fff;
  font: inherit;
  cursor: pointer;
}
.spelling-deck-grid button > span:last-child { min-width: 0; display: grid; gap: 4px; }
.spelling-deck-grid button strong { overflow-wrap: anywhere; }
.spelling-deck-grid button small { color: var(--spell-muted); font-weight: 760; }
.spelling-deck-grid button[aria-pressed="true"] { border-color: var(--spell-green); background: var(--spell-green-soft); }
.spelling-deck-check { flex: 0 0 auto; width: 19px; height: 19px; margin-top: 2px; display: grid; place-items: center; border: 2px solid var(--spell-gray); border-radius: 6px; }
.spelling-deck-grid button[aria-pressed="true"] .spelling-deck-check { border-color: var(--spell-green-dark); background: var(--spell-green-dark); box-shadow: inset 0 0 0 3px white; }
.spelling-library-empty { min-height: 180px; padding: 30px; display: grid; place-content: center; gap: 7px; text-align: center; color: var(--spell-muted); border: 1px dashed var(--spell-gold); border-radius: 18px; background: #fffdf5; }
.spelling-library-empty strong { color: var(--spell-ink); font: 800 22px/1.2 Georgia, serif; }

/* The practice sheet is a hard containment boundary on every device. */
.spelling-card { width: min(100%, 1100px); max-width: 100%; min-width: 0; overflow: hidden; box-sizing: border-box; }
.spelling-meaning-row { width: 100%; max-width: 100%; min-width: 0; flex-wrap: wrap; }
.spelling-meaning-row h1 { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; text-wrap: balance; }
.spelling-card.is-long .spelling-meaning-row h1 { font-size: clamp(28px, 4vw, 52px); }
.spelling-card.is-very-long .spelling-meaning-row h1 { font-size: clamp(23px, 3.1vw, 42px); line-height: 1.15; }
.spelling-card form,
.spelling-slots,
.spelling-line-mode { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
.spelling-slots { justify-content: center; align-items: flex-end; }
.spelling-token { max-width: 100%; min-width: 0; flex-wrap: nowrap; white-space: nowrap; }
.spelling-card.is-long .spelling-slot { width: clamp(22px, 4vw, 46px); font-size: clamp(23px, 3.2vw, 38px); }
.spelling-card.is-very-long .spelling-slot { width: clamp(15px, 3vw, 38px); min-width: 13px; font-size: clamp(18px, 2.7vw, 32px); }
.spelling-line-mode { display: grid; justify-items: center; }
.spelling-line-answer { width: min(100%, 900px); max-width: 100%; min-width: 0; }
.spelling-line-answer input { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
.spelling-line-answer input::placeholder {
  color: var(--spell-red);
  -webkit-text-fill-color: var(--spell-red);
  opacity: .82;
  letter-spacing: .28em;
}

@media (max-width: 900px) {
  .spelling-library__tabs { grid-template-columns: 1fr; }
  .spelling-section-menu { grid-template-columns: 1fr; }
  .spelling-deck-grid { grid-template-columns: 1fr 1fr; }
  .spelling-library__heading,
  .spelling-deck-explorer__top { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 640px) {
  .spelling-hero { min-height: 300px; background-position: 62% center; }
  .spelling-library,
  .spelling-deck-explorer { padding: 18px 13px; }
  .spelling-deck-grid { grid-template-columns: 1fr; }
  .spelling-section-choice { grid-template-columns: auto minmax(0, 1fr) auto; padding: 15px; }
  .spelling-section-choice b { display: none; }
  .spelling-section-stage { align-items: flex-start; }
  .spelling-section-card summary { align-items: flex-start; flex-wrap: wrap; }
  .spelling-section-card summary em { width: 100%; margin-left: 29px; }
  .spelling-card.is-very-long { padding-inline: 11px; }
  .spelling-card.is-very-long .spelling-slots { gap: 3px; }
  .spelling-card.is-very-long .spelling-token { gap: 2px; }
  .spelling-touch-keyboard { width: calc(100% + 8px); margin: 19px -4px 14px; padding: 9px 7px 11px; gap: 6px; border-radius: 13px; }
  .spelling-touch-keyboard__row { gap: 3px; }
  .spelling-touch-keyboard button { width: min(39px, calc((100% - 27px) / 10)); min-width: 0; height: 43px; border-radius: 5px; font-size: 15px; box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 2px 0 #080809, 0 3px 5px rgba(0,0,0,.28); }
  .spelling-touch-keyboard .spelling-touch-keyboard__delete { width: min(52px, calc((100% - 18px) / 7)); font-size: 20px; }
}

/* Records, collection search, completion states and quick practice modes. */
.spelling-view-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.spelling-record-tabs { margin-left: auto; }

.spelling-record-panel { transition: border-color .18s ease, background .18s ease; }
.spelling-record-panel.is-fully-complete {
  border-color: #4f9c72;
  background: linear-gradient(145deg, #fffdf5, #e7f7ec);
  box-shadow: 0 22px 54px rgba(53, 109, 89, .16);
}
.spelling-record-heading {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.spelling-record-heading h2 { margin: 0; font: 800 clamp(27px, 3vw, 39px)/1.1 Georgia, "Noto Serif TC", serif; }
.spelling-record-heading p:last-child { max-width: 720px; margin: 9px 0 0; color: var(--spell-muted); font-weight: 720; }
.spelling-record-heading__actions { display: flex; align-items: center; gap: 12px; }
.spelling-record-heading__actions > span { color: var(--spell-green-dark); font-weight: 950; }
.spelling-record-list { display: grid; gap: 10px; }
.spelling-record-row {
  padding: 15px 17px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--spell-line);
  border-radius: 16px;
  background: white;
}
.spelling-record-row.is-complete { border-color: #7abb98; background: #eff9f2; }
.spelling-record-state {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: #805213;
  border-radius: 50%;
  background: #fff1c7;
  font-weight: 950;
}
.spelling-record-row.is-complete .spelling-record-state { color: white; background: var(--spell-green-dark); }
.spelling-record-copy { min-width: 0; display: grid; gap: 3px; }
.spelling-record-copy strong { font-size: 18px; overflow-wrap: anywhere; }
.spelling-record-copy span { color: var(--spell-muted); font-weight: 750; }
.spelling-record-copy small { color: var(--spell-muted); overflow-wrap: anywhere; }
.spelling-record-counts { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.spelling-record-counts span,
.spelling-record-counts em { padding: 5px 9px; border-radius: 999px; font-size: 12px; font-style: normal; font-weight: 900; white-space: nowrap; }
.spelling-record-counts .is-correct { color: var(--spell-green-dark); background: #e3f3e9; }
.spelling-record-counts .is-wrong { color: #8b4d18; background: #fff0dd; }
.spelling-record-counts em { color: var(--spell-muted); background: #f2eee7; }
.spelling-record-row.is-complete .spelling-record-counts em { color: var(--spell-green-dark); background: #d6eddf; }
.spelling-record-row > button {
  min-height: 42px;
  padding: 0 14px;
  color: var(--spell-ink);
  border: 1px solid var(--spell-line);
  border-radius: 12px;
  background: white;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.spelling-deck-search-area { margin: 0 0 18px; }
.spelling-deck-search { display: grid; gap: 7px; }
.spelling-deck-search > span { font-size: 13px; font-weight: 950; }
.spelling-deck-search input {
  width: min(100%, 660px);
  min-height: 46px;
  padding: 0 17px;
  color: var(--spell-ink);
  border: 1px solid var(--spell-line);
  border-radius: 999px;
  background: white;
  font: inherit;
  font-weight: 760;
}
.spelling-deck-search input:focus { outline: 3px solid rgba(116, 173, 147, .24); border-color: var(--spell-green); }
.spelling-deck-search-results { margin-top: 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.spelling-deck-search-results:empty { display: none; }
.spelling-deck-search-result {
  min-width: 0;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  color: var(--spell-ink);
  border: 1px solid var(--spell-line);
  border-radius: 14px;
  background: white;
  font: inherit;
  cursor: pointer;
}
.spelling-deck-search-result > span:nth-child(2) { min-width: 0; display: grid; gap: 4px; }
.spelling-deck-search-result strong,
.spelling-deck-search-result small { overflow-wrap: anywhere; }
.spelling-deck-search-result small { color: var(--spell-muted); font-weight: 740; }
.spelling-deck-search-result em { color: var(--spell-red); font-size: 12px; font-style: normal; font-weight: 950; }
.spelling-deck-search-result[aria-pressed="true"] { border-color: #e2bb3f; background: #fff9cf; }
.spelling-deck-search-result.is-complete { border-color: #4f9c72; background: #e5f6eb; }
.spelling-deck-search-empty { grid-column: 1 / -1; margin: 0; padding: 13px 15px; color: var(--spell-muted); border: 1px dashed var(--spell-line); border-radius: 14px; }

.spelling-deck-grid button.is-complete,
.spelling-section-choice.is-complete {
  border-color: #4f9c72;
  background: linear-gradient(145deg, #effaf2, #dff3e6);
  box-shadow: inset 0 0 0 2px rgba(79, 156, 114, .14);
}
.spelling-deck-grid button.is-complete .spelling-deck-check,
.spelling-section-choice.is-complete .spelling-section-card__badge {
  color: white;
  border-color: var(--spell-green-dark);
  background: var(--spell-green-dark);
  box-shadow: none;
}
.spelling-section-choice.is-complete em { color: var(--spell-green-dark); }

.spelling-quick-modes {
  margin-top: 22px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--spell-gold);
  border-radius: 20px;
  background: linear-gradient(145deg, #fffdf5, #fff8dc);
}
.spelling-quick-modes__heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.spelling-quick-modes__heading h3 { margin: 0; font: 800 clamp(23px, 2.5vw, 32px)/1.15 Georgia, "Noto Serif TC", serif; }
.spelling-quick-modes__heading p:last-child { max-width: 720px; margin: 8px 0 0; color: var(--spell-muted); font-weight: 740; }
.spelling-quick-modes__heading > strong { color: var(--spell-red); white-space: nowrap; }
.spelling-quick-random { margin-top: 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.spelling-quick-random > span { margin-right: 4px; font-weight: 950; }
.spelling-quick-random button,
.spelling-quick-ranges button {
  min-height: 42px;
  padding: 0 14px;
  color: var(--spell-ink);
  border: 1px solid var(--spell-line);
  border-radius: 12px;
  background: white;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.spelling-quick-random button:hover,
.spelling-quick-ranges button:hover { border-color: #e2bb3f; background: var(--spell-yellow); }
.spelling-quick-random button:disabled,
.spelling-quick-ranges button:disabled { opacity: .4; cursor: not-allowed; }
.spelling-quick-ranges { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spelling-range-card { padding: 13px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; border: 1px solid var(--spell-line); border-radius: 15px; background: rgba(255,255,255,.75); }
.spelling-range-card > span { font-weight: 950; }
.spelling-range-card .spelling-dropdown { min-width: 0; }
.spelling-quick-status { min-height: 1.5em; margin: 12px 0 0; color: var(--spell-green-dark); font-weight: 900; }

@media (max-width: 900px) {
  .spelling-record-heading { align-items: flex-start; flex-direction: column; }
  .spelling-record-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .spelling-record-counts { grid-column: 2 / -1; grid-row: 2; justify-content: flex-start; }
  .spelling-record-row > button { grid-column: 3; grid-row: 1; }
  .spelling-deck-search-results,
  .spelling-quick-ranges { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .spelling-view-navigation,
  .spelling-view-tabs { width: 100%; }
  .spelling-view-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .spelling-record-tabs { margin-left: 0; }
  .spelling-record-heading__actions { width: 100%; align-items: stretch; flex-direction: column; }
  .spelling-record-row { grid-template-columns: auto minmax(0, 1fr); }
  .spelling-record-row > button { grid-column: 1 / -1; grid-row: auto; }
  .spelling-record-counts { grid-column: 1 / -1; grid-row: auto; justify-content: flex-start; }
  .spelling-deck-search-results { grid-template-columns: 1fr; }
  .spelling-quick-modes__heading { align-items: flex-start; flex-direction: column; }
  .spelling-range-card { grid-template-columns: 1fr; }
  .spelling-quick-ranges button { width: 100%; }
}
