/* ===== 設計變數 ===== */
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --border: #dfe5e2;
  --border-strong: #c5cfca;
  --text: #1d2723;
  --text-2: #55635d;
  --text-3: #85928c;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #e3f2ef;
  --ok: #15803d;
  --ok-soft: #e4f5e8;
  --warn: #b45309;
  --warn-soft: #fdf1de;
  --bad: #b91c1c;
  --bad-soft: #fbe7e7;
  --na: #64748b;
  --na-soft: #edf0f4;
  --focus: #2563eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 4px 16px rgba(16, 24, 20, .05);
  --header-h: 56px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111614; --surface: #19201d; --surface-2: #1e2622; --border: #2b3531; --border-strong: #3a4641;
    --text: #e6ece9; --text-2: #a9b6b0; --text-3: #7c8a84;
    --primary: #2dd4bf; --primary-ink: #062a26; --primary-soft: #133430;
    --ok: #4ade80; --ok-soft: #15301f; --warn: #fbbf24; --warn-soft: #3a2c0f; --bad: #f87171; --bad-soft: #3b1a1a;
    --na: #94a3b8; --na-soft: #252c33; --focus: #60a5fa;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111614; --surface: #19201d; --surface-2: #1e2622; --border: #2b3531; --border-strong: #3a4641;
  --text: #e6ece9; --text-2: #a9b6b0; --text-3: #7c8a84;
  --primary: #2dd4bf; --primary-ink: #062a26; --primary-soft: #133430;
  --ok: #4ade80; --ok-soft: #15301f; --warn: #fbbf24; --warn-soft: #3a2c0f; --bad: #f87171; --bad-soft: #3b1a1a;
  --na: #94a3b8; --na-soft: #252c33; --focus: #60a5fa;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

/* ===== 基本 ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, h4 { line-height: 1.35; margin: 0; font-weight: 700; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.num { font-variant-numeric: tabular-nums; }

/* ===== 按鈕與表單 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 34px; padding: 0 10px; font-size: 14px; }
.btn.block { width: 100%; }
.icon-btn { width: 44px; height: 44px; padding: 0; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 16px;
}
textarea.input { min-height: 88px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; margin-right: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ===== 頂部列 ===== */
.topbar {
  position: sticky; top: 0; z-index: 40; height: calc(var(--header-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; gap: 12px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar .brand img { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.topbar .brand > div { flex: 1; }
.topbar .brand b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand small { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.save-state.err { color: var(--bad); }
.save-state.ok { color: var(--ok); }

/* ===== 版面 ===== */
.wrap { max-width: 1120px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.page-title { font-size: 22px; margin: 4px 0 4px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 10px; flex-wrap: wrap; }
.section-head h2 { font-size: 18px; }

/* ===== 登入 ===== */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; padding: 28px 24px; }
.login-card .logo { width: 56px; height: 56px; border-radius: 14px; display: block; margin-bottom: 16px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { margin: 0 0 22px; color: var(--text-2); font-size: 14px; }
.form-error { color: var(--bad); font-size: 14px; min-height: 22px; margin: 4px 0 10px; }

/* ===== 徽章 ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.badge.complete, .badge.submitted { background: var(--ok-soft); color: var(--ok); }
.badge.partial, .badge.draft { background: var(--warn-soft); color: var(--warn); }
.badge.incomplete { background: var(--bad-soft); color: var(--bad); }
.badge.na, .badge.pending, .badge.none { background: var(--na-soft); color: var(--na); }
.badge.must { background: var(--bad-soft); color: var(--bad); }
.badge.cat { background: var(--primary-soft); color: var(--primary); }

/* ===== 評核清單 ===== */
.sub-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.sub-item { padding: 16px; display: grid; gap: 10px; cursor: pointer; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.sub-item:hover { border-color: var(--primary); }
.sub-item h3 { font-size: 17px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s; }
.empty { padding: 36px 16px; text-align: center; color: var(--text-2); }

/* ===== 評分頁 三欄 ===== */
.sheet { display: grid; grid-template-columns: 250px minmax(0, 1fr) 300px; gap: 20px; max-width: 1440px; margin: 0 auto; padding: 20px 16px 120px; align-items: start; }
.toc, .summary { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100dvh - var(--header-h) - 32px); overflow: auto; }
.toc { padding: 12px 8px; }
.toc h4 { font-size: 13px; color: var(--text-3); padding: 10px 10px 4px; font-weight: 600; }
.toc a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.toc a:hover { background: var(--surface-2); }
.toc a .code { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; min-width: 38px; }
.toc a .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); flex: none; }
.dot.complete { background: var(--ok); } .dot.partial { background: var(--warn); } .dot.incomplete { background: var(--bad); } .dot.progress { background: var(--primary); opacity: .5; }

.sheet-head { padding: 18px; margin-bottom: 16px; }
.sheet-head h1 { font-size: 21px; }
.sheet-head .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 14px; color: var(--text-2); }
.locked-banner { margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); font-weight: 600; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.locked-banner.view { background: var(--na-soft); color: var(--text-2); }

.std-head { margin: 28px 0 12px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.std-head h2 { font-size: 20px; }
.std-head .en { font-size: 13px; color: var(--text-3); }
.sec-title { font-size: 15px; color: var(--text-2); margin: 18px 0 8px; padding-left: 10px; border-left: 3px solid var(--primary); }

.crit { margin-bottom: 16px; overflow: hidden; scroll-margin-top: calc(var(--header-h) + 12px); }
.crit-head { padding: 16px 18px 12px; display: grid; gap: 8px; }
.crit-head .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crit-code { font-weight: 700; font-size: 15px; color: var(--primary); font-variant-numeric: tabular-nums; }
.crit-title { font-size: 17px; font-weight: 600; }
.rule { font-size: 13.5px; color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 6px 10px; }
.items { border-top: 1px solid var(--border); }
.item { padding: 14px 18px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.item .itext { display: flex; gap: 10px; }
.item .itext .n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--text-2); margin-top: 1px; }
.item.rated-complete .itext .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.item.rated-partial .itext .n { background: var(--warn); border-color: var(--warn); color: #fff; }
.item.rated-incomplete .itext .n { background: var(--bad); border-color: var(--bad); color: #fff; }
.item.rated-na .itext .n { background: var(--na); border-color: var(--na); color: #fff; }

/* 評分按鈕（分段選擇） */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; max-width: 520px; }
.seg button {
  min-height: 44px; border-radius: 10px; border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer;
  font-weight: 600; font-size: 15px; color: var(--text-2); padding: 0 6px; transition: all .12s;
}
.seg button:hover:not(:disabled) { border-color: var(--text-3); }
.seg button[aria-pressed="true"].complete { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg button[aria-pressed="true"].partial { background: var(--warn); border-color: var(--warn); color: #fff; }
.seg button[aria-pressed="true"].incomplete { background: var(--bad); border-color: var(--bad); color: #fff; }
.seg button[aria-pressed="true"].na { background: var(--na); border-color: var(--na); color: #fff; }
.seg button[aria-pressed="true"].auto { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.seg button:disabled { cursor: default; }
.seg button:disabled:not([aria-pressed="true"]) { opacity: .45; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .seg button[aria-pressed="true"]:not(.auto) { color: #0b0f0d; }
}
:root[data-theme="dark"] .seg button[aria-pressed="true"]:not(.auto) { color: #0b0f0d; }

details.defs { font-size: 14px; }
details.defs summary { cursor: pointer; color: var(--primary); font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
details.defs summary::-webkit-details-marker { display: none; }
details.defs summary::before { content: "▸"; transition: transform .15s; display: inline-block; }
details.defs[open] summary::before { transform: rotate(90deg); }
.def-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.def-grid > div { padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); white-space: pre-line; }
.def-grid > div b { display: block; font-size: 13px; margin-bottom: 2px; }
.def-grid .d-complete b { color: var(--ok); } .def-grid .d-partial b { color: var(--warn); } .def-grid .d-incomplete b { color: var(--bad); }
.note { margin: 0 18px 12px; font-size: 13.5px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; white-space: pre-line; }

.result { padding: 14px 18px 18px; background: var(--surface-2); display: grid; gap: 12px; }
.result .line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.result .label { font-weight: 700; font-size: 14px; color: var(--text-2); min-width: 72px; }
.result .auto-result { font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.result .big { font-size: 15px; padding: 4px 12px; }
.warn-text { color: var(--bad); font-size: 13.5px; font-weight: 600; }
.std-sub { padding: 12px 18px; margin: 4px 0 8px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; font-size: 14px; }
.std-sub b { font-size: 15px; }

/* 綜合意見 */
.general { padding: 18px; display: grid; gap: 16px; }
.general .q > div:first-child { font-weight: 600; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 600; color: var(--text-2); }
.chips button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

/* 分數摘要 */
.summary { padding: 16px; }
.summary h3 { font-size: 15px; margin-bottom: 10px; }
.score-big { display: flex; align-items: baseline; gap: 6px; }
.score-big b { font-size: 38px; line-height: 1; color: var(--primary); font-variant-numeric: tabular-nums; }
.score-big span { color: var(--text-2); }
.count-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; text-align: center; }
.count-row > div { border-radius: 8px; padding: 6px 4px; font-size: 12px; font-weight: 600; }
.count-row b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.count-row .c1 { background: var(--ok-soft); color: var(--ok); } .count-row .c2 { background: var(--warn-soft); color: var(--warn); } .count-row .c3 { background: var(--bad-soft); color: var(--bad); }
table.mini { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.mini th, table.mini td { padding: 6px 4px; border-bottom: 1px solid var(--border); text-align: center; font-variant-numeric: tabular-nums; }
table.mini th:first-child, table.mini td:first-child { text-align: left; }
table.mini tfoot td { font-weight: 700; border-bottom: 0; }

/* 手機下方分數列 */
.bottom-bar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); gap: 10px; align-items: center; box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.bottom-bar .bb-score { flex: 1; min-width: 0; display: flex; flex-direction: column; background: none; border: 0; text-align: left; padding: 0; cursor: pointer; }
.bottom-bar .bb-score b { font-size: 18px; font-variant-numeric: tabular-nums; }
.bottom-bar .bb-score span { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bottom-bar .btn { flex: none; }

/* 抽屜 / 對話框 */
.backdrop { position: fixed; inset: 0; background: rgba(10, 15, 13, .45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.backdrop.center { align-items: center; padding: 16px; }
.sheet-panel { background: var(--surface); width: 100%; max-width: 640px; max-height: 88dvh; overflow: auto; border-radius: 18px 18px 0 0; padding: 8px 18px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet-panel .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--border-strong); margin: 6px auto 12px; }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 90dvh; overflow: auto; border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .15s ease-out; }
.modal.wide { max-width: 880px; }
.modal h3 { font-size: 18px; margin-bottom: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1d2723; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 80; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); animation: fade .15s; }
.toast.err { background: #b91c1c; }
.offline-pill { background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }

/* ===== 後台 ===== */
.admin-nav { position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top)); z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav a { padding: 12px 14px; text-decoration: none; color: var(--text-2); font-weight: 600; white-space: nowrap; border-bottom: 2.5px solid transparent; font-size: 15px; }
.admin-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { padding: 16px; }
.stat b { display: block; font-size: 28px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--text-2); font-size: 14px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { font-size: 13px; color: var(--text-2); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--surface-2); }
table.data td.c, table.data th.c { text-align: center; }
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button { min-height: 36px; padding: 0 14px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; font-weight: 600; color: var(--text-2); }
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* 條文編輯器 */
.ed-std { margin-bottom: 16px; }
.ed-std > summary, .ed-crit > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 16px; flex-wrap: wrap; }
.ed-std > summary::-webkit-details-marker, .ed-crit > summary::-webkit-details-marker { display: none; }
.ed-std > summary h3 { font-size: 17px; flex: 1; min-width: 200px; }
.ed-body { padding: 0 16px 16px; display: grid; gap: 12px; }
.ed-crit { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.ed-crit > summary { padding: 12px 14px; }
.ed-crit > summary .t { flex: 1; min-width: 180px; font-weight: 600; }
.ed-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); display: grid; gap: 10px; }
.ed-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.ed-grid .field { margin: 0; }
.ed-toolbar { position: sticky; top: calc(var(--header-h) + 50px); z-index: 20; background: var(--bg); padding: 10px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dirty-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); display: inline-block; }
.report-table td, .report-table th { text-align: center; }
.report-table td:first-child, .report-table th:first-child { text-align: left; }
.comment-cell { font-size: 13.5px; color: var(--text-2); white-space: pre-line; min-width: 220px; }

/* ===== 斷點：平板 ===== */
@media (max-width: 1180px) {
  .sheet { grid-template-columns: minmax(0, 1fr) 280px; }
  .toc { display: none; }
}
/* ===== 斷點：手機 / 直式平板 ===== */
@media (max-width: 860px) {
  .sheet { grid-template-columns: minmax(0, 1fr); padding: 12px 12px 110px; gap: 0; }
  .summary { display: none; }
  .bottom-bar { display: flex; }
  .def-grid { grid-template-columns: 1fr; }
  .crit-head, .item, .result { padding-left: 14px; padding-right: 14px; }
  .note { margin: 0 14px 12px; }
  .result .line > .seg { flex: 1 1 100% !important; }
  .result .line { gap: 6px; }
  .sheet-head { padding: 16px; }
  .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }
}
@media (max-width: 520px) {
  body { font-size: 15.5px; }
  .seg { max-width: none; }
  .seg button { font-size: 14px; }
  .topbar .hide-sm { display: none; }
  .crit-title { font-size: 16px; }
  .modal { padding: 18px; }
  .sub-list { grid-template-columns: 1fr; }
  table.data.stack thead { display: none; }
  table.data.stack tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  table.data.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 12px; }
  table.data.stack td::before { content: attr(data-label); color: var(--text-3); font-size: 13px; flex: none; }
}

/* ===== 列印：對應紙本評核紀錄 ===== */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --shadow: none; }
  body { font-size: 11pt; background: #fff; }
  .topbar, .toc, .summary, .bottom-bar, .no-print, .admin-nav, .ed-toolbar, .toast, details.defs summary { display: none !important; }
  .sheet { display: block; padding: 0; }
  .card { box-shadow: none; border-color: #999; }
  .crit { break-inside: avoid; }
  .seg button:not([aria-pressed="true"]) { display: none; }
  .seg { display: block; }
  .seg button { min-height: 0; padding: 2px 10px; border: 1px solid #333 !important; background: #fff !important; color: #000 !important; }
  .print-only { display: block !important; }
  a { color: #000; text-decoration: none; }
}
.print-only { display: none; }
