/* ============================================================
   Reset & Variables
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #2563eb;
  --blue-dark:  #1d4ed8;
  --blue-light: #eff6ff;
  --green:      #16a34a;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-300:   #cbd5e1;
  --gray-400:   #94a3b8;
  --gray-500:   #64748b;
  --gray-800:   #1e293b;
  --gray-900:   #0f172a;
  --white:      #ffffff;
  --red:        #dc2626;

  --sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  /* Kaiti font stack:
     - 'LXGW WenKai Screen' = open-source webfont (OFL) loaded via CDN
       in index.html — guarantees Kaiti rendering on Android/iOS/PC
       where no system Kaiti is installed
     - 'Kaiti SC' = iOS / macOS native Kaiti
     - 'STKaiti' / 'KaiTi' / 'Kaiti' = Windows / older macOS Kaiti names
     - rest are last-resort serif fallbacks */
  --chinese: 'LXGW WenKai Screen', 'Kaiti SC', 'STKaiti', 'KaiTi', 'Kaiti', 'AR PL UKai CN', 'STSong', 'SimSun', 'Noto Serif CJK SC', serif;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);

  --grid-border: #b8cad8;
  --grid-guide:  #dce8f0;
  --grid-cols:   10;
}

/* ============================================================
   Base
   ============================================================ */
body {
  font-family: var(--sans);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0.875rem 1.5rem;
}
.header-inner { max-width: 1200px; margin: 0 auto; }

.brand { display: flex; align-items: center; gap: 0.75rem; }

.brand-icon {
  width: 38px; height: 38px;
  background: var(--blue);
  color: var(--white);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--chinese);
  font-size: 1.15rem; font-weight: bold;
  flex-shrink: 0; line-height: 1;
  position: relative; overflow: hidden;
}
.brand-icon::before,
.brand-icon::after { content: ''; position: absolute; background: rgba(255,255,255,.25); }
.brand-icon::before { width: 1px; height: 100%; left: 50%; top: 0; }
.brand-icon::after  { height: 1px; width: 100%; top: 50%; left: 0; }

.brand-logo {
  height: 80px;
  width: auto;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.brand h1 { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.brand p  { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.1rem; }

/* ============================================================
   Layout
   ============================================================ */
.app-layout {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 276px 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* ============================================================
   Sidebar card
   ============================================================ */
.card {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.5rem;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 0.4rem;
  position: sticky; top: 1.5rem;
}

.card-section {
  background: var(--white);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: 0.85rem;
  border: 1px solid var(--gray-200);
}
.card-section-panel {
  background: var(--white);
  border-radius: 10px !important;
  border: 1px solid var(--gray-200) !important;
  overflow: hidden;
}

.divider { height: 1px; background: var(--gray-200); margin: 0 -1.25rem; }

/* ============================================================
   User Status Block
   ============================================================ */

/* — logged out — */
.status-logged-out {
  text-align: center;
  padding: 0.5rem 0;
}
.status-logged-out p {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}
.status-logged-out p strong { color: var(--gray-800); }
.status-auth-btns {
  display: flex; gap: 0.5rem;
}
.status-auth-btns .btn-login {
  flex: 1;
  border: 1.5px solid var(--blue);
  background: transparent;
  color: var(--blue);
  border-radius: 7px;
  padding: 0.45rem;
  font-size: 0.8125rem; font-weight: 600;
  cursor: pointer; font-family: var(--sans);
  transition: all 0.15s;
}
.status-auth-btns .btn-login:hover { background: var(--blue-light); }
.status-auth-btns .btn-register {
  flex: 1;
  background: var(--blue);
  color: var(--white);
  border: none;
  border-radius: 7px;
  padding: 0.45rem;
  font-size: 0.8125rem; font-weight: 600;
  cursor: pointer; font-family: var(--sans);
  transition: background 0.15s;
}
.status-auth-btns .btn-register:hover { background: var(--blue-dark); }

/* — logged in — */
.status-logged-in {
  display: flex; flex-direction: column; gap: 0.5rem;
}
.status-user-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
}
.status-email {
  font-size: 0.75rem; font-weight: 600;
  color: var(--gray-800);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1;
}
.status-pro-badge {
  font-size: 0.65rem; font-weight: 700;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-logout-btn {
  background: none; border: none;
  font-size: 0.72rem; color: var(--gray-400);
  cursor: pointer; font-family: var(--sans);
  padding: 0.1rem 0.25rem; border-radius: 4px;
  transition: color 0.15s; flex-shrink: 0;
}
.status-logout-btn:hover { color: var(--red); }

/* Usage bar */
.status-usage {
  display: flex; flex-direction: column; gap: 0.3rem;
}
.status-usage-label {
  display: flex; justify-content: space-between;
  font-size: 0.7rem; color: var(--gray-500);
}
.usage-bar-track {
  height: 5px; background: var(--gray-200);
  border-radius: 99px; overflow: hidden;
}
.usage-bar-fill {
  height: 100%; border-radius: 99px;
  background: var(--blue);
  transition: width 0.4s ease;
}
.usage-bar-fill.full { background: var(--red); }

.status-upgrade-link {
  font-size: 0.72rem; color: var(--gray-500);
  text-align: center;
}
.status-upgrade-link a {
  color: var(--blue); text-decoration: none; font-weight: 600;
}
.status-upgrade-link a:hover { text-decoration: underline; }

/* Pro unlimited label */
.status-pro-info {
  font-size: 0.75rem; color: var(--green); font-weight: 500;
}

/* ============================================================
   Form fields
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 0.4rem; }

.field-label {
  font-size: 0.78rem; font-weight: 700;
  color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.06em;
}
.field-row, .field-footer {
  display: flex; justify-content: space-between; align-items: center;
}

textarea {
  width: 100%;
  border: 1.5px solid var(--gray-200); border-radius: 8px;
  padding: 0.625rem 0.75rem;
  font-family: var(--chinese); font-size: 1.125rem; line-height: 1.8;
  color: var(--gray-900); background: var(--white);
  resize: vertical; outline: none; min-height: 96px;
  transition: border-color 0.15s;
}
textarea:focus { border-color: var(--blue); }
textarea::placeholder {
  color: var(--gray-400); font-size: 0.875rem;
  font-family: var(--sans); line-height: 1.6;
}

.count { font-size: 0.72rem; color: var(--gray-400); }

.link-btn {
  background: none; border: none;
  font-size: 0.72rem; color: var(--gray-400);
  cursor: pointer; padding: 0.15rem 0.3rem;
  border-radius: 4px; font-family: var(--sans); transition: color 0.15s;
}
.link-btn:hover { color: var(--red); }
.link-btn-danger { color: var(--red) !important; }
.link-btn-danger:hover { color: #b91c1c !important; }

.input-actions { display: flex; gap: 0.25rem; align-items: center; }

.field-select {
  width: 100%;
  border: 1.5px solid var(--gray-200); border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.8125rem; color: var(--gray-900); font-family: var(--sans);
  background: var(--white); outline: none; cursor: pointer;
  transition: border-color 0.15s;
}
.field-select:focus { border-color: var(--blue); }

/* ============================================================
   Segmented controls
   ============================================================ */
.seg-ctrl {
  display: flex;
  border: 1.5px solid var(--gray-200); border-radius: 7px; overflow: hidden;
}
.seg {
  flex: 1; border: none; background: transparent;
  padding: 0.4rem 0.25rem;
  font-size: 0.8125rem; color: var(--gray-500);
  cursor: pointer; font-family: var(--sans);
  transition: all 0.15s;
  border-right: 1.5px solid var(--gray-200);
}
.seg:last-child { border-right: none; }
.seg:hover:not(.active) { background: var(--gray-50); }
.seg.active { background: var(--blue); color: var(--white); font-weight: 600; }

/* Color swatches */
.color-swatch-ctrl {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}
.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid transparent;
  outline: 2px solid transparent;
  outline-offset: 1px;
  cursor: pointer;
  transition: transform 0.15s, outline-color 0.15s;
  padding: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active {
  border-color: white;
  outline-color: rgba(0,0,0,0.35);
}

/* ============================================================
   Range slider
   ============================================================ */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%; height: 3px;
  background: var(--gray-200);
  border-radius: 99px;
  cursor: pointer; outline: none;
  margin: 0.55rem 0 0.35rem;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 6px rgba(37,99,235,0.35);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.range::-webkit-slider-thumb:hover {
  box-shadow: 0 2px 10px rgba(37,99,235,0.5);
  transform: scale(1.12);
}
.range:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(37,99,235,0.15);
}
.range::-moz-range-thumb {
  border: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 6px rgba(37,99,235,0.35);
  cursor: pointer;
}
.range::-moz-range-track {
  background: var(--gray-200);
  height: 3px; border-radius: 99px;
}
.range-labels {
  display: flex; justify-content: space-between;
  font-size: 0.62rem; color: var(--gray-300);
  letter-spacing: 0.04em;
}
.badge {
  font-size: 0.82rem; font-weight: 600;
  color: var(--gray-800);
  background: var(--gray-100);
  padding: 0.2rem 0.6rem;
  border-radius: 7px;
  min-width: 2.4rem; text-align: center;
  border: 1px solid var(--gray-200);
}

/* ============================================================
   Toggle rows
   ============================================================ */
.toggle-row {
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; user-select: none;
}
.toggle-row input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--blue); cursor: pointer; flex-shrink: 0;
}
.toggle-text { font-size: 0.8125rem; color: var(--gray-800); }

.stepper {
  display: flex; align-items: center; gap: 0.5rem; margin-top: 0.25rem;
}
.stepper-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--gray-200); background: var(--gray-100);
  font-size: 1rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-700); transition: background 0.15s;
}
.stepper-btn:hover { background: var(--gray-200); }
.stepper-btn:disabled { opacity: 0.35; cursor: default; }
.stepper-val {
  min-width: 24px; text-align: center;
  font-size: 0.875rem; font-weight: 600; color: var(--gray-800);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary {
  width: 100%; background: var(--blue); color: var(--white);
  border: none; border-radius: 8px; padding: 0.6875rem;
  font-size: 0.9375rem; font-weight: 600;
  cursor: pointer; font-family: var(--sans);
  transition: background 0.15s, transform 0.1s; margin-top: 0.25rem;
}
.btn-primary:hover  { background: var(--blue-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
  background: var(--gray-300); cursor: not-allowed; transform: none;
}

.btn-outline {
  display: inline-flex; align-items: center; gap: 0.375rem;
  background: transparent; border: 1.5px solid var(--gray-200);
  border-radius: 7px; padding: 0.375rem 0.75rem;
  font-size: 0.8125rem; color: var(--gray-800);
  cursor: pointer; font-family: var(--sans); transition: all 0.15s;
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }

/* ============================================================
   Preview section
   ============================================================ */
.preview-section {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; min-width: 0;
}
.preview-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--gray-200);
}
.preview-bar-actions {
  display: flex; align-items: center; gap: 0.5rem;
}
.preview-label {
  font-size: 0.72rem; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.copybook-wrap {
  padding: 1.5rem; min-height: 480px;
  background: var(--gray-100);
  overflow-x: hidden; overflow-y: auto;
  width: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center;
  gap: 1.5rem;
}

/* ============================================================
   Empty hint
   ============================================================ */
.empty-hint {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1rem; min-height: 400px; color: var(--gray-400);
  align-self: stretch;
}
.tian-demo {
  width: 72px; height: 72px; border: 2px solid var(--gray-200);
  border-radius: 10px; position: relative;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.tian-demo::before,
.tian-demo::after { content: ''; position: absolute; background: var(--gray-200); }
.tian-demo::before { width: 1px; height: 100%; left: 50%; top: 0; }
.tian-demo::after  { height: 1px; width: 100%; top: 50%; left: 0; }
.tian-demo span {
  position: relative; z-index: 1;
  font-family: var(--chinese); font-size: 2.25rem; color: var(--gray-300); line-height: 1;
}
.empty-hint p { font-size: 0.875rem; text-align: center; line-height: 1.75; }

/* ============================================================
   Limit-reached banner (shown below the partial copybook)
   ============================================================ */
.limit-banner {
  margin-top: 1rem;
  border: 1.5px dashed var(--gray-300);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  text-align: center;
  background: var(--gray-50);
  align-self: stretch;
}
.limit-banner .limit-icon { font-size: 1.5rem; margin-bottom: 0.4rem; }
.limit-banner h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.3rem; }
.limit-banner p  { font-size: 0.8rem; color: var(--gray-500); line-height: 1.5; }
.limit-banner .btn-upgrade {
  display: inline-block; margin-top: 0.75rem;
  background: var(--blue); color: var(--white);
  border: none; border-radius: 7px;
  padding: 0.45rem 1.25rem;
  font-size: 0.8125rem; font-weight: 600;
  cursor: pointer; font-family: var(--sans);
  transition: background 0.15s;
}
.limit-banner .btn-upgrade:hover { background: var(--blue-dark); }

/* ============================================================
   田字格 copybook grid
   ============================================================ */
.copybook-grid {
  display: inline-block;
  border-top:  1px solid var(--grid-border);
  border-left: 1px solid var(--grid-border);
  line-height: 0;
  max-width: 100%;
}
/* Top-level grid (笔画帖 mode — no .copybook-container wrapper) */
.copybook-wrap > .copybook-grid { animation: fadeUp 0.25s ease; align-self: center; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.char-row { display: flex; line-height: 0; }

.cell-wrapper { display: flex; flex-direction: column; align-items: center; }

/* ── 汉字帖 seq row (pinyin + stroke progression above grid) ── */
.copybook-container {
  display: flex; flex-direction: column;
  animation: fadeUp 0.25s ease;
  width: fit-content;
}
.char-block { display: flex; flex-direction: column; }

/* Visual separation between consecutive character blocks on the same page
   so the practice area for one character doesn't visually merge into the
   next one (especially noticeable when Blank rows > 0). */
.preview-page .char-block + .char-block { margin-top: 10mm; }
@media print {
  .preview-page .char-block + .char-block { margin-top: 8mm; }
}

/* ── A4 page card (screen preview) ──────────────────────── */
.preview-page {
  background: var(--white);
  box-shadow: 0 2px 12px rgba(0,0,0,.12), 0 1px 4px rgba(0,0,0,.06);
  width: 100%; box-sizing: border-box;
  padding: 1.25rem;
  display: flex; flex-direction: column;
}
.preview-page-num {
  text-align: center; font-size: 0.7rem; color: var(--gray-400);
  margin-top: auto; padding-top: 0.75rem; font-family: var(--sans);
  align-self: stretch;
}

/* ── Preview page: grid fills the page card width on screen ─ */
.preview-page .copybook-grid { display: block !important; width: 100% !important; }
.preview-page .char-row { width: 100% !important; }
.preview-page .cell-wrapper { flex: 1 1 0 !important; min-width: 0 !important; display: flex !important; flex-direction: column !important; }
.preview-page .tian-cell { width: 100% !important; height: auto !important; aspect-ratio: 1 / 1 !important; flex-shrink: unset !important; }
.preview-page .tian-cell .char { font-size: calc(var(--cell-px, 80px) * 0.72) !important; }
.preview-page .seq-svg-cell {
  width:  calc(var(--cell-px, 80px) * 0.46) !important;
  height: calc(var(--cell-px, 80px) * 0.46) !important;
}

.char-seq-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.25rem 0.15rem;
  /* No overflow:hidden — the stroke-order steps may wrap to extra lines; the
     row must grow to its real height (and push the grid down) so it is never
     clipped or overlapped onto the practice cells. */
}
.char-seq-pinyin {
  font-size: 13px; color: var(--gray-600);
  font-family: var(--sans); line-height: 1.2;
  min-width: 2.5rem; flex-shrink: 0;
}
/* Stroke name label (笔画帖) — keep examples inline on the same row */
.stroke-name-row {
  overflow: visible;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
}
.stroke-name-label {
  font-size: 12px; color: var(--gray-500);
  font-family: var(--sans); line-height: 1.2;
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Multiple readings: same font-size as single, but allow soft-wrap so
   3-reading polyphones (e.g. "de / dí / dì") gracefully wrap to 2 lines. */
.char-seq-pinyin-multi {
  font-size: 13px;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: break-word;
  max-width: 5.5rem;
}
.seq-steps-container {
  display: flex; align-items: center; gap: 3px;
  flex-wrap: wrap; flex: 1; min-width: 0;
}
.seq-svg-cell {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.char-seq-step {
  font-size: 22px; line-height: 1;
  transition: color 0.1s;
}
.char-seq-final { /* color set by JS (state.charColor) */ }
.char-seq-fallback {
  font-size: 12px; color: var(--gray-400);
  font-family: var(--sans);
}

.tian-cell {
  position: relative;
  border-right:  1px solid var(--grid-border);
  border-bottom: 1px solid var(--grid-border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.tian-cell::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image:
    repeating-linear-gradient(90deg, var(--grid-guide) 0px, var(--grid-guide) 3px, transparent 3px, transparent 7px),
    repeating-linear-gradient(0deg,  var(--grid-guide) 0px, var(--grid-guide) 3px, transparent 3px, transparent 7px);
  background-size:     100% 1px, 1px 100%;
  background-position: 0 50%,    50% 0;
  background-repeat:   repeat-x, repeat-y;
}
.tian-cell .char {
  position: relative; z-index: 1;
  line-height: 1; display: block; text-align: center;
}

.char-note {
  width: 100%; box-sizing: border-box;
  font-family: var(--sans); font-size: 0.72rem;
  color: var(--gray-500); line-height: 1;
  padding: 0.3rem 0.5rem 0.35rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.note-label { font-weight: 700; color: var(--gray-800); margin-right: 0.1rem; }
.char-note em { font-style: italic; }
.note-example { font-family: var(--chinese); font-weight: 600; color: var(--gray-800); }

/* ============================================================
   Stroke panel
   ============================================================ */
.stroke-panel {
  border: 1px solid var(--gray-200);
  border-radius: 10px; overflow: hidden;
  background: var(--white);
}
.card-section .stroke-panel,
.card-section .cmp-panel {
  border-color: var(--gray-200);
  border-radius: 10px;
}
.stroke-panel-header {
  width: 100%; display: flex; align-items: center; gap: 0.6rem;
  background: var(--white); border: none;
  padding: 0.85rem 1rem; cursor: pointer; font-family: var(--sans);
  text-align: left; transition: background 0.15s;
}
.stroke-panel-header:hover { background: var(--gray-50); }

/* CSS chevron — matches cmp-chevron style */
.stroke-arrow {
  display: inline-block; flex-shrink: 0;
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--gray-300);
  border-top: 1.5px solid var(--gray-300);
  transform: rotate(45deg);
  transition: transform 0.22s ease, border-color 0.18s;
  margin-top: -1px;
}
.stroke-arrow.open {
  transform: rotate(135deg);
  margin-top: 2px;
}

.stroke-panel-title { font-size: 0.85rem; font-weight: 600; color: var(--gray-900); flex: 1; letter-spacing: -0.01em; }
.stroke-panel-hint  { font-size: 0.72rem; color: var(--gray-400); font-weight: 400; }

.stroke-content {
  display: none; flex-direction: column; gap: 1rem;
  padding: 0.9rem 1rem 1rem; background: var(--white);
  border-top: 1px solid var(--gray-100);
}

.stroke-group-label {
  font-size: 0.62rem; font-weight: 600; color: var(--gray-400);
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 0.5rem;
}

.stroke-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.45rem; }

.stroke-btn {
  background: var(--white);
  color: #334155;
  border: 1px solid var(--gray-200);
  border-radius: 9px;
  padding: 0; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-family: var(--chinese); line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s, background 0.15s, color 0.15s;
}
/* Each img is sized in JS as (vbW / STROKE_BOX_REF) × (vbH / STROKE_BOX_REF)
   of the button, preserving the real relative size of every stroke. */
.stroke-btn img {
  display: block;
  pointer-events: none;
  user-select: none;
}
.stroke-btn .stroke-missing {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ef4444;
  text-align: center;
  line-height: 1.15;
  padding: 0 2px;
}

.stroke-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #2563eb;
  box-shadow: 0 2px 6px rgba(37,99,235,.12);
  transform: translateY(-1px) scale(1.08);
}
.stroke-btn:active { transform: scale(0.93); box-shadow: none; }
.stroke-btn.selected {
  background: #2563eb; color: #fff;
  border-color: #1d4ed8;
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}

/* ── Stroke worksheet name row: example characters with red-highlighted stroke ── */
.stroke-name-examples {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}
.stroke-ex-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: transparent;
  border: 0;
  overflow: hidden;
  font-size: 11px;
  color: var(--gray-400);
  flex-shrink: 0;
  flex-grow: 0;
}
.stroke-ex-tile svg { display: block; width: 100%; height: 100%; }
.stroke-ex-tile.loading::after {
  content: '';
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue);
  animation: stroke-ex-spin 0.8s linear infinite;
}
.stroke-ex-tile.failed {
  color: var(--gray-400);
  font-size: 16px;
}
@keyframes stroke-ex-spin { to { transform: rotate(360deg); } }

/* On printed output, keep tiles small and quiet */
@media print {
  .stroke-ex-tile {
    width: 8mm; height: 8mm;
    border-color: rgba(118, 96, 70, 0.35);
    background: transparent;
  }
  .stroke-ex-tile.loading::after,
  .stroke-ex-tile.failed { display: none; }
}

/* ============================================================
   Component Panel — Accordion (部件帖)
   ============================================================ */

/* Outer panel shell */
.cmp-panel {
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  overflow: hidden;
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

/* Outer header (collapse/expand whole panel) */
.cmp-panel-header {
  width: 100%; display: flex; align-items: center; gap: 0.6rem;
  padding: 0.85rem 1rem;
  background: var(--white);
  border: none; cursor: pointer; font-family: var(--sans); text-align: left;
  transition: background 0.15s;
}
.cmp-panel-header:hover { background: var(--gray-50); }
.cmp-panel-header.open  { background: var(--white); }

.cmp-panel-title {
  font-size: 0.85rem; font-weight: 600; color: var(--gray-900); flex: 1;
  letter-spacing: -0.01em;
}
.cmp-panel-badge {
  font-size: 0.72rem; font-weight: 400;
  color: var(--gray-400);
  transition: color 0.2s;
}
.cmp-panel-header.open .cmp-panel-badge { color: var(--gray-400); }

/* Shared chevron — thin, elegant, no box artifact */
.cmp-chevron {
  display: inline-block; flex-shrink: 0;
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--gray-300);
  border-top: 1.5px solid var(--gray-300);
  transform: rotate(45deg);
  transition: transform 0.22s ease, border-color 0.18s;
  margin-top: -1px;
}
.cmp-panel-header.open .cmp-chevron,
.cmp-acc-header.open   .cmp-chevron {
  transform: rotate(135deg);
  margin-top: 2px;
}

/* Outer body */
.cmp-panel-body { display: none; }
.cmp-panel-body.open { display: block; }

/* ── Accordion items ──────────────────────────────────────── */
.cmp-acc-item { border-top: 1px solid var(--gray-100); }

.cmp-acc-header {
  width: 100%; display: flex; align-items: center; gap: 0.55rem;
  padding: 0.6rem 0.9rem 0.6rem 0.85rem;
  background: var(--white); border: none; cursor: pointer;
  font-family: var(--sans); text-align: left;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.18s;
}
.cmp-acc-header:hover { background: var(--gray-50); }

/* Level accent colors — left border + text tint when open */
.cmp-acc-item[data-level="1"] .cmp-acc-header.open { border-left-color: #10b981; background: #f0fdf4; }
.cmp-acc-item[data-level="2"] .cmp-acc-header.open { border-left-color: #3b82f6; background: #eff6ff; }
.cmp-acc-item[data-level="3"] .cmp-acc-header.open { border-left-color: #f59e0b; background: #fffbeb; }
.cmp-acc-item[data-level="4"] .cmp-acc-header.open { border-left-color: #8b5cf6; background: #f5f3ff; }

.cmp-acc-item[data-level="1"] .cmp-acc-header.open .cmp-chevron { border-color: #10b981; }
.cmp-acc-item[data-level="2"] .cmp-acc-header.open .cmp-chevron { border-color: #3b82f6; }
.cmp-acc-item[data-level="3"] .cmp-acc-header.open .cmp-chevron { border-color: #f59e0b; }
.cmp-acc-item[data-level="4"] .cmp-acc-header.open .cmp-chevron { border-color: #8b5cf6; }

.cmp-acc-name {
  font-size: 0.8rem; font-weight: 500; color: var(--gray-600); flex: 1;
  transition: color 0.15s;
}
.cmp-acc-item[data-level="1"] .cmp-acc-header.open .cmp-acc-name { color: #059669; font-weight: 600; }
.cmp-acc-item[data-level="2"] .cmp-acc-header.open .cmp-acc-name { color: #2563eb; font-weight: 600; }
.cmp-acc-item[data-level="3"] .cmp-acc-header.open .cmp-acc-name { color: #d97706; font-weight: 600; }
.cmp-acc-item[data-level="4"] .cmp-acc-header.open .cmp-acc-name { color: #7c3aed; font-weight: 600; }

.cmp-acc-badge {
  font-size: 0.68rem; font-weight: 500;
  color: var(--gray-400);
  min-width: 20px; text-align: right;
  transition: color 0.15s;
}
.cmp-acc-item[data-level="1"] .cmp-acc-header.open .cmp-acc-badge { color: #10b981; }
.cmp-acc-item[data-level="2"] .cmp-acc-header.open .cmp-acc-badge { color: #3b82f6; }
.cmp-acc-item[data-level="3"] .cmp-acc-header.open .cmp-acc-badge { color: #f59e0b; }
.cmp-acc-item[data-level="4"] .cmp-acc-header.open .cmp-acc-badge { color: #8b5cf6; }

/* Smooth expand/collapse */
.cmp-acc-body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.28s cubic-bezier(0.4,0,0.2,1);
}
.cmp-acc-body.open { max-height: 700px; }

.cmp-acc-inner { padding: 0.65rem 0.9rem 0.85rem; }

/* Select-all row */
.cmp-level-actions { margin-bottom: 0.6rem; }
.cmp-sel-all-btn {
  font-size: 0.7rem; font-weight: 500;
  padding: 0.25rem 0.85rem;
  border: 1.5px solid var(--gray-200); border-radius: 999px;
  background: var(--white); color: var(--gray-600);
  cursor: pointer; transition: all 0.15s;
}
.cmp-sel-all-btn:hover {
  border-color: #93c5fd; background: #eff6ff; color: #2563eb;
}

/* ── Component grid ───────────────────────────────────────── */
.cmp-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.45rem;
}

/* ── Component card — square, large char only ─────────────── */
.cmp-card {
  aspect-ratio: 1;
  border: none; border-radius: 12px;
  background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--chinese); font-size: 1.45rem;
  color: #334155; line-height: 1;
  cursor: pointer; position: relative;
  transition: background 0.15s, transform 0.18s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.18s, color 0.15s;
}
.cmp-card:hover {
  background: #e2e8f0;
  transform: scale(1.12);
  box-shadow: 0 6px 16px rgba(0,0,0,.1);
  z-index: 1;
}
.cmp-card:active { transform: scale(0.93); transition-duration: 0.08s; }

.cmp-card.selected {
  background: #3b82f6; color: #fff;
  box-shadow: 0 3px 10px rgba(59,130,246,.38);
}
.cmp-card.selected:hover {
  background: #2563eb;
  box-shadow: 0 6px 18px rgba(59,130,246,.45);
  transform: scale(1.12);
}

/* Mobile — slightly denser grid inside the same sidebar */
@media (max-width: 480px) {
  .cmp-grid { grid-template-columns: repeat(6, 1fr); gap: 0.3rem; }
  .cmp-card  { font-size: 1.25rem; border-radius: 10px; }
}

.page-limit-notice {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px;
  padding: 0.35rem 0.6rem; margin-bottom: 0.5rem;
  font-size: 0.75rem; color: #92400e; font-family: var(--sans);
}

/* ============================================================
   Auth modal
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
  animation: backdropIn 0.2s ease;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--white);
  border-radius: 14px;
  padding: 2rem;
  width: 100%; max-width: 380px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none;
  color: var(--gray-400); font-size: 1rem;
  cursor: pointer; line-height: 1;
  padding: 0.2rem 0.4rem; border-radius: 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--gray-800); }

.auth-tabs {
  display: flex; gap: 0; margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--gray-200);
}
.auth-tab {
  flex: 1; background: none; border: none;
  padding: 0.6rem; font-size: 0.9rem; font-weight: 600;
  color: var(--gray-400); cursor: pointer; font-family: var(--sans);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.15s;
}
.auth-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.auth-tab:hover:not(.active) { color: var(--gray-800); }

.auth-form { display: flex; flex-direction: column; gap: 0.85rem; }

.form-field { display: flex; flex-direction: column; gap: 0.3rem; }
.form-field label {
  font-size: 0.78rem; font-weight: 600; color: var(--gray-700, #374151);
}
.form-field .hint { font-weight: 400; color: var(--gray-400); font-size: 0.72rem; }
.form-field input {
  width: 100%;
  border: 1.5px solid var(--gray-200); border-radius: 7px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem; color: var(--gray-900); font-family: var(--sans);
  outline: none; transition: border-color 0.15s;
}
.form-field input:focus { border-color: var(--blue); }

.auth-error {
  font-size: 0.78rem; color: var(--red);
  min-height: 1.2em; line-height: 1.2;
}

.auth-form .btn-primary { margin-top: 0.25rem; }

.auth-note {
  margin-top: 1rem; text-align: center;
  font-size: 0.72rem; color: var(--gray-400);
}

/* Loading spinner on buttons */
.btn-loading { opacity: 0.7; pointer-events: none; }
.btn-loading::after {
  content: ' ···'; letter-spacing: 0.05em;
}

/* (笔顺帖 styles removed — replaced by 汉字帖 seq row above)

/* ── Print layout: not used (print uses #copybook directly) ─ */
#print-layout { display: none; }

/* ============================================================
   Print
   ============================================================ */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: white; }

  /* Hide screen chrome; keep preview section */
  .site-header, .sidebar, .preview-bar, .modal-backdrop,
  #print-layout, .limit-banner, .empty-hint { display: none !important; }

  /* Reset 2-col layout so preview fills the page */
  .app-layout {
    display: block !important;
    margin: 0 !important; padding: 0 !important; max-width: none !important;
  }
  .preview-section {
    display: block !important;
    border: none !important; box-shadow: none !important; border-radius: 0 !important;
  }
  .copybook-wrap {
    background: white !important;
    padding: 0 !important; gap: 0 !important;
    min-height: 0 !important; overflow: visible !important;
  }

  /* ── Each preview-page = one A4 print page ─────────────── */
  .preview-page {
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important; box-sizing: border-box !important;
    align-items: stretch !important;
    break-after: page;
    display: flex !important; flex-direction: column !important;
  }
  .preview-page:last-child { break-after: auto; }

  /* Undo the screen-only fixed A4 box (JS sets an explicit px height + the CSS
     aspect-ratio) so print flows on real A4 and never clips content. Each
     .preview-page is still its own physical page via break-after. */
  .worksheet-v2 .preview-page    { height: auto !important; aspect-ratio: auto !important; overflow: visible !important; }
  .worksheet-v2 .preview-content { display: block !important; overflow: visible !important; }

  /* ── Character block fills page width; never split across pages ─ */
  .preview-page .char-block { width: 100% !important; break-inside: avoid; page-break-inside: avoid; }

  /* ── Grid: full width, square cells ────────────────────── */
  .preview-page .copybook-grid {
    display: block !important; width: 100% !important; box-sizing: border-box;
    border-top:  1px solid var(--grid-border);
    border-left: 1px solid var(--grid-border);
    line-height: 0;
  }
  .preview-page .char-row    { display: flex; width: 100%; line-height: 0; }
  .preview-page .cell-wrapper { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
  .preview-page .tian-cell {
    width: 100% !important; height: auto !important;
    aspect-ratio: 1 / 1; flex-shrink: unset;
    position: relative;
    border-right:  1px solid var(--grid-border);
    border-bottom: 1px solid var(--grid-border);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
  }
  .preview-page .tian-cell::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image:
      repeating-linear-gradient(90deg, var(--grid-guide) 0px, var(--grid-guide) 3px, transparent 3px, transparent 7px),
      repeating-linear-gradient(0deg,  var(--grid-guide) 0px, var(--grid-guide) 3px, transparent 3px, transparent 7px);
    background-size: 100% 1px, 1px 100%;
    background-position: 0 50%, 50% 0;
    background-repeat: repeat-x, repeat-y;
  }
  .preview-page .tian-cell .char {
    position: relative; z-index: 1;
    font-size: calc(18cm / var(--grid-cols) * 0.72) !important;
    line-height: 1; display: block; text-align: center;
  }

  /* ── Seq row (pinyin + stroke steps) ───────────────────── */
  .preview-page .char-seq-row {
    display: flex; align-items: center; gap: 3px;
    padding: 1mm 0 0.5mm; line-height: 1;
    /* No overflow:hidden — wrapped stroke-order steps must grow the row, not be
       clipped/overlapped onto the cells below. */
  }
  .preview-page .char-seq-pinyin {
    font-size: 9pt !important; font-family: var(--sans);
    color: var(--gray-600); min-width: 2rem; flex-shrink: 0;
    line-height: 1.2;
  }
  .preview-page .char-seq-pinyin-multi {
    font-size: 9pt !important; white-space: normal;
    overflow-wrap: break-word; max-width: 4rem;
    line-height: 1.2;
  }
  .preview-page .stroke-name-row {
    overflow: visible !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 4mm;
  }
  .preview-page .stroke-name-label {
    font-size: 9pt !important; font-family: var(--sans);
    color: var(--gray-500); flex: 0 0 auto;
    white-space: nowrap;
  }
  .preview-page .stroke-name-examples {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 3mm;
    flex-shrink: 0;
  }
  .preview-page .stroke-ex-tile {
    width:  8mm !important;
    height: 8mm !important;
    border: 0;
    background: transparent;
    flex-shrink: 0;
  }

  .preview-page .seq-steps-container { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
  .preview-page .seq-svg-cell {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width:  calc(18cm / var(--grid-cols) * 0.46) !important;
    height: calc(18cm / var(--grid-cols) * 0.46) !important;
  }
  .preview-page .seq-svg-cell svg { width: 100% !important; height: 100% !important; display: block; }

  /* ── Page number ────────────────────────────────────────── */
  .preview-page-num {
    text-align: center; font-size: 8.5pt; color: #94a3b8;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    padding: 2mm 0 0; margin-top: auto;
  }

  /* ── 部件帖 header ──────────────────────────────────────── */
  .preview-page .comp-block-header {
    padding: 1mm 2mm; margin-bottom: 1mm;
    border-bottom: 0.5pt solid var(--gray-200);
  }
  .preview-page .comp-char-big  { font-size: 12pt; }
  .preview-page .comp-name-text { font-size: 7pt; }
  .preview-page .comp-example-char {
    width: 16pt; height: 16pt; font-size: 11pt; border-radius: 3pt;
  }

  @page { size: A4 portrait; margin: 1.5cm 1.5cm 1.8cm 1.5cm; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .app-layout { grid-template-columns: 1fr; padding: 0 1rem; margin: 1rem auto; }
  .card { position: static; }
}

/* ============================================================
   Shared Nav — updated header-inner layout
   ============================================================ */
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.5rem;
}

/* ============================================================
   Writing page — 3-column layout
   ============================================================ */
.writing-layout {
  grid-template-columns: 240px 1fr 240px;
  max-width: 1400px;
}
.sidebar-right {
  order: 3;
}

@media print {
  .sidebar-right { display: none !important; }
}

@media (max-width: 900px) {
  .writing-layout { grid-template-columns: 1fr; }
  .sidebar-right  { order: unset; }
}


.brand {
  display: flex; align-items: center; gap: 0.6rem;
  text-decoration: none; color: inherit; flex-shrink: 0;
}
.brand-name {
  font-size: 1rem; font-weight: 700; color: var(--gray-900);
  white-space: nowrap;
}

.site-nav-links {
  display: flex; align-items: center; gap: 0.25rem; flex: 1;
}
.nav-link {
  padding: 0.35rem 0.7rem; border-radius: 6px;
  font-size: 0.8125rem; font-weight: 500; color: var(--gray-500);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-link.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }

.nav-auth {
  display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0;
}
.btn-nav-ghost {
  padding: 0.35rem 0.7rem; border-radius: 6px;
  font-size: 0.8125rem; font-weight: 500; color: var(--gray-600);
  background: none; border: none; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
  transition: background 0.15s;
}
.btn-nav-ghost:hover { background: var(--gray-100); }
.btn-nav-outline {
  padding: 0.35rem 0.75rem; border-radius: 6px;
  font-size: 0.8125rem; font-weight: 500; color: var(--blue);
  border: 1px solid #bfdbfe; background: none; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
  transition: background 0.15s;
}
.btn-nav-outline:hover { background: var(--blue-light); }
.btn-nav-primary {
  padding: 0.35rem 0.75rem; border-radius: 6px;
  font-size: 0.8125rem; font-weight: 600; color: #fff;
  background: var(--blue); border: none; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
  transition: background 0.15s;
}
.btn-nav-primary:hover { background: var(--blue-dark); }
.nav-user-email {
  font-size: 0.8125rem; color: var(--gray-700, #374151);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============================================================
   Shared page content wrapper
   ============================================================ */
.page-content {
  max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem;
}
.page-header { margin-bottom: 2rem; }
.page-title   { font-size: 1.6rem; font-weight: 700; color: var(--gray-900); }
.page-subtitle { font-size: 0.9rem; color: var(--gray-500); margin-top: 0.35rem; }

/* ============================================================
   Home Page
   ============================================================ */
.home-hero {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border-bottom: 1px solid var(--gray-200);
  padding: 5rem 1.5rem 4rem;
  text-align: center;
}
.home-hero-inner { max-width: 640px; margin: 0 auto; }
.home-badge {
  display: inline-block; padding: 0.25rem 0.8rem;
  background: var(--blue-light); color: var(--blue);
  border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  margin-bottom: 1.25rem; letter-spacing: 0.04em;
}
.home-title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800; line-height: 1.2;
  color: var(--gray-900); margin-bottom: 1rem;
}
.home-subtitle {
  font-size: 1rem; color: var(--gray-500); line-height: 1.7;
  margin-bottom: 2rem;
}
.btn-hero {
  display: inline-block; padding: 0.7rem 1.75rem;
  background: var(--blue); color: #fff;
  border-radius: 8px; font-weight: 600; font-size: 0.9375rem;
  text-decoration: none; transition: background 0.15s, transform 0.15s;
}
.btn-hero:hover { background: var(--blue-dark); transform: translateY(-1px); }

.home-modules { padding: 3.5rem 1.5rem; }
.home-modules-inner { max-width: 1000px; margin: 0 auto; }
.home-modules-title {
  font-size: 1.25rem; font-weight: 700; color: var(--gray-800);
  margin-bottom: 1.5rem; text-align: center;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.module-card {
  display: flex; flex-direction: column;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 12px; padding: 1.75rem 1.5rem;
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
.module-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.09);
  transform: translateY(-3px);
  border-color: #bfdbfe;
}
.module-card-icon { font-size: 2rem; margin-bottom: 0.85rem; }
.module-card-title { font-size: 1.05rem; font-weight: 700; color: var(--gray-900); margin-bottom: 0.5rem; }
.module-card-desc  { font-size: 0.85rem; color: var(--gray-500); line-height: 1.6; flex: 1; }
.module-card-link  { margin-top: 1.25rem; font-size: 0.85rem; font-weight: 600; color: var(--blue); }

/* ============================================================
   Character Components Page
   ============================================================ */
.comp-layout {
  display: grid; grid-template-columns: 200px 1fr;
  gap: 1.5rem; align-items: start;
}
.comp-sidebar { background: var(--white); border: 1px solid var(--gray-200); border-radius: 12px; padding: 1rem; box-shadow: var(--shadow); }
.comp-sidebar-label { font-size: 0.7rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 0.6rem; }
.comp-char-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.comp-char-btn {
  aspect-ratio: 1; border-radius: 8px;
  border: 1px solid var(--gray-200); background: var(--gray-50);
  font-family: var(--chinese); font-size: 1.4rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.comp-char-btn:hover { background: var(--blue-light); border-color: #93c5fd; }
.comp-char-btn.active { background: var(--blue); color: #fff; border-color: var(--blue-dark); }

.comp-empty {
  text-align: center; padding: 4rem 1rem;
  color: var(--gray-400);
}
.comp-empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }

.comp-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 12px; padding: 2rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 1.25rem;
}
.comp-card-top { display: flex; align-items: center; gap: 1.5rem; }
.comp-big-char {
  font-family: var(--chinese); font-size: 4.5rem; line-height: 1;
  color: var(--gray-900); min-width: 100px; text-align: center;
}
.comp-pinyin   { font-size: 1.1rem; font-weight: 600; color: var(--blue); }
.comp-meaning  { font-size: 0.9rem; color: var(--gray-500); margin-top: 0.25rem; }

.comp-row {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 0; border-top: 1px solid var(--gray-100);
}
.comp-row-block { align-items: flex-start; flex-direction: column; gap: 0.4rem; }
.comp-label { font-size: 0.7rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .06em; min-width: 90px; }
.comp-value { font-size: 0.9rem; color: var(--gray-800); }

.comp-parts-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.comp-part {
  font-family: var(--chinese); font-size: 1.75rem; line-height: 1;
  padding: 0.3rem 0.6rem; background: var(--gray-100);
  border-radius: 6px; color: var(--gray-900);
}
.comp-plus { font-size: 1.1rem; color: var(--gray-400); font-weight: 300; }
.comp-explanation { font-size: 0.9rem; color: var(--gray-700); line-height: 1.7; }
.comp-video-wrap { border-radius: 10px; overflow: hidden; border: 1px solid var(--gray-200); }
.comp-no-video {
  padding: 1.5rem; text-align: center;
  background: var(--gray-50); border: 1px dashed var(--gray-200);
  border-radius: 10px; color: var(--gray-400); font-size: 0.85rem;
}

/* ============================================================
   Graded Practice — Level Bar & Flip Cards
   ============================================================ */
.grade-level-bar {
  display: flex; gap: 0.5rem; margin-bottom: 1.75rem; flex-wrap: wrap;
}
.grade-level-btn {
  padding: 0.45rem 1rem; border-radius: 8px;
  border: 1px solid var(--gray-200); background: var(--white);
  font-size: 0.8125rem; font-weight: 500; color: var(--gray-600);
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.grade-level-btn:hover { border-color: #93c5fd; color: var(--blue); }
.grade-level-btn.active { background: var(--blue); color: #fff; border-color: var(--blue-dark); }

.flip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.1rem;
}
.flip-card {
  height: 190px; cursor: pointer;
  perspective: 800px;
}
.flip-card-inner {
  width: 100%; height: 100%;
  position: relative; transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(.4,0,.2,1);
}
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-card-front,
.flip-card-back {
  position: absolute; inset: 0;
  border-radius: 12px; backface-visibility: hidden;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}
.flip-card-front {
  background: var(--white);
}
.flip-card-back {
  background: var(--blue); color: #fff;
  transform: rotateY(180deg);
  justify-content: flex-start; align-items: flex-start;
  padding: 1rem;
}
.flip-char  { font-family: var(--chinese); font-size: 3.5rem; line-height: 1; color: var(--gray-900); }
.flip-hint  { font-size: 0.68rem; color: var(--gray-400); margin-top: 0.5rem; }

.flip-back-char  { font-family: var(--chinese); font-size: 1.75rem; line-height: 1; margin-bottom: 0.4rem; }
.flip-pinyin     { font-size: 0.875rem; font-weight: 600; opacity: 0.9; }
.flip-meaning    { font-size: 0.8rem; margin-top: 0.3rem; opacity: 0.85; }
.flip-structure  { font-size: 0.7rem; margin-top: 0.2rem; opacity: 0.7; background: rgba(255,255,255,.15); padding: 0.15rem 0.5rem; border-radius: 4px; }
.flip-example    { font-size: 0.72rem; margin-top: 0.4rem; opacity: 0.8; line-height: 1.5; }

/* ============================================================
   Auth Pages (Login / Register)
   ============================================================ */
.auth-page {
  min-height: calc(100vh - 58px);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem;
  background: var(--gray-50);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 14px; padding: 2.25rem 2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.auth-card-brand {
  display: flex; align-items: center; gap: 0.6rem;
  margin-bottom: 1.5rem;
}
.auth-card-title { font-size: 1.2rem; font-weight: 700; color: var(--gray-900); margin-bottom: 0.35rem; }
.auth-card-sub   { font-size: 0.8125rem; color: var(--gray-500); margin-bottom: 1.5rem; }
.auth-card-sub a { color: var(--blue); text-decoration: none; font-weight: 500; }
.auth-card-sub a:hover { text-decoration: underline; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   Dashboard
   ============================================================ */
.dash-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 2rem; gap: 1rem; flex-wrap: wrap;
}
.dash-title { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.dash-email { font-size: 0.875rem; color: var(--gray-500); margin-top: 0.25rem; }
.dash-usage { display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-end; }
.dash-usage-label { font-size: 0.8rem; color: var(--gray-500); }
.dash-pro-badge {
  padding: 0.3rem 0.75rem; background: #d1fae5; color: #065f46;
  border-radius: 6px; font-size: 0.8rem; font-weight: 600;
}
.dash-section-title {
  font-size: 1rem; font-weight: 700; color: var(--gray-800);
  margin-bottom: 1rem; margin-top: 2rem;
}
.dash-module-grid {
  display: flex; flex-direction: column; gap: 0.75rem;
}
.dash-module-card {
  display: flex; align-items: center; gap: 1rem;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 10px; padding: 1rem 1.25rem;
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dash-module-card:hover { border-color: #bfdbfe; box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.dash-module-icon { font-size: 1.6rem; flex-shrink: 0; }
.dash-module-name { font-size: 0.9rem; font-weight: 600; color: var(--gray-900); }
.dash-module-desc { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.15rem; }
.dash-placeholder {
  background: var(--gray-50); border: 1px dashed var(--gray-200);
  border-radius: 10px; padding: 2rem; text-align: center;
  color: var(--gray-400); font-size: 0.85rem;
}

/* ============================================================
   Responsive additions
   ============================================================ */
@media (max-width: 760px) {
  .site-nav-links { display: none; }
  .comp-layout { grid-template-columns: 1fr; }
  .home-hero { padding: 3rem 1rem 2.5rem; }
  .flip-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .lc-char-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ============================================================
   Home — 2-CTA layout & feature strip
   ============================================================ */
.home-cta-row {
  display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap;
}
.btn-hero-outline {
  display: inline-block; padding: 0.7rem 1.75rem;
  border: 1.5px solid var(--blue); color: var(--blue);
  border-radius: 8px; font-weight: 600; font-size: 0.9375rem;
  text-decoration: none; transition: background 0.15s;
}
.btn-hero-outline:hover { background: var(--blue-light); }

.home-features {
  padding: 3rem 1.5rem;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
}
.home-features-inner {
  max-width: 900px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}
.home-feature-card {
  padding: 1.5rem; border-radius: 12px;
  border: 1px solid var(--gray-200); background: var(--gray-50);
}
.home-feature-icon { font-size: 1.75rem; margin-bottom: 0.6rem; }
.home-feature-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.35rem; }
.home-feature-card p  { font-size: 0.82rem; color: var(--gray-500); line-height: 1.6; }

/* ============================================================
   Characters page — tabs
   ============================================================ */
.lc-tab-bar {
  display: flex; gap: 0; margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--gray-200);
}
.lc-tab {
  padding: 0.6rem 1.25rem; font-size: 0.875rem; font-weight: 600;
  color: var(--gray-500); background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.lc-tab:hover { color: var(--gray-900); }
.lc-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Filter pills ── */
.lc-filter-bar {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
  background: var(--gray-100);
  border-radius: 10px;
  padding: 0.25rem;
  width: fit-content;
  max-width: 100%;
}
.lc-filter {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.85rem;
  border-radius: 7px;
  border: none;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.lc-filter:hover:not(.active) { color: var(--gray-800); }
.lc-filter.active {
  background: var(--white);
  color: var(--gray-900);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

.type-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.type-picture { background: #16a34a; }
.type-buildup { background: #2563eb; }
.type-sound   { background: #d97706; }
.type-special { background: #7c3aed; }

/* ── Character card grid ── */
.lc-char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 1rem;
}

/* ── Card enter animation ── */
@keyframes card-enter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Flip card wrapper ── */
.lc-char-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  animation: card-enter .3s ease both;
}
.lc-char-card:nth-child(1)  { animation-delay: .03s; }
.lc-char-card:nth-child(2)  { animation-delay: .06s; }
.lc-char-card:nth-child(3)  { animation-delay: .09s; }
.lc-char-card:nth-child(4)  { animation-delay: .12s; }
.lc-char-card:nth-child(5)  { animation-delay: .15s; }
.lc-char-card:nth-child(6)  { animation-delay: .18s; }
.lc-char-card:nth-child(7)  { animation-delay: .21s; }
.lc-char-card:nth-child(8)  { animation-delay: .24s; }
.lc-char-card:nth-child(9)  { animation-delay: .27s; }
.lc-char-card:nth-child(10) { animation-delay: .30s; }
.lc-char-card:nth-child(11) { animation-delay: .33s; }
.lc-char-card:nth-child(12) { animation-delay: .36s; }

/* The 3-D flipper */
.lc-card-flipper {
  position: relative;
  height: 260px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.4,0,.2,1);
}
/* hover scale only when not flipped */
.lc-char-card:not(.flipped) .lc-card-flipper:hover {
  transform: scale(1.03);
}
.lc-char-card.flipped .lc-card-flipper {
  transform: rotateY(180deg);
}

/* Shared face styles */
.lc-card-front,
.lc-card-back {
  position: absolute;
  inset: 0;
  border-radius: 13px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: box-shadow .2s, border-color .2s;
  overflow: hidden;
}
.lc-char-card:not(.flipped) .lc-card-flipper:hover .lc-card-front {
  border-color: #bfdbfe;
  box-shadow: 0 8px 24px rgba(37,99,235,.1);
}

/* Front: large character, clean */
.lc-card-front { gap: 0; background: var(--white); }
.lc-char-main {
  font-family: var(--chinese);
  font-size: 4.5rem;
  line-height: 1;
  color: var(--gray-900);
  letter-spacing: -.01em;
}
.lc-flip-hint {
  position: absolute;
  bottom: 0.4rem; right: 0.55rem;
  font-size: 0.58rem;
  color: var(--gray-300);
  user-select: none;
  letter-spacing: .02em;
}

/* Back: rotated, shows details */
.lc-card-back {
  transform: rotateY(180deg);
  padding: 0.65rem 0.75rem 0.6rem;
  gap: 0.15rem;
  justify-content: flex-start;
}

/* Image area */
.lc-back-img-area {
  position: relative;
  width: 88px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 0.1rem;
}
.lc-back-img {
  position: absolute;
  width: 88px;
  height: 70px;
  object-fit: contain;
  z-index: 1;
}
.lc-back-img-ghost {
  font-family: var(--chinese);
  font-size: 2.8rem;
  line-height: 1;
  color: var(--gray-100);
  user-select: none;
  pointer-events: none;
}

/* Speak row */
.lc-back-speak-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.05rem;
}
.lc-speak-btn {
  background: none;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  font-size: 0.8rem;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  flex-shrink: 0;
}
.lc-speak-btn:hover { border-color: var(--blue); background: var(--blue-light); }

.lc-char-pinyin  { font-size: 0.9rem; font-weight: 700; color: var(--blue); letter-spacing: .02em; }
.lc-char-meaning { font-size: 0.75rem; color: var(--gray-500); text-align: center; line-height: 1.3; }

/* Mnemonic hint */
.lc-back-mnemonic {
  font-size: 0.68rem;
  color: var(--gray-400);
  font-style: italic;
  text-align: center;
  line-height: 1.35;
  margin-top: 0.15rem;
  padding: 0 0.25rem;
}

/* Common words */
.lc-back-vocab {
  font-family: var(--chinese);
  font-size: 0.82rem;
  color: var(--gray-600);
  text-align: center;
  margin-top: 0.15rem;
  line-height: 1.4;
}

.lc-type-tag {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: .03em;
  margin-top: 0.2rem;
}
.lc-type-tag.type-picture { background: #dcfce7; color: #15803d; }
.lc-type-tag.type-buildup { background: #dbeafe; color: #1d4ed8; }
.lc-type-tag.type-sound   { background: #fef3c7; color: #b45309; }
.lc-type-tag.type-special { background: #ede9fe; color: #6d28d9; }

.lc-parts-row {
  display: flex; align-items: center; gap: 0.25rem;
  flex-wrap: wrap; justify-content: center; margin-top: 0.25rem;
}
.lc-part-btn {
  font-family: var(--chinese); font-size: 1rem; line-height: 1;
  padding: 0.15rem 0.4rem; border-radius: 6px;
  border: 1px solid #bfdbfe; background: var(--blue-light);
  color: var(--blue); cursor: pointer;
  transition: background .15s, transform .1s;
}
.lc-part-btn:hover { background: #bfdbfe; transform: scale(1.08); }
.lc-plus { font-size: 0.7rem; color: var(--gray-300); }

/* Add button — small outline strip below the card */
.lc-add-btn {
  padding: 0.27rem 0;
  border-radius: 8px;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-400);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .01em;
  transition: border-color .15s, color .15s, background .15s;
}
.lc-add-btn:hover:not(.added) {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-light);
}
.lc-add-btn.added {
  border-color: #86efac;
  background: #f0fdf4;
  color: #15803d;
  cursor: default;
}

/* ── Layout: main col + cart ── */
.chars-layout-wrap {
  display: flex;
  gap: 1.75rem;
  align-items: flex-start;
}
.chars-main-col { flex: 1; min-width: 0; }

/* ── Writing Sheet Cart ── */
.writing-cart {
  width: 236px;
  flex-shrink: 0;
  position: sticky;
  top: 1.5rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cart-header {
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.cart-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: .03em;
  text-transform: uppercase;
}
.cart-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-400);
  background: var(--gray-100);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.cart-char-list {
  padding: 0.6rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 56px;
  max-height: 320px;
  overflow-y: auto;
}
.cart-empty {
  font-size: 0.73rem;
  color: var(--gray-400);
  line-height: 1.6;
  text-align: center;
  padding: 0.6rem 0;
}

.cart-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: 8px;
  padding: 0.25rem 0.4rem 0.25rem 0.6rem;
  transition: border-color .15s;
}
.cart-chip:hover { border-color: var(--gray-200); }
.cart-chip-char {
  font-family: var(--chinese);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--gray-900);
}
.cart-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-300);
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.cart-chip-remove:hover { color: var(--red); background: #fee2e2; }

.cart-actions {
  padding: 0.75rem 0.85rem;
  border-top: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.cart-clear-btn {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.32rem 0;
  font-size: 0.75rem;
  color: var(--gray-400);
  cursor: pointer;
  width: 100%;
  transition: border-color .15s, color .15s;
}
.cart-clear-btn:hover { border-color: var(--red); color: var(--red); }

.cart-go-btn {
  display: block;
  text-align: center;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .01em;
  transition: background .15s, box-shadow .15s;
  box-shadow: 0 1px 3px rgba(37,99,235,.3);
}
.cart-go-btn:hover { background: var(--blue-dark); box-shadow: 0 3px 8px rgba(37,99,235,.35); }
.cart-go-btn:disabled { opacity: 0.4; cursor: default; box-shadow: none; }

@media (max-width: 860px) {
  .chars-layout-wrap { flex-direction: column; }
  .writing-cart { width: 100%; position: static; }
}

/* ── Components tab ── */
.comp-section-title {
  font-size: 1rem; font-weight: 700; color: var(--gray-800); margin-bottom: 0.35rem;
}
.comp-section-desc {
  font-size: 0.82rem; color: var(--gray-500); margin-bottom: 1rem;
}
.comp-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.85rem;
}
.comp-mini-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 10px; padding: 1rem 0.85rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.comp-mini-char {
  font-family: var(--chinese); font-size: 2.25rem; line-height: 1;
  color: var(--gray-900);
}
.comp-mini-meaning { font-size: 0.75rem; color: var(--gray-500); text-align: center; }
.comp-mini-examples {
  display: flex; gap: 0.25rem; flex-wrap: wrap; justify-content: center;
  margin-top: 0.2rem;
}
.comp-mini-ex {
  font-family: var(--chinese); font-size: 1rem;
  padding: 0.1rem 0.35rem; background: var(--gray-100);
  border-radius: 4px; color: var(--gray-700);
}

/* Highlight when jumping from Characters tab */
.comp-highlighted {
  border-color: var(--blue) !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,.2) !important;
  animation: comp-pulse 0.4s ease;
}
@keyframes comp-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ── Level grid ──────────────────────────────────────────── */
.level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  padding: 0.25rem 0 1.75rem;
}
.level-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 13px;
  padding: 1.6rem 1rem;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.level-card:not(.level-card-empty):hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 16px rgba(37,99,235,.1);
  transform: translateY(-3px);
}
.level-card-empty {
  opacity: 0.38;
  cursor: default;
}
.level-card-num {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 0.3rem;
  letter-spacing: .01em;
}
.level-card-count {
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* ── Stage grid ──────────────────────────────────────────── */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 0.25rem 0 1.75rem;
  max-width: 520px;
}

/* ── Level chars header (back button + title) ─────────────── */
.level-chars-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-100);
}
.back-btn {
  background: none;
  border: 1.5px solid var(--gray-200);
  border-radius: 7px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--gray-400);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.back-btn:hover {
  border-color: var(--gray-400);
  color: var(--gray-700);
}
.level-chars-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.01em;
}

/* ── Pagination ───────────────────────────────────────────── */
.chars-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 0 0.5rem;
}
.page-btn {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  font-size: 0.875rem;
  color: var(--gray-800);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}
.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.page-info {
  font-size: 0.85rem;
  color: var(--gray-500);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════
   山 Teaching Animation
   ══════════════════════════════════════════════════════════ */

.shan-demo-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 14px;
  padding: 2rem 1.5rem 1.25rem;
  margin-bottom: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.shan-demo-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gray-400);
}

/* stage: fixed size, all layers stacked via position:absolute */
.shan-stage {
  position: relative;
  width: 220px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Layer 1: SVG mountain ── */
.shan-svg-mountain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* paths start invisible (dashoffset set by JS after measuring length) */
.shan-path {
  fill: none;
  transition: none;
}

/* ── Layer 2: 山 character ── */
.shan-char-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}
.shan-char {
  font-family: var(--chinese);
  font-size: 6rem;
  color: var(--gray-800);
  line-height: 1;
}

/* ── Layer 3: pinyin + meaning ── */
.shan-text-wrap {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  opacity: 0;
}
.shan-pinyin  { font-size: 0.95rem; color: var(--blue);      font-weight: 600; }
.shan-meaning { font-size: 0.8rem;  color: var(--gray-500);  }

/* replay button */
.shan-replay-btn {
  background: none;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  color: var(--gray-500);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.shan-replay-btn:hover { border-color: var(--blue); color: var(--blue); }

/* ══ Keyframes ══════════════════════════════════════════════ */

/* draw a path from invisible to full */
@keyframes shan-draw {
  to { stroke-dashoffset: 0; }
}

/* mountain SVG fades out after drawing */
@keyframes shan-svg-out {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* character fades in */
@keyframes shan-char-in {
  0%   { opacity: 0; transform: scale(.85); }
  100% { opacity: 1; transform: scale(1);   }
}

/* label fades in */
@keyframes shan-text-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ══ Animation state: activated by .shan-play on the stage ══ */

/* draw all paths, staggered */
.shan-play .shan-path {
  animation: shan-draw .55s cubic-bezier(.4,0,.2,1) forwards;
}
.shan-play #sp-left   { animation-delay: 0s;    }
.shan-play #sp-mid    { animation-delay: .12s;  }
.shan-play #sp-right  { animation-delay: .24s;  }
.shan-play #sp-ground { animation-delay: .36s;  }

/* mountain svg fades out starting at 1.0s */
.shan-play .shan-svg-mountain {
  animation: shan-svg-out .5s ease-in forwards;
  animation-delay: 1.0s;
}

/* character fades in starting at 1.1s */
.shan-play .shan-char-wrap {
  animation: shan-char-in .55s cubic-bezier(.34,1.56,.64,1) forwards;
  animation-delay: 1.1s;
}

/* label fades in starting at 1.9s */
.shan-play .shan-text-wrap {
  animation: shan-text-in .45s ease forwards;
  animation-delay: 1.9s;
}

/* ── Type tag tooltip ─────────────────────────────────────── */
.lc-type-tag {
  position: relative;
  cursor: help;
}
.lc-type-tag::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  font-size: 0.68rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  width: max-content;
  max-width: 190px;
  white-space: normal;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
/* arrow */
.lc-type-tag::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s;
  z-index: 200;
}
.lc-type-tag:hover::after,
.lc-type-tag:hover::before,
.lc-type-tag.tooltip-show::after,
.lc-type-tag.tooltip-show::before {
  opacity: 1;
}

/* ============================================================
   Component Sheet (部件练习帖)
   ============================================================ */

.comp-block-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem 0.25rem;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}

.comp-block-name {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-shrink: 0;
}

.comp-char-big {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gray-900);
  font-family: var(--chinese);
  line-height: 1;
}

.comp-name-text {
  font-size: 0.72rem;
  color: var(--gray-500);
  white-space: nowrap;
}

.comp-block-examples {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.comp-example-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  font-size: 1.1rem;
  font-family: var(--chinese);
  color: var(--blue);
  background: var(--blue-light);
  border-radius: 5px;
  line-height: 1;
}

.comp-variant-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.75rem;
  margin: 0.35rem 0 0.4rem;
  background: #faf6ef;
  border-left: 3px solid var(--blue);
  border-radius: 4px;
  flex-wrap: wrap;
}

.comp-variant-label {
  font-size: 0.7rem;
  color: var(--gray-500);
  letter-spacing: 0.04em;
}

.comp-variant-group {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.comp-variant-char {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--blue);
  line-height: 1;
}

.comp-variant-eg-label {
  font-size: 0.65rem;
  color: var(--gray-500);
  font-style: italic;
  margin-left: 0.15rem;
}

.comp-variant-example {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.3rem;
  font-size: 0.95rem;
  font-family: var(--chinese);
  color: var(--gray-700, #475569);
  background: #fff;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 4px;
  line-height: 1;
}

.preview-page .comp-variant-bar {
  padding: 0.5mm 2mm;
  margin: 0.5mm 0;
  border-left-width: 1pt;
  gap: 1mm;
}
.preview-page .comp-variant-label    { font-size: 6pt; }
.preview-page .comp-variant-char     { font-size: 10pt; }
.preview-page .comp-variant-eg-label { font-size: 5pt; }
.preview-page .comp-variant-example  {
  min-width: 9pt; height: 9pt;
  font-size: 8pt; padding: 0 1pt;
}

/* ============================================================
   Characters Immersive Page
   ============================================================ */

/* ── Hero ──────────────────────────────────────────────────── */
.ci-hero {
  position: relative;
  min-height: 88vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #faf6ef;
  overflow: hidden;
  padding: 6rem 2rem 5rem;
}

.ci-hero-bg {
  position: absolute; inset: 0; pointer-events: none;
  color: #c5a97a;
}

.ci-deco-char {
  position: absolute;
  font-family: var(--chinese);
  font-weight: 400;
  color: rgba(180,145,80,.07);
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

.ci-seal {
  position: absolute;
  bottom: 12%; right: 8%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 72px; height: 72px;
  border: 2.5px solid rgba(185,28,28,.35);
  border-radius: 4px;
  transform: rotate(-12deg);
  font-family: var(--chinese);
  font-size: 1.5rem;
  color: rgba(185,28,28,.45);
  line-height: 1.1; gap: 0;
}
.ci-seal span { display: block; text-align: center; }

.ci-hero-lines {
  position: absolute; inset: 0; width: 100%; height: 100%;
  color: rgba(180,145,80,.18);
}

.ci-hero-body {
  position: relative; z-index: 1;
  text-align: center; max-width: 720px;
}

.ci-hero-eyebrow {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.14em;
  color: #b45309; text-transform: uppercase;
  margin-bottom: 1.25rem; display: block;
}

.ci-hero-title {
  font-family: var(--sans);
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 700; line-height: 1.18;
  color: #1c1209;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
}

.ci-hero-sub {
  font-size: 1.1rem; color: #6b5a3e; line-height: 1.7;
  max-width: 500px; margin: 0 auto 2.5rem;
}

.ci-hero-cta {
  display: inline-block;
  padding: 0.85rem 2.2rem;
  background: #1c1209; color: #fdf8f0;
  border-radius: 999px; font-weight: 600; font-size: 0.95rem;
  text-decoration: none; letter-spacing: 0.01em;
  transition: background 0.18s, transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 4px 20px rgba(28,18,9,.22);
}
.ci-hero-cta:hover {
  background: #3d2c0f;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(28,18,9,.3);
}

.ci-hero-scroll {
  position: absolute; bottom: 2.5rem; left: 50%; transform: translateX(-50%);
}
.ci-scroll-line {
  display: block; width: 1px; height: 48px;
  background: linear-gradient(to bottom, transparent, rgba(180,145,80,.5));
  margin: 0 auto;
  animation: scroll-pulse 2s ease-in-out infinite;
}
@keyframes scroll-pulse {
  0%, 100% { opacity: 0.4; transform: scaleY(0.8); }
  50%       { opacity: 1;   transform: scaleY(1); }
}

/* ── Sections ──────────────────────────────────────────────── */
.ci-section {
  padding: 5rem 2rem;
  background: #ffffff;
}
.ci-section-warm {
  background: #faf6ef;
}
.ci-inner {
  max-width: 1000px; margin: 0 auto;
}

.ci-section-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: #b45309;
  margin-bottom: 0.75rem;
}
.ci-section-title {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 700; letter-spacing: -0.025em; color: #1c1209;
  line-height: 1.2; margin-bottom: 1rem;
}
.ci-section-sub {
  font-size: 1.02rem; color: #6b5a3e; line-height: 1.75;
  max-width: 680px; margin-bottom: 2.5rem;
}

/* ── Video ──────────────────────────────────────────────────── */
.ci-video-card {
  background: var(--white);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 4px 32px rgba(28,18,9,.1), 0 1px 4px rgba(28,18,9,.06);
  border: 1px solid #e8dcc8;
}
.ci-video-wrapper {
  position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;
}
.ci-video-wrapper iframe {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  border: none;
}
.ci-video-meta {
  padding: 1.5rem 2rem;
  display: flex; align-items: flex-start; gap: 1.5rem;
  border-top: 1px solid #f0e6d4;
  background: #fdfaf5;
}
.ci-video-tag {
  flex-shrink: 0;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: #b45309;
  background: #fef3c7; padding: 0.35rem 0.8rem;
  border-radius: 999px; white-space: nowrap; margin-top: 0.1rem;
}
.ci-video-caption {
  font-size: 0.9rem; color: #6b5a3e; line-height: 1.65;
}

/* ── Explore Cards ──────────────────────────────────────────── */
.ci-explore-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem;
  margin-top: 2rem;
}
.ci-explore-card {
  background: var(--white);
  border: 1px solid #e8dcc8;
  border-radius: 16px;
  padding: 2rem 1.75rem;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: default;
}
.ci-explore-card:hover {
  box-shadow: 0 8px 32px rgba(28,18,9,.1);
  transform: translateY(-3px);
}
.ci-explore-glyph {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--chinese); font-size: 1.8rem; line-height: 1;
  margin-bottom: 1.25rem;
}
.ci-explore-name {
  font-size: 1.02rem; font-weight: 700; color: #1c1209;
  margin-bottom: 0.6rem;
}
.ci-explore-desc {
  font-size: 0.88rem; color: #6b5a3e; line-height: 1.65;
  margin-bottom: 1.25rem;
}
.ci-explore-link {
  font-size: 0.82rem; font-weight: 600; color: #b45309;
  letter-spacing: 0.02em;
}

/* ── Learning section ───────────────────────────────────────── */
.ci-learn-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 1.75rem; gap: 1rem;
}
.ci-learn-nav {
  display: flex; align-items: center; gap: 0;
  border-bottom: 2px solid #e8dcc8;
  margin-bottom: 2.5rem;
}
.ci-learn-tab {
  padding: 0.75rem 1.5rem; font-size: 0.9rem; font-weight: 600;
  color: #6b5a3e; background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.ci-learn-tab:hover { color: #1c1209; }
.ci-learn-tab.active { color: #b45309; border-bottom-color: #b45309; }
.ci-learn-ext {
  margin-left: auto; display: flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.1rem; border-radius: 8px;
  font-size: 0.82rem; font-weight: 600; color: #6b5a3e;
  text-decoration: none; border: 1px solid #e8dcc8;
  transition: all 0.15s; background: var(--white);
  margin-bottom: 4px;
}
.ci-learn-ext:hover { color: #b45309; border-color: #b45309; background: #fdf8f0; }

.ci-learn-panel { animation: fade-in 0.25s ease both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Level intro ────────────────────────────────────────────── */
.ci-level-intro {
  font-size: 0.95rem; color: #6b5a3e; line-height: 1.7;
  margin-bottom: 2rem; max-width: 600px;
}

/* ── Level path cards ───────────────────────────────────────── */
.ci-level-path {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;
}
.ci-level-card {
  display: flex; gap: 1.25rem; align-items: flex-start;
  background: var(--white); border: 1.5px solid #e8dcc8;
  border-radius: 16px; padding: 1.5rem 1.5rem 1.4rem;
  cursor: pointer; text-align: left;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.ci-level-card:not(.ci-level-empty):hover {
  border-color: var(--lc-color, #b45309);
  box-shadow: 0 6px 24px rgba(0,0,0,.08);
  transform: translateY(-3px);
}
.ci-level-empty { cursor: default; opacity: 0.6; }

.ci-lc-num {
  flex-shrink: 0; width: 44px; height: 44px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--chinese); font-size: 1.15rem; font-weight: 400;
  line-height: 1;
}
.ci-lc-body { flex: 1; min-width: 0; }
.ci-lc-level { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #94a3b8; margin-bottom: 0.2rem; }
.ci-lc-name  { font-size: 1rem; font-weight: 700; color: #1c1209; margin-bottom: 0.4rem; }
.ci-lc-desc  { font-size: 0.82rem; color: #6b5a3e; line-height: 1.55; margin-bottom: 0.85rem; }
.ci-lc-foot  { display: flex; align-items: center; justify-content: space-between; }
.ci-lc-count { font-size: 0.78rem; font-weight: 500; color: #94a3b8; }
.ci-lc-soon  { font-size: 0.75rem; color: #cbd5e1; font-style: italic; }
.ci-lc-arrow { font-size: 1rem; font-weight: 700; transition: transform 0.18s; }
.ci-level-card:hover .ci-lc-arrow { transform: translateX(4px); }

/* Stage cards — narrower 3-col */
.ci-stage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.ci-stage-card .ci-lc-num { font-size: 1.1rem; }

/* ── Nav bar (back button + breadcrumb) ─────────────────────── */
.ci-nav-bar {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1.75rem;
}
.ci-back-btn {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.45rem 0.9rem; border-radius: 8px;
  font-size: 0.82rem; font-weight: 600; color: #6b5a3e;
  background: #fdf8f0; border: 1px solid #e8dcc8;
  cursor: pointer; transition: all 0.15s;
}
.ci-back-btn:hover { color: #b45309; border-color: #b45309; }
.ci-breadcrumb {
  font-size: 0.85rem; font-weight: 600; color: #1c1209;
}

/* ── Floating Writing Basket ────────────────────────────────── */
.ci-basket {
  position: fixed; bottom: 1.75rem; right: 1.75rem;
  z-index: 200;
}
.ci-basket-trigger {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem 1.25rem;
  background: #1c1209; color: #fdf8f0;
  border: none; border-radius: 999px; cursor: pointer;
  font-size: 0.88rem; font-weight: 600;
  box-shadow: 0 4px 20px rgba(28,18,9,.35);
  transition: background 0.18s, transform 0.18s;
}
.ci-basket-trigger:hover { background: #3d2c0f; transform: translateY(-2px); }
.ci-basket-label { white-space: nowrap; }
.ci-basket-badge {
  display: flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: #b45309; color: #fff;
  border-radius: 999px; font-size: 0.72rem; font-weight: 700;
}

.ci-basket-panel {
  display: none; position: absolute;
  bottom: calc(100% + 0.75rem); right: 0;
  width: 280px;
  background: var(--white); border-radius: 16px;
  box-shadow: 0 8px 40px rgba(28,18,9,.18), 0 2px 8px rgba(28,18,9,.08);
  border: 1px solid #e8dcc8;
  overflow: hidden;
  animation: basket-in 0.2s ease both;
}
.ci-basket-panel.open { display: flex; flex-direction: column; }
@keyframes basket-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.ci-basket-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid #f0e6d4;
}
.ci-basket-head-title { font-size: 0.85rem; font-weight: 700; color: #1c1209; }
.ci-basket-close {
  width: 24px; height: 24px;
  border-radius: 50%; border: none; background: #f1f5f9;
  color: #64748b; font-size: 1rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.ci-basket-close:hover { background: #e2e8f0; }

.ci-basket-chars {
  padding: 0.75rem 1rem; max-height: 200px; overflow-y: auto;
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  min-height: 56px; align-content: flex-start;
}
.ci-basket-chars .cart-empty {
  font-size: 0.8rem; color: #94a3b8; line-height: 1.5; width: 100%;
}
.ci-basket-chars .cart-chip {
  display: flex; align-items: center; gap: 0.2rem;
  background: #fdf8f0; border: 1px solid #e8dcc8;
  border-radius: 6px; padding: 0.2rem 0.4rem;
}
.ci-basket-chars .cart-chip-char { font-family: var(--chinese); font-size: 1.1rem; line-height: 1; color: #1c1209; }
.ci-basket-chars .cart-chip-remove { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 0.85rem; line-height: 1; padding: 0; }
.ci-basket-chars .cart-chip-remove:hover { color: #dc2626; }

.ci-basket-actions {
  display: flex; gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid #f0e6d4;
}
.ci-basket-actions .cart-clear-btn {
  flex: 1; padding: 0.55rem; border-radius: 8px;
  border: 1px solid #e8dcc8; background: var(--white);
  font-size: 0.8rem; font-weight: 600; color: #6b5a3e;
  cursor: pointer; transition: all 0.15s;
}
.ci-basket-actions .cart-clear-btn:hover { border-color: #dc2626; color: #dc2626; }
.ci-basket-actions .cart-go-btn {
  flex: 2; padding: 0.55rem;
  border-radius: 8px; border: none;
  background: #1c1209; color: #fdf8f0;
  font-size: 0.8rem; font-weight: 700;
  cursor: pointer; transition: background 0.15s;
}
.ci-basket-actions .cart-go-btn:not([disabled]):hover { background: #3d2c0f; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 700px) {
  .ci-explore-grid  { grid-template-columns: 1fr; }
  .ci-level-path    { grid-template-columns: 1fr; }
  .ci-level-path    { grid-template-columns: 1fr; }
  .ci-stage-grid    { grid-template-columns: 1fr; }
  .ci-hero-title    { font-size: 2rem; }
  .ci-video-meta    { flex-direction: column; gap: 0.75rem; }
  .ci-basket        { bottom: 1rem; right: 1rem; }
}

/* ============================================================
   Background Colour Picker FAB
   ============================================================ */
.bg-fab-wrap {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200;
}
.bg-panel {
  position: absolute; bottom: calc(100% + 0.6rem); right: 0;
  background: var(--white);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.08);
  padding: 1rem 1rem 0.85rem;
  width: 222px;
  transform-origin: bottom right;
  animation: bg-panel-in 0.18s ease;
}
@keyframes bg-panel-in {
  from { opacity: 0; transform: scale(.93) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.bg-panel[hidden] { display: none; }
.bg-panel-title {
  display: block; margin-bottom: 0.85rem;
  font-size: 0.67rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--gray-400);
}
.bg-swatches {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem 0.4rem;
}
.bg-swatch-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.28rem;
  cursor: pointer; user-select: none;
}
.bg-circle {
  width: 46px; height: 46px; border-radius: 50%;
  border: 2.5px solid transparent;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  display: block; flex-shrink: 0;
}
.bg-swatch-item.active .bg-circle {
  border-color: #e8a020;
  box-shadow: 0 0 0 3px rgba(232,160,32,.22);
  transform: scale(1.09);
}
.bg-label {
  font-size: 0.63rem; font-weight: 500; color: var(--gray-500);
  text-align: center; line-height: 1.2;
}
/* Confirm strip */
.bg-confirm {
  margin-top: 0.75rem; padding-top: 0.7rem;
  border-top: 1px solid var(--gray-100);
}
.bg-confirm[hidden] { display: none; }
.bg-confirm-text {
  font-size: 0.75rem; font-weight: 600; color: var(--gray-800);
  margin-bottom: 0.45rem;
}
.bg-confirm-sub {
  font-size: 0.68rem; color: var(--gray-500); margin-bottom: 0.6rem; line-height: 1.35;
}
.bg-confirm-btns { display: flex; gap: 0.35rem; }
.bg-confirm-btn {
  flex: 1; border: none; border-radius: 8px;
  font-size: 0.71rem; font-weight: 600; cursor: pointer;
  padding: 0.45rem 0.2rem; transition: background 0.15s;
}
.bg-confirm-all  { background: #1c1209; color: #fdf8f0; }
.bg-confirm-all:hover  { background: #3d2c0f; }
.bg-confirm-page { background: var(--gray-100); color: var(--gray-700); }
.bg-confirm-page:hover { background: var(--gray-200); }
/* FAB */
.bg-fab {
  display: flex; align-items: center; gap: 0.38rem;
  background: #e8a020; color: var(--white);
  border: none; border-radius: 2rem;
  padding: 0.58rem 1.05rem;
  font-size: 0.84rem; font-weight: 600; font-family: var(--sans);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(232,160,32,.38);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.bg-fab:hover  { background: #c98d10; box-shadow: 0 6px 18px rgba(232,160,32,.48); }
.bg-fab:active { transform: scale(0.97); }
/* Saved toast */
.bg-saved-toast {
  position: fixed; bottom: 5rem; left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: #1c1209; color: #fdf8f0;
  border-radius: 2rem; padding: 0.55rem 1.15rem;
  font-size: 0.8rem; font-weight: 600;
  opacity: 0; transition: opacity 0.22s, transform 0.22s;
  z-index: 400; pointer-events: none; white-space: nowrap;
}
.bg-saved-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   Site footer (Credits link)
   ============================================================ */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem 1.75rem;
  font-size: 0.78rem;
  color: #a8a29e;
  font-family: var(--sans);
  border-top: 1px solid #f0eeec;
  margin-top: 2rem;
}
.site-footer a {
  color: #78716c;
  text-decoration: none;
  transition: color 0.15s;
}
.site-footer a:hover { color: #18181b; text-decoration: underline; }
.site-footer-sep { margin: 0 0.5em; color: #d6d3d1; }

