:root {
  color-scheme: light;
  --ink: #18232d;
  --muted: #62707e;
  --page: #f5f6f1;
  --paper: #ffffff;
  --line: #d9e1df;
  --soft: #edf3f2;
  --teal: #176f68;
  --teal-dark: #0e514c;
  --coral: #d85f4a;
  --blue: #2877aa;
  --green: #34794d;
  --gold: #e0a930;
  --purple: #6f5aa8;
  --right-bg: #e8f5ec;
  --wrong-bg: #fff0ec;
  --focus: #f0bc42;
  --shadow: 0 18px 42px rgba(22, 35, 45, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "PingFang TC",
    "Microsoft JhengHei", Arial, sans-serif;
  line-height: 1.5;
}

body.auth-pending,
body.authenticated {
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  min-height: 100vh;
  overflow: auto;
  padding: 22px;
  isolation: isolate;
}

.auth-background,
.auth-shade {
  position: absolute;
  inset: 0;
}

.auth-background {
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.auth-shade {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(255, 252, 244, 0.28), rgba(255, 252, 244, 0.1)),
    linear-gradient(0deg, rgba(21, 32, 38, 0.25), rgba(21, 32, 38, 0.04));
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: clamp(22px, 5vw, 32px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.auth-card .eyebrow {
  color: var(--teal-dark);
}

.auth-card h1 {
  max-width: none;
  margin: 0 0 4px;
  color: var(--ink);
  font-size: clamp(2.1rem, 7vw, 3.1rem);
  line-height: 1;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 800;
}

.auth-card input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  font-weight: 500;
}

.auth-card button {
  width: 100%;
  margin-top: 2px;
}

.auth-message {
  min-height: 1.4em;
  margin: 0;
  color: var(--coral);
  font-size: 0.94rem;
  font-weight: 800;
}

.page-shell {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 52px;
}

.hero {
  position: relative;
  min-height: clamp(220px, 26vw, 300px);
  overflow: hidden;
  border-radius: 8px;
  background: #23323c;
  box-shadow: var(--shadow);
}

.hero-image,
.hero-shade {
  position: absolute;
  inset: 0;
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-shade {
  background:
    linear-gradient(90deg, rgba(14, 26, 33, 0.78), rgba(14, 26, 33, 0.36) 46%, rgba(14, 26, 33, 0.04)),
    linear-gradient(0deg, rgba(14, 26, 33, 0.22), transparent 44%);
}

.hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  min-height: inherit;
  width: min(760px, 100%);
  padding: clamp(22px, 4vw, 42px);
  color: #ffffff;
}

.eyebrow,
.kicker {
  margin: 0;
  color: inherit;
  font-size: 0.88rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #ffe7a6;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  max-width: 10ch;
  margin: 9px 0 0;
  font-size: clamp(2.7rem, 7vw, 5.8rem);
  line-height: 0.96;
}

.hero h1 {
  max-width: none;
  font-size: clamp(2.2rem, 5vw, 4rem);
}

.today-line {
  max-width: 30rem;
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(0.98rem, 1.5vw, 1.12rem);
}

.hero-actions,
.action-row,
.reader-actions,
.quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: min(860px, 100%);
  gap: 8px;
  margin-top: 16px;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 9px 14px;
}

button span[aria-hidden="true"] {
  display: inline-block;
  min-width: 1.1em;
  text-align: center;
}

button.primary,
.book-card .open-button,
.quiz-submit {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.hero-actions button {
  min-width: 0;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  padding: 9px 12px;
  text-decoration: none;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.hero-actions button.primary {
  background: #ffffff;
  color: var(--teal-dark);
}

.game-entry-button,
.puzzle-entry-button,
.parrot-entry-button {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff3a8 0%, #8ee98b 48%, #5bc6ff 100%);
  color: #073f3f !important;
  padding: 11px 18px;
  text-decoration: none !important;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 12px 28px rgba(18, 98, 89, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.game-entry-button {
  background: linear-gradient(135deg, #ffe1a8 0%, #7bd7c6 52%, #7c9df2 100%);
}

.puzzle-entry-button {
  background: linear-gradient(135deg, #fff3a8 0%, #f49a78 46%, #7bd7c6 100%);
}

.game-entry-button span[aria-hidden="true"],
.puzzle-entry-button span[aria-hidden="true"],
.parrot-entry-button span[aria-hidden="true"] {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.pet-reward-count {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #073f3f;
  color: #fff;
  padding: 0 6px;
  font-size: 12px;
}

.game-entry-button:hover,
.game-entry-button:focus-visible,
.puzzle-entry-button:hover,
.puzzle-entry-button:focus-visible,
.parrot-entry-button:hover,
.parrot-entry-button:focus-visible {
  transform: translateY(-2px);
  outline: 3px solid rgba(255, 243, 168, 0.42);
}

.hero-actions .hero-game-entry,
.hero-actions .hero-puzzle-entry,
.hero-actions .hero-parrot-entry {
  min-width: 0;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  padding: 9px 12px;
  color: #073f3f !important;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(18, 31, 39, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.hero-actions .hero-game-entry span[aria-hidden="true"],
.hero-actions .hero-puzzle-entry span[aria-hidden="true"],
.hero-actions .hero-parrot-entry span[aria-hidden="true"] {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
}

.hero-actions .pet-reward-count {
  min-width: 20px;
  height: 20px;
  padding-inline: 5px;
  font-size: 11px;
}

.hero-actions .tasks-progress {
  min-width: 34px;
  margin-left: auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  padding: 2px 7px;
  color: inherit;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.tasks-card {
  width: min(700px, 100%);
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 8px;
  background: rgba(8, 38, 38, 0.62);
  color: #ffffff;
  backdrop-filter: blur(10px);
}

.tasks-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.tasks-card-head span,
.tasks-card > small {
  color: rgba(255, 255, 255, 0.84);
}

.tasks-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tasks-list button {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.12);
  padding: 8px 10px;
  color: #ffffff;
  text-align: left;
  white-space: normal;
}

.tasks-list button:hover,
.tasks-list button:focus-visible {
  background: rgba(255, 255, 255, 0.2);
}

.tasks-list .task-status {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 900;
}

.tasks-list li.done .task-status {
  background: #dff5e8;
  color: var(--green);
}

.tasks-list li.bonus button {
  border-color: rgba(255, 231, 166, 0.72);
  background: rgba(224, 169, 48, 0.18);
}

.tasks-list li.bonus .task-status {
  background: #fff0bb;
  color: #805a00;
}

.tasks-list li.locked button {
  cursor: not-allowed;
  opacity: 0.66;
}

.tasks-list .task-label {
  min-width: 0;
  line-height: 1.25;
}

.auth-game-entry,
.auth-puzzle-entry,
.auth-parrot-entry {
  width: 100%;
}

.stats-band {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  overflow: hidden;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.stats-band div {
  min-width: 0;
  padding: 15px 18px;
  background: var(--paper);
}

.stats-band span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.stats-band strong {
  display: block;
  margin-top: 3px;
  color: var(--teal-dark);
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.08;
}

.pet-study-bridge {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid #bedbd2;
  border-radius: 8px;
  background: #e9f8ef;
}

.pet-study-bridge__avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffffff;
  font-size: 24px;
}

.pet-study-bridge strong {
  color: var(--teal-dark);
}

.pet-study-bridge p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.pet-study-bridge a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #ffffff;
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 800;
}

.app-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 22px;
  align-items: start;
}

body.rail-collapsed .app-grid {
  grid-template-columns: minmax(0, 1fr);
}

body.rail-collapsed .rail {
  display: none;
}

.rail {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
  min-width: 0;
  max-height: calc(100svh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.tool-panel,
.reader-sheet,
.quiz-sheet,
.parent-sheet {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.tool-panel {
  min-width: 0;
  padding: 16px;
}

.panel-head,
.section-head,
.reader-head,
.quiz-head,
.parent-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tool-panel h2,
.section-head h2,
.reader-head h2,
.quiz-head h2,
.parent-head h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.2;
}

.small-button {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 0.88rem;
}

.status-note {
  min-height: 1.4em;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip-row button,
.word-chip {
  min-height: 34px;
  border-color: var(--line);
  background: var(--soft);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 0.92rem;
}

.chip-row button[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.filter-stack {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin-top: 12px;
}

.rail-search {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 0.92rem;
}

.filter-stack .chip-row {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 0;
}

.topic-filter-details {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.topic-filter-details summary {
  cursor: pointer;
  color: var(--teal-dark);
  font-weight: 800;
}

.workspace {
  min-width: 0;
}

.mobile-controls-toggle {
  display: none;
}

.mobile-controls-close {
  display: none;
}

.mode-tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 14px;
  background: rgba(245, 246, 241, 0.94);
  backdrop-filter: blur(10px);
}

.mode-tabs button {
  min-width: 94px;
  white-space: nowrap;
}

.mode-tabs button[aria-selected="true"] {
  border-color: var(--teal);
  background: var(--teal-dark);
  color: #ffffff;
}

body.raz-focus-mode .mode-tabs,
body.raz-focus-mode .raz-dashboard > .section-head,
body.raz-focus-mode .raz-summary,
body.raz-focus-mode .raz-library-details,
body.raz-focus-mode .raz-book-list,
body.raz-focus-mode .raz-extra-section,
body.raz-focus-mode .raz-extra-audio {
  display: none;
}

.view-panel {
  min-width: 0;
}

.section-head {
  margin-bottom: 16px;
}

.kicker {
  margin-bottom: 4px;
  color: var(--teal-dark);
}

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

.album-view {
  display: grid;
  gap: 18px;
}

.album-heading {
  align-items: end;
  margin-bottom: 0;
}

.album-heading > div > p:last-child {
  max-width: 660px;
  margin: 7px 0 0;
  color: var(--muted);
}

.album-level-picker {
  display: grid;
  gap: 5px;
  min-width: 160px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.album-level-picker select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 8px 34px 8px 10px;
  font: inherit;
}

.album-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-block: 1px solid var(--line);
}

.album-summary div {
  display: grid;
  gap: 2px;
  padding: 13px 16px;
  border-right: 1px solid var(--line);
}

.album-summary div:last-child {
  border-right: 0;
}

.album-summary span {
  color: var(--muted);
  font-size: 0.84rem;
}

.album-summary strong {
  font-size: 1.35rem;
}

.album-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.album-toolbar button {
  min-height: 38px;
  padding: 7px 12px;
}

.album-toolbar button[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--teal-dark);
  color: #ffffff;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.album-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.album-art {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #dfe7e4;
}

.album-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.album-card--locked .album-art img {
  filter: grayscale(1) blur(8px);
  opacity: 0.42;
  transform: scale(1.08);
}

.album-card--ready .album-art img {
  filter: saturate(0.72);
}

.album-status {
  position: absolute;
  top: 10px;
  left: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 900;
}

.album-card--collected .album-status {
  background: #e8f5ec;
  color: #215d35;
}

.album-card--ready .album-status {
  background: #fff3c8;
  color: #684b00;
}

.album-lock {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  font-size: 1.45rem;
  transform: translate(-50%, -50%);
}

.album-card__body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.album-card__body .kicker {
  margin: 0 0 3px;
  font-size: 0.8rem;
}

.album-card__body h3 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.25;
}

.album-card__body > button {
  width: 100%;
}

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

.album-records span {
  display: grid;
  padding: 7px 8px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.76rem;
}

.album-records b {
  color: var(--ink);
  font-size: 0.98rem;
}

.album-hint,
.album-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.album-empty {
  grid-column: 1 / -1;
  padding: 28px 0;
  border-block: 1px solid var(--line);
  text-align: center;
}

.raz-dashboard {
  display: grid;
  gap: 16px;
}

.raz-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.raz-summary div {
  padding: 14px;
  background: var(--paper);
}

.raz-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.raz-summary strong {
  display: block;
  margin-top: 3px;
  color: var(--teal-dark);
  font-size: 1.45rem;
  line-height: 1.1;
}

.raz-library-details {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.raz-library-details summary {
  cursor: pointer;
  color: var(--teal-dark);
  font-weight: 800;
}

.raz-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 2fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.raz-search {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 12px;
}

.raz-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.88fr) minmax(0, 1.42fr);
  gap: 16px;
  align-items: start;
}

body.raz-focus-mode .raz-layout {
  grid-template-columns: minmax(0, 1fr);
}

.raz-book-list {
  display: grid;
  gap: 10px;
  max-height: 760px;
  overflow: auto;
  padding-right: 4px;
}

.raz-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.raz-card[aria-current="true"] {
  border-color: var(--teal);
  box-shadow: inset 4px 0 0 var(--teal);
}

.raz-card h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
}

.raz-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.raz-card-actions,
.raz-resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.raz-card-actions button {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.9rem;
}

.raz-resource-links a,
.raz-card-actions a,
.raz-extra-list a,
.quiz-actions a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 7px 10px;
  text-decoration: none;
  font-size: 0.9rem;
}

.raz-resource-links.compact a {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 0.84rem;
}

.raz-reader {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 16px;
}

body.raz-focus-mode .raz-reader {
  padding: clamp(14px, 2vw, 22px);
}

.raz-reader audio {
  width: 100%;
}

.reader-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.study-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 10px;
}

.study-actions a,
.study-actions button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 9px 12px;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
}

.study-actions .primary-link {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.pdf-panel {
  display: grid;
  gap: 10px;
}

.pdf-panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.pdf-panel-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.pdf-panel-head a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 7px 10px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
}

.raz-quiz-panel {
  display: grid;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.raz-quiz-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.raz-quiz-head h3 {
  margin: 2px 0 0;
  font-size: 1.22rem;
}

.raz-quiz-head strong {
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--teal-dark);
  white-space: nowrap;
}

.raz-quiz-form,
.raz-quiz-questions,
.raz-extended-list {
  display: grid;
  gap: 12px;
}

.raz-quiz-progress {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--teal-dark);
  font-weight: 800;
}

.raz-quiz-question {
  margin: 0;
}

.answers label.answer-right {
  border-color: rgba(52, 121, 77, 0.5);
  background: var(--right-bg);
}

.raz-extended-list {
  padding-top: 4px;
}

.raz-extended-list h4 {
  margin: 0;
  font-size: 1rem;
}

.raz-extended-question {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.raz-extended-question label {
  font-weight: 800;
}

.raz-extended-question textarea {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
}

.raz-pdf-frame {
  width: 100%;
  height: min(72vh, 780px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.raz-empty {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
}

.raz-extra-audio {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.raz-extra-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.raz-extra-audio h3,
.raz-extra-section h3 {
  margin: 0;
  font-size: 1rem;
}

.raz-extra-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.raz-extra-list audio {
  width: 230px;
  max-width: 100%;
}

.raz-extra-files {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.raz-extra-files summary {
  cursor: pointer;
  color: var(--teal-dark);
  font-weight: 700;
}

.raz-extra-files .raz-resource-links {
  margin-top: 10px;
}

.raz-packet-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.raz-packet {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.raz-packet:nth-child(-n + 2) {
  padding-top: 0;
  border-top: 0;
}

.raz-packet audio {
  width: 100%;
}

.book-card {
  display: grid;
  grid-template-columns: 124px 1fr;
  gap: 16px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.book-cover {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  min-height: 154px;
  overflow: hidden;
  border-radius: 8px;
  color: #ffffff;
  isolation: isolate;
}

.book-cover::before,
.book-cover::after {
  position: absolute;
  content: "";
  z-index: -1;
}

.book-cover::before {
  inset: 0;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.22), transparent 42%);
}

.book-cover::after {
  right: -28px;
  bottom: -28px;
  width: 96px;
  height: 96px;
  border: 18px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
}

.tone-coral {
  background: var(--coral);
}

.tone-blue {
  background: var(--blue);
}

.tone-green {
  background: var(--green);
}

.tone-purple {
  background: var(--purple);
}

.cover-mark {
  font-size: 3.4rem;
  font-weight: 900;
  line-height: 1;
}

.book-info {
  min-width: 0;
}

.book-info h3 {
  margin: 0;
  font-size: 1.2rem;
}

.book-meta,
.mini-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.book-meta span,
.mini-meta span {
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--soft);
}

.book-info p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  margin: 12px 0 11px;
  border-radius: 999px;
  background: #e3e8e5;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.book-actions button {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.92rem;
}

.story-puzzle-button {
  border-color: #d8a027;
  background: #fff8df;
  color: #694900;
  font-weight: 800;
}

.story-puzzle-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.reader-sheet,
.quiz-sheet,
.parent-sheet {
  padding: clamp(16px, 3vw, 24px);
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 20px;
  margin-top: 18px;
}

.story-page {
  min-height: 330px;
  padding: clamp(18px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
}

.page-count {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.story-page h3 {
  margin: 0 0 16px;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  line-height: 1.1;
}

.story-text {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.78rem);
  line-height: 1.8;
}

mark {
  border-radius: 5px;
  background: #ffe59a;
  color: inherit;
  padding: 0 0.08em;
}

.vocab-box {
  display: grid;
  gap: 10px;
  align-content: start;
  border-left: 4px solid var(--gold);
  padding-left: 14px;
}

.vocab-box h3 {
  margin: 0;
  font-size: 1rem;
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-chip {
  border: 1px solid var(--line);
}

.reader-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
}

.page-dots {
  display: flex;
  gap: 7px;
}

.page-dots button {
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  height: 24px;
  border-radius: 999px;
  padding: 0;
  color: transparent;
}

.page-dots button[aria-current="page"] {
  border-color: var(--teal);
  background: var(--teal);
}

.quiz-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.question {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.question.correct {
  border-color: rgba(52, 121, 77, 0.45);
  background: var(--right-bg);
}

.question.incorrect {
  border-color: rgba(216, 95, 74, 0.55);
  background: var(--wrong-bg);
}

.question legend {
  padding: 0;
  font-weight: 800;
}

.answers {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.answers label {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.answers input {
  margin-top: 3px;
  accent-color: var(--teal);
}

.feedback {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.quiz-result {
  margin: 0;
  color: var(--teal-dark);
  font-size: 1.05rem;
  font-weight: 800;
}

.parent-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.parent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.parent-focus {
  display: grid;
  gap: 3px;
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--gold);
  background: #fff8df;
}

.parent-focus span {
  color: var(--muted);
  font-size: 0.88rem;
}

.parent-focus strong {
  color: var(--teal-dark);
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.metric strong {
  display: block;
  margin-top: 3px;
  color: var(--teal-dark);
  font-size: 1.55rem;
  line-height: 1.1;
}

.reward-panel {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.reward-panel h3,
.reward-card h4 {
  margin: 0;
}

.reward-head,
.redemption-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.reward-head strong {
  color: var(--teal-dark);
  white-space: nowrap;
}

.reward-shop {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.reward-card {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.reward-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.reward-card button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.raz-level-report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.level-report-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.level-report-card h4 {
  margin: 0;
}

.level-report-metrics {
  display: grid;
  gap: 7px;
}

.level-report-metrics span {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
}

.level-report-metrics strong {
  color: var(--teal-dark);
  text-align: right;
}

.level-status-list {
  display: grid;
  gap: 10px;
}

.level-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.level-status summary {
  cursor: pointer;
  padding: 11px 12px;
  color: var(--teal-dark);
  font-weight: 800;
}

.level-status .progress-table {
  margin: 0;
  border-width: 1px 0 0;
  border-radius: 0 0 8px 8px;
}

.parent-compact-table {
  margin-top: 0;
  font-size: 0.92rem;
}

.skill-stat-list,
.wrong-question-list,
.wrong-review-form {
  display: grid;
  gap: 10px;
}

.skill-stat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.skill-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.skill-stat meter {
  width: 100%;
  height: 12px;
}

.wrong-question-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.wrong-question-card p,
.wrong-review-form .feedback {
  margin: 0;
}

.question-skill {
  margin: 4px 0 10px;
  color: var(--teal-dark);
  font-size: 0.88rem;
  font-weight: 800;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge-list span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 800;
}

.badge-list span.earned {
  border-color: rgba(224, 169, 48, 0.5);
  background: #fff6d9;
  color: #72530d;
}

.redemption-list {
  display: grid;
  gap: 8px;
}

.redemption-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.redemption-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9rem;
}

.reward-ledger {
  margin-top: 0;
}

.progress-table {
  width: 100%;
  margin-top: 18px;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.progress-table th,
.progress-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.progress-table th {
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-table tr:last-child td {
  border-bottom: 0;
}

.recommendation {
  margin: 18px 0 0;
  padding: 14px;
  border-left: 4px solid var(--coral);
  background: #fff7f4;
}

.recommendation h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.recommendation p {
  margin: 0;
  color: var(--muted);
}

.reward-celebration {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  width: min(430px, calc(100% - 28px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid #b4d9c5;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 46px rgba(15, 65, 58, 0.24);
  animation: reward-in 220ms ease-out both;
}

.reward-celebration__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff3b5;
  font-size: 26px;
}

.reward-celebration p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.reward-celebration__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.reward-celebration__actions a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #ffffff;
  padding: 7px 10px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.reward-celebration__actions button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 1.35rem;
}

@keyframes reward-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .app-grid,
  .reader-layout,
  .raz-layout {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
    padding-right: 0;
    scrollbar-gutter: auto;
  }

  .book-grid {
    grid-template-columns: 1fr;
  }

  .raz-packet-list {
    grid-template-columns: 1fr;
  }

  .raz-packet:nth-child(2) {
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  .raz-book-list {
    max-height: none;
  }

  .raz-extra-section,
  .raz-extra-audio {
    display: none;
  }
}

@media (max-width: 720px) {
  body.mobile-controls-open {
    overflow: hidden;
  }

  body.mobile-controls-open::before {
    position: fixed;
    inset: 0;
    z-index: 28;
    content: "";
    background: rgba(11, 28, 34, 0.42);
  }

  .page-shell {
    width: min(100% - 20px, 1220px);
    padding: 10px 0 92px;
  }

  .hero {
    min-height: 250px;
  }

  .hero-image {
    object-position: 52% center;
  }

  .hero-shade {
    background: linear-gradient(0deg, rgba(14, 26, 33, 0.78), rgba(14, 26, 33, 0.16) 68%);
  }

  .hero-content {
    align-content: center;
    padding: 20px;
  }

  .hero h1 {
    max-width: 11ch;
    font-size: clamp(2.1rem, 11vw, 3rem);
  }

  .today-line {
    margin-top: 8px;
  }

  .hero-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tasks-list {
    grid-template-columns: 1fr;
  }

  .stats-band {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border: 0;
    background: transparent;
    scrollbar-width: thin;
  }

  .stats-band div {
    flex: 0 0 142px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
  }

  .stats-band strong {
    font-size: 1.42rem;
  }

  .pet-study-bridge {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
  }

  .pet-study-bridge a {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .app-grid {
    display: flex;
    flex-direction: column;
  }

  .workspace {
    order: 1;
  }

  .raz-summary {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .album-level-picker {
    width: 100%;
  }

  .album-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .album-summary div:nth-child(2) {
    border-right: 0;
  }

  .album-summary div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .raz-controls {
    grid-template-columns: 1fr;
  }

  .rail {
    position: fixed;
    inset: auto 10px 72px;
    z-index: 30;
    order: 2;
    display: none;
    grid-template-columns: 1fr;
    max-height: min(72svh, 620px);
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--page);
    box-shadow: var(--shadow);
  }

  body.mobile-controls-open .rail {
    display: grid;
  }

  .mobile-controls-close {
    display: block;
    border-color: var(--teal);
    color: var(--teal-dark);
    font-weight: 800;
  }

  .mobile-controls-toggle {
    position: sticky;
    top: 8px;
    z-index: 4;
    display: inline-flex;
    width: 100%;
    justify-content: center;
    margin-bottom: 10px;
    border-color: var(--teal);
    color: var(--teal-dark);
    font-weight: 800;
  }

  .filter-stack .chip-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 3px;
  }

  .topic-filter-details[open] {
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 4px;
  }

  .topic-filter-details[open] .chip-row {
    width: max-content;
    max-width: none;
  }

  .filter-stack .chip-row button {
    flex: 0 0 auto;
  }

  .book-card {
    grid-template-columns: 92px 1fr;
    gap: 12px;
    padding: 12px;
  }

  .book-cover {
    min-height: 116px;
  }

  .cover-mark {
    font-size: 2.5rem;
  }

  .reader-footer {
    grid-template-columns: 1fr;
  }

  .mode-tabs {
    position: fixed;
    inset: auto 10px 8px;
    z-index: 31;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    overflow: visible;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 28px rgba(22, 35, 45, 0.18);
  }

  .mode-tabs button {
    min-width: 0;
    padding-inline: 3px;
    font-size: 0.82rem;
  }

  .raz-pdf-frame {
    height: 62vh;
  }

  .study-actions {
    grid-template-columns: 1fr;
  }

  .raz-reader audio {
    position: sticky;
    top: 56px;
    z-index: 2;
    border-radius: 8px;
    background: var(--paper);
  }

  .raz-quiz-head {
    grid-template-columns: 1fr;
  }

  .raz-quiz-head strong {
    justify-self: start;
  }

  .reader-actions,
  .quiz-actions,
  .action-row {
    width: 100%;
  }

  .reader-actions button,
  .quiz-actions button,
  .action-row button {
    flex: 1 1 135px;
  }

  .parent-grid {
    grid-template-columns: 1fr;
  }

  .parent-head,
  .parent-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .raz-level-report-grid,
  .skill-stat {
    grid-template-columns: 1fr;
  }

  .reward-shop {
    grid-template-columns: 1fr;
  }

  .reward-head,
  .redemption-item {
    align-items: stretch;
    flex-direction: column;
  }

  .progress-table {
    display: block;
    overflow-x: auto;
  }

  .reward-celebration {
    right: 14px;
    bottom: 82px;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .reward-celebration__actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .hero,
  .stats-band,
  .rail,
  .mode-tabs,
  .section-head,
  .raz-controls,
  .raz-summary,
  .raz-book-list,
  .raz-resource-links,
  .reader-actions,
  .quiz-actions,
  .page-dots,
  .vocab-box,
  .status-note {
    display: none !important;
  }

  .page-shell {
    width: 100%;
    padding: 0;
  }

  .app-grid,
  .reader-layout {
    display: block;
  }

  .reader-sheet,
  .story-page {
    border: 0;
    padding: 0;
  }
}
