/* Hanzi Sheets — main.css */
/* ---------- fonts ---------- */
@font-face {
  font-family: "ZhiMangXing";
  src: url("../fonts/ZhiMangXing-simp6500.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "ChenYuluoyan";
  src: url("../fonts/ChenYuluoyan-trad6500.woff2") format("woff2");
  font-display: swap;
}

/* ---------- base ---------- */
:root {
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e4e6eb;
  --brand: #b03a2a;
  --brand-soft: #f7ecea;
  --grid: #d0d0d0;
  --paper-bg: #fff;
  --app-bg: #f4f5f7;
  --ink-font: "ZhiMangXing", "Kaiti SC", "STKaiti", "KaiTi", serif;
  --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
body.hw-trad { --ink-font: "ChenYuluoyan", "TW-Kai", "DFKai-SB", serif; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--ui-font); color: var(--ink);
  background: var(--app-bg); line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { line-height: 1.25; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 17px; }
.brand img { width: 26px; height: 26px; }
.topbar nav { display: flex; gap: 16px; margin-left: 6px; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { color: var(--brand); }
.script-switch { margin-left: auto; display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.script-switch button { border: 0; background: #fff; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.script-switch button.on { background: var(--brand); color: #fff; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 34px 16px 10px; }
.hero h1 { font-size: clamp(24px, 4vw, 36px); margin: 0 0 8px; letter-spacing: -0.5px; }
.hero .sub { color: var(--muted); max-width: 640px; margin: 0 auto 12px; font-size: 15px; }
.badges { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 0 0 6px; padding: 0; }
.badges span {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 14px; font-size: 13px; color: var(--ink);
}
.badges span::before { content: "✓ "; color: #1a9e54; font-weight: 700; }

/* ---------- tool layout ---------- */
.tool { display: flex; gap: 18px; align-items: flex-start; max-width: 1280px; margin: 14px auto 30px; padding: 0 16px; }
.panel { flex: 0 0 356px; min-width: 300px; display: flex; flex-direction: column; gap: 14px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.card h2 { font-size: 14px; margin: 0 0 10px; color: var(--ink); }

/* input tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button, .bank-groups button, .bank-levels button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 6px 10px; font-size: 13px; color: var(--muted);
}
.tabs button.on, .bank-groups button.on, .bank-levels button.on {
  border-color: var(--brand); color: var(--brand); background: var(--brand-soft); font-weight: 600;
}
textarea {
  width: 100%; min-height: 76px; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-family: inherit; font-size: 14px; resize: vertical;
}
textarea:focus { outline: 2px solid #e7c8c3; border-color: var(--brand); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; word-break: break-all; }
.wordcount { font-size: 12.5px; color: var(--brand); margin-top: 8px; font-weight: 600; }

/* word bank */
.bank-groups { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.bank-levels { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.bank-levels .ct { color: #b3b3b3; font-size: 11px; }
#bankFilter { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.bank-actions { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.bank-actions button { border: 1px solid var(--brand); color: var(--brand); background: #fff; border-radius: 8px; padding: 4px 10px; font-size: 12.5px; }
.bank-n { font-size: 12px; color: var(--muted); }
.bank-list { max-height: 210px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.bw { display: flex; gap: 8px; align-items: baseline; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 9px; font-size: 13px; }
.bw b { font-weight: 600; }
.bw i { color: var(--muted); font-style: normal; }
.bw small { color: #9aa0aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bw.on { border-color: var(--brand); background: var(--brand-soft); }
.bank-sel { margin-top: 8px; }
.bs-t { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chip { border: 1px solid #e7c8c3; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; margin: 0 5px 5px 0; }

/* options */
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.opts label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.opts select, .opts input[type="text"] {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13.5px;
  background: #fff; color: var(--ink); font-family: inherit;
}
.opts .wide { grid-column: 1 / -1; }
.opts .check { flex-direction: row; align-items: center; gap: 7px; color: var(--ink); font-size: 13.5px; }
.opts .dimmed { opacity: 0.38; pointer-events: none; }

/* actions */
.actions { display: flex; flex-direction: column; gap: 9px; }
button.primary {
  background: var(--brand); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 14px; font-size: 15px; font-weight: 700;
}
button.primary:hover { background: #98311f; }
button.ghost { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.quota { font-size: 12px; color: var(--muted); margin: 0; text-align: center; }
.wrongbtn { background: #fff; border: 1px dashed #e3b7b0; color: var(--brand); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; }
#wrongBadge { display: inline-block; min-width: 20px; background: var(--brand); color: #fff; border-radius: 999px; font-size: 11.5px; padding: 1px 6px; margin-left: 6px; }

/* ---------- preview ---------- */
.preview { flex: 1 1 auto; min-width: 0; }
.ptoolbar { display: flex; justify-content: flex-end; padding: 2px 4px 8px; font-size: 12.5px; color: var(--muted); min-height: 24px; }
.notice {
  background: #fff8e6; border: 1px solid #f0ddaa; color: #7a5b12;
  border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; font-size: 13.5px;
}
.notice .prosoon { font-size: 12px; color: #a08428; margin-top: 3px; }
.page {
  --cw: 190mm;
  width: 100%;
  max-width: calc(var(--cw) + 20mm);
  margin: 0 auto; padding: 10mm;
  background: var(--paper-bg);
  box-shadow: 0 2px 14px rgba(20, 24, 40, 0.12);
  border-radius: 3px;
  overflow-x: auto;
}
#sheet { width: var(--cw); color: #111; }
#sheet:empty::before {
  content: attr(data-empty);
  display: block; color: #b6bcc7; text-align: center; padding: 60px 20px; font-size: 14px;
}

/* ---------- sheet: shared ---------- */
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 2px solid #333; padding-bottom: 2mm; margin-bottom: 5mm; }
.sheet-head h1 { font-size: 17px; margin: 0; }
.sheet-meta { font-size: 11px; color: #555; white-space: pre; }
.part { font-size: 14px; margin: 0 0 4mm; color: #333; border-left: 4px solid var(--brand); padding-left: 8px; }
.pagebreak { break-before: page; margin: 8mm 0; border-top: 1px dashed #ddd; }

.word-block { margin-bottom: 7mm; break-inside: avoid; }
.word-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 2mm; flex-wrap: wrap; }
.word-head .ww { font-family: var(--ink-font); font-size: 25px; }
.word-head .wp { font-size: 13px; color: #333; }
.word-head .we { font-size: 12px; color: #8a8f99; }

.crow { display: flex; align-items: flex-end; gap: 1.6mm; margin-bottom: 2.6mm; flex-wrap: wrap; position: relative; }
.stack { display: flex; flex-direction: column; align-items: center; flex: none; }
.plabel { font-size: 11px; color: #333; height: 15px; line-height: 15px; font-family: var(--ui-font); }

.cell {
  position: relative; flex: none;
  border: 1px solid var(--grid); background-color: #fff;
  display: flex; align-items: center; justify-content: center;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.s-s { width: 10mm; height: 10mm; } .s-s .ch { font-size: 7.6mm; }
.s-m { width: 13mm; height: 13mm; } .s-m .ch { font-size: 10.2mm; }
.s-l { width: 16mm; height: 16mm; } .s-l .ch { font-size: 12.6mm; }
.cell .ch { font-family: var(--ink-font); line-height: 1; }
.cell-spacer.s-s { width: 10mm; } .cell-spacer.s-m { width: 13mm; } .cell-spacer.s-l { width: 16mm; }

/* grid guides */
.cell::before, .cell::after { content: ""; position: absolute; background: var(--grid); display: none; }
.g-tian::before, .g-mi::before { display: block; left: 0; right: 0; top: 50%; height: 1px; transform: scaleY(0.6); }
.g-tian::after, .g-mi::after { display: block; top: 0; bottom: 0; left: 50%; width: 1px; transform: scaleX(0.6); }
.g-mi { background-image:
  linear-gradient(45deg, transparent calc(50% - 0.5px), var(--grid) calc(50% - 0.5px), var(--grid) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
  linear-gradient(-45deg, transparent calc(50% - 0.5px), var(--grid) calc(50% - 0.5px), var(--grid) calc(50% + 0.5px), transparent calc(50% + 0.5px)); }
.g-jing { background-image:
  linear-gradient(90deg, transparent calc(33.33% - 0.5px), var(--grid) calc(33.33% - 0.5px), var(--grid) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px)),
  linear-gradient(90deg, transparent calc(66.66% - 0.5px), var(--grid) calc(66.66% - 0.5px), var(--grid) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)),
  linear-gradient(0deg, transparent calc(33.33% - 0.5px), var(--grid) calc(33.33% - 0.5px), var(--grid) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px)),
  linear-gradient(0deg, transparent calc(66.66% - 0.5px), var(--grid) calc(66.66% - 0.5px), var(--grid) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)); }

.cell.model .ch { color: #1c1c1c; }
.cell.trace .ch { color: #d2d2d2; }
.crow.wrong .cell.model { outline: 2px solid #d63031; outline-offset: 1px; }

/* mistake mark */
.markdot {
  width: 6mm; height: 6mm; border-radius: 50%; flex: none;
  border: 1.5px solid #e3b7b0; background: #fff; margin-bottom: 3.5mm; padding: 0;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.markdot:hover { border-color: #d63031; }
.crow.wrong .markdot { background: #d63031; border-color: #d63031; }

/* stroke strip */
.strip { display: inline-flex; margin-left: 2mm; align-self: flex-end; }
.strip-missing { display: none; }
.strip-svg { display: block; }

/* ---------- quiz sheet ---------- */
.quiz { display: flex; flex-direction: column; }
.qrow { display: flex; align-items: center; gap: 5mm; margin-bottom: 4.5mm; break-inside: avoid; }
.qmeta { flex: 0 0 52mm; display: flex; flex-direction: column; gap: 1px; }
.qidx { font-size: 11px; color: #999; }
.qphon { font-size: 14px; color: #111; font-weight: 600; }
.qgl { font-size: 11px; color: #8a8f99; }
.qcells { display: flex; gap: 1.6mm; flex-wrap: wrap; }
.answerkey { margin-top: 8mm; border-top: 1px dashed #ccc; padding-top: 3mm; font-size: 11px; color: #777; break-inside: avoid; }
.akt { font-weight: 700; }
.akw { margin-right: 5mm; white-space: nowrap; }

/* ---------- drawer ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(340px, 92vw);
  background: #fff; border-left: 1px solid var(--line); box-shadow: -6px 0 24px rgba(20, 24, 40, 0.15);
  z-index: 40; display: flex; flex-direction: column; padding: 16px;
}
.drawer[hidden] { display: none; }
.drawer header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.drawer header b { font-size: 16px; }
.drawer header button { border: 0; background: none; font-size: 22px; color: var(--muted); }
.drawer .hint { margin: 0 0 10px; }
#wrongList { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
#wrongList li { display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); padding: 8px 2px; }
#wrongList .wc { font-family: var(--ink-font); font-size: 26px; }
#wrongList .wp2 { font-size: 13px; color: #333; }
#wrongList .we2 { font-size: 11.5px; color: #9aa0aa; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#wrongList .rm { border: 0; background: none; color: #c00; font-size: 16px; }
#wrongList .empty { color: var(--muted); font-size: 13px; border: 0; }
.drawer footer { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }

/* ---------- FAQ / footer ---------- */
.faq { max-width: 820px; margin: 30px auto; padding: 0 16px; }
.faq h2 { font-size: 20px; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.faq summary { font-weight: 600; cursor: pointer; font-size: 14.5px; }
.faq p { color: var(--muted); font-size: 13.5px; margin: 8px 0 2px; }
footer.site { border-top: 1px solid var(--line); background: #fff; padding: 18px 20px 26px; text-align: center; font-size: 12.5px; color: var(--muted); }
footer.site a { color: var(--muted); margin: 0 8px; }
footer.site .footlinks { font-size: 12px; }
footer.site .footlinks a { margin: 0 4px; }

/* ---------- static marketing / SEO pages (pricing, scenes, char, lists) ---------- */
.static-page { max-width: 860px; margin: 0 auto; padding: 26px 18px 50px; }
.static-page h1 { font-size: clamp(24px, 4vw, 32px); margin: 6px 0 10px; letter-spacing: -0.4px; }
.static-page h2 { font-size: 19px; margin: 30px 0 8px; }
.static-page h3 { font-size: 15.5px; margin: 18px 0 6px; }
.static-page p, .static-page li { font-size: 14.5px; color: #3c414c; }
.static-page .lede { font-size: 16px; color: var(--muted); margin: 0 0 14px; }
.static-page a { color: var(--brand); }
.cta-card {
  background: #fff; border: 1px solid #e7c8c3; border-radius: 14px; padding: 18px 20px;
  margin: 18px 0 26px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px;
}
.cta-card .cta-txt { flex: 1 1 260px; }
.cta-card .cta-txt b { font-size: 15.5px; }
.cta-card .cta-txt p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
a.cta-btn {
  display: inline-block; background: var(--brand); color: #fff; text-decoration: none;
  border-radius: 10px; padding: 12px 20px; font-size: 15px; font-weight: 700;
}
a.cta-btn:hover { background: #98311f; }
a.cta-btn.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.cta-note { font-size: 12px; color: var(--muted); width: 100%; margin: 0; }
.static-page table.cmp { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
.static-page table.cmp th, .static-page table.cmp td { border: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top; }
.static-page table.cmp th { background: #fafafa; }
.scene-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.scene-links li { margin: 0; }
.scene-links a {
  display: inline-block; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; text-decoration: none; color: var(--ink);
}
.scene-links a:hover { border-color: var(--brand); color: var(--brand); }

/* pricing */
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 18px 0 8px; }
.price-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.price-card.hot { border: 2px solid var(--brand); position: relative; }
.price-card .tag { position: absolute; top: -11px; left: 14px; background: var(--brand); color: #fff; font-size: 11.5px; border-radius: 999px; padding: 2px 10px; }
.price-card h3 { margin: 0; font-size: 16px; }
.price-card .amount { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.price-card .amount small { font-size: 13px; font-weight: 400; color: var(--muted); }
.price-card .strike { text-decoration: line-through; color: var(--muted); font-size: 16px; font-weight: 400; margin-right: 6px; }
.price-card ul { margin: 2px 0 6px; padding-left: 18px; }
.price-card li { font-size: 13.5px; margin: 3px 0; }

/* char pages */
.char-hero { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; margin: 10px 0 8px; }
.bigcell {
  position: relative; width: 168px; height: 168px; flex: none;
  border: 1.5px solid #c9c9c9; background: #fff; display: flex; align-items: center; justify-content: center;
}
.bigcell::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: #dcdcdc; }
.bigcell::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: #dcdcdc; }
.bigcell .ch { font-family: var(--ink-font); font-size: 118px; line-height: 1; color: #1c1c1c; }
.char-meta p { margin: 4px 0; font-size: 15px; }
.char-meta .pinyin { font-size: 22px; font-weight: 700; color: var(--ink); }
.char-meta .zhuyin { font-size: 16px; color: #3c414c; margin-left: 10px; font-weight: 400; }
.stroke-strip { overflow-x: auto; padding: 6px 0; }
.stroke-strip svg { max-width: 100%; height: auto; display: block; }
table.wordtab { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
table.wordtab th, table.wordtab td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
table.wordtab th { background: #fafafa; }
table.wordtab .hw { font-family: var(--ink-font); font-size: 20px; }

/* list pages */
.list-table { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
.list-table th, .list-table td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.list-table th { background: #fafafa; }
.list-table .hw { font-family: var(--ink-font); font-size: 19px; }
.list-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 14px 0; }
.list-cards a { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; text-decoration: none; color: var(--ink); }
.list-cards a:hover { border-color: var(--brand); }
.list-cards b { font-size: 14.5px; }
.list-cards small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.list-group-t { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin: 24px 0 4px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .tool { flex-direction: column; align-items: stretch; }
  .panel { flex: none; width: 100%; }
  .topbar { flex-wrap: wrap; }
  .topbar nav { order: 3; width: 100%; justify-content: center; padding-top: 6px; border-top: 1px solid var(--line); }
}
/* small phones: never let the header clip — wrap rows and shrink the script switch */
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .brand { font-size: 15px; }
  .brand img { width: 22px; height: 22px; }
  .script-switch { margin-left: auto; }
  .script-switch button { padding: 5px 9px; font-size: 12px; }
  .script-switch .sc-en { display: none; }
}

/* ---------- print ---------- */
@media print {
  .no-print, .drawer, .notice { display: none !important; }
  body { background: #fff; }
  .tool { display: block; margin: 0; padding: 0; max-width: none; }
  .page { width: auto; max-width: none; margin: 0; padding: 0; box-shadow: none; border-radius: 0; overflow: visible; }
  #sheet { width: auto; }
  .markdot { visibility: hidden; }           /* interactive aid, not for paper */
  .crow.wrong .cell.model { outline: none; }
}
