/* 练习单生成器 · Chinese Worksheet Generator */
.wg-page {
  --wg-green: #356e57;
  --wg-green-dark: #24503f;
  --wg-green-light: #e5efe9;
  --wg-ink: #1f2a26;
  --wg-muted: #5b6863;
  --wg-line: #d5ddd8;
  --wg-red: #c0392b;
}

.wg-wrap { max-width: 1400px; margin: 0 auto; padding: 20px 16px 48px; color: var(--wg-ink); }

.wg-header {
  position: relative; overflow: hidden; margin-bottom: 22px; padding: 30px 38px 32px; border-radius: 24px;
  background: linear-gradient(120deg, rgba(255, 255, 255, .04), transparent 36%), linear-gradient(135deg, #123f37, #1f5a4c 64%, #34725c);
  box-shadow: 0 24px 60px rgba(25, 79, 69, .2); color: #fffdf7;
}
.wg-header .back-btn { display: inline-flex; margin-bottom: 18px; padding: 6px 14px; text-decoration: none; }
.wg-eyebrow { margin: 0; color: #ffe49a; font-size: .74rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.wg-header h1 { margin: 6px 0 10px; color: #fffdf7 !important; font-family: 'DM Serif Display', 'Noto Sans SC', serif; font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 400; line-height: 1.1; }
.wg-header > p:not(.wg-eyebrow) { max-width: 780px; margin: 0; color: rgba(255, 253, 247, .88); line-height: 1.6; }

.wg-layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }

/* ---- Controls ---- */
.wg-controls { display: grid; gap: 14px; position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; padding-right: 4px; }
.wg-panel { background: #fff; border: 1px solid var(--wg-line); border-top: 4px solid var(--wg-green); border-radius: 14px; padding: 14px 16px 16px; }
.wg-panel-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.wg-panel-heading h2 { margin: 0; font-size: 1.05rem; color: var(--wg-green-dark); }
.wg-step {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--wg-green); color: #fff; font-weight: 700; font-size: 14px; flex: none;
}
.wg-hint { margin: 0 0 8px; color: var(--wg-muted); font-size: 13px; line-height: 1.5; }
.wg-hint code { background: var(--wg-green-light); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.wg-hint.is-ready { color: var(--wg-green); }
.wg-hint.is-error { color: var(--wg-red); }
.wg-label { display: block; margin: 12px 0 4px; font-size: 13px; font-weight: 700; color: var(--wg-ink); }
.wg-label small { font-weight: 400; color: var(--wg-muted); }

.wg-controls textarea,
.wg-controls input[type=text],
.wg-controls select {
  width: 100%; font: inherit; font-size: 15px; color: var(--wg-ink); background: #fff;
  border: 1px solid var(--wg-line); border-radius: 8px; padding: 8px 10px;
}
.wg-controls textarea { resize: vertical; line-height: 1.6; font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif; }
.wg-controls textarea:focus, .wg-controls input:focus, .wg-controls select:focus,
.wg-page button:focus-visible { outline: 3px solid #f2b935; outline-offset: 1px; }

.wg-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.wg-row-tight { margin: 0 0 6px; }
.wg-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.wg-checks { display: grid; gap: 6px; margin-top: 12px; }

.wg-check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.wg-check input { width: 17px; height: 17px; accent-color: var(--wg-green); flex: none; }
.wg-check small { color: var(--wg-muted); }

.wg-types { display: grid; gap: 2px; }
.wg-type-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 6px; border-radius: 8px; }
.wg-type-row:hover { background: var(--wg-green-light); }
.wg-count { width: 58px; font: inherit; font-size: 14px; padding: 4px 6px; border: 1px solid var(--wg-line); border-radius: 6px; text-align: center; }

.wg-page button {
  font: inherit; font-size: 14px; cursor: pointer; border-radius: 9px; padding: 9px 14px; min-height: 40px;
}
.wg-primary { background: var(--wg-green); border: 1px solid var(--wg-green); color: #fff; font-weight: 700; }
.wg-primary:hover { background: var(--wg-green-dark); }
.wg-primary:disabled { opacity: .5; cursor: not-allowed; }
.wg-secondary { background: #fff; border: 1px solid var(--wg-line); color: var(--wg-green-dark); }
.wg-secondary:hover { border-color: var(--wg-green); }
.wg-page .wg-link-btn { background: none; border: none; color: var(--wg-green); padding: 2px 4px; min-height: 0; font-size: 13px; text-decoration: underline; }

/* ---- Preview ---- */
.wg-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.wg-status { color: var(--wg-muted); font-size: 13px; }
.wg-paper-scroll { overflow-x: auto; padding-bottom: 8px; }
.wg-output { display: flex; flex-direction: column; align-items: center; gap: 18px; width: max-content; margin: 0 auto; }

/* ---- The printed sheet ---- */
.wg-output {
  --hz: 22px; --lat: 14px; --box: 16mm;
  --hz-font: "KaiTi", "STKaiti", "Kaiti SC", "BiauKai", "楷体", serif;
}
.wg-size-s { --hz: 18px; --lat: 13px; --box: 14mm; }
.wg-size-l { --hz: 27px; --lat: 16px; --box: 17mm; }
.wg-font-song { --hz-font: "SimSun", "Songti SC", "STSong", "Noto Serif SC", serif; }
.wg-font-hei { --hz-font: "Microsoft YaHei", "PingFang SC", "Heiti SC", "Noto Sans SC", sans-serif; }

.wg-sheet {
  width: 210mm; min-height: 297mm; padding: 12mm; background: #fff; color: #111;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .12); border-radius: 2px;
  font-family: "Segoe UI", Arial, sans-serif; font-size: var(--lat); line-height: 1.5;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.wg-paper-letter .wg-sheet { width: 216mm; min-height: 279mm; }
.wg-sheet.wg-empty { display: grid; place-items: center; text-align: center; color: var(--wg-muted); min-height: 160mm; }

.wg-hz, .wg-sheet ruby, .wg-cell-hz, .wg-tzg, .wg-sentence, .wg-chunk, .wg-ws-grid td, .wg-sheet .wg-answer {
  font-family: var(--hz-font);
}
.wg-hz, .wg-sentence, .wg-chunk, .wg-cell-hz { font-size: var(--hz); }
.wg-sheet rt { font-family: "Segoe UI", Arial, sans-serif; font-size: .5em; color: #333; }

.wg-sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 2px solid #111; padding-bottom: 6px; }
.wg-sheet-head h2 { margin: 0; font-family: var(--hz-font); font-size: 26px; line-height: 1.3; color: #111; }
.wg-sheet-head p { margin: 2px 0 0; color: #444; }
.wg-key-tag { font-family: "Segoe UI", Arial, sans-serif; font-size: 13px; color: var(--wg-red); border: 1.5px solid var(--wg-red); border-radius: 4px; padding: 1px 6px; vertical-align: middle; }
.wg-version { border: 1.5px solid #111; border-radius: 4px; padding: 2px 10px; font-weight: 700; white-space: nowrap; }

.wg-info { display: flex; gap: 18px; margin: 10px 0 4px; font-size: 13px; }
.wg-info span { display: flex; flex: 1; align-items: flex-end; gap: 6px; white-space: nowrap; }
.wg-info i { flex: 1; border-bottom: 1px solid #111; min-width: 20mm; }

.wg-section { margin-top: 16px; }
.wg-section-head { display: flex; align-items: center; gap: 8px; break-after: avoid; page-break-after: avoid; }
.wg-section-num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid #111; font-weight: 700; font-size: 13px; flex: none;
}
.wg-section-head h3 { margin: 0; font-family: var(--hz-font); font-size: 19px; color: #111; }
.wg-section-head h3 small { font-family: "Segoe UI", Arial, sans-serif; font-size: 13px; color: #555; font-weight: 400; }
.wg-instr { margin: 3px 0 8px; color: #333; font-size: 13px; font-style: italic; break-after: avoid; page-break-after: avoid; }
.wg-note { margin: 6px 0; padding: 6px 10px; background: #fff6dd; border-radius: 6px; font-size: 13px; color: #6b4e00; }
.wg-teacher-note { margin: 6px 0; font-size: 13px; }

.wg-item { break-inside: avoid; page-break-inside: avoid; }
.wg-answer { color: var(--wg-red); font-weight: 700; }
.wg-num { color: #444; font-weight: 600; }

/* Numbers are drawn with counters so they never get clipped by large Chinese text. */
.wg-list { margin: 0; padding: 0; list-style: none; counter-reset: wg-q; display: grid; gap: 10px 18px; }
.wg-list > li { position: relative; padding-left: 26px; counter-increment: wg-q; }
.wg-list > li::before {
  content: counter(wg-q) "."; display: inline-block; width: 26px; margin-left: -26px;
  font-family: "Segoe UI", Arial, sans-serif; font-size: 13px; font-weight: 600; color: #444;
}
.wg-list > li.wg-tf::before, .wg-list > li.wg-translate::before, .wg-list > li.wg-py-item::before {
  position: absolute; left: 0; bottom: .35em; margin: 0;
}
.wg-cols-2 { grid-template-columns: 1fr 1fr; }
.wg-cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* vocabulary table */
.wg-vocab { width: 100%; border-collapse: collapse; }
.wg-vocab th, .wg-vocab td { border: 1px solid #999; padding: 4px 8px; text-align: left; }
.wg-vocab th { background: #f0f0f0; font-size: 12.5px; }
.wg-vocab tr { break-inside: avoid; }
.wg-vocab .wg-num { width: 2em; text-align: center; }

/* matching */
.wg-match { display: grid; gap: 10px; }
.wg-match-row { display: grid; grid-template-columns: minmax(0, 1fr) 10px 28mm 10px minmax(0, 1fr); align-items: center; gap: 6px; }
.wg-match-right { padding-left: 4px; }
.wg-dot { width: 9px; height: 9px; border-radius: 50%; background: #111; }

/* multiple choice */
.wg-q { display: inline-block; font-weight: 600; margin-bottom: 2px; }
.wg-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 12px; }
.wg-option { padding: 1px 6px; border: 1.5px solid transparent; border-radius: 6px; }
.wg-option.is-correct { border-color: var(--wg-red); }

/* true / false */
.wg-tf { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.wg-eq { color: #666; }
.wg-paren { margin-left: auto; white-space: nowrap; }

/* 田字格 */
.wg-tzg {
  display: inline-grid; place-items: center; width: var(--box); height: var(--box);
  border: 1px solid #555; margin-left: -1px; font-size: calc(var(--box) * .72); line-height: 1; color: #111;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M50 0V100M0 50H100' stroke='%23999' stroke-width='1' stroke-dasharray='4 4' vector-effect='non-scaling-stroke' fill='none'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}
.wg-tzg:first-child { margin-left: 0; }
.wg-tzg.is-trace { color: #c8c8c8; }
.wg-tzg.is-answer { color: var(--wg-red); }
.wg-tzg-word { display: inline-flex; }
.wg-py-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.wg-py-label { font-size: calc(var(--lat) + 2px); min-height: 1.4em; }

.wg-trace { display: grid; gap: 6px; }
.wg-trace-row { display: flex; align-items: center; gap: 4px; }
.wg-trace-py { width: 13mm; flex: none; text-align: right; padding-right: 2px; font-size: 13px; }
.wg-trace-boxes { display: flex; }
.wg-trace-row .wg-tzg { --box: 16mm; }
.wg-paper-letter .wg-trace-row .wg-tzg { --box: 15.5mm; }

/* fill in the blanks / sentences */
.wg-bank { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; border: 1.5px dashed #777; border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; break-inside: avoid; }
.wg-bank-label { font-size: 12px; font-weight: 700; color: #444; text-transform: uppercase; letter-spacing: .04em; }
.wg-bank-word { padding: 0 6px; }
.wg-sentence { line-height: 2.1; }
.wg-blank { display: inline-block; border-bottom: 1.5px solid #111; margin: 0 4px; height: 1.1em; vertical-align: baseline; text-align: center; }
.wg-blank.is-filled { height: auto; padding: 0 8px; }

/* sentence order */
.wg-chunks { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.wg-chunk { border: 1.5px solid #333; border-radius: 6px; padding: 2px 8px; line-height: 1.9; }
.wg-sheet .wg-line { display: block; border-bottom: 1px solid #111; min-height: 1.9em; margin-top: 6px; }
.wg-line-wrap { display: flex; align-items: flex-end; gap: 4px; }
.wg-line-wrap .wg-line { flex: 1; }
.wg-line-end { font-family: var(--hz-font); font-size: var(--hz); line-height: 1.2; }

/* translation / make a sentence */
.wg-translate { display: flex; align-items: flex-end; gap: 8px; }
.wg-translate .wg-en { white-space: nowrap; }
.wg-translate .wg-line { flex: 1; margin-top: 0; }
.wg-make-word { display: inline-block; }
.wg-make-word small { color: #555; }
.wg-make .wg-line { min-height: 2.2em; }

/* word search */
.wg-ws { display: flex; gap: 8mm; align-items: flex-start; flex-wrap: wrap; break-inside: avoid; }
.wg-ws-grid { border-collapse: collapse; }
.wg-ws-grid td { width: 9.5mm; height: 9.5mm; border: 1px solid #999; text-align: center; font-size: 20px; padding: 0; }
.wg-ws-grid td.is-hit { background: #fde2dd; color: var(--wg-red); font-weight: 700; }
.wg-ws-words { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wg-ws-words li { display: flex; align-items: center; gap: 6px; }
.wg-ws-box { width: 12px; height: 12px; border: 1.5px solid #333; border-radius: 3px; flex: none; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .wg-header { padding: 22px 20px 24px; }
  .wg-layout { grid-template-columns: 1fr; }
  .wg-controls { position: static; max-height: none; overflow: visible; }
}

/* ---- Print: only the sheets ---- */
@media print {
  html body.wg-page { background: #fff; margin: 0; min-height: 0; padding-top: 0 !important; }
  .wg-no-print, .site-main-nav, .tool-learning-guide, .milk-tea-footer, #milkTeaFooter, .account-coming-soon { display: none !important; }
  .wg-wrap { padding: 0; max-width: none; }
  .wg-layout { display: block; }
  .wg-paper-scroll { overflow: visible; padding: 0; }
  .wg-output { display: block; zoom: 1 !important; width: auto; }
  .wg-sheet, .wg-paper-letter .wg-sheet { width: auto; min-height: 0; padding: 0; box-shadow: none; border-radius: 0; }
  .wg-sheet + .wg-sheet { break-before: page; page-break-before: always; }
}

/* ---- Meaning languages ---- */
.wg-langs { border: 0; padding: 0; margin: 10px 0 0; min-width: 0; }
.wg-langs legend { padding: 0; margin-top: 0; }
.wg-lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.wg-lang-grid .wg-check input:disabled + span { opacity: .45; }
.wg-vocab-3 td:not(.wg-cell-hz), .wg-vocab-4 td:not(.wg-cell-hz) { font-size: .92em; }
.wg-vocab-4 .wg-cell-hz { white-space: nowrap; }
