:root {
  --ink: #233047;
  --ink-soft: #5b6a7d;
  --paper: #f4efe5;
  --paper-strong: #fffdf8;
  --panel: rgba(255, 251, 245, 0.88);
  --line: rgba(35, 48, 71, 0.12);
  --line-strong: rgba(35, 48, 71, 0.24);
  --accent: #1f5ea8;
  --ai-cyan: #13b8d7;
  --ai-lime: #88d95a;
  --ai-violet: #6d5dfc;
  --tech-cyan: #1bb8de;
  --tech-violet: #7e6dff;
  --tech-border: rgba(27, 184, 222, 0.16);
  --tech-panel: rgba(255, 255, 255, 0.74);
  --tech-glow: 0 18px 48px rgba(27, 184, 222, 0.14);
  --accent-soft: #dbe8f7;
  --gold: #b58a49;
  --shadow: 0 28px 80px rgba(35, 48, 71, 0.12);
  --radius-xl: 32px;
  --radius-lg: 22px;
  --radius-md: 14px;
  --sheet-square: 86px;
  --sheet-gap: 12px;
  --max-width: 1200px;
  --practice-grid-white: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='1.5' y='1.5' width='97' height='97' fill='white' stroke='%23c8d1de' stroke-width='3'/%3E%3Cline x1='50' y1='0' x2='50' y2='100' stroke='%23c2cad6' stroke-width='2'/%3E%3Cline x1='0' y1='50' x2='100' y2='50' stroke='%23c2cad6' stroke-width='2'/%3E%3Cline x1='25' y1='0' x2='25' y2='100' stroke='%23ccd3de' stroke-width='1.7' stroke-dasharray='6 5'/%3E%3Cline x1='75' y1='0' x2='75' y2='100' stroke='%23ccd3de' stroke-width='1.7' stroke-dasharray='6 5'/%3E%3Cline x1='0' y1='25' x2='100' y2='25' stroke='%23ccd3de' stroke-width='1.7' stroke-dasharray='6 5'/%3E%3Cline x1='0' y1='75' x2='100' y2='75' stroke='%23ccd3de' stroke-width='1.7' stroke-dasharray='6 5'/%3E%3C/svg%3E");
  --practice-grid-blue: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='1.5' y='1.5' width='97' height='97' fill='%236ea3e8' stroke='%234a79c0' stroke-width='3'/%3E%3Cline x1='50' y1='0' x2='50' y2='100' stroke='%23ffffff' stroke-opacity='0.38' stroke-width='2.2'/%3E%3Cline x1='0' y1='50' x2='100' y2='50' stroke='%23ffffff' stroke-opacity='0.38' stroke-width='2.2'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(181, 138, 73, 0.14), transparent 28%),
    radial-gradient(circle at right top, rgba(31, 94, 168, 0.12), transparent 24%),
    linear-gradient(180deg, #f7f3ea 0%, #f0e9dd 100%);
  font-family: "Work Sans", "Avenir Next", "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(35, 48, 71, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 48, 71, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  z-index: -2;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.site-shell {
  position: relative;
}

.container {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto;
}

.narrow {
  max-width: 820px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 243, 234, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(35, 48, 71, 0.08);
}

.nav-row {
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "nav toggle";
  align-items: start;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-empty {
  min-width: 1px;
  min-height: 1px;
}

.header-pill {
  display: none !important;
}

.header-pill:not(.ai-pill) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(27, 184, 222, 0.09)),
    rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(27, 184, 222, 0.12);
  box-shadow: 0 10px 28px rgba(27, 184, 222, 0.08);
  color: #7d8ca0;
}

.header-pill.ai-pill,
.ai-eyebrow {
  color: #12536f;
  background:
    linear-gradient(135deg, rgba(19, 184, 215, 0.2), rgba(136, 217, 90, 0.16)),
    rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(19, 184, 215, 0.22);
  box-shadow: 0 12px 34px rgba(19, 184, 215, 0.12);
}

.strokes-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.strokes-title-row h1 {
  margin: 0;
}

.strokes-map-button {
  flex: 0 0 auto;
  margin-top: 6px;
}

.strokes-map-page {
  width: min(calc(100% - 32px), 1220px);
  margin: 0 auto;
  padding: 32px 0 48px;
}

.strokes-map-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 22px;
}

.strokes-map-toolbar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
}

.strokes-map-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.strokes-map-frame {
  padding: 18px;
  border: 1px solid rgba(35, 48, 71, 0.12);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}

.strokes-map-frame img {
  width: 100%;
  height: auto;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), #2b7ad0);
  color: #fff;
  font-family: "Noto Serif SC", serif;
  font-size: 1.45rem;
  box-shadow: 0 16px 32px rgba(31, 94, 168, 0.22);
}

.brand strong,
h1,
h2,
h3,
.worksheet-character {
  font-family: "Libre Baskerville", "Noto Serif SC", serif;
}

.brand span:last-child {
  display: grid;
  gap: 2px;
}

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

.site-nav {
  grid-area: nav;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  justify-content: flex-start;
}

.language-toggle {
  grid-area: toggle;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(27, 184, 222, 0.14);
  box-shadow: 0 10px 24px rgba(35, 48, 71, 0.06);
}

.language-toggle button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}

.language-toggle button.is-active {
  background: linear-gradient(135deg, rgba(27, 184, 222, 0.18), rgba(126, 109, 255, 0.14));
  color: var(--ink);
}

html[dir="rtl"] body {
  text-align: right;
}

html[dir="rtl"] .toolbar-actions,
html[dir="rtl"] .worksheet-actions,
html[dir="rtl"] .ai-feature-strip,
html[dir="rtl"] .ai-listen-actions {
  flex-direction: row-reverse;
}

html[dir="rtl"] .site-nav {
  justify-content: flex-start;
  flex-direction: row;
}

html[dir="rtl"] .game-hero,
html[dir="rtl"] .game-topics-head,
html[dir="rtl"] .game-board-head,
html[dir="rtl"] .game-status-card {
  text-align: right;
}

html[dir="rtl"] .game-topic-button {
  text-align: right;
}

html[dir="rtl"] .game-prompt-copy,
html[dir="rtl"] .game-feedback,
html[dir="rtl"] .game-status-text {
  text-align: center;
}

html[dir="rtl"] .pronunciation-engine-card,
html[dir="rtl"] .generator-panel,
html[dir="rtl"] .measure-search-card,
html[dir="rtl"] .measure-result-card,
html[dir="rtl"] .measure-reference-card,
html[dir="rtl"] .pinyin-legend-card,
html[dir="rtl"] .pinyin-card,
html[dir="rtl"] .strokes-card,
html[dir="rtl"] .lesson-card,
html[dir="rtl"] .worksheet-copy,
html[dir="rtl"] .word-results-page,
html[dir="rtl"] .dialogue-card,
html[dir="rtl"] .lesson-note {
  text-align: right;
}

html[dir="rtl"] .measure-search-card {
  grid-template-columns: auto minmax(260px, 1fr) auto;
}

html[dir="rtl"] .pronunciation-chinese,
html[dir="rtl"] .pronunciation-pinyin,
html[dir="rtl"] .ai-listen-dialog h2,
html[dir="rtl"] .ai-listen-pinyin,
html[dir="rtl"] .worksheet-character-row,
html[dir="rtl"] .worksheet-character,
html[dir="rtl"] .worksheet-pinyin,
html[dir="rtl"] .word-results-word,
html[dir="rtl"] .word-results-pinyin,
html[dir="rtl"] .dialogue-lines,
html[dir="rtl"] .dialogue-lines p,
html[dir="rtl"] .lesson-reading-text,
html[dir="rtl"] .stroke-copy h2,
html[dir="rtl"] .measure-word-highlight,
html[dir="rtl"] .measure-classifier-highlight,
html[dir="rtl"] .measure-pinyin {
  direction: ltr;
  text-align: left;
}

html[dir="rtl"] .lesson-reading-text,
html[dir="rtl"] .dialogue-lines p,
html[dir="rtl"] .dialogue-lines em {
  unicode-bidi: plaintext;
}

.site-nav a {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.site-nav a:not(.ai-nav-link):not(.ai-numbers-link) {
  border: 1px solid rgba(27, 184, 222, 0.08);
  background: rgba(255, 255, 255, 0.32);
}

.site-nav a:hover,
.site-nav a.is-active {
  background: rgba(31, 94, 168, 0.1);
  color: var(--ink);
  transform: translateY(-1px);
}

.site-nav a:not(.ai-nav-link):not(.ai-numbers-link):hover,
.site-nav a:not(.ai-nav-link):not(.ai-numbers-link).is-active {
  background:
    linear-gradient(135deg, rgba(27, 184, 222, 0.14), rgba(126, 109, 255, 0.08)),
    rgba(255, 255, 255, 0.6);
  border-color: rgba(27, 184, 222, 0.22);
  box-shadow: 0 12px 26px rgba(27, 184, 222, 0.12);
}

.site-nav .ai-nav-link {
  position: relative;
  color: #145a74;
  background: linear-gradient(135deg, rgba(19, 184, 215, 0.12), rgba(136, 217, 90, 0.1));
  border: 1px solid rgba(19, 184, 215, 0.16);
}

.site-nav .ai-nav-link::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 7px;
  display: inline-block;
  border-radius: 999px;
  background: var(--ai-lime);
  box-shadow: 0 0 0 5px rgba(136, 217, 90, 0.14), 0 0 14px rgba(19, 184, 215, 0.44);
}

.site-nav .ai-nav-link:hover,
.site-nav .ai-nav-link.is-active {
  color: #07384e;
  background: linear-gradient(135deg, rgba(19, 184, 215, 0.22), rgba(136, 217, 90, 0.18));
}

.site-nav .ai-numbers-link {
  position: relative;
  order: 99;
  flex: 0 0 auto;
  width: fit-content;
  align-self: flex-start;
  color: #7a4b05;
  background: linear-gradient(135deg, rgba(255, 178, 43, 0.18), rgba(19, 184, 215, 0.1));
  border: 1px solid rgba(255, 178, 43, 0.22);
}

.site-nav .ai-numbers-link::before {
  content: "01";
  margin-right: 7px;
  padding: 2px 5px;
  border-radius: 7px;
  color: #fff;
  background: linear-gradient(135deg, #f29d22, #13b8d7);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 0 14px rgba(242, 157, 34, 0.34);
}

.site-nav .ai-numbers-link:hover,
.site-nav .ai-numbers-link.is-active {
  color: #4d2d00;
  background: linear-gradient(135deg, rgba(255, 178, 43, 0.28), rgba(19, 184, 215, 0.16));
}

main {
  padding-bottom: 72px;
}

section {
  padding: 64px 0;
}

.hero {
  padding-top: 56px;
}

.hero-grid,
.split-panel,
.generator-layout {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 26px;
  align-items: start;
}

.hero-copy,
.hero-preview,
.feature-card,
.section-copy,
.mini-library,
.teacher-strip-inner,
.generator-panel,
.generator-preview,
.preview-card {
  background: var(--panel);
  border: 1px solid rgba(35, 48, 71, 0.08);
  box-shadow: var(--shadow);
  border-radius: var(--radius-xl);
}

.hero-copy,
.hero-preview,
.feature-card,
.section-copy,
.mini-library,
.teacher-strip-inner,
.generator-panel,
.generator-preview {
  padding: 30px;
}

.generator-panel,
.generator-preview,
.measure-search-card,
.measure-result-card,
.measure-reference-card,
.pinyin-legend-card,
.pinyin-card,
.strokes-card,
.lesson-card,
.dialogue-card,
.hand-sign-card,
.worksheet-sheet {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.82), rgba(246, 252, 255, 0.7)),
    var(--tech-panel);
  border: 1px solid var(--tech-border);
  box-shadow: var(--shadow), var(--tech-glow);
}

.measure-reference-table,
.pinyin-table,
.strokes-table,
.lesson-table {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(246, 251, 255, 0.78));
}

.measure-reference-table th,
.pinyin-table th,
.strokes-table th,
.lesson-table th {
  background: rgba(245, 250, 255, 0.84);
}

.measure-reference-table-wrap,
.pinyin-table-wrap,
.strokes-table-wrap,
.lesson-table-wrap {
  border-radius: 20px;
  border: 1px solid rgba(27, 184, 222, 0.1);
  overflow: hidden;
}

.preview-card {
  padding: 20px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.92), rgba(239, 233, 221, 0.78));
}

.preview-header,
.section-toolbar,
.toolbar-inner,
.worksheet-meta,
.generator-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.preview-label,
.preview-chip,
.eyebrow {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow {
  background: rgba(181, 138, 73, 0.12);
  color: var(--gold);
  margin-bottom: 14px;
}

.preview-label,
.preview-chip {
  background: rgba(31, 94, 168, 0.1);
  color: var(--accent);
}

h1 {
  margin: 0 0 16px;
  font-size: clamp(2.6rem, 6vw, 4.8rem);
  line-height: 1.02;
}

h2 {
  margin: 0 0 12px;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  line-height: 1.08;
}

h3 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.lead {
  font-size: 1.1rem;
  max-width: 64ch;
}

.lead.small {
  font-size: 1rem;
}

.hero-actions,
.toolbar-actions,
.generator-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #fff;
  background: linear-gradient(145deg, var(--accent), #2a77cb);
  box-shadow: 0 18px 34px rgba(31, 94, 168, 0.22);
}

.ai-check-button,
.lesson-action-ai-listen {
  position: relative;
  isolation: isolate;
  background: linear-gradient(135deg, #0c6cc2, #12b6d6 52%, #5fbf6b);
  color: #fff;
  box-shadow: 0 16px 34px rgba(19, 184, 215, 0.24);
}

.ai-check-button::after,
.lesson-action-ai-listen::after {
  content: "";
  position: absolute;
  inset: -5px;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(19, 184, 215, 0.45), rgba(136, 217, 90, 0.32));
  filter: blur(10px);
  opacity: 0.62;
}

.ai-check-button:hover,
.lesson-action-ai-listen:hover {
  box-shadow: 0 20px 42px rgba(19, 184, 215, 0.32);
}

.button-warm {
  color: #fff;
  background: #de4b37;
  box-shadow: 0 18px 34px rgba(222, 75, 55, 0.22);
}

.button-secondary {
  color: var(--ink);
  background: rgba(31, 94, 168, 0.08);
}

.hero-points,
.sheet-badges,
.sheet-notes {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  display: grid;
  gap: 12px;
}

.hero-points li,
.sheet-notes li {
  position: relative;
  padding-left: 18px;
  color: var(--ink-soft);
}

.hero-points li::before,
.sheet-notes li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
}

.feature-band {
  padding-top: 0;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

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

.mini-library {
  background: transparent;
  padding: 0;
  box-shadow: none;
  border: 0;
}

.library-card {
  background: rgba(255, 253, 248, 0.86);
  border: 1px solid rgba(35, 48, 71, 0.08);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: grid;
  gap: 14px;
  box-shadow: 0 18px 40px rgba(35, 48, 71, 0.08);
}

.library-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.library-card-character {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: linear-gradient(145deg, #f2f6fb, #dfeaf8);
  color: var(--accent);
  font-family: "Noto Serif SC", serif;
  font-size: 1.85rem;
}

.price-tag,
.status-tag {
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(181, 138, 73, 0.12);
  color: #8c6a34;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-tag.free {
  background: rgba(65, 148, 94, 0.12);
  color: #2f6d46;
}

.page-hero {
  padding-bottom: 24px;
}

.generator-title {
  max-width: 31ch;
  margin-top: -18px;
  font-size: clamp(1.8rem, 3.7vw, 2.7rem);
  line-height: 1.1;
}

body[data-page="generator"] .page-hero {
  padding: 18px 0 8px;
}

body[data-page="generator"] .page-hero .narrow {
  display: grid;
  justify-items: center;
  text-align: center;
}

body[data-page="generator"] .page-main {
  padding-top: 8px;
}

body[data-page="generator"] .generator-section {
  padding: 10px 0 40px;
}

body[data-page="generator"] .generator-layout {
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 20px;
}

body[data-page="generator"] .generator-panel {
  width: min(100%, 620px);
  text-align: center;
  margin-top: -12px;
}

body[data-page="generator"] .generator-form {
  justify-items: center;
}

body[data-page="generator"] .field-row {
  width: 100%;
  justify-content: center;
}

body[data-page="generator"] .generator-preview {
  display: none;
}

.page-main {
  padding-top: 24px;
}

.measure-page {
  padding-top: 56px;
}

.pronunciation-page {
  padding-top: 48px;
}

.chat-page {
  padding-top: 48px;
}

.chat-shell {
  display: grid;
  gap: 26px;
}

.game-page {
  padding-top: 42px;
}

.game-shell {
  display: grid;
  gap: 26px;
}

.game-hero,
.game-status-card,
.game-topics-card,
.game-board-card {
  position: relative;
  padding: 28px;
  border: 1px solid rgba(19, 184, 215, 0.18);
  border-radius: 34px;
  background:
    radial-gradient(circle at 88% 18%, rgba(136, 217, 90, 0.18), transparent 26%),
    radial-gradient(circle at 12% 18%, rgba(19, 184, 215, 0.2), transparent 28%),
    linear-gradient(135deg, rgba(255, 253, 248, 0.92), rgba(230, 246, 245, 0.8));
  box-shadow: 0 28px 80px rgba(19, 184, 215, 0.12);
  overflow: hidden;
}

.game-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 22px;
  align-items: stretch;
}

.game-hero h1 {
  margin: 0 0 14px;
  color: #183858;
  font-size: clamp(2.3rem, 4.7vw, 4rem);
}

.game-status-card {
  display: grid;
  align-content: start;
}

.game-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.game-status-item {
  padding: 16px 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(19, 184, 215, 0.14);
  text-align: center;
}

.game-status-item strong {
  display: block;
  margin-top: 8px;
  font-size: 1.9rem;
  color: #183858;
}

.game-status-label {
  display: block;
  color: var(--ink-soft);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.game-status-text {
  margin-top: 16px;
}

.game-topics-card,
.game-board-card {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(241, 250, 250, 0.78));
}

.game-topics-head {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.game-topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.game-topic-button {
  border: 1px solid rgba(19, 184, 215, 0.16);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 24px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 5px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.game-topic-button:hover,
.game-topic-button.is-active {
  transform: translateY(-1px);
  border-color: rgba(19, 184, 215, 0.28);
  box-shadow: 0 16px 32px rgba(19, 184, 215, 0.14);
}

.game-topic-button.is-active {
  background: linear-gradient(135deg, rgba(19, 184, 215, 0.18), rgba(136, 217, 90, 0.14));
}

.game-topic-en {
  font-weight: 700;
  color: #183858;
}

.game-topic-zh {
  color: var(--ink-soft);
  font-family: "Noto Serif SC", serif;
}

.game-topic-pinyin {
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 600;
}

.book-exercises-page {
  padding: 48px 0 72px;
}

.book-exercises-shell {
  display: grid;
  gap: 24px;
}

.book-exercises-hero,
.book-exercises-controls,
.book-exercises-board {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.book-exercises-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  gap: 24px;
  padding: 28px;
}

.book-exercises-summary {
  border-radius: 24px;
  padding: 24px;
  background: linear-gradient(135deg, rgba(31, 94, 168, 0.08), rgba(19, 184, 215, 0.08));
  border: 1px solid rgba(31, 94, 168, 0.12);
  align-self: start;
}

.book-summary-label {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(31, 94, 168, 0.1);
  color: #30527a;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.book-exercises-summary h2 {
  margin: 16px 0 10px;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
}

.book-exercises-summary p {
  margin: 0;
  color: var(--ink-soft);
}

.book-exercises-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px)) minmax(0, 1fr);
  gap: 16px;
  padding: 20px 24px;
  align-items: end;
}

.book-control-field {
  display: grid;
  gap: 8px;
}

.book-mode-toggle {
  display: inline-flex;
  padding: 4px;
  border-radius: 18px;
  background: rgba(244, 248, 255, 0.9);
  border: 1px solid rgba(31, 94, 168, 0.12);
  gap: 4px;
}

.book-mode-button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #4c5f79;
  font-weight: 700;
  cursor: pointer;
}

.book-mode-button.is-active {
  background: rgba(31, 94, 168, 0.12);
  color: #1f5ea8;
}

.book-control-field label {
  font-size: 0.92rem;
  font-weight: 700;
  color: #3d516d;
}

.book-control-field select {
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.9);
  padding: 0 16px;
  color: var(--ink);
}

.book-control-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.book-exercises-board {
  padding: 24px;
}

.book-quiz-summary {
  padding: 16px 20px;
  border-radius: 22px;
  background: rgba(244, 248, 255, 0.82);
  border: 1px solid rgba(31, 94, 168, 0.12);
  color: #314868;
}

.book-quiz-summary.is-result {
  background: rgba(226, 247, 219, 0.85);
  border-color: rgba(79, 163, 53, 0.25);
  color: #2f6c1c;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.25;
  padding: 20px 24px;
}

.book-quiz-summary.is-result strong {
  font-size: 1.1em;
}

.book-empty-state {
  padding: 36px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed rgba(35, 48, 71, 0.18);
  text-align: center;
  color: var(--ink-soft);
}

.book-exercise-section {
  display: grid;
  gap: 18px;
}

.book-exercise-section + .book-exercise-section {
  margin-top: 28px;
}

.book-quiz-submit-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.book-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.book-section-head h2 {
  margin: 0;
  font-size: 1.45rem;
}

.book-section-head p {
  margin: 0;
  color: var(--ink-soft);
}

.book-question-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 18px;
  padding: 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(31, 94, 168, 0.12);
}

.book-question-card-wide {
  background: rgba(247, 250, 255, 0.76);
}

.book-question-number {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #1f5ea8;
  background: rgba(31, 94, 168, 0.1);
}

.book-question-copy h3 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-family: "Work Sans", "Avenir Next", "Segoe UI", sans-serif;
}

.book-question-prompt-zh {
  margin-bottom: 14px;
}

.book-term {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.book-term-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.book-term-zh {
  font-size: 1.2rem;
  font-weight: 700;
  font-family: "Noto Serif SC", "Songti SC", serif;
}

.book-term-tools {
  display: inline-flex;
  gap: 8px;
}

.book-tool-button {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(31, 94, 168, 0.15);
  background: rgba(31, 94, 168, 0.08);
  color: #1f5ea8;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.book-tool-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.book-term-pinyin {
  font-size: 0.94rem;
  color: #5573a4;
  font-weight: 600;
}

.book-choice-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.book-choice-item {
  margin: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  cursor: pointer;
  border-radius: 18px;
  transition: transform 140ms ease;
}

.book-choice-item:hover {
  transform: translateY(-1px);
}

.book-choice-item:focus-visible {
  outline: 3px solid rgba(31, 94, 168, 0.22);
  outline-offset: 3px;
}

.book-choice-select {
  min-width: 102px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 14px;
  border-radius: 18px;
  background: rgba(244, 248, 255, 0.9);
  border: 1px solid rgba(31, 94, 168, 0.1);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.book-choice-select:focus-visible {
  outline: 3px solid rgba(31, 94, 168, 0.22);
  outline-offset: 3px;
}

.book-choice-select:hover {
  transform: translateY(-1px);
  border-color: rgba(31, 94, 168, 0.22);
  box-shadow: 0 10px 24px rgba(31, 94, 168, 0.08);
}

.book-choice-select.is-selected {
  border-color: rgba(31, 94, 168, 0.36);
  background: rgba(226, 239, 255, 0.95);
}

.book-choice-select.is-correct,
.book-choice-select.show-correct {
  border-color: rgba(79, 163, 53, 0.42);
  background: rgba(226, 247, 219, 0.95);
}

.book-choice-select.is-incorrect {
  border-color: rgba(214, 88, 67, 0.35);
  background: rgba(255, 237, 233, 0.95);
}

.book-choice-select-text {
  font-size: 0.92rem;
  font-weight: 700;
  color: #314868;
}

.book-choice-content {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(244, 248, 255, 0.9);
  border: 1px solid rgba(31, 94, 168, 0.1);
  min-width: 0;
}

.book-choice-item.is-selected .book-choice-select,
.book-choice-item.is-selected .book-choice-content {
  border-color: rgba(31, 94, 168, 0.36);
  background: rgba(226, 239, 255, 0.95);
}

.book-choice-item.is-correct .book-choice-select,
.book-choice-item.is-correct .book-choice-content,
.book-choice-item.show-correct .book-choice-select,
.book-choice-item.show-correct .book-choice-content {
  border-color: rgba(79, 163, 53, 0.42);
  background: rgba(226, 247, 219, 0.95);
}

.book-choice-item.is-incorrect .book-choice-select,
.book-choice-item.is-incorrect .book-choice-content {
  border-color: rgba(214, 88, 67, 0.35);
  background: rgba(255, 237, 233, 0.95);
}

.book-choice-feedback {
  min-height: 22px;
  margin-top: 12px;
  font-size: 0.95rem;
  font-weight: 700;
}

.book-choice-feedback.is-correct {
  color: #2f6c1c;
}

.book-choice-feedback.is-incorrect {
  color: #a13d2d;
}

.book-choice-letter,
.book-matching-label {
  font-weight: 700;
  color: #314868;
}

.book-english-option {
  display: inline-block;
  line-height: 1.45;
}

.book-matching-board {
  position: relative;
}

.book-matching-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.book-matching-line {
  fill: none;
  stroke: #7aa2d8;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(31, 94, 168, 0.16));
}

.book-matching-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.book-matching-instruction {
  margin: 0 0 12px;
  color: var(--ink-soft);
}

.book-matching-left,
.book-matching-right,
.book-sort-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.book-matching-left-item,
.book-matching-right-item,
.book-sort-chip {
  border-radius: 18px;
}

.book-matching-left-item,
.book-matching-right-item {
  position: relative;
}

.book-matching-button {
  width: 100%;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(35, 48, 71, 0.1);
  background: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.book-matching-button-left {
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: start;
}

.book-matching-button:hover {
  transform: translateY(-1px);
  border-color: rgba(31, 94, 168, 0.22);
  box-shadow: 0 10px 24px rgba(31, 94, 168, 0.08);
}

.book-matching-button:focus-visible {
  outline: 3px solid rgba(31, 94, 168, 0.22);
  outline-offset: 3px;
}

.book-matching-button.is-active {
  border-color: rgba(31, 94, 168, 0.35);
  background: rgba(226, 239, 255, 0.95);
}

.book-matching-button.is-paired {
  border-color: rgba(79, 163, 53, 0.4);
  background: rgba(226, 247, 219, 0.95);
}

.book-matching-button.is-correct {
  border-color: rgba(79, 163, 53, 0.4);
  background: rgba(226, 247, 219, 0.95);
}

.book-matching-button.is-incorrect {
  border-color: rgba(214, 88, 67, 0.35);
  background: rgba(255, 237, 233, 0.95);
}

.book-matching-button[disabled] {
  cursor: default;
  opacity: 0.96;
}

.book-matching-left-item {
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.book-matching-right-item {
  padding: 0;
}

.book-matching-tools {
  display: grid;
  gap: 8px;
}

.book-matching-term .book-term-zh {
  display: block;
}

.book-term-compact .book-term-pinyin {
  margin-top: 4px;
}

.book-sort-chip {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(35, 48, 71, 0.1);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.book-sort-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(31, 94, 168, 0.22);
  box-shadow: 0 10px 24px rgba(31, 94, 168, 0.08);
}

.book-sort-chip:focus-visible {
  outline: 3px solid rgba(31, 94, 168, 0.22);
  outline-offset: 3px;
}

.book-sort-chip.is-selected {
  border-color: rgba(31, 94, 168, 0.36);
  background: rgba(226, 239, 255, 0.95);
}

.book-sort-chip-term {
  display: grid;
  gap: 8px;
}

.book-sorting-builder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.book-sorting-current {
  min-height: 48px;
  flex: 1 1 320px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(244, 248, 255, 0.9);
  border: 1px solid rgba(31, 94, 168, 0.1);
  color: #314868;
  font-weight: 700;
}

.book-sorting-current-list {
  font-weight: 600;
  color: #1f5ea8;
}

.book-sorting-feedback {
  min-height: 22px;
  margin-top: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #4c5f79;
}

.book-sorting-feedback.is-correct {
  color: #2f6c1c;
}

.book-sorting-feedback.is-incorrect {
  color: #a13d2d;
}

.book-matching-feedback {
  min-height: 22px;
  margin-top: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #4c5f79;
}

.book-matching-feedback.is-correct,
.book-matching-feedback.is-complete {
  color: #2f6c1c;
}

.book-matching-feedback.is-incorrect {
  color: #a13d2d;
}

.book-matching-feedback.is-warning {
  color: #8b5c11;
}

@media (max-width: 980px) {
  .book-exercises-hero,
  .book-exercises-controls,
  .book-matching-grid {
    grid-template-columns: 1fr;
  }

  .book-control-actions {
    justify-content: flex-start;
  }

  .book-matching-lines {
    display: none;
  }

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

  .book-matching-tools {
    grid-auto-flow: column;
    justify-content: start;
  }
}

@media (max-width: 720px) {
  .book-question-card {
    grid-template-columns: 1fr;
  }

  .book-question-number {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }
}

.game-board-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.game-board-head h2 {
  margin: 8px 0 0;
}

.game-board-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.game-prompt-card {
  padding: 22px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 16% 20%, rgba(126, 109, 255, 0.14), transparent 28%),
    radial-gradient(circle at 88% 20%, rgba(19, 184, 215, 0.15), transparent 24%),
    rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(19, 184, 215, 0.14);
}

.game-prompt-copy {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
}

.game-prompt-zh {
  font-family: "Noto Serif SC", serif;
  font-size: clamp(2.7rem, 6vw, 4.5rem);
  color: #183858;
}

.game-prompt-pinyin {
  font-size: 1.28rem;
  font-weight: 700;
  color: var(--accent);
}

.game-choice-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.game-choice-card {
  border: 1px solid rgba(19, 184, 215, 0.14);
  background: rgba(255, 255, 255, 0.84);
  border-radius: 28px;
  padding: 18px 14px;
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.game-choice-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(19, 184, 215, 0.14);
}

.game-choice-card.is-correct {
  border-color: rgba(72, 166, 92, 0.42);
  background: rgba(233, 250, 237, 0.96);
}

.game-choice-card.is-wrong {
  border-color: rgba(222, 75, 55, 0.38);
  background: rgba(255, 239, 236, 0.96);
}

.game-choice-card:disabled {
  cursor: default;
}

.game-choice-emoji {
  width: 100%;
  min-height: 148px;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 24px;
  background:
    radial-gradient(circle at 24% 20%, rgba(255, 255, 255, 0.84), transparent 18%),
    linear-gradient(145deg, rgba(227, 240, 252, 0.94), rgba(238, 249, 245, 0.92));
  font-size: 4rem;
}

.game-art-desk {
  font-size: 0;
  overflow: hidden;
}

.game-art-desk::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 52%;
  width: 74%;
  height: 18px;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  background: linear-gradient(180deg, #c89056, #a86f3c);
  box-shadow: 0 10px 22px rgba(73, 50, 25, 0.16);
}

.game-art-desk::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 58%;
  width: 66%;
  height: 54px;
  transform: translateX(-50%);
  background:
    linear-gradient(180deg, transparent 0 8px, #8b5a31 8px 100%),
    linear-gradient(180deg, transparent 0 8px, #8b5a31 8px 100%);
  background-repeat: no-repeat;
  background-size: 10px 100%, 10px 100%;
  background-position: left 8px top, right 8px top;
}

.game-choice-label {
  color: #183858;
  font-weight: 700;
  line-height: 1.35;
}

.game-feedback {
  margin-top: 16px;
  font-size: 1rem;
  color: var(--ink-soft);
}

.game-feedback.is-correct {
  color: #2b7a43;
}

.game-feedback.is-wrong {
  color: #b34738;
}

.chat-hero,
.chat-panel {
  position: relative;
  padding: 28px;
  border: 1px solid rgba(19, 184, 215, 0.18);
  border-radius: 34px;
  background:
    radial-gradient(circle at 88% 18%, rgba(136, 217, 90, 0.18), transparent 26%),
    radial-gradient(circle at 12% 18%, rgba(19, 184, 215, 0.2), transparent 28%),
    linear-gradient(135deg, rgba(255, 253, 248, 0.9), rgba(230, 246, 245, 0.78));
  box-shadow: 0 28px 80px rgba(19, 184, 215, 0.12);
  overflow: hidden;
}

.chat-hero h1 {
  margin: 0 0 14px;
  color: #183858;
  font-size: clamp(2.5rem, 5vw, 4.2rem);
}

.chat-hero .lead {
  margin: 0;
  max-width: 44rem;
}

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

.chat-field {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

.chat-field select,
.chat-input {
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid rgba(35, 48, 71, 0.18);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-size: 1.05rem;
}

.chat-input {
  direction: ltr;
  text-align: left;
}

.chat-composer-card {
  display: grid;
  gap: 16px;
  padding: 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 48, 71, 0.1);
}

.chat-composer-card {
  position: relative;
}

.chat-tutor-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.chat-tutor-setting {
  display: grid;
  gap: 8px;
}

.chat-tutor-setting-label {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-sound-toggle {
  justify-self: start;
  border: 1px solid rgba(57, 109, 202, 0.18);
  border-radius: 999px;
  background: rgba(73, 131, 232, 0.08);
  color: var(--accent);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
}

.chat-avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chat-avatar-option {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(35, 48, 71, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.chat-avatar-option:hover,
.chat-avatar-option.is-active {
  transform: translateY(-1px);
  border-color: rgba(58, 119, 221, 0.5);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.88),
    0 8px 18px rgba(57, 109, 202, 0.12);
}

.chat-avatar-option[data-avatar="blue"] {
  background: linear-gradient(145deg, #63c1ff, #6b74ff 58%, #8f71ff);
}

.chat-avatar-option[data-avatar="mint"] {
  background: linear-gradient(145deg, #5fe2c2, #39c4e8 54%, #5c8dff);
}

.chat-avatar-option[data-avatar="sunset"] {
  background: linear-gradient(145deg, #ffb86b, #ff7f8a 55%, #a06dff);
}

.chat-avatar-option[data-avatar="rose"] {
  background: linear-gradient(145deg, #ff9dba, #f37bd5 55%, #7e6dff);
}

.chat-avatar-option[data-avatar="gold"] {
  background: linear-gradient(145deg, #ffd978, #ffb35c 55%, #ff8b63);
}

.chat-input-label {
  color: var(--ink);
  font-weight: 700;
}

.chat-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.chat-helper {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 700;
}

.chat-helper[data-state="invalid"] {
  color: #c04734;
}

.chat-helper[data-state="valid"] {
  color: #2f8c55;
}

.chat-autocomplete {
  display: grid;
  gap: 8px;
  margin-top: -4px;
  padding: 10px;
  border-radius: 20px;
  border: 1px solid rgba(27, 184, 222, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 248, 255, 0.94));
  box-shadow: 0 18px 32px rgba(17, 45, 76, 0.08);
}

.chat-autocomplete.is-hidden {
  display: none;
}

.chat-layout {
  margin-top: 22px;
  display: grid;
  gap: 20px;
}

.chat-section-head h2 {
  margin: 0 0 6px;
  color: var(--ink);
}

.chat-section-head p {
  margin: 0;
  color: var(--ink-soft);
}

.chat-suggestions-list,
.chat-thread {
  display: grid;
  gap: 12px;
}

.chat-thread {
  gap: 10px;
}

.chat-suggestions-list {
  gap: 8px;
}

.chat-suggestion {
  border: 1px solid rgba(27, 184, 222, 0.16);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(240, 248, 255, 0.96));
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.chat-suggestion:hover {
  transform: translateY(-1px);
  border-color: rgba(19, 184, 215, 0.28);
  box-shadow: 0 12px 22px rgba(27, 184, 222, 0.1);
}

.chat-suggestion-label {
  display: block;
  color: var(--ink);
  font-weight: 800;
  font-size: 1rem;
}

.chat-suggestion-meta {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 0.95rem;
}

.chat-turn {
  display: grid;
  gap: 8px;
}

.chat-bubble {
  display: grid;
  gap: 6px;
  max-width: 82%;
  padding: 13px 15px;
  border-radius: 18px;
  border: 1px solid rgba(35, 48, 71, 0.08);
}

.chat-bubble-user {
  justify-self: end;
  background: linear-gradient(135deg, rgba(19, 184, 215, 0.12), rgba(126, 109, 255, 0.12));
}

.chat-bubble-ai {
  justify-self: start;
  background: rgba(255, 255, 255, 0.95);
}

.chat-bubble-ai-wrap {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.chat-tutor {
  display: grid;
  gap: 6px;
  justify-items: center;
  align-content: start;
  padding-top: 4px;
}

.chat-tutor-avatar {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.18) 20%, transparent 26%),
    radial-gradient(circle at 68% 70%, rgba(104, 208, 255, 0.24), transparent 24%),
    linear-gradient(145deg, #63c1ff, #6b74ff 58%, #8f71ff);
  box-shadow:
    0 10px 24px rgba(74, 112, 205, 0.2),
    inset 0 -10px 18px rgba(16, 31, 79, 0.16);
}

.chat-tutor.chat-avatar-blue .chat-tutor-avatar {
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.18) 20%, transparent 26%),
    radial-gradient(circle at 68% 70%, rgba(104, 208, 255, 0.24), transparent 24%),
    linear-gradient(145deg, #63c1ff, #6b74ff 58%, #8f71ff);
}

.chat-tutor.chat-avatar-mint .chat-tutor-avatar {
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.18) 20%, transparent 26%),
    radial-gradient(circle at 68% 70%, rgba(124, 255, 230, 0.18), transparent 24%),
    linear-gradient(145deg, #5fe2c2, #39c4e8 54%, #5c8dff);
}

.chat-tutor.chat-avatar-sunset .chat-tutor-avatar {
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.18) 20%, transparent 26%),
    radial-gradient(circle at 68% 70%, rgba(255, 196, 118, 0.18), transparent 24%),
    linear-gradient(145deg, #ffb86b, #ff7f8a 55%, #a06dff);
}

.chat-tutor.chat-avatar-rose .chat-tutor-avatar {
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.18) 20%, transparent 26%),
    radial-gradient(circle at 68% 70%, rgba(255, 160, 224, 0.18), transparent 24%),
    linear-gradient(145deg, #ff9dba, #f37bd5 55%, #7e6dff);
}

.chat-tutor.chat-avatar-gold .chat-tutor-avatar {
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.18) 20%, transparent 26%),
    radial-gradient(circle at 68% 70%, rgba(255, 214, 119, 0.16), transparent 24%),
    linear-gradient(145deg, #ffd978, #ffb35c 55%, #ff8b63);
}

.chat-tutor-avatar::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(97, 171, 255, 0.18);
}

.chat-tutor-face {
  position: absolute;
  inset: 0;
}

.chat-tutor-eye {
  position: absolute;
  top: 23px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.chat-tutor-eye.left {
  left: 17px;
}

.chat-tutor-eye.right {
  right: 17px;
}

.chat-tutor-mouth {
  position: absolute;
  left: 50%;
  bottom: 14px;
  width: 12px;
  height: 5px;
  margin-left: -6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  transform-origin: center;
}

.chat-tutor-label {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-tutor-speaking .chat-tutor-avatar {
  animation: chatTutorFloat 0.9s ease-in-out infinite alternate;
}

.chat-tutor-speaking .chat-tutor-mouth {
  animation: chatTutorTalk 0.24s ease-in-out infinite alternate;
}

.chat-tutor-speaking .chat-tutor-eye {
  animation: chatTutorBlink 2.4s ease-in-out infinite;
}

.chat-tutor-idle .chat-tutor-avatar {
  animation: chatTutorIdle 3.6s ease-in-out infinite;
}

.chat-bubble-tag {
  color: #8c6a34;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-bubble-chinese {
  direction: ltr;
  text-align: left;
  font-family: "Noto Serif SC", serif;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  line-height: 1.06;
  color: var(--ink);
}

.chat-bubble-pinyin {
  direction: ltr;
  text-align: left;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 800;
}

.chat-bubble-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 2px;
}

.chat-reply-audio {
  border: 1px solid rgba(57, 109, 202, 0.16);
  border-radius: 999px;
  background: rgba(73, 131, 232, 0.08);
  color: var(--accent);
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.chat-reply-audio:disabled,
.chat-sound-toggle.is-off {
  opacity: 0.58;
}

.chat-bubble-meaning {
  color: var(--ink-soft);
  line-height: 1.6;
  font-size: 0.92rem;
}

.chat-empty {
  padding: 18px;
  border-radius: 18px;
  background: rgba(243, 246, 250, 0.9);
  color: var(--ink-soft);
}

.chat-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

html[dir="rtl"] .chat-panel,
html[dir="rtl"] .chat-hero,
html[dir="rtl"] .chat-field,
html[dir="rtl"] .chat-composer-card,
html[dir="rtl"] .chat-section-head,
html[dir="rtl"] .chat-helper,
html[dir="rtl"] .chat-empty,
html[dir="rtl"] .chat-bubble-meaning {
  text-align: right;
}

html[dir="rtl"] .chat-input,
html[dir="rtl"] .chat-autocomplete,
html[dir="rtl"] .chat-suggestions-list,
html[dir="rtl"] .chat-suggestion,
html[dir="rtl"] .chat-thread,
html[dir="rtl"] .chat-turn,
html[dir="rtl"] .chat-bubble,
html[dir="rtl"] .chat-bubble-user,
html[dir="rtl"] .chat-bubble-ai,
html[dir="rtl"] .chat-bubble-tag {
  direction: ltr;
  text-align: left;
}

@keyframes chatTutorFloat {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-4px);
  }
}

@keyframes chatTutorIdle {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes chatTutorTalk {
  0% {
    transform: scaleX(1) scaleY(1);
    opacity: 0.9;
  }
  100% {
    transform: scaleX(1.5) scaleY(1.9);
    opacity: 1;
  }
}

@keyframes chatTutorBlink {
  0%, 44%, 48%, 100% {
    transform: scaleY(1);
  }
  46% {
    transform: scaleY(0.2);
  }
}

.pronunciation-shell {
  display: grid;
  gap: 26px;
}

.pronunciation-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 24px;
  align-items: stretch;
  padding: 28px;
  border: 1px solid rgba(19, 184, 215, 0.18);
  border-radius: 34px;
  background:
    radial-gradient(circle at 88% 18%, rgba(136, 217, 90, 0.22), transparent 26%),
    radial-gradient(circle at 12% 18%, rgba(19, 184, 215, 0.2), transparent 28%),
    linear-gradient(135deg, rgba(255, 253, 248, 0.9), rgba(230, 246, 245, 0.78));
  box-shadow: 0 28px 80px rgba(19, 184, 215, 0.12);
  overflow: hidden;
}

.pronunciation-hero::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -120px;
  width: 300px;
  height: 300px;
  border-radius: 999px;
  border: 1px solid rgba(19, 184, 215, 0.2);
  box-shadow: inset 0 0 42px rgba(19, 184, 215, 0.12);
  pointer-events: none;
}

.pronunciation-hero h1 {
  margin-bottom: 14px;
}

.pronunciation-engine-card,
.pronunciation-card,
.pronunciation-category-head {
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid rgba(35, 48, 71, 0.1);
  border-radius: 26px;
  box-shadow: 0 20px 50px rgba(35, 48, 71, 0.08);
}

.pronunciation-engine-card {
  position: relative;
  min-height: 420px;
  padding: 240px 24px 24px;
  display: block;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(235, 249, 247, 0.84)),
    rgba(255, 253, 248, 0.88);
  overflow: hidden;
}

.pronunciation-engine-card strong {
  display: block;
  color: var(--accent);
  font-size: 1.05rem;
}

.pronunciation-engine-card p {
  margin: 14px 0 0;
}

.ai-orb {
  position: absolute;
  width: 62px;
  height: 62px;
  top: 92px;
  left: 162px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 34% 28%, #fff, rgba(255, 255, 255, 0.15) 24%, transparent 25%),
    linear-gradient(135deg, var(--ai-cyan), var(--ai-violet) 58%, var(--ai-lime));
  box-shadow: 0 0 0 10px rgba(19, 184, 215, 0.08), 0 18px 40px rgba(19, 184, 215, 0.24);
  animation: aiPulse 2.8s ease-in-out infinite;
}

.ai-feature-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.ai-feature-strip span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(19, 184, 215, 0.16);
  color: #225168;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(35, 48, 71, 0.06);
}

.ai-feature-strip span::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ai-lime);
  box-shadow: 0 0 12px rgba(136, 217, 90, 0.7);
}

.pronunciation-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pronunciation-tab {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: rgba(31, 94, 168, 0.08);
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 700;
}

.pronunciation-tab:hover,
.pronunciation-tab.is-active {
  background: var(--accent);
  color: #fff;
}

.pronunciation-list {
  display: grid;
  gap: 18px;
}

.pronunciation-category-head {
  padding: 24px;
}

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

.pronunciation-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  display: grid;
  gap: 12px;
}

.pronunciation-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--ai-cyan), var(--ai-lime));
  opacity: 0.68;
}

.pronunciation-card.is-correct-pop {
  animation: correctCardPop 0.62s cubic-bezier(0.2, 1.4, 0.34, 1);
  box-shadow: 0 24px 60px rgba(47, 140, 85, 0.18);
}

.pronunciation-card.is-try-again-nudge {
  animation: tryAgainNudge 0.52s ease-in-out;
  box-shadow: 0 20px 52px rgba(192, 71, 52, 0.16);
}

.pronunciation-card-top,
.pronunciation-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pronunciation-type {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(181, 138, 73, 0.14);
  color: #8c6a34;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
  font-weight: 800;
}

.pronunciation-card .button-primary {
  min-width: 104px;
}

.pronunciation-icon-button {
  border: 0;
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(31, 94, 168, 0.08);
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.pronunciation-chinese {
  font-family: "Noto Serif SC", serif;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 1;
  color: var(--ink);
}

.pronunciation-pinyin {
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 800;
}

.pronunciation-english {
  min-height: 2.8em;
}

.pronunciation-feedback {
  color: var(--ink-soft);
  font-weight: 800;
}

.pronunciation-feedback[data-state="correct"] {
  color: #2f8c55;
}

.pronunciation-feedback[data-state="try"] {
  color: #c04734;
}

.pronunciation-feedback[data-state="listening"] {
  color: var(--accent);
}

.star-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.star-burst span {
  position: absolute;
  left: 50%;
  top: 50%;
  color: #f3b43f;
  font-size: 1.25rem;
  text-shadow: 0 2px 8px rgba(181, 138, 73, 0.28);
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  animation: starPop 0.92s ease-out forwards;
}

.star-burst span:nth-child(1) { --star-x: -98px; --star-y: -54px; }
.star-burst span:nth-child(2) { --star-x: -52px; --star-y: -86px; }
.star-burst span:nth-child(3) { --star-x: 8px; --star-y: -94px; }
.star-burst span:nth-child(4) { --star-x: 70px; --star-y: -72px; }
.star-burst span:nth-child(5) { --star-x: 102px; --star-y: -18px; }
.star-burst span:nth-child(6) { --star-x: 78px; --star-y: 46px; }
.star-burst span:nth-child(7) { --star-x: 18px; --star-y: 76px; }
.star-burst span:nth-child(8) { --star-x: -58px; --star-y: 58px; }
.star-burst span:nth-child(9) { --star-x: -106px; --star-y: 8px; }

@keyframes correctCardPop {
  0% {
    transform: translateY(0) scale(1);
  }
  28% {
    transform: translateY(-8px) scale(1.025) rotate(-0.5deg);
  }
  56% {
    transform: translateY(2px) scale(0.995) rotate(0.4deg);
  }
  100% {
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

@keyframes aiPulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
    filter: saturate(1);
  }
  50% {
    transform: translateY(-3px) scale(1.04);
    filter: saturate(1.18);
  }
}

@keyframes tryAgainNudge {
  0% {
    transform: translateX(0);
    background: rgba(255, 253, 248, 0.88);
  }
  20% {
    transform: translateX(-7px) rotate(-0.35deg);
    background: rgba(255, 238, 235, 0.96);
  }
  42% {
    transform: translateX(7px) rotate(0.35deg);
  }
  64% {
    transform: translateX(-4px) rotate(-0.2deg);
  }
  84% {
    transform: translateX(3px) rotate(0.15deg);
  }
  100% {
    transform: translateX(0);
    background: rgba(255, 253, 248, 0.88);
  }
}

@keyframes starPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(0deg) scale(0.2);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translate(
        calc(-50% + var(--star-x)),
        calc(-50% + var(--star-y))
      )
      rotate(160deg)
      scale(1.15);
  }
}

.measure-shell {
  max-width: 1120px;
  display: grid;
  gap: 28px;
}

.measure-intro,
.pinyin-intro,
.strokes-intro,
body[data-page="lesson07"] .lesson-intro,
body[data-page="generator"] .page-hero .narrow {
  position: relative;
  padding: 30px;
  border-radius: 32px;
  border: 1px solid rgba(27, 184, 222, 0.16);
  background:
    radial-gradient(circle at 90% 18%, rgba(27, 184, 222, 0.16), transparent 28%),
    radial-gradient(circle at 16% 20%, rgba(126, 109, 255, 0.12), transparent 26%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(243, 249, 255, 0.8));
  box-shadow: 0 28px 72px rgba(35, 48, 71, 0.1), 0 18px 46px rgba(27, 184, 222, 0.1);
  overflow: hidden;
}

.measure-intro::after,
.pinyin-intro::after,
.strokes-intro::after,
body[data-page="lesson07"] .lesson-intro::after,
body[data-page="generator"] .page-hero .narrow::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0, rgba(27, 184, 222, 0.08) 50%, transparent 100%);
  transform: translateX(-72%);
  pointer-events: none;
}

.measure-intro h1 {
  margin: 0 0 14px;
  color: #183858;
  font-size: clamp(2.4rem, 5vw, 4rem);
}

.measure-intro p {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  color: #617487;
}

.measure-search-card,
.measure-result-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 48, 71, 0.12);
  border-radius: 24px;
  padding: 20px;
}

.measure-search-card {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.measure-search-label {
  font-size: 1.2rem;
  font-weight: 600;
  color: #373737;
}

.measure-search-card input {
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(35, 48, 71, 0.28);
  background: #fff;
  font-size: 1.5rem;
}

.measure-result-card {
  display: grid;
  gap: 14px;
}

.measure-summary {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  color: #3a3a3a;
}

.measure-word-highlight,
.measure-classifier-highlight {
  color: #de4b37;
  font-family: "Noto Serif SC", serif;
  font-weight: 700;
}

.measure-pinyin {
  color: #666;
  font-style: italic;
  font-size: 0.84em;
}

.measure-example {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2rem);
  color: #3a3a3a;
}

.measure-subheading {
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}

.measure-alt-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.measure-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(222, 75, 55, 0.1);
  color: #a43929;
}

.measure-definition,
.measure-loading {
  margin: 0;
  line-height: 1.6;
  color: var(--ink-soft);
}

.measure-reference-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 48, 71, 0.12);
  border-radius: 24px;
  padding: 24px 20px;
  display: grid;
  gap: 18px;
}

.measure-reference-head h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  text-transform: capitalize;
}

.measure-reference-head p {
  margin: 0;
}

.measure-reference-table-wrap {
  overflow-x: auto;
}

.measure-reference-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.58);
}

.measure-reference-table th,
.measure-reference-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(35, 48, 71, 0.1);
  text-align: left;
  vertical-align: top;
}

.measure-reference-table th {
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.measure-ref-classifier,
.measure-ref-example {
  font-family: "Noto Serif SC", serif;
  color: var(--ink);
  font-size: 1.15rem;
}

.measure-ref-pinyin-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

html[dir="rtl"] .measure-ref-pinyin-cell {
  direction: ltr;
  justify-content: flex-start;
  text-align: left;
}

.measure-ai-listen-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 13px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #0c6cc2, #12b6d6 52%, #5fbf6b);
  box-shadow: 0 12px 26px rgba(19, 184, 215, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.measure-ai-listen-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(19, 184, 215, 0.3);
}

.measure-ai-listen-button .ai-mic-icon {
  width: 22px;
  height: 22px;
}

.pinyin-page {
  padding-top: 56px;
}

.pinyin-shell {
  display: grid;
  gap: 28px;
}

.pinyin-intro h1 {
  margin: 0 0 14px;
  color: #183858;
  font-size: clamp(2.4rem, 5vw, 4rem);
}

.pinyin-intro p {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  color: #617487;
}

.pinyin-legend-card,
.pinyin-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 48, 71, 0.12);
  border-radius: 24px;
  padding: 24px 20px;
}

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

.pinyin-sections {
  display: grid;
  gap: 20px;
}

.pinyin-card-head h2 {
  margin: 0;
}

.pinyin-table-wrap {
  overflow-x: auto;
}

.pinyin-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.58);
}

.pinyin-table th,
.pinyin-table td {
  padding: 8px;
  text-align: center;
  border-bottom: 1px solid rgba(35, 48, 71, 0.08);
  border-right: 1px solid rgba(35, 48, 71, 0.06);
}

.pinyin-table th:last-child,
.pinyin-table td:last-child {
  border-right: 0;
}

.pinyin-table th {
  color: var(--ink-soft);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  background: rgba(247, 243, 234, 0.7);
}

.pinyin-corner {
  min-width: 88px;
}

.pinyin-empty {
  background: rgba(35, 48, 71, 0.03);
}

.pinyin-cell-button {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px 8px;
  background: rgba(31, 94, 168, 0.08);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.pinyin-cell-button:hover {
  transform: translateY(-1px);
  background: rgba(31, 94, 168, 0.14);
  color: var(--ink);
}

.pinyin-modal[hidden] {
  display: none;
}

.pinyin-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.pinyin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 48, 0.58);
  backdrop-filter: blur(10px);
}

.pinyin-modal-dialog {
  position: relative;
  width: min(92vw, 1040px);
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(245, 250, 255, 0.92));
  border-radius: 28px;
  border: 1px solid rgba(27, 184, 222, 0.14);
  box-shadow: 0 28px 80px rgba(35, 48, 71, 0.24);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.pinyin-modal-head,
.pinyin-modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 28px;
  border-bottom: 1px solid rgba(35, 48, 71, 0.1);
}

.pinyin-modal-foot {
  border-bottom: 0;
  border-top: 1px solid rgba(35, 48, 71, 0.08);
  justify-content: flex-end;
}

.pinyin-modal-head h2 {
  margin: 0;
  color: var(--ink);
}

.pinyin-modal-close {
  border: 0;
  background: transparent;
  color: #a0a8b4;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.pinyin-modal-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  padding: 22px 24px 24px;
  overflow-y: auto;
}

.pinyin-tone-list {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 10px;
}

.pinyin-modal-main {
  display: grid;
  gap: 14px;
}

.pinyin-tone-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 48, 71, 0.08);
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.pinyin-tone-row:hover,
.pinyin-tone-row.is-active {
  border-color: rgba(31, 94, 168, 0.28);
  box-shadow: 0 8px 22px rgba(31, 94, 168, 0.12);
  transform: translateY(-1px);
}

.pinyin-speaker {
  width: 100%;
  border: 1px solid rgba(35, 48, 71, 0.16);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  padding: 10px 16px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  max-width: 72px;
  min-height: 52px;
}

.pinyin-speaker svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.pinyin-tone-stack {
  display: grid;
  justify-items: start;
  gap: 4px;
}

.pinyin-tone-word {
  font-size: clamp(1.55rem, 2.8vw, 2.45rem);
  font-weight: 700;
  line-height: 1;
}

.pinyin-tone-label {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.88rem;
  text-align: left;
}

.pinyin-breakdown {
  display: grid;
  gap: 12px;
}

.pinyin-breakdown-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: start;
  gap: 12px;
}

.pinyin-breakdown-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(35, 48, 71, 0.16);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 700;
}

.pinyin-mouth-guide {
  display: grid;
}

.pinyin-guide-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(27, 184, 222, 0.14);
  background:
    linear-gradient(135deg, rgba(235, 247, 255, 0.92), rgba(255, 249, 242, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.pinyin-guide-head {
  display: grid;
  gap: 6px;
}

.pinyin-guide-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.02rem;
}

.pinyin-guide-head p {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.92rem;
}

.pinyin-guide-visuals {
  display: grid;
  grid-template-columns: minmax(0, 150px) minmax(0, 1fr);
  gap: 12px;
}

.pinyin-guide-stage {
  position: relative;
  min-height: 360px;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(90deg, #bfe9ff 0%, #9ed8fb 46%, #ffd8b8 46%, #ffd3ad 100%);
  border: 1px solid rgba(35, 48, 71, 0.08);
}

.pinyin-guide-sound-tag {
  position: absolute;
  top: 18px;
  left: 26px;
  z-index: 3;
  color: #111;
  font-size: clamp(2.2rem, 4.2vw, 3.35rem);
  font-weight: 800;
  line-height: 1;
  text-transform: lowercase;
}

.pinyin-guide-tone-badge {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 3;
  display: grid;
  justify-items: end;
  gap: 4px;
  color: rgba(255, 255, 255, 0.98);
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.pinyin-guide-tone-badge span {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pinyin-guide-tone-visual {
  position: absolute;
  left: 18px;
  top: 76px;
  width: 116px;
  height: 88px;
  z-index: 3;
}

.pinyin-tone-curve {
  width: 100%;
  height: 100%;
  display: block;
}

.pinyin-tone-curve-path {
  stroke-dasharray: 150;
  stroke-dashoffset: 150;
  animation: pinyinGuideToneTrace 1.25s ease-in-out infinite;
}

.pinyin-guide-lips-inset {
  position: absolute;
  left: 30px;
  bottom: 16px;
  width: 132px;
  height: 132px;
  z-index: 2;
}

.pinyin-guide-profile-main {
  position: absolute;
  inset: 0;
  padding-left: 108px;
}

.pinyin-guide-profile-main .pinyin-guide-visual-card,
.pinyin-guide-lips-inset .pinyin-guide-visual-card {
  min-height: 0;
  height: 100%;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.pinyin-guide-visual-card {
  min-height: 128px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 48, 71, 0.08);
  overflow: hidden;
}

.pinyin-guide-visual-card svg {
  width: 100%;
  height: 100%;
  display: block;
}

.pinyin-guide-svg .pinyin-guide-lips {
  transform-box: fill-box;
  transform-origin: center;
  animation: pinyinGuideLipsPulse 1.8s ease-in-out infinite;
}

.pinyin-guide-svg .pinyin-guide-tongue {
  transform-box: fill-box;
  transform-origin: 18% 72%;
  animation: pinyinGuideTongueMove 1.8s ease-in-out infinite;
}

.pinyin-guide-svg .pinyin-guide-jaw {
  transform-box: fill-box;
  transform-origin: 34% 50%;
  animation: pinyinGuideJawOpen 1.8s ease-in-out infinite;
}

.pinyin-guide-stage--dental .pinyin-guide-svg .pinyin-guide-tongue,
.pinyin-guide-stage--alveolar .pinyin-guide-svg .pinyin-guide-tongue {
  animation-duration: 1.15s;
}

.pinyin-guide-stage--retroflex .pinyin-guide-svg .pinyin-guide-tongue,
.pinyin-guide-stage--rhotic .pinyin-guide-svg .pinyin-guide-tongue {
  animation-duration: 1.4s;
}

.pinyin-guide-stage--palatal .pinyin-guide-svg .pinyin-guide-tongue {
  animation-duration: 1.25s;
}

.pinyin-guide-stage--bilabial .pinyin-guide-svg .pinyin-guide-lips,
.pinyin-guide-stage--labiodental .pinyin-guide-svg .pinyin-guide-lips {
  animation-duration: 1.05s;
}

.pinyin-guide-stage--roundedU .pinyin-guide-svg .pinyin-guide-lips,
.pinyin-guide-stage--roundedUmlaut .pinyin-guide-svg .pinyin-guide-lips {
  animation-duration: 1.6s;
  animation-name: pinyinGuideRoundedLips;
}

.pinyin-guide-stage--tone-1 .pinyin-guide-svg .pinyin-guide-jaw {
  animation-duration: 1.9s;
}

.pinyin-guide-stage--tone-2 .pinyin-guide-svg .pinyin-guide-jaw,
.pinyin-guide-stage--tone-2 .pinyin-guide-svg .pinyin-guide-tongue {
  animation-duration: 1.35s;
}

.pinyin-guide-stage--tone-3 .pinyin-guide-svg .pinyin-guide-jaw,
.pinyin-guide-stage--tone-3 .pinyin-guide-svg .pinyin-guide-tongue {
  animation-duration: 2.1s;
}

.pinyin-guide-stage--tone-4 .pinyin-guide-svg .pinyin-guide-jaw,
.pinyin-guide-stage--tone-4 .pinyin-guide-svg .pinyin-guide-tongue {
  animation-duration: 1s;
}

.pinyin-guide-svg .pinyin-guide-airflow-stream {
  stroke-dashoffset: 0;
  opacity: 0.95;
  animation: pinyinGuideAirflowStream 1.1s linear infinite;
}

.pinyin-guide-svg .pinyin-guide-airflow-core {
  opacity: 0.7;
  animation: pinyinGuideAirflowCore 1.1s ease-in-out infinite;
}

.pinyin-guide-svg .pinyin-guide-teeth {
  animation: pinyinGuideTeethFlash 1.9s ease-in-out infinite;
}

.pinyin-guide-front-svg {
  animation: pinyinGuideInsetFloat 2.8s ease-in-out infinite;
}

.pinyin-guide-side-svg {
  animation: none;
}

.pinyin-guide-side-svg .pinyin-guide-throat {
  opacity: 0.9;
}

.pinyin-guide-profile {
  min-height: 150px;
}

.pinyin-guide-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.pinyin-guide-note {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 48, 71, 0.08);
}

.pinyin-guide-note strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
}

.pinyin-guide-note p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
  font-size: 0.94rem;
}

body.lang-ar .pinyin-guide-note p,
body.lang-ar .pinyin-guide-head p {
  text-align: right;
}

@keyframes pinyinGuideFloat {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }
}

@keyframes pinyinGuideInsetFloat {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-3px) scale(1.02);
  }
}

@keyframes pinyinGuideLipsPulse {
  0%,
  100% {
    transform: scale(0.96, 0.94);
  }

  50% {
    transform: scale(1.05, 1.12);
  }
}

@keyframes pinyinGuideRoundedLips {
  0%,
  100% {
    transform: scale(0.9);
  }

  50% {
    transform: scale(1.08);
  }
}

@keyframes pinyinGuideJawOpen {
  0%,
  100% {
    transform: translateY(0) scaleY(1);
  }

  45% {
    transform: translateY(2px) scaleY(1.04);
  }

  70% {
    transform: translateY(4px) scaleY(1.08);
  }
}

@keyframes pinyinGuideTongueMove {
  0%,
  100% {
    transform: translateX(0) translateY(0) rotate(0deg);
  }

  35% {
    transform: translateX(3px) translateY(-3px) rotate(-2deg);
  }

  70% {
    transform: translateX(-2px) translateY(2px) rotate(1deg);
  }
}

.pinyin-guide-stage--dental .pinyin-guide-svg .pinyin-guide-tongue {
  animation-name: pinyinGuideDentalTongue;
}

.pinyin-guide-stage--alveolar .pinyin-guide-svg .pinyin-guide-tongue {
  animation-name: pinyinGuideAlveolarTongue;
}

.pinyin-guide-stage--retroflex .pinyin-guide-svg .pinyin-guide-tongue,
.pinyin-guide-stage--rhotic .pinyin-guide-svg .pinyin-guide-tongue {
  animation-name: pinyinGuideRetroflexTongue;
}

.pinyin-guide-stage--palatal .pinyin-guide-svg .pinyin-guide-tongue {
  animation-name: pinyinGuidePalatalTongue;
}

@keyframes pinyinGuideDentalTongue {
  0%,
  100% {
    transform: translateX(0) translateY(0) rotate(0deg);
  }

  40% {
    transform: translateX(5px) translateY(-4px) rotate(-2.5deg);
  }

  75% {
    transform: translateX(1px) translateY(2px) rotate(0.5deg);
  }
}

@keyframes pinyinGuideAlveolarTongue {
  0%,
  100% {
    transform: translateX(0) translateY(0) rotate(0deg);
  }

  35% {
    transform: translateX(7px) translateY(-1px) rotate(-1deg);
  }

  70% {
    transform: translateX(2px) translateY(1px) rotate(0.8deg);
  }
}

@keyframes pinyinGuideRetroflexTongue {
  0%,
  100% {
    transform: translateX(0) translateY(0) rotate(0deg);
  }

  42% {
    transform: translateX(4px) translateY(-5px) rotate(-5deg);
  }

  74% {
    transform: translateX(-1px) translateY(2px) rotate(2deg);
  }
}

@keyframes pinyinGuidePalatalTongue {
  0%,
  100% {
    transform: translateX(0) translateY(0) rotate(0deg);
  }

  38% {
    transform: translateX(6px) translateY(-6px) rotate(-3deg);
  }

  70% {
    transform: translateX(1px) translateY(1px) rotate(0.5deg);
  }
}

@keyframes pinyinGuideAirflowStream {
  0% {
    stroke-dashoffset: 40;
    opacity: 0.18;
  }

  45% {
    opacity: 0.92;
  }

  100% {
    stroke-dashoffset: 0;
    opacity: 0.12;
  }
}

@keyframes pinyinGuideAirflowCore {
  0%,
  100% {
    opacity: 0.3;
    transform: scaleX(0.88);
    transform-origin: left center;
  }

  50% {
    opacity: 0.95;
    transform: scaleX(1.08);
    transform-origin: left center;
  }
}

@keyframes pinyinGuideToneTrace {
  0%,
  100% {
    stroke-dashoffset: 150;
    opacity: 0.35;
  }

  45% {
    stroke-dashoffset: 0;
    opacity: 1;
  }

  80% {
    stroke-dashoffset: 0;
    opacity: 0.65;
  }
}

@keyframes pinyinGuideTeethFlash {
  0%,
  100% {
    opacity: 0.85;
  }

  50% {
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .pinyin-modal-body {
    grid-template-columns: 1fr;
  }

  .pinyin-tone-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pinyin-guide-notes {
    grid-template-columns: 1fr;
  }

  .pinyin-guide-stage {
    min-height: 300px;
  }

  .pinyin-guide-profile-main {
    padding-left: 92px;
  }

  .pinyin-guide-lips-inset {
    width: 112px;
    height: 112px;
  }
}

@media (max-width: 680px) {
  .pinyin-modal-dialog {
    max-height: calc(100vh - 24px);
    margin: 12px auto;
  }

  .pinyin-tone-row {
    grid-template-columns: 64px 1fr;
  }

  .pinyin-breakdown-row {
    grid-template-columns: 1fr;
  }

  .pinyin-guide-stage {
    min-height: 250px;
  }

  .pinyin-guide-lips-inset {
    left: 16px;
    bottom: 14px;
    width: 88px;
    height: 88px;
  }

  .pinyin-guide-profile-main {
    padding-left: 44px;
  }

  .pinyin-guide-sound-tag {
    left: 16px;
    top: 14px;
    font-size: clamp(1.8rem, 7vw, 2.4rem);
  }

  .pinyin-guide-tone-visual {
    left: 12px;
    top: 58px;
    width: 84px;
    height: 64px;
  }

  .pinyin-guide-tone-badge {
    right: 12px;
    top: 12px;
    font-size: 1.3rem;
  }
}

.strokes-page {
  padding-top: 56px;
}

.strokes-shell {
  display: grid;
  gap: 28px;
}

.strokes-intro h1 {
  margin: 0 0 14px;
  color: #183858;
  font-size: clamp(2.4rem, 5vw, 4rem);
}

.strokes-intro p {
  margin: 0 0 16px;
  font-size: clamp(1.02rem, 2vw, 1.3rem);
  color: #617487;
}

.strokes-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 48, 71, 0.12);
  border-radius: 24px;
  padding: 24px 20px;
  display: grid;
  gap: 18px;
}

.strokes-card-head h2 {
  margin: 0 0 8px;
  color: var(--ink);
}

.strokes-card-head p {
  margin: 0;
}

.strokes-table-wrap {
  overflow-x: auto;
}

.strokes-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.58);
}

.strokes-table th,
.strokes-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(35, 48, 71, 0.08);
  text-align: left;
  vertical-align: middle;
}

.strokes-table th {
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.stroke-symbol-cell {
  width: 116px;
}

.stroke-symbol {
  font-family: "Noto Serif SC", serif;
  font-size: 2.2rem;
  color: #de4b37;
}

.stroke-symbol-image {
  width: 78px;
  height: 78px;
  object-fit: contain;
  margin: 0 auto;
}

.stroke-name-cell {
  font-family: "Noto Serif SC", serif;
  font-size: 1.25rem;
  color: var(--ink);
}

.stroke-meaning-cell {
  color: var(--ink-soft);
}

.stroke-direction-cell {
  color: var(--ink-soft);
  min-width: 180px;
}

.stroke-pinyin-button {
  border: 0;
  border-radius: 999px;
  background: rgba(31, 94, 168, 0.08);
  color: var(--accent);
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.stroke-pinyin-button:hover,
.stroke-example-chip:hover {
  transform: translateY(-1px);
}

.stroke-pinyin-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.stroke-example-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stroke-example-chip {
  border: 0;
  border-radius: 999px;
  background: rgba(222, 75, 55, 0.1);
  color: #a43929;
  padding: 10px 14px;
  font-family: "Noto Serif SC", serif;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease;
}

@media (max-width: 1024px) {
  .pronunciation-hero,
  .pronunciation-grid {
    grid-template-columns: 1fr;
  }

  .strokes-table {
    min-width: 760px;
  }
}

.lesson-page {
  padding-top: 56px;
}

.lesson-shell {
  display: grid;
  gap: 28px;
}

.lesson-intro h1 {
  margin: 0 0 14px;
  color: #183858;
  font-size: clamp(2.4rem, 5vw, 4rem);
}

body[data-page="lesson"] .lesson-intro {
  position: relative;
  padding: 30px;
  border-radius: 32px;
  border: 1px solid rgba(242, 157, 34, 0.2);
  background:
    radial-gradient(circle at 88% 18%, rgba(242, 157, 34, 0.22), transparent 28%),
    radial-gradient(circle at 12% 24%, rgba(19, 184, 215, 0.18), transparent 30%),
    linear-gradient(135deg, rgba(255, 253, 248, 0.92), rgba(247, 240, 224, 0.84));
  box-shadow: 0 28px 80px rgba(181, 138, 73, 0.12);
  overflow: hidden;
}

body[data-page="lesson"] .lesson-intro::after {
  content: "AI";
  position: absolute;
  right: 28px;
  top: 18px;
  color: rgba(19, 184, 215, 0.1);
  font-size: clamp(4rem, 10vw, 8rem);
  font-weight: 900;
  letter-spacing: -0.08em;
  pointer-events: none;
}

body[data-page="lesson"] .lesson-intro h1 {
  color: #1f3d5f;
}

.lesson-ai-strip {
  margin-top: 20px;
}

.lesson-intro p {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.4rem);
  color: #617487;
}

.lesson-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 48, 71, 0.12);
  border-radius: 24px;
  padding: 24px 20px;
  display: grid;
  gap: 18px;
}

.lesson-card-head h2 {
  margin: 0 0 8px;
  color: var(--ink);
}

.lesson-card-head p {
  margin: 0;
}

.lesson-note {
  display: grid;
  gap: 10px;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(255, 251, 245, 0.92);
  border: 1px solid rgba(35, 48, 71, 0.08);
}

.lesson-note p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.lesson-note strong {
  color: var(--ink);
}

.dialogue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.dialogue-card {
  display: grid;
  gap: 16px;
  padding: 22px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(35, 48, 71, 0.1);
}

.dialogue-card h3 {
  margin: 0;
  color: var(--ink);
}

.dialogue-lines,
.dialogue-translation {
  display: grid;
  gap: 10px;
}

.dialogue-lines p,
.dialogue-translation p {
  margin: 0;
  line-height: 1.6;
}

.dialogue-lines em,
.lesson-reading-text {
  font-family: "Noto Serif SC", serif;
}

.lesson-hand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
}

.hand-sign-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(35, 48, 71, 0.1);
}

.hand-sign-number {
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hand-sign-character {
  font-family: "Noto Serif SC", serif;
  font-size: 3rem;
  line-height: 1;
  color: #de4b37;
}

.hand-sign-visual {
  min-height: 138px;
  border-radius: 18px;
  background-color: rgba(255, 253, 248, 0.96);
  background-image: url("../hand-signs-reference.png");
  background-repeat: no-repeat;
  background-size: 400% 300%;
  border: 1px solid rgba(35, 48, 71, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.hand-sign-1 { background-position: 0% 0%; }
.hand-sign-2 { background-position: 33.333% 0%; }
.hand-sign-3 { background-position: 66.666% 0%; }
.hand-sign-4 { background-position: 100% 0%; }
.hand-sign-5 { background-position: 0% 50%; }
.hand-sign-6 { background-position: 33.333% 50%; }
.hand-sign-7 { background-position: 66.666% 50%; }
.hand-sign-8 { background-position: 100% 50%; }
.hand-sign-9 { background-position: 0% 100%; }
.hand-sign-10 { background-position: 33.333% 100%; }

.hand-sign-pinyin {
  color: var(--accent);
  font-weight: 600;
}

.hand-sign-note {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.hand-sign-actions {
  margin-top: 4px;
}

.lesson-table-wrap {
  overflow-x: auto;
}

.lesson-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.58);
}

.lesson-table th,
.lesson-table td {
  padding: 14px;
  border-bottom: 1px solid rgba(35, 48, 71, 0.1);
  text-align: left;
  vertical-align: middle;
}

.lesson-table th {
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.lesson-number {
  font-weight: 700;
  color: var(--ink);
}

.lesson-character {
  font-family: "Noto Serif SC", serif;
  font-size: 1.9rem;
  color: #de4b37;
}

.lesson-pinyin {
  color: var(--accent);
  font-weight: 600;
}

.lesson-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lesson-action {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 0;
  display: inline-grid;
  place-items: center;
  background: rgba(31, 94, 168, 0.1);
  color: var(--accent);
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.lesson-action:hover {
  transform: translateY(-1px);
  background: rgba(31, 94, 168, 0.16);
}

.lesson-action svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.lesson-action .ai-mic-icon {
  width: 23px;
  height: 23px;
}

.ai-mic-icon .ai-mic-body,
.ai-mic-icon .ai-mic-base {
  fill: #fff;
}

.ai-mic-icon .ai-mic-spark,
.ai-mic-icon .ai-mic-dot {
  fill: #d8ff7a;
  filter: drop-shadow(0 0 3px rgba(216, 255, 122, 0.75));
}

.lesson-action-grid {
  text-decoration: none;
}

.stroke-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(20, 30, 48, 0.9);
  backdrop-filter: blur(10px);
  padding: 24px;
}

.stroke-overlay[hidden] {
  display: none;
}

.ai-listen-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(20, 30, 48, 0.88);
  backdrop-filter: blur(10px);
  padding: 24px;
}

.ai-listen-overlay[hidden] {
  display: none;
}

.ai-listen-dialog {
  position: relative;
  overflow: hidden;
  width: min(100%, 560px);
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 34px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(136, 217, 90, 0.22), transparent 28%),
    radial-gradient(circle at top left, rgba(19, 184, 215, 0.24), transparent 32%),
    rgba(255, 253, 248, 0.98);
  border: 10px solid rgba(19, 184, 215, 0.32);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28), 0 0 42px rgba(19, 184, 215, 0.22);
  text-align: center;
}

.ai-listen-dialog::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(19, 184, 215, 0.14);
  border-radius: 20px;
  pointer-events: none;
}

.ai-listen-dialog.is-correct-pop {
  animation: correctCardPop 0.62s cubic-bezier(0.2, 1.4, 0.34, 1);
}

.ai-listen-dialog.is-try-again-nudge {
  animation: tryAgainNudge 0.52s ease-in-out;
}

.ai-listen-dialog h2 {
  margin: 0;
  font-family: "Noto Serif SC", serif;
  font-size: clamp(3rem, 10vw, 6rem);
  line-height: 1;
  color: var(--ink);
}

.ai-listen-pinyin {
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 800;
}

.ai-listen-instruction {
  max-width: 34ch;
}

.ai-listen-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.ai-listen-feedback {
  margin: 0;
  min-height: 1.6em;
  font-weight: 800;
  color: var(--ink-soft);
}

.ai-listen-feedback[data-state="correct"] {
  color: #2f8c55;
}

.ai-listen-feedback[data-state="try"] {
  color: #c04734;
}

.ai-listen-feedback[data-state="listening"] {
  color: var(--accent);
}

.ai-listen-close {
  position: absolute;
  top: 26px;
  right: 34px;
  border: 0;
  background: none;
  color: white;
  font-size: 3rem;
  line-height: 1;
  cursor: pointer;
}

.stroke-dialog {
  width: min(100%, 780px);
  display: grid;
  gap: 18px;
  justify-items: center;
}

.stroke-canvas-card {
  width: 100%;
  display: grid;
  place-items: center;
  background: white;
  border: 12px solid rgba(181, 138, 73, 0.75);
  border-radius: 20px;
  padding: 28px;
}

.stroke-targets {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
}

.stroke-target {
  width: 260px;
  height: 260px;
  display: grid;
  place-items: center;
  background: rgba(247, 243, 234, 0.62);
  border-radius: 18px;
  font-family: "Noto Serif SC", serif;
  font-size: 7rem;
  color: rgba(35, 48, 71, 0.18);
}

.stroke-target[data-fallback="true"],
.stroke-target[data-fallback="error"] {
  border: 1px dashed rgba(31, 94, 168, 0.16);
}

.stroke-svg {
  width: 220px;
  height: 220px;
  display: block;
  transform: scaleY(-1);
  transform-origin: center;
}

.stroke-copy {
  display: grid;
  justify-items: center;
  gap: 14px;
  color: white;
}

.stroke-copy h2 {
  margin: 0;
  color: white;
  font-size: 3rem;
}

.stroke-close {
  position: absolute;
  top: 26px;
  right: 34px;
  border: 0;
  background: none;
  color: white;
  font-size: 3rem;
  line-height: 1;
  cursor: pointer;
}

.section-toolbar {
  margin-bottom: 24px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.generator-form {
  display: grid;
  gap: 12px;
}

.generator-form label {
  font-weight: 600;
}

.generator-form input {
  width: 100%;
  min-height: 54px;
  border-radius: 16px;
  border: 1px solid rgba(35, 48, 71, 0.14);
  padding: 0 16px;
  background: rgba(255, 253, 248, 0.92);
}

.helper-text {
  font-size: 0.94rem;
}

.generator-meta {
  margin-top: 22px;
  padding: 16px 18px;
  background: rgba(31, 94, 168, 0.06);
  border-radius: 18px;
}

.generator-meta strong {
  color: var(--ink);
}

.teacher-strip-inner {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.workflow-list {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.workflow-list span,
.sheet-badge {
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(31, 94, 168, 0.08);
  color: var(--accent);
  font-weight: 600;
}

.worksheet-page {
  padding-top: 0;
}

.worksheet-toolbar {
  padding-top: 34px;
  padding-bottom: 18px;
}

.worksheet-actions {
  justify-content: flex-end;
  margin: 0 0 22px;
}

.sound-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.sound-button-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
}

.sound-button-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.worksheet-sheet {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 251, 255, 0.9)),
    var(--paper-strong);
  border-radius: 28px;
  padding: 28px;
  box-shadow: 0 24px 64px rgba(35, 48, 71, 0.12), 0 18px 46px rgba(27, 184, 222, 0.08);
  border: 1px solid rgba(27, 184, 222, 0.14);
}

.worksheet-sheet-inner {
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.95), rgba(248, 244, 236, 0.95)),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(35, 48, 71, 0.02) 27px 28px);
  border: 1px solid rgba(35, 48, 71, 0.08);
  border-radius: 24px;
  padding: 28px;
}

.worksheet-top {
  display: grid;
  grid-template-columns: 1.1fr auto;
  gap: 22px;
  margin-bottom: 22px;
  align-items: center;
}

.worksheet-copy {
  display: grid;
  gap: 10px;
}

.worksheet-character-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.worksheet-character {
  font-size: 6.2rem;
  line-height: 1;
  color: var(--ink);
}

.worksheet-pinyin {
  font-size: 2.5rem;
  color: var(--accent);
  font-weight: 700;
}

.worksheet-meaning {
  font-weight: 600;
  color: var(--ink);
}

.sheet-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
}

.worksheet-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, var(--sheet-square)));
  gap: var(--sheet-gap);
  justify-content: start;
}

.practice-cell {
  width: var(--sheet-square);
  aspect-ratio: 1 / 1;
  border-radius: 0;
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(31, 94, 168, 0.26);
}

.practice-cell::before,
.practice-cell::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 50%;
  pointer-events: none;
  z-index: 1;
}

.practice-cell::before {
  width: 1px;
  transform: translateX(-0.5px);
  border-left: 1.5px dashed rgba(31, 94, 168, 0.34);
}

.practice-cell::after {
  inset: 50% 0 auto 0;
  top: 50%;
  height: 1px;
  transform: translateY(-0.5px);
  border-top: 1.5px dashed rgba(31, 94, 168, 0.34);
}

.practice-cell.sample {
  background: linear-gradient(180deg, #4f95e3, #2f71bc);
  border-color: rgba(38, 92, 156, 0.95);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.practice-cell.sample::before {
  border-left-color: rgba(255, 255, 255, 0.5);
}

.practice-cell.sample::after {
  border-top-color: rgba(255, 255, 255, 0.5);
}

.practice-character {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: "Noto Serif SC", serif;
  font-size: 3.5rem;
  z-index: 2;
}

.practice-cell:not(.sample) .practice-character {
  color: transparent;
}

.worksheet-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(35, 48, 71, 0.08);
}

.worksheet-footer strong {
  display: block;
  margin-bottom: 6px;
}

.sheet-caption {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.7s ease forwards;
}

.stagger-1 {
  animation-delay: 0.12s;
}

.stagger-2 {
  animation-delay: 0.24s;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@page {
  size: auto;
  margin: 12mm;
}

@media (max-width: 1024px) {
  .hero-grid,
  .split-panel,
  .generator-layout,
  .feature-grid,
  .library-grid,
  .mini-library {
    grid-template-columns: 1fr;
  }

  .game-hero,
  .game-choice-grid {
    grid-template-columns: 1fr 1fr;
  }

  .worksheet-grid {
    grid-template-columns: repeat(9, minmax(0, var(--sheet-square)));
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .pinyin-legend-grid {
    grid-template-columns: 1fr;
  }

  .chat-layout,
  .chat-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .nav-row,
  .teacher-strip-inner,
  .worksheet-top,
  .field-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .site-nav {
    width: 100%;
  }

  .game-hero,
  .game-choice-grid,
  .game-status-grid,
  .game-topic-grid {
    grid-template-columns: 1fr;
  }

  .worksheet-grid {
    grid-template-columns: repeat(9, minmax(0, var(--sheet-square)));
  }

  :root {
    --sheet-square: 72px;
    --sheet-gap: 10px;
  }

  .measure-search-card {
    grid-template-columns: 1fr;
  }

  .chat-input-row {
    grid-template-columns: 1fr;
  }

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

  .chat-bubble {
    max-width: 100%;
  }

  .pinyin-modal-dialog {
    width: min(96vw, 1040px);
    margin: 20px auto;
  }

  .pinyin-tone-row,
  .pinyin-breakdown-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body::before,
  .no-print,
  .site-header {
    display: none !important;
  }

  main,
  .page-main,
  .worksheet-stage,
  section {
    padding: 0;
    margin: 0;
  }

  .container {
    width: 100%;
    max-width: none;
  }

  .worksheet-sheet {
    box-shadow: none;
    border: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .worksheet-sheet-inner {
    border-radius: 0;
    border: 0;
    padding: 0;
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .worksheet-top {
    display: flex !important;
    flex-direction: row;
    gap: 28px;
    align-items: start;
    margin-bottom: 18px;
  }

  .worksheet-copy {
    flex: 0 0 244px;
    min-width: 244px;
  }

  .worksheet-copy,
  .worksheet-layout,
  .practice-group,
  .practice-row {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .practice-cell,
  .practice-cell.sample {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .page-two {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    break-before: page;
    page-break-before: always;
  }

  .word-results-page,
  .word-results-heading,
  .word-results-title {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .word-results-table-wrap {
    overflow: visible;
  }

  body[data-page="strokes-map"] {
    background: #fff;
  }

  body[data-page="strokes-map"]::before,
  .strokes-map-toolbar {
    display: none !important;
  }

  .strokes-map-page,
  .strokes-map-frame {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    background: #fff;
  }

  .strokes-map-frame img {
    width: 100%;
  }
}

.worksheet-sheet {
  background: transparent;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  border: 0;
}

.worksheet-sheet-inner {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 8px 0 0;
}

.worksheet-top {
  grid-template-columns: auto 1fr;
  gap: 26px;
  align-items: start;
  margin-bottom: 14px;
}

.worksheet-copy {
  gap: 14px;
  min-width: 246px;
}

.eyebrow {
  margin-bottom: 0;
  padding: 10px 16px;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
}

.worksheet-character-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.worksheet-character {
  font-size: 5.8rem;
}

.worksheet-meta-copy {
  display: grid;
  gap: 2px;
}

.worksheet-pinyin {
  font-size: 2.2rem;
  line-height: 1;
}

.worksheet-meaning {
  font-size: 0.95rem;
  text-transform: lowercase;
}

.worksheet-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px;
  margin-top: 10px;
}

.practice-group {
  display: grid;
  gap: 14px;
}

.practice-row {
  display: grid;
  grid-template-columns: repeat(5, var(--sheet-square));
  gap: 14px;
}

.practice-cell {
  width: var(--sheet-square);
  border-radius: 0;
}

.practice-character {
  font-size: 3.4rem;
}

.worksheet-footer {
  display: none;
}

@media (max-width: 1180px) {
  .worksheet-top {
    grid-template-columns: 1fr;
  }

  .worksheet-layout {
    grid-template-columns: 1fr;
  }
}

/* Latest worksheet match */
  .worksheet-stage .container {
    width: min(calc(100% - 40px), 1360px);
  }

.worksheet-sheet-inner {
  padding-top: 2px;
}

.worksheet-top {
  grid-template-columns: 244px 1fr;
  gap: 28px;
  margin-bottom: 14px;
}

.worksheet-copy {
  min-width: 0;
  gap: 18px;
}

.eyebrow {
  padding: 12px 18px;
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  background: rgba(181, 138, 73, 0.14);
}

.worksheet-character-row {
  align-items: center;
  gap: 20px;
  flex-wrap: nowrap;
}

.worksheet-meta-copy {
  min-width: 360px;
}

.worksheet-character {
  font-size: 6rem;
  line-height: 0.92;
}

.worksheet-pinyin {
  font-size: 2rem;
  font-weight: 700;
}

.worksheet-meaning {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: lowercase;
}

.worksheet-definition {
  margin-top: 8px;
  max-width: 40ch;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink-soft);
  text-transform: none;
}

.page-two {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid rgba(35, 48, 71, 0.08);
}

.word-results-page {
  display: grid;
  gap: 18px;
}

.word-results-title {
  margin: 0;
  font-family: "Libre Baskerville", serif;
  font-size: 2rem;
  color: var(--ink);
}

.word-results-section {
  display: grid;
  gap: 10px;
}

.word-results-heading {
  margin: 0;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 700;
}

.word-results-table-wrap {
  overflow: hidden;
  border: 1px solid rgba(35, 48, 71, 0.08);
  background: rgba(255, 255, 255, 0.72);
}

.word-results-table {
  width: 100%;
  border-collapse: collapse;
}

.word-results-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(35, 48, 71, 0.08);
  vertical-align: top;
  font-size: 0.96rem;
  line-height: 1.45;
}

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

.word-results-word {
  width: 18%;
  color: var(--ink);
  font-family: "Noto Serif SC", serif;
  font-size: 1.2rem;
}

.word-results-pinyin {
  width: 22%;
  color: var(--accent);
  font-weight: 600;
}

.word-results-definition {
  color: var(--ink-soft);
}

.word-results-empty {
  margin: 0;
  color: var(--ink-soft);
}

.worksheet-layout {
  display: block;
  margin-top: 4px;
}

.practice-group {
  display: grid;
  gap: 14px;
  width: fit-content;
}

.practice-row {
  display: grid;
  grid-template-columns: repeat(7, var(--sheet-square));
  gap: 14px;
}

.practice-cell {
  width: var(--sheet-square);
  aspect-ratio: 1 / 1;
  border-radius: 0;
  border: 0;
  background-color: transparent;
  background-image: var(--practice-grid-white);
  background-size: 100% 100%;
  background-position: center center;
  background-repeat: no-repeat;
}

.practice-cell.sample {
  background-image: var(--practice-grid-blue);
}

.practice-cell-stroke {
  background-image: var(--practice-grid-stroke-white);
}

.practice-cell-stroke.sample {
  background-image: var(--practice-grid-stroke-blue);
}

.practice-cell.sample .practice-character {
  color: #ffffff;
}

.practice-cell.trace .practice-character {
  color: rgba(35, 48, 71, 0.18);
}

.practice-cell::before,
.practice-cell::after {
  display: none;
}

.practice-character {
  font-size: 3.25rem;
}

@media (max-width: 1180px) {
  .worksheet-top {
    grid-template-columns: 1fr;
  }

  .practice-group {
    width: auto;
    overflow-x: auto;
    padding-bottom: 8px;
  }
}

.quiz-page {
  padding: 42px 0 84px;
}

.quiz-shell {
  display: grid;
  gap: 24px;
}

.quiz-hero {
  padding: 10px 0 0;
}

.quiz-hero-copy {
  max-width: 860px;
}

.quiz-hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2.6rem, 5vw, 4.6rem);
}

.quiz-subtitle {
  margin: -4px 0 12px;
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.quiz-hero .lead {
  margin: 0;
  max-width: 880px;
  color: var(--ink-soft);
  font-size: 1.14rem;
  line-height: 1.72;
}

.quiz-builder-card,
.quiz-output-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(243, 248, 255, 0.7)),
    rgba(255, 255, 255, 0.7);
  border: 1px solid var(--tech-border);
  border-radius: 28px;
  box-shadow: var(--tech-glow);
  backdrop-filter: blur(16px);
}

.quiz-builder-card {
  padding: 28px;
}

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

.quiz-builder-head h2 {
  margin: 0 0 8px;
  font-size: 1.7rem;
}

.quiz-builder-head p {
  margin: 0;
  color: var(--ink-soft);
}

.quiz-builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.quiz-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.quiz-control-field,
.quiz-toggle-field {
  display: grid;
  gap: 8px;
}

.quiz-control-field span,
.quiz-toggle-field span {
  color: var(--ink);
  font-weight: 700;
}

.quiz-control-field select {
  min-width: 132px;
  padding: 10px 12px;
  border: 1px solid rgba(35, 48, 71, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.quiz-toggle-field {
  min-width: 140px;
}

.quiz-toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.quiz-input-label {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 700;
}

.quiz-source {
  width: 100%;
  min-height: 220px;
  padding: 18px 20px;
  border: 1px solid rgba(35, 48, 71, 0.12);
  border-radius: 22px;
  resize: vertical;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 1.04rem;
  line-height: 1.65;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.quiz-source:focus {
  outline: none;
  border-color: rgba(27, 184, 222, 0.42);
  box-shadow: 0 0 0 4px rgba(27, 184, 222, 0.12);
}

.quiz-status {
  margin: 14px 0 0;
  color: var(--ink-soft);
}

.quiz-builder-actions .button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.quiz-output-card {
  padding: 24px;
}

.quiz-print-note {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(27, 184, 222, 0.08);
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.quiz-paper {
  padding: 26px 28px 22px;
  border-radius: 26px;
  background: #fffdfa;
  border: 1px solid rgba(35, 48, 71, 0.1);
  box-shadow: 0 22px 60px rgba(35, 48, 71, 0.08);
}

.quiz-paper-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  padding-bottom: 16px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(35, 48, 71, 0.12);
}

.quiz-paper-head h2 {
  margin: 4px 0 0;
  font-size: 2rem;
}

.quiz-paper-title-single {
  white-space: nowrap;
}

.quiz-paper-label {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  font-weight: 700;
}

.quiz-paper-lines {
  display: grid;
  gap: 10px;
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}

.quiz-paper-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.quiz-paper-lines {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.quiz-paper-meta-below .quiz-paper-lines {
  width: 100%;
}

.quiz-section + .quiz-section {
  margin-top: 12px;
}

.quiz-section h3 {
  margin: 0 0 9px;
  font-size: 1.24rem;
}

.quiz-grid-sections {
  display: block;
}

.quiz-grid-sections .quiz-section + .quiz-section {
  margin-top: 12px;
}

.quiz-mcq-list,
.quiz-fill-list,
.quiz-sort-list {
  display: grid;
  gap: 10px;
}

.quiz-mcq-item,
.quiz-fill-item,
.quiz-sort-item,
.quiz-match-item {
  break-inside: avoid;
}

.quiz-mcq-item p,
.quiz-fill-item,
.quiz-sort-item {
  margin: 0;
  line-height: 1.45;
}

.quiz-sort-list {
  gap: 12px;
}

.quiz-sort-intro {
  margin: 0 0 2px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.quiz-sort-item {
  display: grid;
  gap: 6px;
}

.quiz-sort-number-line {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(28px, max-content));
  gap: 16px;
  padding-left: 12px;
  justify-content: start;
}

.quiz-sort-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 18px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--ink-soft);
  border-bottom: 1.5px solid rgba(35, 48, 71, 0.28);
}

.quiz-fill-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 18px;
  align-items: start;
}

.quiz-fill-prompts {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.quiz-fill-item,
.quiz-fill-option {
  min-height: 42px;
  display: grid;
  align-items: center;
}

.quiz-fill-item {
  grid-template-columns: max-content 1fr;
  column-gap: 8px;
}

.quiz-fill-options {
  position: relative;
  padding: 16px 12px 10px;
  border-radius: 16px;
  background: rgba(244, 248, 255, 0.72);
}

.quiz-fill-options h4 {
  position: absolute;
  top: -12px;
  right: 12px;
  margin: 0;
  padding: 2px 10px;
  border-radius: 999px;
  background: #fffdfa;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.quiz-fill-options-list {
  display: grid;
  gap: 8px;
}

.quiz-fill-option {
  grid-template-columns: 24px 1fr;
  gap: 6px;
  line-height: 1.35;
}

.quiz-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  margin-top: 10px;
}

.quiz-choice {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  min-height: 30px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(244, 248, 255, 0.72);
}

.quiz-matching-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quiz-matching-column {
  display: grid;
  gap: 8px;
}

.quiz-match-item {
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(244, 248, 255, 0.72);
  line-height: 1.45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quiz-match-item-right {
  justify-content: flex-start;
}

.quiz-match-text {
  flex: 1 1 auto;
}

.quiz-match-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(35, 48, 71, 0.7);
  flex: 0 0 auto;
}

.quiz-answer-key {
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(35, 48, 71, 0.05);
  color: var(--ink-soft);
  font-size: 0.96rem;
  line-height: 1.45;
}

.quiz-answer-key h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 1.04rem;
}

.quiz-answer-key p {
  margin: 8px 0 0;
}

.is-hidden {
  display: none !important;
}

html[dir="rtl"] .quiz-builder-head,
html[dir="rtl"] .quiz-builder-actions,
html[dir="rtl"] .quiz-paper-head,
html[dir="rtl"] .quiz-grid-sections,
html[dir="rtl"] .quiz-matching-wrap,
html[dir="rtl"] .quiz-choice-grid {
  direction: rtl;
}

html[dir="rtl"] .quiz-fill-options h4 {
  right: auto;
  left: 12px;
}

html[dir="rtl"] .quiz-source {
  direction: ltr;
  text-align: left;
}

html[dir="rtl"] .quiz-mcq-item p,
html[dir="rtl"] .quiz-fill-item,
html[dir="rtl"] .quiz-fill-option,
html[dir="rtl"] .quiz-match-item,
html[dir="rtl"] .quiz-sort-item p,
html[dir="rtl"] .quiz-sort-number-line,
html[dir="rtl"] .quiz-answer-key p {
  direction: ltr;
  text-align: left;
}

html[dir="rtl"] .quiz-choice-grid,
html[dir="rtl"] .quiz-choice,
html[dir="rtl"] .quiz-matching-wrap,
html[dir="rtl"] .quiz-matching-column,
html[dir="rtl"] .quiz-match-item-left,
html[dir="rtl"] .quiz-match-item-right {
  direction: ltr;
}

html[dir="rtl"] .quiz-choice {
  text-align: left;
}

html[dir="rtl"] .quiz-match-item-left {
  justify-content: space-between;
}

html[dir="rtl"] .quiz-match-item-right {
  justify-content: flex-start;
}

@media (max-width: 980px) {
  .quiz-builder-head,
  .quiz-paper-head,
  .quiz-grid-sections,
  .quiz-fill-wrap,
  .quiz-matching-wrap,
  .quiz-choice-grid {
    grid-template-columns: 1fr;
  }

  .quiz-builder-head,
  .quiz-paper-head {
    display: grid;
  }

  .quiz-paper-meta {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .quiz-paper-lines-right {
    text-align: left;
  }

  .quiz-builder-actions {
    width: 100%;
  }

  .quiz-builder-actions .button {
    flex: 1 1 180px;
  }

  .quiz-paper {
    padding: 26px 22px;
  }
}

@media print {
  @page {
    margin: 0.55in;
    size: auto;
  }

  body {
    background: #fff !important;
  }

  body::before,
  .site-header,
  .quiz-hero,
  .quiz-builder-card,
  .quiz-print-note,
  .quiz-answer-key {
    display: none !important;
  }

  .quiz-page,
  .quiz-shell,
  .quiz-output-card,
  .quiz-paper {
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    border: 0 !important;
  }

  .quiz-output-card {
    display: block !important;
  }

  .quiz-paper-head,
  .quiz-mcq-item,
  .quiz-fill-item,
  .quiz-sort-item,
  .quiz-match-item {
    break-inside: avoid;
  }

  .quiz-paper-head {
    margin-bottom: 18px;
    display: grid !important;
    grid-template-columns: 1fr !important;
    align-items: start !important;
    gap: 16px !important;
  }

  .quiz-section {
    break-inside: auto;
    page-break-inside: auto;
  }

  .quiz-section h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  .quiz-choice-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px 18px !important;
  }

  .quiz-paper-meta {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    align-items: start !important;
  }

  .quiz-paper-lines {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(220px, 1fr)) !important;
    gap: 10px 28px !important;
    width: 100% !important;
  }

  .quiz-matching-wrap {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .quiz-fill-wrap {
    display: grid !important;
    grid-template-columns: minmax(0, 1.3fr) minmax(180px, 0.7fr);
    gap: 14px;
  }

  .quiz-fill-options-list {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .quiz-fill-options {
    float: none !important;
    width: auto !important;
    margin-left: 0 !important;
    margin-bottom: 0 !important;
  }

  .quiz-choice,
  .quiz-match-item {
    margin-bottom: 6px;
  }

}
