/* 全字庫正楷體 TW-Kai (政府資料開放授權條款 1.0), subset to bopomofo + tone marks only */
@font-face { font-family: "TW-Kai Zhuyin"; src: url(fonts/twkai-zhuyin.woff2) format("woff2"); font-display: block; }
:root {
  --ink: #222;
  --muted: #777;
  --line: #e2ddd5;
  --bg: #f4f1ec;
  --panel: #fffdf9;
  --accent: #b23a2e;
  font-family: "Noto Sans TC", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); display: flex; min-height: 100vh; }

#panel {
  width: 300px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  height: 100vh; overflow-y: auto; position: sticky; top: 0; display: flex; flex-direction: column;
}
.panel-head {
  position: sticky; top: 0; z-index: 2; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
}
#panel h1 { font-family: "LXGW WenKai TC", serif; font-size: 22px; margin: 0; color: var(--accent); }
#panel section { padding: 12px 16px 4px; }
.text-box { border-bottom: 1px solid var(--line); }
label.check { display: flex; align-items: center; gap: 6px; font-size: 14px; margin-bottom: 8px; }
label.inline { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.field { display: grid; grid-template-columns: 88px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.field output { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; display: block; }
.field[hidden], .check[hidden] { display: none; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 0; }
input[type=checkbox] { accent-color: var(--accent); }
select, textarea, input[type=text], input[type=number], input[type=date] {
  width: 100%; font: inherit; font-size: 14px; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
textarea { font-family: "LXGW WenKai TC", serif; font-size: 17px; resize: vertical; line-height: 1.5; margin-top: 4px; min-height: 11em; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 6px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 8px; }
.seg button { padding: 5px 0; font-size: 13px; }
button {
  font: inherit; font-size: 14px; border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 6px 12px; cursor: pointer; color: var(--ink);
}
button:hover { border-color: var(--accent); }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); padding: 6px 14px; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; font-size: 13px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 12px; position: sticky; top: 55px; background: var(--panel); z-index: 1; }
.tabs button { flex: 1; border: 0; border-radius: 0; background: none; padding: 10px 0 8px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.swatches { display: flex; align-items: center; gap: 4px; }
.swatches button { width: 19px; height: 19px; padding: 0; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatches button.on { box-shadow: 0 0 0 2px var(--accent); }
.swatches input[type=color] { width: 24px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.tab { display: none; }
.tab.on { display: block; }
.muted { color: var(--muted); font-size: 12px; }
.credits { margin-top: auto; padding: 10px 16px 16px; font-size: 12px; color: var(--muted); line-height: 1.6; border-top: 1px solid var(--line); }
.credits summary { cursor: pointer; }
.credits a { color: var(--muted); }

#sheet { flex: 1; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 24px; overflow-x: auto; }
.page { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.12); width: 210mm; height: 297mm; flex: none; }
.page svg { display: block; width: 210mm; height: 297mm; }
.page .hit { cursor: pointer; }
.page .hit:hover { fill: rgba(178,58,46,.08); }

dialog#anim { border: 0; border-radius: 12px; padding: 16px; width: min(420px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog#anim::backdrop { background: rgba(0,0,0,.35); }
.anim-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.anim-head strong { font-family: "LXGW WenKai TC", serif; font-size: 20px; }
#animSvg { width: 100%; aspect-ratio: 1; background: #fff; border: 1px solid #d9534f; }

@media (max-width: 900px) {
  body { flex-direction: column; }
  #panel { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .tabs { top: 55px; }
  #sheet { padding: 12px; align-items: flex-start; max-width: 100vw; overflow-x: auto; }
  body { overflow-x: hidden; }
  .panel-head { position: static; }
}

@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; display: block; }
  #panel, dialog { display: none !important; }
  #sheet { padding: 0; gap: 0; display: block; overflow: visible; }
  .page { box-shadow: none; break-after: page; page-break-after: always; }
  .page:last-child { break-after: auto; page-break-after: auto; }
  .page .hit:hover { fill: none; }
}
