/* Japanese writing practice sheets: generator UI + printable sheet (2026-11-24).
   Adapted from css/writing.css. Uses only the site-wide variables of styles.css
   (--ja from japanese.css when present). The sheet is paper: always white with
   fixed inks, whatever the screen theme. */

.ws-wrap { --ws-accent: var(--ja, var(--primary-ink)); --ws-accent-tint: var(--ja-tint, var(--primary-tint)); }
.ws-app { margin: 18px 0 8px; }
.ws-controls { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 14px; }
.ws-controls label { display: block; font-weight: 700; font-size: .92rem; color: var(--ink); }
.ws-controls label > span { display: block; margin-bottom: 5px; }
.ws-input { width: 100%; box-sizing: border-box; min-height: 84px; resize: vertical; font: 1.25rem/1.5 'Nunito', 'Hiragino Sans', 'Yu Gothic', 'Noto Sans JP', sans-serif;
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); }
.ws-input:focus { outline: none; border-color: var(--ws-accent); }
.ws-quick { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 10px 0 2px; font-size: .88rem; color: var(--muted); }
.ws-quick button { font: 600 .85rem 'Nunito', sans-serif; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--ws-accent); cursor: pointer; }
.ws-quick button:hover { background: var(--ws-accent-tint); }
.ws-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 14px; margin-top: 14px; }
.ws-controls > .ws-opts:first-child { margin-top: 0; }
.ws-opts select { width: 100%; font: 600 .95rem 'Nunito', sans-serif; padding: 7px 8px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--card); color: var(--ink); }
.ws-checks { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px; }
.ws-checks label { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; cursor: pointer; }
.ws-checks input { width: 17px; height: 17px; accent-color: var(--ws-accent); }
.ws-preset .ws-only-free { display: none; }
.ws-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.ws-btn { font: 700 1rem 'Nunito', sans-serif; cursor: pointer; }
.ws-btn-ghost { padding: 11px 20px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--card); color: var(--ink); }
.ws-btn-ghost:hover { border-color: var(--ws-accent); color: var(--ws-accent); }
.ws-status { margin: 10px 0 0; font-size: .9rem; color: var(--ink); min-height: 1.3em; }
.ws-status-muted { color: var(--muted); }
.ws-status-warn { color: var(--danger); }
.ws-status-ok { color: var(--ws-accent); }
.ws-parts { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-top: 10px; font-size: .9rem; }
.ws-parts-label { color: var(--muted); margin-right: 4px; }
.ws-part { font: 700 .85rem 'Nunito', sans-serif; padding: 5px 12px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--card); color: var(--ink); cursor: pointer; }
.ws-part.is-on { background: var(--ws-accent-tint); border-color: var(--ws-accent); color: var(--ws-accent); }
.ws-preset-note { margin-top: 12px; font-size: .9rem; color: var(--muted); }

/* ---- preview ---- */
#ws-preview { margin-top: 22px; overflow: hidden; }
#ws-out { display: flex; flex-direction: column; align-items: flex-start; }
#ws-out .ws-sheet { flex: none; }
.ws-sheet { position: relative; box-sizing: border-box; width: var(--ws-w, 215.9mm); height: var(--ws-h, 279.4mm); padding: var(--ws-margin, 11mm);
  background: #fff; color: #111; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12), 0 6px 28px rgba(0, 0, 0, .18); margin: 0 0 18px; transform-origin: top left; overflow: hidden;
  font-family: 'Nunito', 'Helvetica Neue', Arial, sans-serif; line-height: 1.2; text-align: left; }
.ws-head { display: flex; align-items: center; justify-content: space-between; height: 11mm; font-size: 10pt; color: #222; border-bottom: .4mm solid #222; margin-bottom: 1.5mm; }
.ws-name { display: inline-flex; align-items: baseline; gap: 2mm; }
.ws-name .ws-line { display: inline-block; width: 38mm; border-bottom: .3mm solid #555; height: 4mm; }
.ws-title { font-weight: 700; }
.ws-page { color: #666; font-size: 9pt; }
.ws-foot { position: absolute; left: var(--ws-margin, 11mm); right: var(--ws-margin, 11mm); bottom: calc(var(--ws-margin, 11mm) - 2mm); display: flex; justify-content: space-between; font-size: 7.5pt; color: #777; }
.ws-row { margin-bottom: 1.2mm; break-inside: avoid; }
.ws-meta { display: flex; align-items: flex-end; gap: 2.2mm; box-sizing: border-box; height: var(--ws-meta, 9mm); font-size: 10pt; line-height: 1; padding-bottom: .7mm; overflow: hidden; white-space: nowrap; }
.ws-sheet [lang="ja"], .ws-text { font-family: 'YuKyokasho', 'YuKyokasho Yoko', 'UD Digi Kyokasho N-R', 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif JP', serif; }
.ws-hw { font-size: 12pt; color: #111; }
.ws-on { color: #1a41af; font-weight: 700; }
.ws-kun { color: #7a4a00; font-weight: 700; }
.ws-ro { color: #1a41af; font-weight: 700; }
.ws-def { color: #555; max-width: 30%; overflow: hidden; text-overflow: ellipsis; }
.ws-so-slot { flex: 1 1 0; min-width: 0; display: flex; justify-content: flex-start; align-items: flex-end; align-self: stretch; overflow: hidden; margin-left: 1.5mm; }
/* The strip shrinks to fit: a 16-stroke kanji gets smaller steps, not a cut-off strip. */
.ws-so { display: flex; align-items: flex-end; gap: .6mm; width: 100%; height: 100%; min-width: 0; }
.ws-so-step { flex: 0 1 calc(var(--ws-meta, 9mm) - 1.2mm); min-width: 0; height: auto; max-height: 100%; aspect-ratio: 1 / 1; }
.ws-cells { display: grid; grid-template-columns: repeat(var(--ws-cols, 10), var(--ws-cell, 19mm)); }
.ws-cell { width: var(--ws-cell, 19mm); height: var(--ws-cell, 19mm); display: block; }
.ws-box { fill: #fff; stroke: #6b6b6b; stroke-width: 7; }
.ws-guide line { stroke: #bdbdbd; stroke-width: 4; stroke-dasharray: 22 16; }
.ws-hw-strokes path { fill: #111; }
.ws-kvg path { fill: none; stroke: #111; stroke-width: 5.2px; stroke-linecap: round; stroke-linejoin: round; }
.ws-text { fill: #111; }
.ws-nums text { font: 800 92px 'Nunito', 'Helvetica Neue', Arial, sans-serif; fill: #c62828; stroke: #fff; stroke-width: 22px; paint-order: stroke; stroke-linejoin: round; }
.ws-so-step .ws-hw-strokes .ws-stroke-done { fill: #b5b5b5; }
.ws-so-step .ws-hw-strokes .ws-stroke-now { fill: #111; }
.ws-so-step .ws-kvg path { stroke-width: 8px; }
.ws-so-step .ws-kvg .ws-stroke-done { stroke: #b5b5b5; }
.ws-so-step .ws-kvg .ws-stroke-now { stroke: #111; }

/* ---- page copy ---- */
.ws-sec { margin-top: 1.6em; }
.ws-steps { padding-left: 1.3em; }
.ws-steps li { margin-bottom: .5em; }
.ws-sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin: 16px 0 6px; }
.ws-set { display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm); }
.ws-set:hover { border-color: var(--ws-accent); }
.ws-set b { display: block; font-size: 1.05rem; margin-bottom: 3px; color: var(--ws-accent); }
.ws-set span { font-size: .88rem; color: var(--muted); }
.ws-set .ws-sample { display: block; margin-top: 8px; font-size: 1.35rem; letter-spacing: .12em; color: var(--ink); }
.ws-chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; margin: 12px 0 0; padding: 0; font-size: .95rem; }
.ws-chars li { list-style: none; display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.ws-chars .c { font-size: 1.35rem; min-width: 1.4em; color: var(--ink); }
.ws-chars .p { color: var(--ws-accent); font-weight: 700; white-space: nowrap; }
.ws-chars .d { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-wrap #list h3 { margin: 1.2em 0 0; font-size: 1.05rem; }
.ws-credit { margin-top: 2em; font-size: .85rem; color: var(--muted); }

@media (max-width: 640px) {
  .ws-controls { padding: 14px 12px 12px; }
  .ws-opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
  @page { margin: 0; }
  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body > :not(main), .ws-wrap > :not(#ws-app), .ws-app > :not(#ws-preview), .ws-controls, .ws-parts, .ws-status { display: none !important; }
  main, main.container, .ws-wrap { max-width: none !important; width: auto !important; padding: 0 !important; margin: 0 !important; }
  .ws-app { margin: 0 !important; }
  #ws-preview { margin: 0 !important; overflow: visible !important; }
  .ws-sheet { transform: none !important; margin: 0 !important; box-shadow: none !important; page-break-after: always; break-after: page; }
  .ws-sheet:last-child { page-break-after: auto; break-after: auto; }
  .ws-box, .ws-glyph path, .ws-guide line, .ws-nums text { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
