:root {
  color-scheme: light;
  --topbar-h: 68px;
  --stepper-h: 66px;
  --bg: #f6f2ea;
  --surface: #fffdf9;
  --field: #ffffff;
  --ink: #2a2723;
  --muted: #6b645a;
  --line: #e4dccd;
  --primary: #2f6f62;
  --primary-hover: #255a4f;
  --primary-soft: #e3efe9;
  --accent: #d9822b;
  --accent-soft: #fbeedd;
  --danger: #b4432f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 8px 24px rgba(60, 40, 10, .06);
  /* 字級階梯：所有字級只准引用這幾階（根字級隨螢幕放大，見下方 html） */
  --fs-xs: .9rem;    /* 徽章、版本號 */
  --fs-sm: .95rem;   /* 提示、標籤、小按鈕 */
  --fs-base: 1rem;   /* 內文、輸入框 */
  --fs-md: 1.1rem;   /* 欄位標題、主要按鈕、結果文字 */
  --fs-lg: 1.38rem;  /* 卡片標題 */
  --fs-xl: 1.7rem;   /* 網站標題 */
  --font: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; }
@media (min-width: 768px) { html { font-size: 17px; } }
@media (min-width: 1200px) { html { font-size: 18px; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
small { font-size: .9em; }
a { color: var(--primary); }

/* ===== 頂部 ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 3vw, 40px);
  background: rgba(255, 253, 249, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { flex: none; }
.brand h1 { margin: 0; font-size: var(--fs-xl); letter-spacing: .03em; white-space: nowrap; }
.brand p { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.top-actions { display: flex; gap: 8px; flex: none; }

.badge {
  display: inline-block; min-width: 1.5em; padding: 0 6px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: var(--fs-xs); font-weight: 700; text-align: center;
}
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #c9c1b3; }
.dot.on { background: #3aa76d; }

/* ===== 版面 ===== */
.layout {
  max-width: 1600px; margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 40px) 8px;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(16px, 2vw, 28px); align-items: start;
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px clamp(16px, 2vw, 30px);
}
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 12px; }
.card-head h2 { white-space: nowrap; margin: 0; font-size: var(--fs-lg); display: flex; align-items: center; gap: 10px; }
.step {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: var(--fs-base);
}

.privacy-note {
  margin: 0 0 16px; padding: 10px 14px; border-radius: 10px;
  background: var(--primary-soft); color: #1f4d44; font-size: var(--fs-sm);
}

/* ===== 表單 ===== */
.grid-3 { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr; gap: 12px; }
.field { display: block; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field-label { display: block; font-weight: 700; font-size: var(--fs-base); margin-bottom: 6px; padding: 0; }
.field-label small, .field small { font-weight: 400; color: var(--muted); }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.req { font-style: normal; font-size: var(--fs-xs); color: #fff; background: var(--accent); border-radius: 6px; padding: 1px 6px; margin-left: 4px; vertical-align: 2px; }

input[type="text"], input:not([type]), input[type="date"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; padding: 10px 12px;
  background: var(--field); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 98, .18);
}

.seg, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label, .chips label { position: relative; }
.seg input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.seg span, .chips span {
  display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--field); cursor: pointer; font-size: var(--fs-base); user-select: none;
  transition: background .15s, border-color .15s, color .15s;
}
.seg span:hover, .chips span:hover { border-color: var(--primary); }
.seg input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.chips input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: #1f4d44; font-weight: 700; }
.seg input:focus-visible + span, .chips input:focus-visible + span { box-shadow: 0 0 0 3px rgba(217, 130, 43, .35); }
.seg.small span { padding: 5px 12px; font-size: var(--fs-sm); }

.templates { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; font-size: var(--fs-sm); color: var(--muted); }
.tpl {
  border: 1px dashed var(--accent); background: var(--accent-soft); color: #8a4d12;
  border-radius: 999px; padding: 4px 13px; cursor: pointer; font-size: var(--fs-sm);
}
.tpl:hover { background: #f7dfc0; }

.mic {
  border: 1px solid var(--line); background: var(--field); border-radius: 999px;
  padding: 5px 13px; font-size: var(--fs-sm); cursor: pointer; margin-bottom: 6px;
}
.mic:hover { border-color: var(--primary); }
.mic.recording { background: #fde8e4; border-color: var(--danger); color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(180, 67, 47, .15); } }

.options { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; background: #fffaf2; }
.options summary { cursor: pointer; font-weight: 700; }
.options-body { display: grid; gap: 10px; margin-top: 10px; }
.opt-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.opt-name { min-width: 2.5em; color: var(--muted); font-size: var(--fs-sm); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-sm); cursor: pointer; }
.check input { margin-top: 5px; accent-color: var(--primary); }

/* ===== 按鈕 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--field); cursor: pointer; font-weight: 600;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.big { padding: 13px 22px; font-size: var(--fs-md); }
.btn.small { padding: 7px 14px; font-size: var(--fs-sm); }
.btn.ghost { background: transparent; }
.btn.danger-ghost { color: var(--danger); background: transparent; }
.btn.danger-ghost:hover { border-color: var(--danger); }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: var(--fs-sm); }
.icon-btn { border: 0; background: none; font-size: var(--fs-lg); cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.actions .btn.big { flex: 1 1 260px; }

.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.peek { margin-top: 14px; font-size: var(--fs-sm); color: var(--muted); }
.peek summary { cursor: pointer; }
.peek pre {
  white-space: pre-wrap; word-break: break-word; background: #faf6ef; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; max-height: 320px; overflow: auto; font-size: var(--fs-sm); color: var(--ink);
}

/* ===== 結果 ===== */
.status { font-size: var(--fs-sm); color: var(--muted); text-align: right; }
.status.ok { color: #2a7a54; }
.status.err { color: var(--danger); }
.result-block { margin-bottom: 16px; }
.result-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.result-head label { font-weight: 800; font-size: var(--fs-md); color: var(--primary); }
.result-head .count { margin-left: auto; color: var(--muted); font-size: var(--fs-sm); }
#keyPoints, #contact { background: #fffefa; font-size: var(--fs-md); }
.output.busy textarea { opacity: .5; }

.paste-back { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 12px; }
.paste-back summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); }
.paste-back textarea { margin: 10px 0 8px; }

.tips { margin-top: 18px; padding: 12px 16px; border-radius: 12px; background: var(--accent-soft); font-size: var(--fs-sm); }
.tips h3 { margin: 0 0 4px; font-size: var(--fs-base); color: #8a4d12; }
.tips ul { margin: 0; padding-left: 1.2em; }

/* ===== 頁尾 ===== */
.site-footer { text-align: center; padding: 18px 16px 28px; color: var(--muted); font-size: var(--fs-sm); }
.site-footer p { margin: 4px 0; }
.site-credit__heart { display: inline-block; margin: 0 2px; filter: saturate(1.1); }
.site-credit__author { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; padding-bottom: 1px; transition: color .2s, border-color .2s; }
.site-credit__author:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== 對話框 ===== */
.modal {
  border: 0; padding: 0; border-radius: 16px; width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.modal::backdrop { background: rgba(40, 32, 20, .45); }
.modal-inner { padding: 20px 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: var(--fs-lg); }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row > input, .input-row > select { flex: 1; min-width: 0; }
.small-text { font-size: var(--fs-sm); color: var(--muted); margin: 0 0 12px; }
.hint { background: var(--accent-soft); color: #8a4d12; padding: 8px 12px; border-radius: 10px; font-size: var(--fs-sm); }
.warn { background: #fff4e5; border: 1px solid #f1d2a8; color: #7a4a14; padding: 10px 12px; border-radius: 10px; font-size: var(--fs-sm); }
.status-line { min-height: 1.4em; font-size: var(--fs-sm); margin: 0 0 10px; }
.status-line.ok { color: #2a7a54; }
.status-line.err { color: var(--danger); }

.drawer { width: min(720px, calc(100vw - 32px)); }
.history-list { list-style: none; padding: 0; margin: 12px 0 0; max-height: 55vh; overflow: auto; display: grid; gap: 10px; }
.history-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--field); }
.history-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: var(--fs-sm); color: var(--muted); }
.history-meta strong { color: var(--ink); font-size: var(--fs-base); }
.history-tag { background: var(--primary-soft); color: #1f4d44; border-radius: 999px; padding: 0 8px; font-size: var(--fs-xs); }
.history-preview { margin: 6px 0 8px; font-size: var(--fs-sm); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.history-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty-text { text-align: center; color: var(--muted); padding: 24px 0; }

/* ===== 提示 ===== */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 12px;
  background: #2a2723; color: #fff; font-size: var(--fs-base); box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.print-only { display: none; }


/* ===== 模式分頁 ===== */
.mode-tabs {
  max-width: 1600px; margin: 0 auto; padding: 18px clamp(16px, 3vw, 40px) 0;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.mode-tab {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  padding: 10px 20px; border-radius: 12px; font-weight: 700; font-size: var(--fs-md); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.mode-tab small { font-weight: 400; }
.mode-tab:hover { border-color: var(--primary); color: var(--ink); }
.mode-tab[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.muted { color: var(--muted); font-size: var(--fs-sm); }
.sub-title { font-size: var(--fs-base); margin: 18px 0 8px; }
.sub-title small { font-weight: 400; color: var(--muted); }
.head-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ===== 標籤庫 ===== */
.taglib { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: -4px 0 16px; background: #fffaf2; }
.taglib summary { cursor: pointer; font-weight: 700; }
.taglib summary small { font-weight: 400; color: var(--muted); }
.tag-count { margin-left: 6px; font-size: var(--fs-xs); color: #fff; background: var(--accent); border-radius: 999px; padding: 0 8px; }
.tag-count:empty { display: none; }
.taglib-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 20px; margin-top: 10px; }
.tag-group h4 { margin: 0 0 5px; font-size: var(--fs-sm); color: var(--primary); border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.chip-btn {
  border: 1px solid var(--line); background: var(--field); border-radius: 999px;
  padding: 6px 14px; font-size: var(--fs-sm); cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.chip-btn:hover { border-color: var(--primary); }
.chip-btn.on { background: var(--primary-soft); border-color: var(--primary); color: #1f4d44; font-weight: 700; }
.chip-btn.warn-tag { border-style: dashed; }
.chip-btn.warn-tag.on { background: #fde8e4; border-color: var(--danger); color: var(--danger); }
.chip-btn.action.on { background: var(--accent-soft); border-color: var(--accent); color: #8a4d12; }
.chips.small { gap: 6px; }
.action-chips { margin-bottom: 8px; }
.report-notice {
  margin: -6px 0 16px; padding: 10px 14px; border-radius: 10px; font-size: var(--fs-sm);
  background: #fde8e4; border: 1px solid #f0bdb2; color: #8c2f1f;
}

/* ===== 結果：載入遮罩與改寫 ===== */
.output { position: relative; }
.overlay {
  position: absolute; inset: 0; z-index: 3; display: none; place-items: center;
  background: rgba(255, 253, 249, .78); border-radius: var(--radius); backdrop-filter: blur(2px);
}
.output.busy .overlay { display: grid; }
.overlay-inner { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--primary); padding: 14px 20px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; }
.rewrite-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 14px; padding: 10px 12px; background: #faf6ef; border-radius: 10px; }
.rewrite-label { font-size: var(--fs-sm); color: var(--muted); margin-right: 2px; }

/* ===== 批次補登 ===== */
.batch-wrap { max-width: 1600px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 40px) 8px; display: grid; gap: clamp(16px, 2vw, 24px); }
.batch-top { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: clamp(16px, 2vw, 24px); align-items: start; }
.seat-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.seat {
  aspect-ratio: 1; border: 1px solid var(--line); background: var(--field); border-radius: 10px;
  font-weight: 700; font-size: var(--fs-md); color: var(--muted); cursor: pointer; position: relative;
  transition: background .12s, border-color .12s, color .12s;
}
.seat:hover { border-color: var(--primary); }
.seat.selected { background: var(--primary-soft); border-color: #9cc8bb; color: #1f4d44; }
.seat.done::after { content: "\2713"; position: absolute; top: 1px; right: 4px; font-size: var(--fs-xs); color: #2a7a54; }
.seat.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(47, 111, 98, .3); }
.seat.active.done::after { color: #fff; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: var(--fs-xs); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 12px; height: 12px; border-radius: 4px; display: inline-block; border: 1px solid var(--line); position: relative; }
.lg.active { background: var(--primary); border-color: var(--primary); }
.lg.selected { background: var(--primary-soft); border-color: #9cc8bb; }
.lg.done { background: #fff; }
.lg.done::after { content: "\2713"; position: absolute; top: -5px; left: 1px; font-size: var(--fs-xs); color: #2a7a54; }
.seat-editor .taglib-body { margin-top: 0; }
.empty-text.big { padding: 60px 12px; font-size: var(--fs-md); }
.seat-card .opt-row { margin-top: 8px; }

.batch-bar {
  position: sticky; bottom: 12px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid #d6cbb6; border-radius: var(--radius);
  padding: 12px 18px; box-shadow: 0 10px 30px rgba(60, 40, 10, .14);
}
.batch-progress { flex: 1 1 280px; min-width: 0; font-size: var(--fs-sm); color: var(--muted); }
.bar { height: 8px; background: #efe8db; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), #4f9a87); transition: width .3s; }
.batch-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.batch-result-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 14px; }
.batch-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fffefa; }
.batch-card.has-error { border-color: #f0bdb2; background: #fff8f6; }
.batch-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.batch-card-head .head-actions { margin-left: auto; }
.seat-pill { background: var(--primary); color: #fff; border-radius: 999px; padding: 2px 12px; font-weight: 700; }
.err-text { color: var(--danger); font-size: var(--fs-sm); }
.mini-label { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--primary); margin: 6px 0 3px; }
.batch-card textarea { font-size: var(--fs-base); }

/* ===== RWD ===== */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .batch-top { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .brand p { display: none; }
  .brand { flex: 1 1 auto; }
  .brand > div { min-width: 0; }
  .brand h1 { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar { gap: 8px; }
  .brand { gap: 10px; }
  .top-actions { gap: 6px; }
  .top-actions .btn { padding: 8px 8px; gap: 4px; }
  .top-actions .badge { padding: 0 5px; }
  .brand img { width: 34px; height: 34px; }
  .top-actions .label { display: none; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 .field:first-child { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: 1fr; }
  .seat-card .grid-2 { grid-template-columns: 1fr 1fr; }
  .seat-grid { gap: 5px; }
  .mode-tab { flex: 1 1 0; padding: 9px 10px; font-size: var(--fs-base); }
  .mode-tab small { display: none; }
  .taglib-body { grid-template-columns: 1fr; }
  .batch-bar { bottom: 8px; padding: 8px 10px; gap: 6px; }
  .batch-progress { flex-basis: 100%; font-size: var(--fs-sm); }
  .bar { margin-top: 4px; height: 6px; }
  .batch-buttons { width: 100%; gap: 6px; flex-wrap: nowrap; }
  .batch-buttons .btn { flex: 1 1 0; padding: 9px 8px; font-size: var(--fs-sm); }
  .actions .batch-buttons .btn, .batch-buttons .btn.big { flex: 1.3 1 0; }
  .batch-card-head .head-actions { margin-left: 0; width: 100%; }
  .card { padding: 18px 16px; }
  .actions .btn { flex: 1 1 100%; }
  .modal-inner { padding: 16px; }
}

/* ===== 列印 ===== */
@media print {
  @page { size: A4; margin: 18mm 16mm; }
  body { background: #fff; }
  .no-print, .toast, dialog { display: none !important; }
  .print-only { display: block; }
  #printArea { font-size: 12pt; color: #000; }
  #printArea h1 { text-align: center; font-size: 18pt; margin: 0 0 12pt; }
  #printArea table { width: 100%; border-collapse: collapse; margin-bottom: 12pt; }
  #printArea th, #printArea td { border: 1px solid #555; padding: 5pt 8pt; text-align: left; vertical-align: top; }
  #printArea th { width: 18%; background: #f1f1f1; }
  #printArea section { break-inside: avoid; margin-bottom: 12pt; }
  #printArea h2 { font-size: 13pt; margin: 0 0 4pt; }
  #printArea p { margin: 0; line-height: 1.8; text-align: justify; }
}

.version-tag { font-size: var(--fs-xs); opacity: .7; letter-spacing: .03em; }
.version-tag:empty { display: none; }

/* ===== 班級名冊、備份、逐位登錄 ===== */
.field-label-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field-label-row .btn-roster { margin-left: auto; font-weight: 600; }
.roster-count { font-size: var(--fs-xs); color: var(--primary); }
#rosterText { font-size: var(--fs-md); line-height: 1.8; }
.roster-preview { margin: -6px 0 0; font-size: var(--fs-sm); color: #2a7a54; }
.roster-preview.warn { color: var(--danger); }

.backup-hint { margin: 4px 0 10px; padding: 10px 14px; border-radius: 10px; background: var(--primary-soft); color: #1f4d44; font-size: var(--fs-sm); }
.backup-hint.need { background: #fff4e5; border: 1px solid #f1d2a8; color: #7a4a14; font-weight: 600; }
.backup-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.badge.warn { background: var(--accent); color: #fff; }

.entered-count { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.entered-count.all-done { color: #2a7a54; }
.seat-name { font-weight: 700; font-size: var(--fs-md); }
.entered-pill { background: #d8efe1; color: #1f6b43; border-radius: 999px; padding: 2px 10px; font-size: var(--fs-sm); font-weight: 700; }
.field-copy { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.field-copy .mini-label { margin: 0; }
.field-copy .btn.small { padding: 4px 12px; }
.batch-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.batch-card.entered { background: #f3faf6; border-color: #a9d8bd; }
.batch-card.entered textarea { color: var(--muted); }
.batch-card.flash { animation: cardFlash 1.4s ease-out; }
@keyframes cardFlash { 0%, 40% { box-shadow: 0 0 0 4px rgba(217, 130, 43, .55); } 100% { box-shadow: 0 0 0 0 rgba(217, 130, 43, 0); } }
.seat.entered { background: #d8efe1; border-color: #7bbf98; color: #1f6b43; }
.seat.entered::after { content: "\2713"; position: absolute; top: 1px; right: 4px; font-size: .7rem; color: #1f6b43; }
.seat.active.entered { background: var(--primary); color: #fff; }
.lg.entered { background: #d8efe1; border-color: #7bbf98; }
@media (prefers-reduced-motion: reduce) { .batch-card.flash { animation: none; } }

/* ===== 公用電腦模式、使用說明、追蹤輔導、學校格式、紀錄本篩選 ===== */
.public-banner {
  max-width: 1600px; margin: 12px auto 0; padding: 10px clamp(16px, 3vw, 40px);
  background: #fff4e5; border-top: 1px solid #f1d2a8; border-bottom: 1px solid #f1d2a8;
  color: #7a4a14; font-size: var(--fs-sm); display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
}
.public-banner .link-btn { color: #7a4a14; }
.help-btn {
  margin-left: auto; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; cursor: pointer;
}
.help-btn:hover { border-color: var(--primary); }
.modal { overflow: auto; }
.dialog-section { font-size: var(--fs-md); margin: 22px 0 8px; padding-top: 14px; border-top: 1px dashed var(--line); }
.modal-inner > .dialog-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 8px; }
.format-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 0 12px; }
input[type="number"] {
  width: 100%; padding: 10px 12px; background: var(--field); border: 1px solid var(--line); border-radius: 10px;
}
input[type="number"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 98, .18); }
.count.over { color: var(--danger); font-weight: 700; }

.followup-box { margin: -4px 0 16px; padding: 12px 14px; border-radius: 12px; background: #eef5fb; border: 1px solid #c9dcee; }
.followup-title { margin: 0 0 6px; font-weight: 700; color: #234a6b; }
.followup-box select { margin-top: 6px; }
.followup-box select:disabled { opacity: .6; }

.help { width: min(680px, calc(100vw - 32px)); }
.help-steps { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.help-steps li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--primary-soft); }
.help-steps p { margin: 2px 0 0; font-size: var(--fs-sm); color: #2f4f48; }
.help-num { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; }
.help-key, .help-tips { margin: 0 0 10px; padding-left: 1.4em; display: grid; gap: 6px; }

.history-filters { display: grid; grid-template-columns: 1.3fr 1.3fr 1fr 1fr; gap: 8px; }
.date-range { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.date-range input { min-width: 0; }
.history-summary-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.history-summary { margin: 0; font-size: var(--fs-sm); color: var(--primary); font-weight: 600; }
.history-student { border: 0; background: none; padding: 0; font: inherit; font-weight: 800; font-size: var(--fs-base); color: var(--ink); cursor: pointer; border-bottom: 1px dotted currentColor; }
.history-student:hover { color: var(--primary); }
.history-list.timeline { border-left: 3px solid var(--primary-soft); padding-left: 12px; }
.tl-no { background: var(--primary); color: #fff; border-radius: 999px; padding: 0 10px; font-size: var(--fs-xs); font-weight: 700; }
.drawer { width: min(860px, calc(100vw - 32px)); }

@media (max-width: 640px) {
  .help-btn { flex: 0 0 auto; padding: 9px 12px; }
  .help-btn .label { display: none; }
  .format-grid { grid-template-columns: 1fr 1fr; }
  .history-filters { grid-template-columns: 1fr 1fr; }
  .history-filters input[type="search"], .history-filters select { grid-column: 1 / -1; }
}

@media print {
  #printArea .print-sub { margin: -6pt 0 12pt; text-align: center; color: #444; }
  #printArea section p + p { margin-top: 4pt; }
}

/* ===== 頁尾（2026-10-20 重新設計：品牌區＋特色重點＋快速連結＋署名列） ===== */
.site-footer {
  margin-top: 36px; padding: 0; text-align: left; color: var(--muted); font-size: var(--fs-sm);
  background: linear-gradient(180deg, #f1ebdf 0%, #ebe3d3 100%); border-top: 1px solid var(--line);
}
.site-footer::before {
  content: ""; display: block; height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, #4f9a87 55%, var(--accent) 100%);
}
.site-footer p { margin: 0; }
.footer-inner {
  max-width: 1600px; margin: 0 auto; padding: 32px clamp(16px, 3vw, 40px) 26px;
  display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 2.2fr) auto; gap: 24px 40px; align-items: start;
}
.footer-brand { display: flex; gap: 14px; align-items: center; }
.footer-brand img { flex: none; border-radius: 12px; box-shadow: 0 4px 12px rgba(47, 111, 98, .18); }
.footer-brand strong { display: block; color: var(--ink); font-size: var(--fs-md); letter-spacing: .02em; }
.footer-brand span { display: block; margin-top: 2px; line-height: 1.5; }
.footer-points { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 22px; }
.footer-points li { display: flex; gap: 10px; align-items: flex-start; }
.fp-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: rgba(255, 255, 255, .75); border: 1px solid var(--line); font-size: 1.15rem; }
.footer-points strong { display: block; color: var(--ink); font-size: var(--fs-sm); }
.footer-points small { display: block; font-size: var(--fs-sm); line-height: 1.55; }
.footer-links { display: flex; flex-direction: column; gap: 4px; }
.footer-link {
  border: 0; background: none; text-align: left; color: var(--primary); font-weight: 700;
  font-size: var(--fs-sm); padding: 5px 0; cursor: pointer; white-space: nowrap;
}
.footer-link:hover { color: var(--accent); }
.footer-link:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; border-radius: 6px; }
.footer-bottom {
  max-width: 1600px; margin: 0 auto; padding: 14px clamp(16px, 3vw, 40px) 24px;
  border-top: 1px solid rgba(60, 40, 10, .08);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
}
.footer-school { color: var(--muted); }
.site-footer .version-tag {
  font-size: var(--fs-xs); opacity: 1; letter-spacing: .03em; color: var(--muted);
  background: rgba(255, 255, 255, .7); border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px;
}
@media (max-width: 1080px) {
  .footer-inner { grid-template-columns: 1fr auto; }
  .footer-points { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) {
  .footer-inner { grid-template-columns: 1fr; gap: 20px; padding-top: 26px; }
  .footer-points { grid-template-columns: 1fr; grid-row: auto; }
  .footer-links { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .footer-link { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .footer-school { display: block; margin-top: 2px; }
  .footer-dot { display: none; }

  /* 紀錄本篩選：日期欄各占一整列，「清除篩選」不換行 */
  .history-filters .date-range { grid-column: 1 / -1; }
}
.date-range input { flex: 1; width: 100%; }
.history-summary-row .link-btn { flex: none; white-space: nowrap; }

/* ===== 登錄前自動品質檢查 ===== */
.qc-panel { margin: -4px 0 14px; padding: 10px 14px; border-radius: 12px; background: #eaf6ef; border: 1px solid #b9e0c8; }
.qc-panel.has-issues { background: #fff8e6; border-color: #f0cf8a; }
.qc-title { margin: 0; font-weight: 700; color: #1f6b43; }
.qc-panel.has-issues .qc-title { color: #7a4a14; }
.qc-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.qc-list:empty { display: none; }
.qc-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: var(--fs-sm); padding: 6px 10px; border-radius: 8px; background: rgba(255, 255, 255, .7); }
.qc-list li small { color: var(--muted); margin-left: 4px; }
.qc-list li .btn { flex: none; }
.qc-label { border-left: 4px solid var(--danger); }
.qc-detail { border-left: 4px solid var(--accent); }
.qc-note, .qc-length { border-left: 4px solid #8a6d3b; }
.qc-mini { margin-top: 8px; padding: 6px 10px; border-radius: 8px; font-size: var(--fs-sm); background: #eaf6ef; color: #1f6b43; }
.qc-mini.has-issues { background: #fff8e6; color: #7a4a14; }
@media (max-width: 640px) {
  .qc-list li { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 360px) { .brand img { display: none; } }

/* ===== 逐步引導（步驟條、步驟標題、下一步按鈕、提示閃光） ===== */
.stepper {
  position: sticky; top: var(--topbar-h); z-index: 6;
  display: flex; gap: 2px; margin: 0 0 14px; padding: 10px 2px 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.stepper button {
  position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 0; background: none; cursor: pointer; color: var(--muted); font-size: var(--fs-xs); padding: 0;
}
.stepper button:not(:last-child)::after {
  content: ""; position: absolute; top: 15px; left: calc(50% + 19px); right: calc(-50% + 19px); height: 2px; background: var(--line);
}
.stepper button.done:not(:last-child)::after { background: var(--primary); }
.stepper .dot {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: #fff; border: 2px solid var(--line); color: var(--muted); transition: background .2s, border-color .2s, color .2s;
}
.stepper button.done .dot { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.stepper button.current { color: var(--ink); font-weight: 700; }
.stepper button.current .dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(47, 111, 98, .16); }
.stepper button:focus-visible .dot { outline: 3px solid var(--accent); outline-offset: 2px; }

.step-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 26px 0 12px; padding-top: 18px;
  border-top: 1px dashed var(--line); font-size: var(--fs-md); font-weight: 800; color: var(--primary);
  scroll-margin-top: calc(var(--topbar-h) + var(--stepper-h) + 10px);
}
.step-head.first { margin-top: 4px; padding-top: 0; border-top: 0; }
.step-head small { font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.step-no { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; font-size: var(--fs-sm); }
.next-step {
  display: flex; margin: 2px 0 6px auto; padding: 9px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: var(--fs-sm);
}
.next-step:hover { background: var(--primary); color: #fff; }

/* 自動捲動的落點要扣掉黏在上方的頁首與步驟條 */
#viewSingle .field, #viewSingle fieldset, #viewSingle .opt-row, #viewSingle .actions, #viewSingle .paste-back {
  scroll-margin-top: calc(var(--topbar-h) + var(--stepper-h) + 16px);
}
#outputCard, .seat-card, .seat-editor, .batch-results { scroll-margin-top: calc(var(--topbar-h) + 16px); }

.guide-flash { animation: guideFlash 1.6s ease-out; border-radius: 12px; }
@keyframes guideFlash { 0%, 35% { box-shadow: 0 0 0 4px rgba(217, 130, 43, .45); } 100% { box-shadow: 0 0 0 0 rgba(217, 130, 43, 0); } }
.pulse-cta { animation: ctaPulse .9s ease-out 2; }
@keyframes ctaPulse { 50% { box-shadow: 0 0 0 10px rgba(47, 111, 98, .22); transform: scale(1.02); } }
@media (prefers-reduced-motion: reduce) {
  .guide-flash, .pulse-cta { animation: none; outline: 3px solid var(--accent); }
}
@media (max-width: 640px) {
  .stepper { margin: 0 -4px 12px; }
  .stepper .dot { width: 28px; height: 28px; }
  .stepper button:not(:last-child)::after { top: 13px; left: calc(50% + 17px); right: calc(-50% + 17px); }
  .next-step { width: 100%; justify-content: center; }
}

/* ===== 右下角「給建議」按鈕（可愛對話框臉） ===== */
.feedback-fab {
  position: fixed; z-index: 40;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--fab-lift, 0px));
  display: flex; align-items: center; gap: 8px; padding: 8px 18px 8px 8px; border-radius: 999px;
  background: linear-gradient(135deg, #f7b468 0%, #e47b30 100%); color: #fff; text-decoration: none; font-weight: 800;
  box-shadow: 0 12px 26px -10px rgba(186, 90, 20, .65), 0 2px 6px rgba(0, 0, 0, .12);
  transition: transform .2s ease, box-shadow .2s ease, bottom .25s ease;
  animation: fabIn .7s cubic-bezier(.34, 1.56, .64, 1) .9s both;
}
.feedback-fab::before {
  content: ""; position: absolute; top: 2px; left: 34px; width: 11px; height: 11px; border-radius: 50%;
  background: #ff5a7a; border: 2px solid #fff; animation: fabDot 2.4s ease-in-out infinite;
}
.feedback-fab:hover { transform: translateY(-3px) rotate(-2deg); box-shadow: 0 16px 30px -10px rgba(186, 90, 20, .75), 0 2px 6px rgba(0, 0, 0, .12); }
.feedback-fab:hover .fab-icon { animation: fabWiggle .6s ease-in-out; }
.feedback-fab:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.fab-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, .24); }
.fab-text { font-size: var(--fs-sm); letter-spacing: .06em; text-shadow: 0 1px 1px rgba(120, 50, 0, .25); }
.fab-tip {
  position: absolute; right: 0; bottom: calc(100% + 10px); white-space: nowrap;
  background: var(--ink); color: #fff; font-weight: 600; font-size: var(--fs-xs); padding: 6px 12px; border-radius: 10px;
  opacity: 0; transform: translateY(6px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.fab-tip::after { content: ""; position: absolute; right: 26px; top: 100%; border: 6px solid transparent; border-top-color: var(--ink); }
.feedback-fab:hover .fab-tip, .feedback-fab:focus-visible .fab-tip { opacity: 1; transform: none; }
@keyframes fabIn { from { opacity: 0; transform: translateY(30px) scale(.6); } to { opacity: 1; transform: none; } }
@keyframes fabWiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@keyframes fabDot { 50% { transform: scale(1.25); } }
@media (max-width: 640px) {
  .feedback-fab { padding: 6px 14px 6px 6px; gap: 6px; }
  .feedback-fab::before { left: 30px; }
  .fab-icon { width: 36px; height: 36px; }
  .fab-tip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .feedback-fab, .feedback-fab::before, .feedback-fab:hover .fab-icon { animation: none; }
}
@media print { .feedback-fab { display: none !important; } }
/* 頁尾留出空間，避免最後一行被按鈕蓋住 */
.footer-bottom { padding-bottom: 84px; }

a.footer-link { text-decoration: none; display: inline-flex; align-items: center; }

.name-hint { margin: -2px 0 0; font-size: var(--fs-sm); color: var(--muted); }

/* ===== 草稿日期提示 ===== */
.date-note {
  display: block; margin-top: 6px; padding: 4px 10px; border-radius: 8px;
  background: #fff4e5; color: #7a4a14; font-size: var(--fs-sm); line-height: 1.6;
}
.date-note .link-btn { color: #7a4a14; font-weight: 700; padding: 0; }

/* ===== 寬螢幕：結果卡片黏在畫面上，左邊往下填也看得到 ===== */
@media (min-width: 1081px) {
  #outputCard {
    position: sticky; top: calc(var(--topbar-h) + 16px);
    max-height: calc(100vh - var(--topbar-h) - 32px);
    overflow-y: auto; overscroll-behavior: contain;
  }
  /* 左欄捲到底（產生按鈕附近）時，右欄要有空間讓結果卡片繼續完整顯示，不被推上去 */
  #viewSingle { padding-bottom: min(42vh, 380px); }
}

/* ===== 先看範例、精簡按鈕、批次停止 ===== */
.demo-note {
  margin: -4px 0 14px; padding: 10px 14px; border-radius: 12px; font-size: var(--fs-sm);
  background: #eef5fb; border: 1px solid #c9dcee; color: #234a6b;
}
.demo-note .link-btn { color: #234a6b; font-weight: 700; }
.qc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.qc-list li .btn.primary, .qc-actions .btn.primary { color: #fff; }

/* ===== 沒有網路的提示 ===== */
.offline-banner {
  max-width: 1600px; margin: 12px auto 0; padding: 10px clamp(16px, 3vw, 40px);
  background: #fdecea; border-top: 1px solid #f0c4bc; border-bottom: 1px solid #f0c4bc;
  color: #8a2f1f; font-size: var(--fs-sm);
}
.offline-banner.flash { animation: cardFlash 1.4s ease-out; }
@media (prefers-reduced-motion: reduce) { .offline-banner.flash { animation: none; } }

/* ===== 紀錄本分頁、學期統計 ===== */
.hist-tabs { display: flex; gap: 6px; margin: 14px 0 12px; border-bottom: 2px solid var(--line); }
.hist-tab {
  border: 0; background: none; padding: 10px 16px; font: inherit; font-weight: 700; font-size: var(--fs-base);
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; border-radius: 10px 10px 0 0;
}
.hist-tab:hover { color: var(--primary); }
.hist-tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-soft); }
.hist-tab:focus-visible { outline: 3px solid rgba(47, 111, 98, .35); outline-offset: 2px; }
.stats-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; justify-content: space-between; }
.stats-period { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; flex: 1 1 260px; max-width: 420px; }
#statsRange { margin: 10px 0 12px; color: var(--primary); font-weight: 600; }
.stats-foot { margin-top: 12px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat-tile { background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat-tile .n { display: block; font-size: clamp(1.7rem, 2.4vw, 2.2rem); font-weight: 800; line-height: 1.15; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-tile .n small { margin-left: 3px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.stat-tile .l { font-size: var(--fs-sm); color: var(--muted); }
.stat-tile.warn { background: #fff4e5; border-color: #f1d2a8; }
.stat-tile.warn .l { color: #7a4a14; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.stat-card { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--field); }
.stat-card.wide { grid-column: 1 / -1; }
.stat-card h3 { margin: 0 0 10px; font-size: var(--fs-base); color: var(--primary); }
.stat-note { margin: 8px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.bar-list li { display: grid; grid-template-columns: minmax(5.5em, 8.5em) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: var(--fs-sm); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.bar-track { height: 12px; border-radius: 4px; background: #f1ebe0; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--primary); }
.bar-num { min-width: 4.6em; text-align: right; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar-num small { margin-left: 5px; font-weight: 500; color: var(--muted); }
.stat-student {
  border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--ink); cursor: pointer;
  border-bottom: 1px dotted currentColor; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat-student:hover { color: var(--primary); }
.month-chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(36px, 1fr); gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.month-col { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: var(--fs-xs); }
.month-num { min-height: 1.3em; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.month-plot { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; width: 100%; height: 128px; border-bottom: 1px solid var(--line); }
.month-bar { width: min(70%, 30px); border-radius: 4px 4px 0 0; background: var(--primary); }
.month-lbl { color: var(--muted); white-space: nowrap; }
@media (max-width: 640px) {
  .hist-tab { flex: 1 1 0; padding: 10px 8px; }
  .stats-head .btn { width: 100%; }
  .stats-period { max-width: none; }
  .bar-list li { grid-template-columns: minmax(4.5em, 6.5em) minmax(0, 1fr) auto; gap: 8px; }
}
