/* LAM 介面：實驗室取向的簡潔排版（保留既有色票，縮小圓角、強化字階） */
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/IBMPlexSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/IBMPlexSans-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/IBMPlexMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/IBMPlexMono-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f3efe6;
  --ink: #1c2a24;
  --text: var(--ink);
  --muted: #5c6b63;
  --panel: #fffdf8;
  --line: #d5cbb8;
  --line-strong: #b8ad96;
  --border: #c5cdd6;
  --accent: #1f6f5b;
  --accent-hover: #165445;
  --danger: #8b2e2e;
  --pill: #e7f1ed;
  --head: #f7f3ea;
  --surface: #ffffff;
  --surface-2: #f4efe6;
  --surface-muted: #faf8f3;
  --input-bg: #ffffff;
  --on-accent: #ffffff;
  --ok: #1f6b4a;
  --ok-bg: #e7f5ee;
  --ok-line: #c5e0d2;
  --error-bg: #f8e8e8;
  --error-line: #e8c8c8;
  --warn: #5c4a12;
  --warn-bg: #fff8e6;
  --warn-line: #d4b56a;
  --highlight: #c4a57a;
  --focus-ring: color-mix(in srgb, var(--accent) 25%, transparent);
  --focus-ring-strong: color-mix(in srgb, var(--accent) 35%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 8%, transparent);
  --accent-soft-2: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-soft-3: color-mix(in srgb, var(--accent) 20%, transparent);
  --accent-glow: color-mix(in srgb, var(--accent) 12%, transparent);
  --sir-s: #0b6b3a;
  --sir-i: #9a6b00;
  --sir-r: #a32020;
  --overlay: color-mix(in srgb, var(--ink) 40%, transparent);
  --shadow: color-mix(in srgb, var(--ink) 12%, transparent);
  --shadow-lg: color-mix(in srgb, var(--ink) 18%, transparent);
  --row-hover: color-mix(in srgb, var(--accent) 4%, transparent);
  --ghost-hover: color-mix(in srgb, var(--ink) 4%, transparent);
  --mark-return-bg: #f8e0e0;
  --mark-flag: #5c4a12;
  --mark-flag-bg: #fff3cc;
  --pill-progress-ok: #dcefe4;
  --pill-need-redo: #f8e0e0;
  --pill-ready-archive: #d9eaf8;
  --pill-note: #eceff3;
  --row-warn-bg: #fff6e8;
  --reopen-bg: #e4eef5;
  --reopen-line: #9bb8cc;
  --notice-bg: #f5e6c8;
  --notice-line: #e2d0a8;
  --status-returned-line: #e0a39a;
  --status-closed-line: #e0c98a;
  --photo-letterbox: #e2ebe6;
  --combo-muted: #8a968f;
  --combo-disabled-ink: #b0b8b5;
  --combo-placeholder-ink: #8a9390;
  --seat-a: #1f6f8f;
  --seat-a-bg: #eef6fa;
  --seat-a-ink: #163a4a;
  --seat-b: #8a5a1f;
  --wl-current-bg: #fff6d8;
  --wl-current-line: #b8860b;
  --wl-done-bg: #d9efe4;
  --wl-done-line: #1f6f5b;
  --wl-done-ink: #0b4f38;
  --wl-idle-bg: #ecece8;
  --wl-peer-bg: #f3f3f1;
  --wl-fail-bg: #fde2e0;
  --wl-fail-line: #aa3333;
  --wl-fail-ink: #7a1f1a;
  --wl-card-bg: #f6f3ec;
  --wl-card-focus-bg: #eef6f2;
  --wl-chip-line: #9a9a92;
  --wl-chip-ink: #333333;
  --wl-pos-line: #3a8f6b;
  --wl-pos-ink: #0b4f38;
  --wl-pos-fill: #1f6f5b;
  --wl-pos-fill-line: #145244;
  --wl-neg-line: #c45c52;
  --wl-neg-ink: #7a1f1a;
  --wl-neg-fill: #b33a32;
  --wl-neg-fill-line: #8a241e;
  --wl-clear-line: #8a8a82;
  --wl-clear-ink: #555555;
  --wl-clear-fill: #5a5a54;
  --wl-clear-fill-line: #3f3f3a;
  --wl-pending-ring: #c9a227;
  --role-admin: #e8f1ee;
  --role-teacher: #eef0f7;
  --role-staff: #f3f1ea;
  --iso-dim: #eceff3;
  --iso-ok-bg: #e8f1ee;
  --radius: 2px;
  --radius-sm: 1px;
  --font: "IBM Plex Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "IBM Plex Mono", "Noto Sans Mono", ui-monospace, monospace;
  --fs: 0.9375rem;
  --fs-sm: 0.8125rem;
  --fs-xs: 0.75rem;
  --fs-display: 1.7rem;
  --lh: 1.45;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --status-draft: #eceff3;
  --status-testing: #d9eaf8;
  --status-pending: #f5e6c8;
  --status-archived: #e2ebe6;
  --status-returned: #f8d9d6;
  --status-closed-banner: #f5e6c8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --touch-min: 2.75rem;
}

/* 深色莫蘭迪：色相走霧藍紫，明度改為深炭底／霧灰字；銅金只當高光 */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191a1f;
  --ink: #e2e5ea;
  --text: var(--ink);
  --muted: #aeb2be;
  --panel: #23242b;
  --line: #42434e;
  --line-strong: #5a5c6a;
  --border: #4a4c58;
  --accent: #8fbfa8;
  --accent-hover: #a8d0bc;
  --danger: #c17b76;
  --pill: #2a2d38;
  --head: #2c2d36;
  --surface: #1e1f25;
  --surface-2: #2c2d34;
  --surface-muted: #262730;
  --input-bg: #1e1f25;
  --on-accent: #14161a;
  --ok: #7a9a88;
  --ok-bg: #24332c;
  --ok-line: #3d5a4c;
  --error-bg: #3a2c2c;
  --error-line: #6a4542;
  --warn: #d4c4a0;
  --warn-bg: #3a3428;
  --warn-line: #6a5a3a;
  --highlight: #c4a57a;
  --focus-ring: color-mix(in srgb, var(--highlight) 40%, transparent);
  --focus-ring-strong: color-mix(in srgb, var(--highlight) 50%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-soft-2: color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-soft-3: color-mix(in srgb, var(--accent) 26%, transparent);
  --accent-glow: color-mix(in srgb, var(--highlight) 14%, transparent);
  --sir-s: #8fb5a3;
  --sir-i: #c4a57a;
  --sir-r: #c17b76;
  --overlay: color-mix(in srgb, #050506 58%, transparent);
  --shadow: color-mix(in srgb, #000 28%, transparent);
  --shadow-lg: color-mix(in srgb, #000 40%, transparent);
  --row-hover: color-mix(in srgb, var(--highlight) 8%, transparent);
  --ghost-hover: color-mix(in srgb, var(--ink) 6%, transparent);
  --mark-return-bg: #3d2c2c;
  --mark-flag: #d4c4a0;
  --mark-flag-bg: #3a3428;
  --pill-progress-ok: #2a3532;
  --pill-need-redo: #3d2c2c;
  --pill-ready-archive: #2a3848;
  --pill-note: #2e3138;
  --row-warn-bg: #3a3428;
  --reopen-bg: #2a3848;
  --reopen-line: #5a7388;
  --notice-bg: #3a3428;
  --notice-line: #6a5a3a;
  --status-returned-line: #6a4542;
  --status-closed-line: #6a5a3a;
  --photo-letterbox: #2a3532;
  --combo-muted: #a4a8b4;
  --combo-disabled-ink: #7a7e8a;
  --combo-placeholder-ink: #9498a4;
  --seat-a: #7a9eb0;
  --seat-a-bg: #243038;
  --seat-a-ink: #b4c8d4;
  --seat-b: #b08a62;
  --wl-current-bg: #3a3428;
  --wl-current-line: #c4a57a;
  --wl-done-bg: #24332c;
  --wl-done-line: #7a9a88;
  --wl-done-ink: #b4c8bc;
  --wl-idle-bg: #2a2b33;
  --wl-peer-bg: #2c2d36;
  --wl-fail-bg: #3a2c2c;
  --wl-fail-line: #c17b76;
  --wl-fail-ink: #e0b4b0;
  --wl-card-bg: #23242b;
  --wl-card-focus-bg: #2a3532;
  --wl-chip-line: #5a5c6a;
  --wl-chip-ink: #e2e5ea;
  --wl-pos-line: #7a9a88;
  --wl-pos-ink: #b4c8bc;
  --wl-pos-fill: #7a9a88;
  --wl-pos-fill-line: #5a7a6a;
  --wl-neg-line: #c17b76;
  --wl-neg-ink: #e0b4b0;
  --wl-neg-fill: #c17b76;
  --wl-neg-fill-line: #8a5550;
  --wl-clear-line: #6a6e7a;
  --wl-clear-ink: #b4b8c2;
  --wl-clear-fill: #5a5c6a;
  --wl-clear-fill-line: #42434e;
  --wl-pending-ring: #c4a57a;
  --role-admin: #24332c;
  --role-teacher: #2a2d38;
  --role-staff: #2c2d36;
  --iso-dim: #2e3138;
  --iso-ok-bg: #24332c;
  --status-draft: #2e3138;
  --status-testing: #2a3848;
  --status-pending: #3a3428;
  --status-archived: #2a3532;
  --status-returned: #3d2c2c;
  --status-closed-banner: #3a3428;
}

@media print {
  html[data-theme="dark"] {
    color-scheme: light;
    --bg: #f3efe6;
    --ink: #1c2a24;
    --text: var(--ink);
    --muted: #5c6b63;
    --panel: #fffdf8;
    --line: #d5cbb8;
    --line-strong: #b8ad96;
    --border: #c5cdd6;
    --accent: #1f6f5b;
    --accent-hover: #165445;
    --danger: #8b2e2e;
    --pill: #e7f1ed;
    --head: #f7f3ea;
    --surface: #ffffff;
    --surface-2: #f4efe6;
    --surface-muted: #faf8f3;
    --input-bg: #ffffff;
    --on-accent: #ffffff;
    --ok: #1f6b4a;
    --ok-bg: #e7f5ee;
    --ok-line: #c5e0d2;
    --error-bg: #f8e8e8;
    --error-line: #e8c8c8;
    --warn: #5c4a12;
    --warn-bg: #fff8e6;
    --warn-line: #d4b56a;
    --highlight: #c4a57a;
    --focus-ring: color-mix(in srgb, var(--accent) 25%, transparent);
    --focus-ring-strong: color-mix(in srgb, var(--accent) 35%, transparent);
    --accent-soft: color-mix(in srgb, var(--accent) 8%, transparent);
    --accent-soft-2: color-mix(in srgb, var(--accent) 14%, transparent);
    --accent-soft-3: color-mix(in srgb, var(--accent) 20%, transparent);
    --accent-glow: color-mix(in srgb, var(--accent) 12%, transparent);
    --sir-s: #0b6b3a;
    --sir-i: #9a6b00;
    --sir-r: #a32020;
    --overlay: color-mix(in srgb, var(--ink) 40%, transparent);
    --shadow: color-mix(in srgb, var(--ink) 12%, transparent);
    --shadow-lg: color-mix(in srgb, var(--ink) 18%, transparent);
    --row-hover: color-mix(in srgb, var(--accent) 4%, transparent);
    --ghost-hover: color-mix(in srgb, var(--ink) 4%, transparent);
    --mark-return-bg: #f8e0e0;
    --mark-flag: #5c4a12;
    --mark-flag-bg: #fff3cc;
    --pill-progress-ok: #dcefe4;
    --pill-need-redo: #f8e0e0;
    --pill-ready-archive: #d9eaf8;
    --pill-note: #eceff3;
    --row-warn-bg: #fff6e8;
    --reopen-bg: #e4eef5;
    --reopen-line: #9bb8cc;
    --notice-bg: #f5e6c8;
    --notice-line: #e2d0a8;
    --status-returned-line: #e0a39a;
    --status-closed-line: #e0c98a;
    --photo-letterbox: #e2ebe6;
    --combo-muted: #8a968f;
    --combo-disabled-ink: #b0b8b5;
    --combo-placeholder-ink: #8a9390;
    --seat-a: #1f6f8f;
    --seat-a-bg: #eef6fa;
    --seat-a-ink: #163a4a;
    --seat-b: #8a5a1f;
    --wl-current-bg: #fff6d8;
    --wl-current-line: #b8860b;
    --wl-done-bg: #d9efe4;
    --wl-done-line: #1f6f5b;
    --wl-done-ink: #0b4f38;
    --wl-idle-bg: #ecece8;
    --wl-peer-bg: #f3f3f1;
    --wl-fail-bg: #fde2e0;
    --wl-fail-line: #aa3333;
    --wl-fail-ink: #7a1f1a;
    --wl-card-bg: #f6f3ec;
    --wl-card-focus-bg: #eef6f2;
    --wl-chip-line: #9a9a92;
    --wl-chip-ink: #333333;
    --wl-pos-line: #3a8f6b;
    --wl-pos-ink: #0b4f38;
    --wl-pos-fill: #1f6f5b;
    --wl-pos-fill-line: #145244;
    --wl-neg-line: #c45c52;
    --wl-neg-ink: #7a1f1a;
    --wl-neg-fill: #b33a32;
    --wl-neg-fill-line: #8a241e;
    --wl-clear-line: #8a8a82;
    --wl-clear-ink: #555555;
    --wl-clear-fill: #5a5a54;
    --wl-clear-fill-line: #3f3f3a;
    --wl-pending-ring: #c9a227;
    --role-admin: #e8f1ee;
    --role-teacher: #eef0f7;
    --role-staff: #f3f1ea;
    --iso-dim: #eceff3;
    --iso-ok-bg: #e8f1ee;
    --status-draft: #eceff3;
    --status-testing: #d9eaf8;
    --status-pending: #f5e6c8;
    --status-archived: #e2ebe6;
    --status-returned: #f8d9d6;
    --status-closed-banner: #f5e6c8;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html.is-busy, html.is-busy body { cursor: progress; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--ink);
}
h1 { font-size: 1.55rem; margin: 0 0 0.35rem; }
h2 { font-size: 0.95rem; margin: 0 0 0.65rem; text-transform: none; }
h3 { font-size: 0.9rem; margin: 0 0 0.5rem; }

.lam-busy {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0.35rem 0.75rem 0.4rem;
  text-align: center;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: var(--on-accent);
  background: var(--accent);
  animation: lam-busy-in 0.12s ease-out;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}
.lam-busy-label {
  position: relative;
  z-index: 1;
  line-height: 1.35;
}
.lam-busy-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}
.lam-busy-fill {
  height: 100%;
  width: 30%;
  background: rgba(255, 255, 255, 0.92);
  transform-origin: left center;
}
.lam-busy.is-indeterminate .lam-busy-fill {
  width: 36%;
  animation: lam-busy-indeterminate 1.1s ease-in-out infinite;
}
.lam-busy.is-determinate .lam-busy-fill {
  width: var(--lam-busy-pct, 0%);
  transition: width 0.18s ease-out;
  animation: none;
}
.lam-busy.is-ok {
  background: #1b7a4a;
}
.lam-busy.is-error {
  background: #a33b32;
}
.lam-busy.is-ok .lam-busy-track,
.lam-busy.is-error .lam-busy-track {
  display: none;
}
@keyframes lam-busy-in {
  from { transform: translateY(-100%); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes lam-busy-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

button, .btn, .tag-chip, a.brand {
  transition:
    transform 160ms var(--ease-out),
    background 0.1s ease,
    border-color 0.1s ease,
    color 0.1s ease,
    opacity 0.1s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:active, .btn:active, .is-pressed { transform: scale(0.985); }
form.is-submitting { opacity: 0.72; pointer-events: none; }
button:disabled { opacity: 0.55; cursor: wait; transform: none; }

/* —— 頂欄：扁平、緊湊 —— */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  padding-top: max(0.55rem, var(--safe-top));
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-brand-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.brand {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  letter-spacing: 0.12em;
  color: var(--ink);
  border: none;
}
.brand:hover { color: var(--accent); }
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  margin: 0;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle-bars {
  display: block;
  width: 1rem;
  height: 2px;
  background: currentColor;
  position: relative;
  box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
}
.top nav {
  display: flex;
  gap: 0.15rem 0.85rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: var(--fs-sm);
}
.top nav > a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.2rem 0;
  border-bottom: 1px solid transparent;
}
.top nav > a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.theme-toggle,
.chrome-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-shrink: 0;
  width: auto;
  height: auto;
  padding: 0.15rem;
  margin: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  outline-offset: 3px;
}
button.theme-toggle,
button.chrome-toggle,
.locale-switch > summary.chrome-toggle {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.locale-switch > summary.chrome-toggle::-webkit-details-marker { display: none; }
.locale-switch > summary.chrome-toggle::marker { content: none; }
.theme-toggle:hover,
button.theme-toggle:hover,
.theme-toggle:focus-visible,
.chrome-toggle:hover,
button.chrome-toggle:hover,
.chrome-toggle:focus-visible,
.locale-switch > summary.chrome-toggle:hover,
.locale-switch > summary.chrome-toggle:focus-visible {
  color: var(--ink);
  background: var(--head);
  border-color: var(--line);
}
.theme-toggle-label,
.chrome-toggle-label { display: none; }
.theme-toggle > svg,
.chrome-toggle > svg {
  width: 0.75rem;
  height: 0.75rem;
  overflow: visible;
  pointer-events: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  shape-rendering: geometricPrecision;
}
.chrome-toggles-fixed {
  position: fixed;
  top: max(0.65rem, var(--safe-top));
  right: max(0.9rem, env(safe-area-inset-right, 0px));
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}
.theme-toggle-fixed {
  background: transparent;
  border-color: transparent;
}
button.theme-toggle-fixed {
  background: transparent;
  border-color: transparent;
}
.theme-toggle-nav { display: none; }
.chrome-toggles-nav { display: none; }
.locale-switch { position: relative; }
.locale-switch .locale-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  min-width: 7.5rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 90;
}
.locale-switch[open] > .locale-menu { display: flex; flex-direction: column; gap: 0.1rem; }
.locale-menu a {
  display: block;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  font-size: var(--fs-sm);
  white-space: nowrap;
}
.locale-menu a:hover,
.locale-menu a:focus-visible {
  background: var(--head);
}
.locale-menu a[aria-current="true"] {
  font-weight: 600;
  color: var(--accent);
}
@media (min-width: 721px) {
  .top { padding-right: 4.5rem; }
}

/* 方案 B：細線光芒收回、圓心放大、遮罩滑入成新月 */
.sun-and-moon > .sun,
.sun-and-moon > .moon,
.sun-and-moon > .sun-beams {
  transform-origin: center center;
  transform-box: fill-box;
}
.sun-and-moon > .sun { fill: currentColor; }
.sun-and-moon > .sun-beams {
  stroke: currentColor;
  stroke-width: 1.15px;
}
html[data-theme="dark"] .sun-and-moon > .sun { transform: scale(1.75); }
html[data-theme="dark"] .sun-and-moon > .sun-beams { opacity: 0; }
html[data-theme="dark"] .sun-and-moon > .moon > circle { transform: translateX(-7px); }
@supports (cx: 1px) {
  html[data-theme="dark"] .sun-and-moon > .moon > circle {
    transform: none;
    cx: 17px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .sun-and-moon > .sun {
    transition: transform 0.45s cubic-bezier(0.5, 1.25, 0.75, 1.25);
  }
  .sun-and-moon > .sun-beams {
    transition:
      transform 0.45s cubic-bezier(0.5, 1.5, 0.75, 1.25),
      opacity 0.35s var(--ease-out);
  }
  .sun-and-moon > .moon > circle {
    transition: transform 0.35s var(--ease-out), cx 0.35s var(--ease-out);
  }
  html[data-theme="dark"] .sun-and-moon > .sun {
    transition-duration: 0.25s;
    transition-timing-function: var(--ease-out);
  }
  html[data-theme="dark"] .sun-and-moon > .sun-beams {
    transform: rotate(-25deg);
    transition-duration: 0.15s;
  }
}
.top-nav-primary {
  display: flex;
  gap: 0.15rem 0.85rem;
  align-items: center;
  flex-wrap: wrap;
}
.top-nav-meta {
  display: flex;
  gap: 0.35rem 0.65rem;
  align-items: center;
  margin-left: 0.25rem;
  padding-left: 0.65rem;
  border-left: 1px solid var(--line);
}
.who {
  color: var(--muted);
  font-size: var(--fs-xs);
}
.top .inline button {
  padding: 0.15rem 0.35rem;
  font-size: var(--fs-xs);
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.top .inline button:hover {
  color: var(--ink);
  border-color: var(--line);
  background: var(--head);
}

.wrap { width: min(1080px, calc(100% - 1.5rem)); margin: 1rem auto 2.5rem; }
.foot {
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-xs);
  padding: 0.75rem 1rem 1.25rem;
  border-top: 1px solid var(--line);
  background: transparent;
}

/* —— 區塊：輕邊框、極小圓角（非卡片感） —— */
.panel, .filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
}
.panel.nested, .quick-add.nested {
  margin-top: 0.5rem;
  background: var(--head);
  border-radius: var(--radius);
  box-shadow: none;
}

/* —— 表格 —— */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  margin-bottom: 0.85rem;
}
.table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  margin: 0;
  font-size: var(--fs-sm);
}
.table th,
.table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.table thead th {
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  background: var(--head);
  border-bottom: 1px solid var(--line);
}
.table tbody tr:hover td { background: var(--row-hover); }
.table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--head) 55%, transparent);
}
.table tbody tr:nth-child(even):hover td { background: var(--row-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table a {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.table a:hover { text-decoration: underline; }
.table td.col-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.table td.col-status { white-space: nowrap; }
.status-marks {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: 0.2rem;
  vertical-align: middle;
}
.status-mark {
  display: inline-flex;
  width: 1.15rem;
  height: 1.15rem;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  text-decoration: none;
}
.status-mark svg { width: 0.85rem; height: 0.85rem; display: block; }
.status-mark.is-return { color: var(--danger); background: var(--mark-return-bg); }
.status-mark.is-flag { color: var(--mark-flag); background: var(--mark-flag-bg); }
.status-mark.is-flag:hover { background: var(--status-pending); }
.table a.status-mark {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: 0;
}

.row-actions {
  white-space: nowrap;
}
/* flex 只套在非 td 包裝（如案件一覽的 div）；td 必須維持 table-cell，否則底線錯位 */
.row-actions:not(td) {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}
td.row-actions {
  display: table-cell;
}
.row-actions a {
  font-family: var(--font);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0;
  text-decoration: none;
  color: var(--muted);
  padding: 0;
  border-radius: 0;
}
.row-actions a:hover {
  color: var(--accent);
  background: transparent;
  text-decoration: underline;
}


/* 窄螢幕列表：同一份表格 markup 改排成扁平卡片（不另外渲染一份） */
@media (max-width: 900px) {
  .cases-table thead { display: none; }
  .cases-table,
  .cases-table tbody,
  .cases-table tr,
  .cases-table td { display: block; }
  .cases-table tr {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.4rem;
    position: relative;
  }
  .cases-table td {
    border: 0;
    padding: 0.1rem 0;
    font-size: var(--fs-sm);
  }
  /* 勾選／案號／狀態同一條標題列，垂直置中對齊 */
  .cases-table td.col-select {
    position: absolute;
    top: 0.65rem;
    left: 0.55rem;
    width: auto;
    height: 1.35rem;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
  }
  .cases-table td.col-select label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 0;
  }
  .cases-table td.col-select input[type="checkbox"] {
    width: 0.95rem;
    height: 0.95rem;
    min-width: 0.95rem;
    min-height: 0.95rem;
    padding: 0;
    margin: 0;
  }
  .cases-table td.col-code {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    padding-right: 0.25rem;
    padding-left: 1.55rem;
    min-height: 1.35rem;
    line-height: 1.35rem;
    display: flex;
    align-items: center;
  }
  .cases-table td.col-code a { text-decoration: none; color: var(--ink); }
  /* 狀態＋批名膠囊：卡牌右側空白，對齊中段欄位，不蓋案號 */
  .cases-table td.col-status {
    position: absolute;
    top: 2.15rem; /* 案號列之下 */
    right: 0.65rem;
    left: auto;
    width: min(42%, 8.75rem);
    height: auto;
    max-height: calc(100% - 4.5rem);
    padding: 0;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 0.2rem;
    white-space: normal;
    overflow: hidden;
    z-index: 1;
  }
  .cases-table td.col-status .pill {
    font-size: 0.6875rem; /* 11px */
    padding: 0.05rem 0.3rem;
    line-height: 1.3;
    text-align: right;
    max-width: 100%;
  }
  .cases-table td.col-status .pill.pill-batch {
    margin-left: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .cases-table td.col-status .status-marks {
    margin-left: 0;
  }
  /* 其餘欄位以「標題：值」呈現；右側留給膠囊 */
  .cases-table td[data-label] {
    padding-right: min(44%, 9.25rem);
  }
  .cases-table td[data-label]::before {
    content: attr(data-label) "：";
    color: var(--muted);
    margin-right: 0.35rem;
  }
  .cases-table td[data-label]:empty { display: none; }
  .cases-table td.col-time {
    padding-right: min(44%, 9.25rem);
  }
  .cases-table td.col-actions {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--line);
  }
  .cases-table td.col-actions:empty { display: none; }
  .cases-table td.col-actions .row-actions a {
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
  }
}

/* 分頁列 */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.9rem 0 0.4rem;
  flex-wrap: wrap;
}
.pager-status { font-size: var(--fs-sm); }
.case-iso-nav { margin-top: 1.25rem; }
.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.narrow { max-width: 400px; margin: 2.5rem auto; }
.stack { display: grid; gap: 0.65rem; }
.stack.tight { gap: 0.3rem; }

label {
  display: grid;
  gap: 0.25rem;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
}
label .muted, label span.hint { font-weight: 400; }

input, select, textarea, button, .btn {
  font: inherit;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--input-bg);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 0;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 4.5rem; }

button, .btn {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  line-height: 1.3;
  letter-spacing: 0.01em;
}
button.danger, .btn.danger { background: var(--danger); color: var(--on-accent); }
.btn.ghost, button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost:hover, button.ghost:hover { background: var(--head); }
button.btn-sm, a.btn-sm, .btn.btn-sm, summary.btn-sm {
  padding: 0.2rem 0.45rem;
  font-size: var(--fs-xs);
  font-weight: 500;
}

.import-commit-actions {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem -0.25rem 0;
  padding: 0.75rem 0.25rem calc(0.75rem + env(safe-area-inset-bottom, 0));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(6px);
  border-top: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
}
.import-commit-actions .btn,
.import-commit-actions button {
  min-height: 2.75rem;
  flex: 1 1 auto;
}
@media (min-width: 720px) {
  .import-commit-actions .btn,
  .import-commit-actions button {
    flex: 0 1 auto;
  }
}

.toolbar, .actions, .filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.toolbar h1 { margin: 0; }
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.bulk-lock-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.65rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.bulk-lock-count { font-size: var(--fs-sm); }
.bulk-select-all-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0.15rem 0.35rem;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius);
}
.bulk-select-all-btn:hover {
  color: var(--ink);
  background: var(--head);
}
.bulk-lock-bar[hidden] { display: none !important; }
.bulk-assay-menu {
  position: relative;
}
.bulk-assay-menu > summary {
  list-style: none;
}
.bulk-assay-menu > summary::-webkit-details-marker { display: none; }
.bulk-assay-menu > summary::after {
  content: " ▾";
  font-size: 0.7em;
  opacity: 0.85;
}
.bulk-assay-menu-body {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  z-index: 8;
  min-width: 7.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 4px 12px var(--shadow);
}
.bulk-assay-menu-body button {
  background: transparent;
  color: var(--ink);
  border: 0;
  text-align: left;
  width: 100%;
  font-weight: 500;
}
.bulk-assay-menu-body button:hover {
  background: var(--head);
}
.bulk-assay-menu-body button:disabled {
  opacity: 0.45;
}
.assay-case-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.35rem 1rem;
  margin: 0 0 0.75rem;
}
.assay-case-fields dt {
  font-size: var(--fs-sm);
  color: var(--muted);
}
.assay-case-fields dd { margin: 0; }
.pcr-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.45rem 0.75rem;
  margin: 0 0 0.55rem;
}
.pcr-row-main {
  flex: 1 1 10rem;
  min-width: 0;
}
.pcr-row-main strong {
  display: block;
  line-height: 1.3;
}
.pcr-catalog {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.65rem;
  margin: 0.15rem 0 0;
  line-height: 1.35;
  max-width: 36rem;
}
.pcr-catalog-thermal {
  flex: 1 1 100%;
  word-break: break-word;
}
.pcr-hits { margin-bottom: 0.75rem; }
@media (max-width: 640px) {
  .pcr-row {
    flex-direction: column;
    align-items: stretch;
  }
  .pcr-row .wl-chip-row {
    width: 100%;
  }
}
.seq-order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  align-items: center;
  margin-top: 0.35rem;
}
.seq-result-sequence {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.35;
  letter-spacing: 0.02em;
  white-space: pre-wrap;
  word-break: break-all;
}
.seq-result-case-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.seq-result-case-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.6rem;
}
.seq-ncbi-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.seq-ncbi-block {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.45rem;
}
.seq-ncbi-draft-fold,
.seq-ncbi-hits-fold,
.seq-overview-more {
  margin-top: 0.35rem;
}
.seq-ncbi-draft-fold > summary,
.seq-ncbi-hits-fold > summary,
.seq-overview-more > summary {
  cursor: pointer;
  list-style: none;
}
.seq-ncbi-draft-fold > summary::-webkit-details-marker,
.seq-ncbi-hits-fold > summary::-webkit-details-marker,
.seq-overview-more > summary::-webkit-details-marker { display: none; }
.seq-ncbi-draft-fold > summary::before,
.seq-ncbi-hits-fold > summary::before,
.seq-overview-more > summary::before {
  content: "▸ ";
  opacity: 0.7;
}
.seq-ncbi-draft-fold[open] > summary::before,
.seq-ncbi-hits-fold[open] > summary::before,
.seq-overview-more[open] > summary::before { content: "▾ "; }
.seq-ncbi-hits {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}
.seq-ncbi-hits li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  font-size: 0.9rem;
}
.seq-order-actions .btn {
  text-decoration: none;
}
.seq-order-more {
  margin-top: 0.35rem;
}
.seq-order-more > summary {
  cursor: pointer;
  list-style: none;
}
.seq-order-more > summary::-webkit-details-marker { display: none; }
.genomics-browser-page .page-head {
  margin-bottom: 0.35rem;
}
.genomics-browser-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
}
.genomics-browser-title {
  font-size: 1.05rem;
  margin: 0;
  flex: 1 1 auto;
}
.genomics-browser-frame-wrap {
  position: relative;
  border: 1px solid var(--border, #ccc);
  background: #1a1a1a;
  min-height: 70vh;
  height: calc(100vh - 7.5rem);
}
.genomics-browser-gate {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.25rem;
  color: #eee;
  text-align: center;
  background: #1a1a1a;
  z-index: 2;
}
.genomics-browser-gate[hidden] { display: none; }
.genomics-browser-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 70vh;
  border: 0;
}
.genomics-browser-frame[hidden] { display: none; }
.seq-order-card {
  margin: 0.75rem 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border, #ddd);
  border-radius: 4px;
}
.seq-ncbi-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  margin: 0.35rem 0 0;
}
.seq-order-items {
  list-style: none;
  margin: 0.35rem 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.seq-order-items li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
}
.seq-order-pick {
  display: grid;
  gap: 0.4rem;
  margin: 0.35rem 0 0.75rem;
}
.seq-order-pick-row {
  display: grid;
  grid-template-columns: auto minmax(6rem, 1fr) minmax(7rem, 1.2fr) minmax(5rem, 0.8fr);
  gap: 0.35rem 0.5rem;
  align-items: center;
}
.seq-batch-block {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border, #ddd);
}
.seq-steps {
  margin: 0.35rem 0 0.65rem 1.1rem;
  padding: 0;
  line-height: 1.45;
}
.seq-steps li {
  margin: 0.15rem 0;
}
.seq-batch-primer-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.65rem;
  align-items: flex-end;
  margin: 0.25rem 0 0.5rem;
}
.seq-batch-primer-apply {
  flex: 1 1 12rem;
  min-width: 0;
}
.seq-batch-table-wrap {
  overflow-x: auto;
  margin: 0.25rem 0 0.65rem;
  -webkit-overflow-scrolling: touch;
}
.seq-batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.seq-batch-table th,
.seq-batch-table td {
  border-bottom: 1px solid var(--border, #ddd);
  padding: 0.4rem 0.45rem;
  vertical-align: middle;
  text-align: left;
}
.seq-batch-table thead th {
  font-weight: 600;
  white-space: nowrap;
  background: color-mix(in srgb, var(--muted, #888) 6%, transparent);
}
.seq-batch-col-check {
  width: 2.2rem;
  text-align: center;
}
.seq-batch-table input[name^="sample_name_"],
.seq-batch-table select[name^="primer_hint_"] {
  width: 100%;
  min-width: 6rem;
  box-sizing: border-box;
}
.seq-order-checklist {
  white-space: pre-wrap;
  margin: 0.35rem 0 0;
  padding: 0.4rem 0.5rem;
  background: color-mix(in srgb, var(--muted, #888) 8%, transparent);
  border-radius: var(--radius);
  max-height: 8rem;
  overflow: auto;
  overscroll-behavior: contain;
}
@media (max-width: 640px) {
  .seq-order-pick-row {
    grid-template-columns: auto 1fr;
  }
  .seq-order-pick-row input[name^="sample_name_"],
  .seq-order-pick-row .seq-order-primer,
  .seq-order-pick-row select[name^="primer_hint_"] {
    grid-column: 1 / -1;
  }
  .seq-batch-table th:nth-child(2),
  .seq-batch-table td:nth-child(2) {
    min-width: 5.5rem;
  }
  .seq-batch-table th:nth-child(3),
  .seq-batch-table td:nth-child(3),
  .seq-batch-table th:nth-child(4),
  .seq-batch-table td:nth-child(4) {
    min-width: 7rem;
  }
}
.seq-order-primer select {
  min-width: 12rem;
  max-width: 100%;
}
.notice.tiny { font-size: var(--fs-sm); padding: 0.35rem 0.5rem; }
.bulk-export-cols {
  margin-left: auto;
  font-size: var(--fs-sm);
}
.bulk-export-cols summary {
  cursor: pointer;
  color: var(--muted);
}
.bulk-export-cols-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.25rem 0.75rem;
  margin-top: 0.4rem;
  min-width: 16rem;
}
.bulk-export-cols-body label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--fs-sm);
}
.table th.col-select,
.table td.col-select {
  width: 2.1rem;
  text-align: center;
  vertical-align: middle;
}
.table td.col-select input[type="checkbox"] {
  width: 0.95rem;
  height: 0.95rem;
  min-width: 0.95rem;
  min-height: 0.95rem;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent);
  vertical-align: middle;
}
.filters { justify-content: flex-start; padding: 0.55rem 0.7rem; }
.filters input[type="search"] { flex: 1; min-width: 180px; }
.filters select, .filters button { font-size: var(--fs-sm); }

.muted { color: var(--muted); }
.tiny { font-size: var(--fs-xs); letter-spacing: 0.01em; }
.block-label {
  margin: 0.55rem 0 0.35rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
}
.error {
  color: var(--danger);
  background: var(--error-bg);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--error-line);
  font-size: var(--fs-sm);
}
.ok {
  color: var(--ok);
  background: var(--ok-bg);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--ok-line);
  font-size: var(--fs-sm);
}
.lam-live-banner {
  margin: 0.65rem 0 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
}
.lam-live-banner[hidden] { display: none !important; }
.lam-live-banner p { margin: 0; }
.lam-live-banner a { font-weight: 600; }
.consistency-banner {
  margin: 0.65rem 0 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
}
.consistency-banner h2 {
  margin: 0 0 0.4rem;
  font-size: var(--fs-md);
}
.plain-list { list-style: none; padding: 0; margin: 0.35rem 0 0; }
.plain-list li { margin: 0.45rem 0; }
.consistency-banner .plain-list { margin: 0; }
.consistency-banner .inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
}
.consistency-banner .inline-form input {
  min-width: 12rem;
  flex: 1 1 12rem;
}
.error-inline { color: var(--danger); }
.field-error {
  display: block;
  margin-top: 0.25rem;
  color: var(--danger);
  font-size: 0.85rem;
}
[aria-invalid="true"] {
  outline: 1px solid var(--danger);
  outline-offset: 1px;
}
.plain { padding-left: 1.1rem; margin: 0; font-size: var(--fs-sm); }

/* —— 案件頁頭與操作 —— */
.case-head { margin-bottom: 0.65rem; }
.case-head h1 {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin: 0.1rem 0;
}
.case-head .muted { font-size: var(--fs-sm); }

.case-ops {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}
.case-ops-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-top: 0.25rem;
}
.pill.status-lg {
  font-size: var(--fs-sm);
  padding: 0.2rem 0.45rem;
  font-weight: 600;
}
.status-rail {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 0;
  padding: 0;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.status-rail li {
  padding: 0.12rem 0.4rem;
  border: 1px solid var(--line);
  border-right: none;
  background: var(--surface);
  border-radius: 0;
}
.status-rail li:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.status-rail li:last-child {
  border-right: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.status-rail li[aria-current="step"] {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--pill);
  font-weight: 600;
  z-index: 1;
}

.case-ops-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.case-ops-primary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
}
.case-ops-primary .inline-form {
  display: inline-flex;
  margin: 0;
}
.isolate-code-list {
  margin: 0 0 0.45rem;
}
.isolate-code-list li {
  font-size: var(--fs-sm);
}
.isolate-code-list strong {
  font-family: var(--font-mono);
}

/* 次要操作：預設收合 */
.ops-more {
  margin: 0;
  border: none;
  padding: 0;
}
.ops-more > summary {
  list-style: none;
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 500;
  padding: 0.35rem 0;
  user-select: none;
}
.ops-more > summary::-webkit-details-marker { display: none; }
.ops-more > summary::before {
  content: "▸ ";
  font-family: var(--font-mono);
  color: var(--muted);
}
.ops-more[open] > summary::before { content: "▾ "; }
.ops-more > summary:hover { color: var(--ink); }
.ops-more-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0 0.15rem;
}


.lam-prompt {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 1rem;
  padding-bottom: max(1rem, var(--safe-bottom));
}
.lam-prompt[hidden] { display: none !important; }
.lam-prompt-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
}
.lam-prompt.is-open .lam-prompt-backdrop { opacity: 1; }
.lam-prompt-card {
  position: relative;
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
  display: grid;
  gap: 0.65rem;
  box-shadow: 0 8px 28px color-mix(in srgb, #000 22%, transparent);
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity 220ms var(--ease-out),
    transform 220ms var(--ease-out);
}
.lam-prompt.is-open .lam-prompt-card {
  opacity: 1;
  transform: scale(1);
}
.lam-prompt.is-closing .lam-prompt-backdrop { opacity: 0; }
.lam-prompt.is-closing .lam-prompt-card {
  opacity: 0;
  transform: scale(0.97);
  transition-duration: 150ms;
}
.lam-prompt-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.lam-prompt-label { display: grid; gap: 0.25rem; font-size: var(--fs-sm); }
.lam-prompt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}
.lam-prompt-actions button {
  min-height: var(--touch-min);
  min-width: 4.5rem;
}

.case-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}
.case-section-head h2 { margin: 0; }

@media (max-width: 720px) {
  /* 操作鈕併排成列高方塊，三顆也可同一列 */
  .case-ops-primary,
  .ops-more-body,
  .case-ops-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5.2rem, 1fr));
    gap: 0.3rem;
    align-items: stretch;
  }
  .case-ops-primary .inline-form,
  .ops-more-body .inline-form {
    display: flex;
    width: 100%;
    margin: 0;
  }
}

/* 狀態標籤：小直角，非膠囊 */
.pill {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius);
  background: var(--pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.35;
  border: 1px solid transparent;
}
.pill.status-draft { background: var(--status-draft); }
.pill.status-received { background: var(--status-draft); }
.pill.status-testing { background: var(--status-testing); }
.pill.status-pending_seq { background: var(--status-pending); }
.pill.status-closed { background: var(--status-pending); }
.pill.status-archived { background: var(--status-archived); }
.pill.mark-progress_ok { background: var(--pill-progress-ok); }
.pill.mark-need_redo { background: var(--pill-need-redo); }
.pill.mark-ready_archive { background: var(--pill-ready-archive); }
.pill.mark-note { background: var(--pill-note); }
.pill.pill-batch {
  margin-left: 0.2rem;
  background: var(--pill-ready-archive);
  text-decoration: none;
  color: inherit;
}
.pill.pill-batch.is-work { background: var(--pill-progress-ok); }

.preview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.75rem;
}
.preview-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem;
}
.preview-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}
.preview-thumbs img {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  border-radius: var(--radius);
}
.preview-missing { color: var(--muted); }
.review-batch-group { margin-top: 1rem; }
.review-batch-group.is-picked,
.review-batch-group:target {
  outline: 2px solid var(--accent, #1f6f5b);
  outline-offset: 4px;
  border-radius: var(--radius);
}
.review-batch-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.review-batch-head h3 { margin: 0; font-size: 1rem; }

/* 核簽儀表板 */
.review-dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin-bottom: 0.65rem;
}
.review-dash-head h1 { margin: 0; }
.review-dash-head .muted { margin: 0; max-width: 42rem; }
.review-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}
.review-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.review-kpi:hover { background: var(--head); border-color: var(--line-strong); }
.review-kpi strong {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--ink);
}
.review-kpi span {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 500;
}
.review-kpi.is-hot {
  border-color: var(--accent);
  background: var(--pill);
}
.review-kpi.is-hot strong { color: var(--accent); }
.review-find {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
  align-items: center;
  margin: 0 0 0.85rem;
}
.review-find-shell {
  display: flex;
  flex: 1 1 16rem;
  min-width: 0;
  gap: 0.35rem;
  align-items: center;
}
.review-find-shell input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
}
.review-find-more {
  flex: 1 1 100%;
  margin: 0;
  border: none;
  padding: 0;
}
.review-find-more > summary {
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 500;
  padding: 0.2rem 0;
  list-style: none;
}
.review-find-more > summary::-webkit-details-marker { display: none; }
.review-find-more-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.35rem;
}
.review-dash-body {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
  gap: 0.85rem 1.1rem;
  align-items: start;
}
.review-queues,
.review-results {
  min-width: 0;
}
.review-queue {
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.review-queue > h2 {
  margin: 0 0 0.35rem;
  font-size: var(--fs-sm);
}
.review-queue.is-empty { display: none; }
.review-dash-body:not(:has(.review-queue:not(.is-empty))) {
  grid-template-columns: 1fr;
}
.review-queue .plain-list { margin: 0; }
.review-queue .table-wrap { margin: 0; }
.review-case-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.review-case-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.5rem;
  padding: 0.28rem 0;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.review-case-list li:first-child { border-top: none; padding-top: 0; }
.review-batch-card {
  margin-top: 0.65rem;
  padding: 0.55rem 0.65rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.review-batch-card .review-batch-head { margin-bottom: 0.25rem; }
.review-batch-card .actions { margin: 0; gap: 0.3rem; }

/* 批次詳情摘要環 */
.batch-dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.45rem 0.75rem;
  margin-bottom: 0.55rem;
}
.batch-dash-head h1 { margin: 0; flex: 1 1 8rem; }
.batch-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0.55rem 0;
}
.batch-kpi {
  min-width: 0;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.batch-kpi span {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 500;
}
.batch-kpi strong {
  display: block;
  margin-top: 0.1rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  word-break: break-word;
}
.batch-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  align-items: center;
  margin: 0 0 0.85rem;
  font-size: var(--fs-sm);
}
.batch-meta-row .inline-form {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
@media (max-width: 720px) {
  .review-kpis,
  .batch-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem;
  }
  .review-kpi,
  .batch-kpi {
    padding: 0.3rem 0.4rem;
    min-height: var(--opt-tile-h);
  }
  .review-kpi strong { font-size: 1.15rem; }
  .review-dash-body { grid-template-columns: 1fr; }
  .review-queue { padding: 0.45rem 0.5rem; }
  .batch-dash-head { flex-direction: column; align-items: stretch; }
  .batch-dash-head .toolbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(3.6rem, 1fr));
    gap: 0.3rem;
  }
}

.case-template-banner {
  margin: 0.75rem 0 1rem;
  border-left: 3px solid var(--accent);
}

.notice {
  margin: 0.5rem 0 0;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius);
  border: 1px solid var(--notice-line);
  background: var(--notice-bg);
  color: var(--ink);
  font-size: var(--fs-sm);
}

.return-banner {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--status-returned);
  border: 1px solid var(--status-returned-line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
}

.closed-banner {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--status-closed-banner);
  border: 1px solid var(--status-closed-line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
}

.reopen-banner {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--reopen-bg);
  border: 1px solid var(--reopen-line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
}

.teacher-marks .case-ops-actions { border-top: none; padding-top: 0; }
.nowrap { white-space: nowrap; }

.grid-2 {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-bottom: 0.85rem;
}
.kv {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.3rem 0.65rem;
  font-size: var(--fs-sm);
  margin: 0;
}
.kv dt {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.kv dd { margin: 0; }
.pre { white-space: pre-wrap; }

.assay-overview-panels {
  display: grid;
  gap: 0.75rem;
  margin: 0.35rem 0 0.75rem;
}
.assay-overview-panel {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2, var(--panel));
}
.assay-overview-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.45rem;
}
.assay-overview-panel-title {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: inherit;
  text-decoration: none;
}
.assay-overview-panel-title:hover {
  color: var(--accent, #2f6f5e);
}
.assay-overview-panel-status {
  font-size: var(--fs-xs);
  color: var(--muted);
}
.assay-overview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.35rem;
  margin-bottom: 0.35rem;
}
.assay-overview-media {
  margin-top: 0.45rem;
  gap: 0.35rem;
}
.assay-overview-media .lam-photo-item.is-compact {
  width: 4.5rem;
  max-width: 4.5rem;
}
.assay-overview-media .lam-photo-item.is-compact img {
  width: 100%;
  height: 4.5rem;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.assay-overview-identity {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.assay-overview-identity-org {
  margin: 0;
  font-weight: 600;
}
.assay-overview-identity-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.35rem;
  align-items: center;
}
.assay-overview-panel[data-kind="identity"] {
  border-left: 3px solid var(--accent, #2a6f6a);
}
.pill.id-accession {
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.overview-iso-summary-main .pill {
  margin-left: 0.35rem;
  vertical-align: middle;
}
.pill.tiny {
  font-size: 0.75em;
  padding: 0.05rem 0.35rem;
}
.assay-result-pill.tone-pos {
  background: color-mix(in srgb, #2f6f5e 16%, transparent);
}
.assay-result-pill.tone-neg {
  background: color-mix(in srgb, #8a4b3a 14%, transparent);
}
.assay-result-pill.tone-neutral {
  background: color-mix(in srgb, var(--accent, #2a6f6a) 10%, transparent);
}
.assay-overview-water {
  margin: 0 0 0.35rem;
}
.assay-overview-text {
  margin: 0 0 0.35rem;
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.assay-overview-ast {
  margin-bottom: 0.35rem;
}

.case-facts-panel .case-section-head,
.case-lab-overview .case-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.case-facts-panel .case-section-head h2,
.case-lab-overview .case-section-head h2 {
  margin: 0;
}
.case-facts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  margin: 0.35rem 0 0.75rem;
}
.case-facts-panel .case-facts-table th,
.case-facts-table th {
  width: 9rem;
  max-width: 42%;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  text-align: left !important;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.case-facts-panel .case-facts-table td,
.case-facts-table td {
  text-align: left !important;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.assay-overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  margin: 0.25rem 0 0.35rem;
}
.assay-overview-table th,
.assay-overview-table td {
  padding: 0.3rem 0.45rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.assay-overview-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: var(--fs-xs);
}
.overview-layer-title {
  margin: 0.75rem 0 0.35rem;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.overview-iso-accordion {
  display: grid;
  gap: 0.45rem;
  margin: 0.5rem 0 0;
}
.overview-iso-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface, var(--panel));
  /* 可見：玫瑰圖外圈藥名不可被裁切 */
  overflow: visible;
}
.overview-iso-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  list-style: none;
}
.overview-iso-summary::-webkit-details-marker {
  display: none;
}
.overview-iso-summary-main {
  font-size: var(--fs-sm);
}
.overview-iso-summary-meta {
  flex-shrink: 0;
}
.overview-iso-body {
  padding: 0 0.7rem 0.7rem;
  border-top: 1px solid var(--line);
}
.overview-iso-actions,
.assay-overview-panel-actions {
  margin: 0.75rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
/* 藥敏玫瑰圖：輕量扇形 SVG（點選顯示數值、可拖曳旋轉／縮放） */
.ast-rose {
  margin: 0.55rem 0 0.1rem;
  padding: 0.35rem 0 0;
  max-width: 100%;
}
.ast-rose-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.35rem 0;
  justify-content: flex-start;
}
.ast-rose-toolbar .btn {
  min-width: 2rem;
  padding-inline: 0.4rem;
}
.ast-rose-stage-wrap {
  width: min(100%, 17.5rem);
  max-width: 100%;
  aspect-ratio: 1;
  margin-inline: auto;
  padding: 0.2rem;
  box-sizing: border-box;
  overflow: visible;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.ast-rose-stage-wrap.is-dragging,
.ast-rose-stage-wrap:active {
  cursor: grabbing;
}
.ast-rose-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.ast-rose-wedge {
  cursor: pointer;
  stroke: color-mix(in srgb, var(--panel) 75%, #fff);
  stroke-width: 0.9;
  transition: opacity 0.15s ease;
}
.ast-rose-wedge:hover,
.ast-rose-wedge:focus-visible {
  filter: brightness(1.06);
  outline: none;
}
.ast-rose.is-focused .ast-rose-wedge {
  opacity: 0.32;
}
.ast-rose.is-focused .ast-rose-wedge.is-focus {
  opacity: 1;
}
.ast-rose-label-g {
  cursor: pointer;
  pointer-events: auto;
}
.ast-rose-label-g.is-focus .ast-rose-label {
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ast-rose-label {
  font-size: 10px;
  font-weight: 650;
  fill: var(--ink);
  paint-order: stroke fill;
  stroke: color-mix(in srgb, var(--panel) 94%, #fff);
  stroke-width: 0.9px;
  stroke-linejoin: round;
  pointer-events: auto;
}
.ast-rose-label.tone-S { fill: var(--sir-s); }
.ast-rose-label.tone-I { fill: var(--sir-i); }
.ast-rose-label.tone-R { fill: var(--sir-r); }
.ast-rose.is-hide-labels .ast-rose-labels {
  display: none;
}
.ast-rose-hub-disk {
  fill: color-mix(in srgb, var(--panel) 92%, var(--head));
  stroke: color-mix(in srgb, var(--line) 80%, var(--accent));
  stroke-width: 1;
  pointer-events: none;
}
.ast-rose-hub-mm {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono, ui-monospace, monospace);
  pointer-events: none;
}
.ast-rose-focus {
  position: sticky;
  top: 0.35rem;
  z-index: 3;
  display: grid;
  gap: 0.2rem;
  margin: 0 0 0.15rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--ink) 6%, transparent);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.ast-rose-focus[data-empty="1"] {
  border-style: dashed;
  border-color: var(--line);
  box-shadow: none;
  background: color-mix(in srgb, var(--panel) 88%, var(--head));
}
.ast-rose-focus[data-empty="1"] .ast-rose-focus-body {
  display: none !important;
}
.ast-rose-focus:not([data-empty="1"]) .ast-rose-focus-empty {
  display: none !important;
}
.ast-rose-focus-empty {
  color: var(--muted);
  font-size: var(--fs-xs);
}
.ast-rose-focus-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem 0.85rem;
}
.ast-rose-focus-drug {
  font-weight: 700;
  font-size: 1.02em;
}
.ast-rose-focus-mm {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 750;
  font-size: 1.08em;
  color: var(--ink);
}
.ast-rose-focus-mark {
  font-weight: 700;
}
.ast-rose-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  justify-content: center;
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.ast-rose-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.ast-rose-swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
}
.ast-rose-hint {
  margin: 0.3rem 0 0;
  text-align: center;
}
@media (max-width: 720px) {
  .ast-rose-stage-wrap {
    width: min(100%, 19rem);
  }
  .ast-rose-label {
    font-size: 11px;
  }
  .ast-rose-hub-mm {
    font-size: 15px;
  }
  .ast-rose-focus {
    top: calc(0.25rem + env(safe-area-inset-top, 0px));
    font-size: 1rem;
  }
  /* 藥敏表改跟整頁一起滾，不再內層小視窗 */
}
@media (min-width: 721px) {
  .ast-rose-stage-wrap {
    width: min(100%, 18rem);
  }
}

.timeline {
  padding-left: 1rem;
  margin: 0;
  font-size: var(--fs-sm);
}
.timeline li { margin-bottom: 0.55rem; }
.timeline strong { font-weight: 600; }

.media-list { list-style: none; padding: 0; display: grid; gap: 0.6rem; }
.inline { display: inline; margin: 0; }
.inline button {
  padding: 0.2rem 0.45rem;
  font-size: var(--fs-xs);
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.75rem), 1fr));
  gap: 0.55rem;
  margin: 0.5rem 0 0.75rem;
}
.media-card {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.media-card > a:has(img) {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--photo-letterbox);
  overflow: hidden;
}
.media-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: transparent;
  content-visibility: auto;
}
.media-card figcaption {
  display: grid;
  gap: 0.15rem;
  padding: 0.4rem 0.45rem;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.media-card figcaption .media-title {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
  word-break: break-all;
}
.media-card figcaption .media-caption {
  color: var(--ink);
  font-size: var(--fs-xs);
  line-height: 1.35;
}
.lam-media-board {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.5rem;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}
.lam-media-board.is-saving {
  opacity: 0.72;
  pointer-events: none;
}
.lam-media-board.is-dragging-board {
  user-select: none;
  -webkit-user-select: none;
}
.lam-media-board.is-dragging-board .lam-media-card,
.lam-media-board.is-dragging-board .photo-table-row {
  touch-action: none;
}
.lam-media-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.55rem 0.4rem;
  background: var(--surface);
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
  box-sizing: border-box;
}
.lam-media-section-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  min-width: 0;
}
.lam-media-section-title {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 650;
  min-width: 0;
  overflow-wrap: anywhere;
}
.lam-media-section-body.is-drop-target,
.photo-table.is-drop-target {
  outline: 2px solid color-mix(in srgb, var(--accent, #2a6f97) 70%, transparent);
  outline-offset: 2px;
  border-radius: calc(var(--radius) - 2px);
}
/* 必須壓過 .media-grid 的 auto-fill／窄螢幕 1fr 1fr，避免 min-content 撐出橫向捲動 */
.media-grid.lam-media-grid,
.lam-media-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0;
  min-height: 2.5rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  align-items: start;
}
@media (min-width: 900px) {
  .media-grid.lam-media-grid,
  .lam-media-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.lam-media-card {
  position: relative;
  display: flex !important;
  flex-direction: column;
  touch-action: pan-y;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
}
.lam-media-card-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.lam-media-card.is-dragging {
  opacity: 0.35;
}
.lam-media-card.is-long-pressing .lam-media-card-shell {
  outline: 2px solid color-mix(in srgb, var(--accent, #2a6f97) 55%, transparent);
  outline-offset: 1px;
}
.lam-media-card.is-editing {
  grid-column: 1 / -1;
}
.lam-media-card.is-editing .lam-media-card-shell {
  border-color: color-mix(in srgb, var(--accent, #2a6f97) 55%, var(--line));
}
.lam-media-card .lam-media-thumb {
  display: block;
  aspect-ratio: 1 / 1 !important;
  width: 100%;
  height: auto;
  max-height: none;
  background: var(--photo-letterbox, var(--head));
  overflow: hidden;
  -webkit-touch-callout: none;
  user-select: none;
}
.lam-media-card .lam-media-thumb img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center;
  pointer-events: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  user-select: none;
  content-visibility: visible !important;
}
.lam-media-card .lam-media-cap {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.28rem 0.35rem 0.32rem;
  min-width: 0;
}
.lam-media-card .media-title {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--muted);
}
.lam-media-card .lam-media-edit-btn {
  flex: 0 0 auto;
  margin: 0;
  min-height: auto;
  min-width: auto;
  padding: 0.1rem 0.15rem;
  border: 0;
  background: transparent;
  color: var(--accent, #2a6f97);
  font-size: 0.68rem;
  line-height: 1.2;
  text-decoration: none;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}
.lam-media-card .lam-media-edit-btn:hover,
.lam-media-card .lam-media-edit-btn:focus-visible {
  text-decoration: underline;
  background: transparent;
}
.lam-media-drag-handle {
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  z-index: 2;
  border: 0;
  border-radius: 0.3rem;
  background: color-mix(in srgb, var(--surface) 78%, #000);
  color: var(--ink);
  cursor: grab;
  padding: 0.12rem 0.3rem;
  font-size: 0.65rem;
  line-height: 1.1;
  opacity: 0.72;
  touch-action: none;
}
.lam-media-drag-handle:active {
  cursor: grabbing;
}
.lam-media-insert-line {
  position: fixed !important;
  z-index: 10000;
  pointer-events: none;
  border-radius: 999px;
  background: var(--accent, #2a6f97);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #2a6f97) 22%, transparent);
  margin: 0;
  padding: 0;
  border: 0;
}
.lam-media-insert-line.is-vertical {
  width: 3px;
}
.lam-media-insert-line.is-horizontal {
  display: none; /* 上下線停用：排序只看左右＝前後 */
}
.lam-media-placeholder {
  display: none !important; /* 舊版佔位殘留時直接隱藏並由 JS 清除 */
}
.lam-media-drag-ghost {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  z-index: 9999;
  margin: 0 !important;
  pointer-events: none !important;
  opacity: 0.95;
  box-shadow: 0 4px 14px color-mix(in srgb, #000 18%, transparent);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  max-width: 46vw;
}
.lam-media-card.is-dragging {
  opacity: 0.35;
}
.lam-media-drag-ghost .lam-media-edit-form,
.lam-media-drag-ghost .lam-media-edit-btn,
.lam-media-drag-ghost .lam-media-drag-handle {
  display: none !important;
}
.lam-media-drag-ghost .lam-media-cap {
  display: none;
}
.lam-media-card img,
.lam-media-card .lam-media-thumb img {
  content-visibility: visible !important;
}
body.lam-media-drag-lock {
  overflow: hidden;
  touch-action: none;
}
.lam-media-edit-form {
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem 0.5rem 0.6rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.lam-media-edit-form .photo-field,
.lam-media-edit-form input,
.lam-media-edit-form select,
.lam-media-edit-form textarea {
  max-width: 100%;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.lam-media-edit-form[hidden] {
  display: none !important;
}
.lam-media-edit-actions {
  align-items: center;
  flex-wrap: wrap;
}
.photo-table-row {
  position: relative;
  touch-action: pan-y;
}
.photo-table-row.is-dragging {
  opacity: 0.4;
}
.photo-table-row.is-editing {
  outline: 1px solid var(--line);
}
.photo-table-preview .lam-media-drag-handle {
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
}
.photo-title-input {
  font-family: var(--font-mono) !important;
  font-size: var(--fs-sm) !important;
  letter-spacing: 0.01em;
}
input.case-code-suggest {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--head);
}
input.case-code-suggest:focus,
input.case-code-suggest.is-edited {
  color: var(--ink);
  background: var(--input-bg);
}
.photo-field .field-hint {
  font-style: normal;
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--muted);
  margin-left: 0.35rem;
  opacity: 0.85;
}
.photo-hint-field input {
  color: var(--muted);
  background: var(--head);
  border-style: dashed;
}
.photo-hint-field input:focus {
  color: var(--ink);
  background: var(--input-bg);
  border-style: solid;
}
.photo-caption-grow textarea::placeholder {
  color: var(--combo-muted);
}
.file-chip {
  display: block;
  padding: 1.5rem 0.75rem;
  text-align: center;
}
.media-fieldset {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem 0.85rem;
}

/* 樣本複選（建案／送檢批） */
.sample-types {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem 0.75rem;
  margin: 0;
}
.sample-types legend {
  padding: 0 0.25rem;
  font-weight: 600;
}
.sample-types .req {
  font-weight: 400;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.35rem 0.75rem;
  margin-top: 0.35rem;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: var(--touch-min, 2.5rem);
  margin: 0;
  font-weight: 400;
  cursor: pointer;
}
.row-warn td { background: var(--row-warn-bg); }


.vocab-panel { margin-top: 0.75rem; }
.vocab-list { list-style: none; padding: 0; display: grid; gap: 0.4rem; }
.vocab-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr auto;
  gap: 0.35rem;
  align-items: center;
  flex: 1;
}
.vocab-list li {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}
.vocab-list.nested {
  margin: 0.35rem 0 0 1.1rem;
  width: 100%;
  border-left: 2px solid var(--line);
  padding-left: 0.6rem;
}

.hidden { display: none; }
/* 多選 file input 不可 display:none：Android Chrome 會只回傳 1 個檔 */
.lam-sr-file {
  position: absolute;
  width: 8px;
  height: 8px;
  opacity: 0.01;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.inline-form { margin-bottom: 0.85rem; }
.link-card {
  text-decoration: none;
  color: inherit;
  display: block;
}
.link-card:hover { border-color: var(--accent); }
.check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 400;
}
.label-row { font-weight: 600; margin: 0.25rem 0 0.35rem; font-size: var(--fs-sm); }

.tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.45rem;
  margin-bottom: 0.4rem;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--fs-xs);
  cursor: pointer;
}
.tag-chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--pill);
}
.inline-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.3rem;
}
.inline-add input,
.inline-add select {
  flex: 1 1 8rem;
  min-width: 7rem;
}
.inactive { opacity: 0.55; }

.photo-slots { display: grid; gap: 0.55rem; margin: 0.65rem 0; }
.batch-photos-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.35rem 0;
}
.batch-photo-preview-item {
  margin: 0;
  width: 5.5rem;
}
.batch-photo-preview-item img {
  display: block;
  width: 5.5rem;
  height: 5.5rem;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--panel, #f6f4ef);
}
.batch-photo-preview-item figcaption {
  font-size: 0.7rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 5.5rem;
}
.photo-add-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.35rem 0 0.15rem;
}
.photo-add-file-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  cursor: pointer;
}
.photo-add-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
  border: 0;
}
.photo-table {
  display: grid;
  gap: 0.55rem;
  margin: 0.4rem 0 0.75rem;
}
.photo-table-head { display: none; }
/* 左：上傳／預覽區｜右：類型＋說明撐滿（欄位可縮，避免平板橫向撐破外框） */
.photo-table-row,
.photo-slot.photo-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 0.65rem 0.85rem;
  align-items: stretch;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
/* 檔案 input：鋪滿左側上傳區但完全透明 */
.photo-dropzone {
  position: relative;
  width: 100%;
  min-width: 0;
  align-self: stretch;
  cursor: pointer;
  outline: none;
}
.photo-dropzone input.photo-file[type="file"] {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  opacity: 0 !important;
  cursor: pointer !important;
  font-size: 0 !important;
  line-height: 0 !important;
  background: transparent !important;
  z-index: 3;
  color: transparent !important;
}
.photo-dropzone:focus-within .photo-slot-preview,
.photo-dropzone:focus-visible .photo-slot-preview {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.photo-dropzone.is-dragover .photo-slot-preview {
  background: var(--pill);
  border-color: var(--accent);
  border-style: solid;
}
.photo-table-preview,
.photo-slot-preview {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  min-width: 0;
  min-height: 12rem;
  /* 與系統米色／綠灰一致，避免厚重實心藍 */
  background: var(--head);
  background: color-mix(in srgb, var(--head) 70%, var(--pill));
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  text-align: center;
  padding: 0;
  box-sizing: border-box;
  margin: 0;
  border: 1px dashed var(--line);
}
.photo-slot-preview.has-image,
.photo-table-preview:has(img) {
  /* 有圖時：淡綠灰 letterbox，與 accent 同系 */
  background: var(--photo-letterbox);
  border-style: solid;
  border-color: var(--line);
  color: var(--ink);
}
.photo-drop-hint {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  pointer-events: none;
}
.photo-drop-hint strong {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.photo-drop-hint span,
.photo-drop-hint.loading {
  font-size: var(--fs-xs);
  color: var(--muted);
  opacity: 1;
}
.photo-drop-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--ink) 42%, transparent);
  color: var(--on-accent);
  font-size: var(--fs-xs);
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}
.photo-dropzone:hover .photo-drop-overlay,
.photo-dropzone:focus-within .photo-drop-overlay {
  opacity: 1;
}

/* 上傳成功後縮圖留在框內；點圖走燈箱，檔案 input 暫時不攔截 */
.photo-dropzone.has-uploaded input.photo-file {
  pointer-events: none;
  z-index: 0;
}
.photo-dropzone.has-uploaded .photo-slot-preview a[data-lam-lightbox] {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
}
.photo-dropzone.has-uploaded .photo-slot-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.photo-dropzone.has-uploaded .photo-drop-overlay {
  z-index: 1;
  opacity: 0.85;
}
.assay-photo-slot-list,
.smear-photo-slot-list,
.wl-smear-photo[data-lam-photo-slot-list] {
  display: grid;
  gap: 0.55rem;
}
.assay-photo-add-slot {
  justify-self: start;
}

/* 文件庫多檔拖曳匯入 */
.document-dropzone {
  position: relative;
  min-height: 13rem;
  display: grid;
  place-items: center;
  padding: 2rem;
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 5%, var(--panel));
  cursor: pointer;
  text-align: center;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.document-dropzone:hover,
.document-dropzone:focus-visible,
.document-dropzone.is-dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, var(--panel));
  outline: none;
}

.document-dropzone.is-dragover {
  transform: scale(1.005);
}

.document-files-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.document-drop-copy {
  display: grid;
  gap: 0.45rem;
  pointer-events: none;
}

.document-drop-copy strong {
  font-size: 1.05rem;
}

.document-file-list {
  max-height: 14rem;
  margin: 0;
  padding: 0.65rem 0.65rem 0.65rem 2rem;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  background: var(--panel);
}

.document-file-list:empty {
  display: none;
}

.document-file-list li {
  padding: 0.18rem 0;
  overflow-wrap: anywhere;
}
.photo-table-preview a {
  display: block;
  width: 100%;
  height: 100%;
}
.photo-slot-preview img,
.photo-table-preview img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 0;
  display: block;
}
.photo-table-fields {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 0.4rem;
  min-width: 0;
  min-height: 100%;
  height: 100%;
}
.photo-meta-form {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 0.4rem;
  min-height: 100%;
  height: 100%;
}
.photo-field {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr);
  gap: 0.35rem;
  align-items: center;
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 400;
}
.photo-field.stacked {
  grid-template-columns: 1fr;
  gap: 0.2rem;
  align-items: stretch;
}
.photo-field span {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.photo-field input,
.photo-field select,
.photo-field textarea,
.photo-field .lam-combo {
  width: 100%;
  min-width: 0;
}
.photo-field input,
.photo-field select,
.photo-field textarea {
  padding: 0.35rem 0.45rem;
}
.photo-field button.lam-combo-trigger {
  padding: 0.35rem 1.75rem 0.35rem 0.45rem;
}
.photo-caption-grow {
  min-height: 0;
  height: 100%;
}
.photo-caption-grow textarea {
  min-height: 5.5rem;
  height: 100%;
  resize: vertical;
}
.photo-table-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 0;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}
.photo-table-ops .remove-slot,
.photo-ops-btns {
  margin-left: auto;
}
.photo-ops-btns {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}
.photo-save-state.is-ok {
  color: var(--ok, #2f6f4e);
}
.file-name,
.photo-fname {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-xs);
  max-width: 60%;
}
.file-chip.compact {
  padding: 0.65rem 0.35rem;
  font-size: var(--fs-xs);
  word-break: break-all;
}
/* 平板橫向／窄桌機：改直向，避免左右兩欄最小寬度加總溢出 */
@media (max-width: 900px) {
  .photo-table-row,
  .photo-slot.photo-table-row {
    grid-template-columns: 1fr;
  }
  .photo-table-preview,
  .photo-slot-preview {
    width: 100%;
    min-height: 11rem;
  }
  .photo-table-fields,
  .photo-meta-form {
    grid-template-rows: auto auto auto auto;
    height: auto;
  }
  .photo-caption-grow textarea {
    min-height: 4.5rem;
    height: auto;
  }
  .vocab-row { grid-template-columns: 1fr; }
}

/* 寬桌機：相片列不要左右拉太開，預覽＋欄位貼近 */
@media (min-width: 901px) {
  .photo-table-row,
  .photo-slot.photo-table-row {
    grid-template-columns: minmax(0, 22rem) minmax(0, 20rem);
    justify-content: start;
    width: max-content;
    max-width: 100%;
  }
}

.media-card.editable figcaption { display: block; }
.highlight-flag {
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--pill);
  font-size: var(--fs-xs);
}

/* 登入頁字階 */
.brand-hero {
  margin: 0 0 0.45rem;
  font-family: var(--font-mono);
  font-size: var(--fs-display);
  letter-spacing: 0.14em;
  color: var(--ink);
  font-weight: 600;
  line-height: 1.1;
}
.login-title {
  font-size: 1.05rem !important;
  font-weight: 500 !important;
  color: var(--muted) !important;
  letter-spacing: 0.01em !important;
  margin: 0 0 0.55rem !important;
}
.login-qr {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin: 1rem 0 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.login-qr-img {
  width: 168px;
  height: 168px;
  flex-shrink: 0;
  image-rendering: pixelated;
  border-radius: 4px;
  background: #fff;
}
.login-qr-copy {
  min-width: 0;
}
.login-qr-title {
  margin: 0 0 0.35rem;
  font-size: var(--fs-sm);
  font-weight: 700;
}
.login-qr-url {
  word-break: break-all;
  margin: 0.4rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
@media (max-width: 520px) {
  .login-qr {
    flex-direction: column;
    align-items: flex-start;
  }
}
.login-hint {
  margin-top: 0.85rem;
}
.pill.role-admin { background: var(--role-admin); }
.pill.role-teacher { background: var(--role-teacher); }
.pill.role-staff { background: var(--role-staff); }
.user-edit-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 1rem;
  margin: 0 0 0.65rem;
}
.narrow h1 {
  font-size: 1.25rem;
  letter-spacing: -0.015em;
}
.narrow code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--head);
  padding: 0.05rem 0.25rem;
  border-radius: var(--radius-sm);
}


/* 摺疊區塊（紀錄、教師標記） */
details.panel.fold > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
  color: var(--ink);
}
details.panel.fold > summary::-webkit-details-marker { display: none; }
details.panel.fold > summary::before {
  content: "▸ ";
  font-family: var(--font-mono);
  color: var(--muted);
  font-weight: 500;
}
details.panel.fold[open] > summary::before { content: "▾ "; }
details.panel.fold .fold-body { margin-top: 0.55rem; }
details.panel.fold + details.panel.fold { margin-top: 0.75rem; }
.teacher-marks .ops-more-body,
details.panel.fold .ops-more-body { margin-top: 0.45rem; }

/* 快速新增：modal，不插入表單欄位中間 */
.lam-quick-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, var(--safe-top)) 1rem max(1rem, var(--safe-bottom));
}
.lam-quick-modal.hidden,
.lam-quick-modal[hidden] {
  display: none !important;
}
.lam-quick-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: var(--overlay);
  cursor: pointer;
}
.lam-quick-modal-card {
  position: relative;
  z-index: 1;
  width: min(28rem, 100%);
  max-height: min(90vh, 36rem);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1rem 1.05rem;
  box-shadow: 0 6px 20px var(--shadow);
}
html.lam-quick-open {
  overflow: hidden;
}
/* 文字按鈕（快速新增等） */
.btn-text {
  display: inline;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.btn-text:hover {
  color: var(--ink);
}

/* 可搜尋／可快速新增的下拉 */
.lam-combo {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
}
.filters .lam-combo {
  width: auto;
  min-width: 10rem;
  flex: 0 1 auto;
}
.vocab-row .lam-combo {
  min-width: 7.5rem;
  width: auto;
  flex: 0 1 10rem;
}
.inline-add .lam-combo {
  width: auto;
  min-width: 7rem;
  display: inline-block;
  vertical-align: middle;
}
.lam-combo-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
/* button.lam-combo-* 提高 specificity，避免被全域 button 預設蓋掉（不再靠 !important） */
button.lam-combo-trigger {
  width: 100%;
  text-align: left;
  background: var(--input-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem 1.75rem 0.4rem 0.55rem;
  font: inherit;
  font-size: inherit;
  font-weight: 400;
  line-height: 1.35;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
button.lam-combo-trigger::after {
  content: "";
  position: absolute;
  right: 0.55rem;
  top: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.lam-combo.is-open button.lam-combo-trigger {
  border-color: var(--accent);
  outline: 2px solid var(--focus-ring);
}
button.lam-combo-trigger.is-placeholder { color: var(--muted); }
button.lam-combo-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* 選項彈窗：與 .lam-quick-modal 同殼，卡片內為可捲清單 */
.lam-picker.lam-quick-modal {
  z-index: 920;
}
.lam-picker-card {
  display: flex;
  flex-direction: column;
  width: min(28rem, 100%);
  max-height: min(85vh, 32rem);
  padding: 0 !important;
  overflow: hidden !important;
}
.lam-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--head);
  flex: 0 0 auto;
}
.lam-picker-title {
  margin: 0;
  font-size: var(--fs);
  font-weight: 600;
}
.lam-picker .lam-combo-search-wrap {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: 0 0 auto;
}
.lam-picker .lam-combo-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overscroll-behavior: contain;
}
.lam-picker button.lam-combo-option {
  min-height: var(--touch-min);
  padding: 0.55rem 0.9rem;
  font-size: var(--fs);
}
.lam-picker .lam-combo-add {
  border-top: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
  background: var(--surface-muted);
  flex: 0 0 auto;
}
.lam-picker .lam-combo-empty {
  padding: 0.85rem 0.9rem;
}
html.lam-picker-open,
html.lam-quick-open {
  overflow: hidden;
}

.lam-combo-search-wrap {
  padding: 0.35rem;
  border-bottom: 1px solid var(--line);
  background: var(--head);
  flex: 0 0 auto;
}
.lam-combo-search {
  width: 100%;
  font-size: var(--fs-sm);
  padding: 0.3rem 0.45rem;
}
.lam-combo-list {
  list-style: none;
  margin: 0;
  padding: 0.2rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 12rem;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.lam-combo-row {
  display: flex;
  align-items: stretch;
  gap: 0;
}
button.lam-combo-option {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 0;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 400;
  cursor: pointer;
}
.lam-combo-row:hover button.lam-combo-option,
button.lam-combo-option:hover,
button.lam-combo-option:focus,
button.lam-combo-option.is-active {
  background: var(--accent-soft);
}
button.lam-combo-option.is-selected {
  background: var(--accent-soft-2);
  font-weight: 500;
}
button.lam-combo-option.is-selected.is-active {
  background: var(--accent-soft-3);
}
button.lam-combo-remove {
  flex: 0 0 auto;
  width: 1.7rem;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--combo-disabled-ink);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}
button.lam-combo-remove:hover,
button.lam-combo-remove:focus {
  color: var(--combo-placeholder-ink);
  background: var(--ghost-hover);
  opacity: 1;
}
.lam-combo-empty {
  padding: 0.5rem 0.65rem;
  color: var(--muted);
  font-size: var(--fs-xs);
}
.lam-combo-add {
  border-top: 1px solid var(--line);
  padding: 0.25rem;
  background: var(--surface-muted);
}
button.lam-combo-add-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--accent);
  border: 0;
  font-weight: 500;
  font-size: var(--fs-sm);
  padding: 0.35rem 0.5rem;
}
button.lam-combo-add-btn:hover { background: var(--accent-soft); }
.lam-combo-add-form {
  display: grid;
  gap: 0.3rem;
  padding: 0.25rem 0.3rem 0.35rem;
}
.lam-combo-add-input {
  width: 100%;
  font-size: var(--fs-sm);
  padding: 0.3rem 0.45rem;
}
.lam-combo-add-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}
.lam-combo-add-actions button.btn-sm,
.lam-combo-add-actions button {
  font-size: var(--fs-xs);
  padding: 0.2rem 0.45rem;
}

/* —— 表單分層 —— */
.form-section {
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem 0 0.25rem;
  border-top: 1px solid var(--line);
  margin-top: 0.35rem;
}
.form-section.is-collapsed {
  display: none;
}

.farmer-master-summary {
  margin: 0.5rem 0 0.75rem;
  padding: 0.5rem 0.65rem;
  border-left: 3px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
}

.farmer-master-summary .kv {
  margin-top: 0.35rem;
  font-size: 0.92em;
}

.farmer-master-on-case {
  margin-top: 0.4rem;
}
.form-section:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.form-section > h2 {
  margin: 0;
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.form-hint details {
  margin: 0 0 0.55rem;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.form-hint summary {
  cursor: pointer;
  list-style: none;
  font-weight: 500;
  color: var(--muted);
  user-select: none;
}
.form-hint summary::-webkit-details-marker { display: none; }
.form-hint summary::before { content: "▸ "; font-family: var(--font-mono); }
.form-hint[open] summary::before { content: "▾ "; }
.form-hint summary:hover { color: var(--ink); }
.form-hint .hint-body {
  margin-top: 0.35rem;
  line-height: 1.5;
}
.form-actions-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.form-actions-bar .btn,
.form-actions-bar button {
  min-height: var(--touch-min);
}

/* —— 篩選 chips —— */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.65rem;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.85rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  text-decoration: none;
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.filter-chip:hover {
  color: var(--ink);
  border-color: var(--accent);
}
.filter-chip.is-active {
  color: var(--ink);
  border-color: var(--accent);
  background: var(--pill);
  font-weight: 600;
}
.filter-chip.is-active.status-draft { background: var(--status-draft); }
.filter-chip.is-active.status-received { background: var(--status-draft); }
.filter-chip.is-active.status-testing { background: var(--status-testing); }
.filter-chip.is-active.status-pending_seq { background: var(--status-pending); }
.filter-chip.is-active.status-closed { background: var(--status-pending); }
.filter-chip.is-active.status-archived { background: var(--status-archived); }

/* —— 可點整列 —— */
.table tbody tr.is-row-link { cursor: pointer; }
.table tbody tr.is-row-link:focus-visible {
  outline: 2px solid var(--focus-ring-strong);
  outline-offset: -2px;
}
.table th.col-code,
.table td.col-code {
  min-width: 7.5rem;
  width: 7.5rem;
}

/* —— 手機導覽與全域適配 —— */
@media (max-width: 720px) {
  /* 併排選項方塊高度對齊原本 .btn 列，不再拉成大方格 */
  body { --opt-tile-h: 2.15rem; }
  /* 防止表單／網格 min-width 把整頁撐出橫向捲動 */
  html, body {
    overflow-x: clip;
  }
  .wrap,
  .panel,
  .filters,
  .toolbar,
  .case-find,
  .case-find-form,
  .case-find-shell,
  .stats-filters,
  .home-toolbar,
  .lam-media-board,
  .lam-media-section,
  .lam-media-grid {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .filters .lam-combo,
  .vocab-row .lam-combo,
  .inline-add .lam-combo {
    min-width: 0 !important;
    max-width: 100%;
  }
  .bulk-export-cols-body {
    min-width: 0;
    width: 100%;
  }
  .consistency-banner .inline-form input {
    min-width: 0;
    flex: 1 1 100%;
  }
  .stats-field {
    min-width: 0;
    flex: 1 1 calc(50% - 0.35rem);
    max-width: 100%;
  }
  .stats-year {
    min-width: 0;
    max-width: none;
    flex: 1 1 calc(50% - 0.35rem);
  }
  .wrap {
    width: min(100%, calc(100% - 1rem));
    margin: 0.75rem auto calc(2rem + var(--safe-bottom));
  }
  h1 { font-size: 1.35rem; }
  .case-head h1 { font-size: 1.25rem; }

  .nav-toggle { display: inline-flex; }
  .top {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.35rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  .top-brand-row {
    flex: 1;
    justify-content: space-between;
    width: 100%;
  }
  .top nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    padding: 0.35rem 0 0.55rem;
    border-top: 1px solid var(--line);
    margin-top: 0.15rem;
  }
  .top.is-nav-open nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem;
  }
  .top-nav-primary {
    display: contents;
  }
  .top-nav-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem;
    grid-column: 1 / -1;
    margin: 0.15rem 0 0;
    padding: 0.45rem 0 0;
    border: none;
    border-top: 1px dashed var(--line);
  }
  .top-nav-meta .who {
    grid-column: 1 / -1;
  }
  .top-nav-meta .chrome-toggles-nav {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
    margin: 0;
    padding: 0;
    min-height: 0;
  }
  .top nav > a,
  .top-nav-primary > a {
    padding: 0.25rem 0.4rem;
    min-height: var(--opt-tile-h);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    font-size: var(--fs-sm);
  }
  .top nav > a:hover {
    border-bottom-color: var(--line);
    background: var(--head);
  }
  .who {
    padding: 0.45rem 0.35rem 0.2rem;
    font-size: var(--fs-sm);
  }
  .top-nav-meta > a.btn,
  .top .inline,
  .top .inline button {
    width: 100%;
    min-height: var(--opt-tile-h);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    padding: 0.25rem 0.4rem !important;
    font-size: var(--fs-sm) !important;
    font-weight: 500;
    border-color: var(--line);
    background: var(--head);
    color: var(--ink);
    border-radius: var(--radius);
  }
  .top-nav-meta > a.btn {
    background: var(--surface);
  }
  .chrome-toggles-fixed {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    top: max(0.55rem, var(--safe-top));
    right: calc(0.75rem + var(--touch-min) + 0.35rem);
  }
  .chrome-toggles-fixed .chrome-toggle-label,
  .chrome-toggles-fixed .theme-toggle-label {
    display: none;
  }
  .chrome-toggles-fixed .chrome-toggle {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
  }
  .chrome-toggles-fixed .chrome-toggle > svg {
    width: 1.1rem;
    height: 1.1rem;
  }
  .chrome-toggles-nav {
    display: none !important;
  }
  body:not(:has(#lam-nav)) .theme-toggle-fixed,
  body:not(:has(#lam-nav)) .chrome-toggles-fixed {
    display: grid;
    grid-template-columns: repeat(2, minmax(4.5rem, 1fr));
    gap: 0.4rem;
    width: auto;
    height: auto;
    padding: 0;
    right: max(0.9rem, env(safe-area-inset-right, 0px));
  }
  body:not(:has(#lam-nav)) .chrome-toggles-fixed .locale-switch,
  body:not(:has(#lam-nav)) .chrome-toggles-fixed .theme-toggle {
    width: 100%;
  }
  body:not(:has(#lam-nav)) .chrome-toggles-fixed .chrome-toggle {
    width: 100%;
    min-width: 0;
    min-height: 3.15rem;
    height: 100%;
    padding: 0.45rem 0.35rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.2rem;
    box-sizing: border-box;
  }
  body:not(:has(#lam-nav)) .chrome-toggles-fixed .chrome-toggle-label {
    display: block;
    text-align: center;
    line-height: 1.2;
    font-size: var(--fs-sm);
    font-weight: 500;
  }
  .chrome-toggles-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-self: stretch;
    align-items: stretch;
    width: 100%;
    height: auto;
    min-height: 0;
    justify-content: stretch;
    margin: 0;
    padding: 0;
    gap: 0.4rem;
  }
  .theme-toggle-nav {
    display: flex;
  }
  .chrome-toggles-nav .locale-switch,
  .chrome-toggles-nav .theme-toggle-nav {
    width: 100%;
    margin: 0;
    min-height: 3.15rem;
    align-self: stretch;
  }
  button.theme-toggle-nav,
  .locale-switch-nav > summary.chrome-toggle {
    width: 100%;
    height: 100%;
    min-height: 3.15rem;
    padding: 0.45rem 0.35rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.2rem;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-sizing: border-box;
  }
  .theme-toggle-nav .theme-toggle-label,
  .chrome-toggles-nav .chrome-toggle-label,
  .chrome-toggles-nav .theme-toggle-label {
    display: block;
    text-align: center;
    line-height: 1.2;
    font-size: var(--fs-sm);
    font-weight: 500;
  }
  .chrome-toggles-nav .chrome-toggle > svg,
  .chrome-toggles-nav .theme-toggle > svg,
  body:not(:has(#lam-nav)) .chrome-toggles-fixed .chrome-toggle > svg {
    width: 1.1rem;
    height: 1.1rem;
  }
  .locale-switch-nav .locale-menu {
    right: auto;
    left: 0;
    min-width: 100%;
  }

  .toolbar {
    align-items: flex-start;
    gap: 0.65rem;
  }
  .toolbar .actions,
  .toolbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5.2rem, 1fr));
    gap: 0.3rem;
    justify-content: stretch;
  }
  .toolbar .actions .btn,
  .toolbar-actions .btn {
    flex: unset;
    width: 100%;
    min-height: var(--opt-tile-h);
    padding: 0.25rem 0.45rem;
    text-align: center;
    white-space: normal;
    line-height: 1.25;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .filters {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.45rem;
  }
  .filters input[type="search"],
  .filters select,
  .filters .lam-combo {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }
  .filters button,
  .filters .btn {
    width: auto;
    min-width: 0;
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 3.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .filter-chips {
    gap: 0.4rem;
  }
  .filter-chip {
    min-height: var(--touch-min);
    padding: 0.35rem 0.7rem;
    font-size: var(--fs-sm);
  }

  .case-ops-status-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .status-rail {
    width: 100%;
  }
  .status-rail li {
    flex: 1 1 auto;
    text-align: center;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .grid-2 { grid-template-columns: 1fr; }
  .kv {
    grid-template-columns: 1fr;
    gap: 0.1rem 0;
  }
  .kv dt { margin-top: 0.35rem; }
  .kv dt:first-child { margin-top: 0; }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.5rem), 1fr));
  }
  .media-grid.lam-media-grid,
  .lam-media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .narrow {
    max-width: none;
    margin: 1.25rem auto;
    padding: 1rem 0.9rem;
  }
  .brand-hero { font-size: 2rem; }
  .narrow button[type="submit"] {
    width: 100%;
    min-height: var(--touch-min);
  }

  .form-actions-bar {
    position: sticky;
    bottom: 0;
    z-index: 40;
    margin-left: -0.95rem;
    margin-right: -0.95rem;
    margin-bottom: calc(-0.85rem);
    padding: 0.75rem 0.95rem calc(0.75rem + var(--safe-bottom));
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  .form-actions-bar .btn,
  .form-actions-bar button[type="submit"] {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }
  .form-actions-bar .btn.ghost {
    flex: 0 0 auto;
  }

  .lam-prompt {
    align-items: end;
    padding: 0;
  }
  .lam-prompt-card {
    width: 100%;
    max-width: none;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1rem 1rem calc(1rem + var(--safe-bottom));
    transform: translateY(8px) scale(1);
  }
  .lam-prompt.is-open .lam-prompt-card {
    transform: translateY(0) scale(1);
  }
  .lam-prompt.is-closing .lam-prompt-card {
    transform: translateY(12px) scale(1);
  }

  .lam-combo-panel {
    max-height: min(16rem, 55vh);
  }
  button.lam-combo-option,
  button.lam-combo-trigger {
    min-height: var(--touch-min);
  }

  .panel, .filters {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .foot {
    padding-bottom: calc(1rem + var(--safe-bottom));
  }
}

@media (max-width: 420px) {
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .media-grid.lam-media-grid,
  .lam-media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (hover: hover) and (pointer: fine) {
  .filter-chip:hover { background: var(--head); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  button:active, .btn:active, .is-pressed { transform: none; }
  .lam-prompt-card,
  .lam-combo-panel {
    transform: none !important;
  }
}

.panel-spaced { margin-top: 0.75rem; }

.media-section {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
  margin-top: 0.35rem;
}
.media-section > summary,
.form-fold > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0.45rem;
}
.media-section > summary::-webkit-details-marker,
.form-fold > summary::-webkit-details-marker { display: none; }
.media-section > summary h2,
.form-fold > summary h2 {
  display: inline;
  margin: 0;
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.media-section > summary::before,
.form-fold > summary::before {
  content: "▸ ";
  font-family: var(--font-mono);
  color: var(--muted);
}
.media-section[open] > summary::before,
.form-fold[open] > summary::before { content: "▾ "; }
.media-section > summary:hover h2,
.form-fold > summary:hover h2 { color: var(--ink); }

/* 收摺疊的次要欄位群；summary 標示已填筆數，避免收起後看不見既有資料 */
.form-fold {
  display: grid;
  gap: 0.65rem;
}
/* details 會被 .form-section:first-of-type 誤判為區段開頭，這裡把分隔線補回 */
.form-fold.form-section {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
  margin-top: 0.35rem;
}
.form-fold.nested-fold {
  border-top: 1px dashed var(--line);
  padding-top: 0.6rem;
  margin-top: 0.15rem;
}
.fold-count {
  margin-left: 0.4rem;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  color: var(--accent);
}
.fold-count.muted { color: var(--muted); }

.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}
.danger-zone > h2 { color: var(--danger); }
.delete-batch-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
}

@media (max-width: 720px) {
  .case-ops-primary .btn,
  .case-ops-primary button,
  .ops-more-body .btn,
  .ops-more-body button,
  .case-ops-actions .btn,
  .case-ops-actions button {
    width: 100%;
    min-height: var(--opt-tile-h);
    padding: 0.25rem 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal;
    line-height: 1.25;
  }
}

/* —— 功能預覽試用（藥敏／生化／報告） —— */
.preview-cards {
  display: grid;
  gap: 0.85rem;
  margin: 1rem 0 1.25rem;
}
@media (min-width: 720px) {
  .preview-cards { grid-template-columns: repeat(3, 1fr); }
}
.preview-card {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  text-decoration: none;
}
.preview-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}
.preview-card p {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.preview-card:hover { border-color: var(--accent); }

.ast-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  margin-bottom: 1rem;
}
.ast-isolate { margin: 1.25rem 0; }
.ast-isolate h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}
.ast-grid-scroll {
  max-width: 100%;
  /* 僅必要時橫向溢出；不要設 max-height，避免手機多一層內捲 */
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}
.ast-grid {
  display: grid;
  gap: 0;
  min-width: 0;
  width: max-content;
  max-width: 100%; /* 桌機貼齊藥名與 mm，不要拉滿整列 */
}
.ast-grid-head,
.ast-grid-row {
  display: grid;
  /* 藥物｜mm｜判讀｜顯示 — 藥物欄適中，其餘固定，縮短左右距離 */
  grid-template-columns: minmax(7.5rem, 1fr) 4.25rem 2.5rem 2.5rem;
  gap: 0.3rem 0.4rem;
  align-items: center;
  padding: 0.35rem 0.15rem;
}
.ast-grid-head {
  font-size: var(--fs-sm);
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
}
.ast-grid-row {
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.ast-grid-row:last-child {
  border-bottom: 0;
}
.ast-drug {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.ast-drug-name {
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 0.92rem;
  line-height: 1.25;
}
.ast-disk {
  font-family: var(--font-mono);
}
.ast-mm {
  width: 100%;
  max-width: 4.25rem;
  min-height: 2.4rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  box-sizing: border-box;
}
.ast-sir,
.ast-mark {
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: center;
  font-size: 0.95rem;
}
.sir-S { color: var(--sir-s); }
.sir-I { color: var(--sir-i); }
.sir-R { color: var(--sir-r); }
.sir-none { color: var(--muted); }
.ast-add-drug {
  margin: 0.6rem 0 0;
}
.ast-add-drug select {
  max-width: 22rem;
}
.ast-grid-row[data-extra="1"] .ast-disk::after {
  content: "例外";
  margin-left: 0.35rem;
  font-family: inherit;
  font-weight: 400;
  color: var(--muted);
}
@media (max-width: 420px) {
  .ast-grid-head,
  .ast-grid-row {
    grid-template-columns: minmax(0, 1fr) 3.6rem 2.2rem 2.2rem;
    gap: 0.3rem;
  }
  .ast-grid {
    max-width: none;
  }
  .ast-drug-name { font-size: 0.85rem; }
  .ast-col-mark,
  .ast-mark { font-size: 0.8rem; }
  .ast-mm {
    max-width: 3.6rem;
    min-height: 2.6rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }
}

@media (min-width: 721px) {
  .ast-grid {
    max-width: min(28rem, 100%);
  }
  .ast-grid-head,
  .ast-grid-row {
    grid-template-columns: minmax(8.5rem, 12rem) 4.25rem 2.5rem 2.5rem;
    gap: 0.3rem 0.45rem;
  }
  .ast-mm {
    max-width: 4.25rem;
  }
}

.ast-report {
  max-width: 52rem;
  margin: 0 auto 2rem;
  padding: 1.25rem 1.1rem 2rem;
  border: 1px solid var(--line);
  background: #fff;
  color: #111;
}
html[data-theme="dark"] .ast-report {
  background: var(--surface);
  color: var(--ink);
}
.ast-report-org { margin: 0; text-align: center; }
.ast-report-title {
  margin: 0.35rem 0 1rem;
  text-align: center;
  font-size: 1.25rem;
}
.ast-report-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1rem;
}
.ast-report-meta div { display: flex; gap: 0.5rem; }
.ast-report-meta dt { color: var(--muted); min-width: 4.5rem; }
.ast-report-meta dd { margin: 0; font-weight: 600; }
.ast-report h2 {
  margin: 1rem 0 0.4rem;
  font-size: 1rem;
}
.ast-report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.ast-report-table th,
.ast-report-table td {
  border: 1px solid #ccc;
  padding: 0.35rem 0.45rem;
  vertical-align: top;
}
.ast-report-table .num { text-align: right; font-family: var(--font-mono); }
.ast-report-note { font-size: 0.82rem; color: #444; margin-top: 0.75rem; }
.ast-report-foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  font-size: 0.92rem;
}

/* 報告字型：標題標楷體、正文新細明體、西文 Times（與 Word／PDF 同一套） */
.case-clinical-report,
.lab-record-en {
  --report-font-title: "標楷體", "DFKai-SB", "TW-Kai", "Noto Serif CJK TC", serif;
  --report-font: "Times New Roman", "新細明體", "PMingLiU",
    "Noto Serif CJK TC", "Noto Serif TC", serif;
  font-family: var(--report-font);
  max-width: 52rem;
  margin: 0 auto 2rem;
  padding: 1.25rem 1.1rem 2rem;
  border: 1px solid var(--line);
  background: #fff;
  color: #111;
  line-height: 1.55;
}
.ccr-head,
.lre-head { text-align: center; margin-bottom: 1rem; }
.ccr-org,
.lre-org { margin: 0; font-size: 0.95rem; }
.ccr-title,
.lre-title {
  margin: 0.4rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  font-family: var(--report-font-title);
}
.ccr-meta,
.ccr-water,
.lre-meta,
.lre-water,
.lre-iso {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin-bottom: 0.85rem;
}
.ccr-meta th,
.ccr-meta td,
.ccr-water th,
.ccr-water td,
.lre-meta th,
.lre-meta td,
.lre-water th,
.lre-water td,
.lre-iso th,
.lre-iso td {
  border: 1px solid #bbb;
  padding: 0.3rem 0.45rem;
  vertical-align: top;
}
.ccr-meta th,
.ccr-water th,
.lre-meta th,
.lre-water th,
.lre-iso th {
  background: #f4f4f4;
  font-weight: 600;
  white-space: nowrap;
  width: 7.5rem;
}
.ccr-block,
.lre-block { margin: 1.1rem 0; }
.ccr-block h2,
.lre-block h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-family: var(--report-font-title);
  border-bottom: 1px solid #ccc;
  padding-bottom: 0.15rem;
}
.lre-block h3 {
  margin: 0.6rem 0 0.25rem;
  font-size: 0.95rem;
}
.ccr-prose,
.lre-prose {
  white-space: pre-wrap;
  margin: 0.25rem 0;
}
.ccr-emphasis,
.lre-emphasis { font-weight: 600; }
.ccr-fig-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 0.5rem 0 0.75rem;
}
.ccr-fig-table td {
  width: 50%;
  vertical-align: top;
  text-align: center;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
}
.ccr-fig-table td.fig-empty {
  border-style: dashed;
  background: transparent;
}
.ccr-fig-table img {
  display: block;
  max-width: 100%;
  max-height: 14rem;
  margin: 0 auto;
  object-fit: contain;
  background: #f0f0f0;
}
.ccr-fig-table .fig-cap {
  margin: 0.35rem 0 0;
  font-size: var(--fs-sm, 0.85rem);
  text-align: left;
  line-height: 1.35;
}
.ccr-banner {
  text-align: center;
  font-size: 1.15rem;
  margin: 1.5rem 0 0.75rem;
  border: none;
}
.ccr-morph { margin: 0.4rem 0 0; }
.clinic-check {
  display: inline-block;
  margin: 0 0.7em 0.15em 0;
  white-space: nowrap;
  vertical-align: middle;
}
.clinic-box {
  display: inline-block;
  width: 0.72em;
  height: 0.72em;
  margin-right: 0.28em;
  border: 1.35px solid #111;
  vertical-align: -0.08em;
  background: #fff;
  box-sizing: border-box;
  position: relative;
}
.clinic-check.is-on .clinic-box {
  background: #111;
  box-shadow: inset 0 0 0 1.6px #fff;
}
.clinic-page2 { margin-top: 1.5rem; }
.clinic-ast th, .clinic-ast td { text-align: center; font-size: 0.85rem; }
.lre-sign { margin-top: 1.25rem; }

.export-hub h2 { margin-top: 0; margin-bottom: 0.25rem; font-size: 1.05rem; }
.export-hub-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.export-hub-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border, #ddd);
}
.export-hub-card:last-of-type { border-bottom: 0; }
.export-hub-card-body { flex: 1 1 12rem; min-width: 0; }
.export-hub-card-body .muted { margin: 0.2rem 0 0; }
.export-hub-card > .btn { flex: 0 0 auto; }
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.45rem 0 0.9rem;
  align-items: center;
}
.export-download-bar {
  margin: 0 0 0.55rem;
  padding: 0;
  border-top: 0;
}
.export-download-bar .export-actions { margin: 0; }
.export-download-primary {
  gap: 0.45rem;
}
.export-download-primary .btn {
  min-height: 2.25rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  flex: 0 0 auto;
}
.export-more-details,
.export-compact-details {
  margin: 0.3rem 0 0;
}
.export-more-details > summary,
.export-compact-details > summary {
  cursor: pointer;
  user-select: none;
  padding: 0.3rem 0;
  font-size: 0.92rem;
}
.export-more-details .export-actions,
.export-compact-details .export-actions {
  margin-top: 0.35rem;
  gap: 0.45rem;
}
.export-more-details .btn,
.export-compact-details .btn {
  min-height: 2.15rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.92rem;
}
.export-note { margin-top: 1.25rem; }

.export-studio-toolbar {
  margin-bottom: 0.75rem;
}
.export-studio-toolbar .export-actions {
  margin: 0;
  align-items: center;
}
.export-studio-toolbar-meta {
  margin: 0.2rem 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}
.export-studio-catalog {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  position: sticky;
  top: 0.5rem;
  align-self: start;
}
.export-studio-layout-dock {
  margin-top: 0.15rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line, #d5d5d0);
  flex: 0 0 auto;
}
.export-studio-layout-actions {
  margin: 0 !important;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.export-studio-layout-actions .btn {
  min-height: 2.25rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  flex: 0 0 auto;
  width: auto;
}
.export-studio-layout-meta {
  margin: 0.35rem 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}
.export-studio-layout-dock button.linkish,
.export-studio-toolbar button.linkish {
  border: 0;
  background: transparent;
  color: var(--muted, #666);
  cursor: pointer;
  padding: 0.25rem 0.15rem;
  font: inherit;
  font-size: 0.92rem;
  text-decoration: underline;
}
@media (max-width: 640px) {
  .export-download-primary .btn,
  .export-studio-layout-actions .btn {
    min-height: 2.4rem;
    font-size: 0.98rem;
  }
}
.export-studio-grid {
  display: grid;
  grid-template-columns: minmax(13rem, 16rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.export-studio-catalog-hint {
  margin: 0;
}
.export-studio-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line, #d5d5d0);
  border-radius: 2px;
  background: var(--surface);
  max-height: min(22rem, 48vh);
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 0 1 auto;
}
.export-studio-item {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.4rem 0.45rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line, #ddd) 65%, transparent);
  cursor: grab;
  background: var(--surface);
}
.export-studio-item:last-child { border-bottom: none; }
.export-studio-item.is-dragging { opacity: 0.55; }
.export-studio-item.is-hidden-section {
  background: color-mix(in srgb, var(--head, #f3f1ea) 80%, #fff);
  opacity: 0.75;
}
.export-studio-item.is-banner .export-studio-label { font-style: italic; }
.export-studio-handle {
  flex: 0 0 auto;
  color: var(--muted);
  line-height: 1.4;
  user-select: none;
}
.export-studio-check {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.export-studio-check input {
  margin-top: 0.12rem;
  flex: 0 0 auto;
}
.export-studio-label {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.35rem;
  align-items: center;
  line-height: 1.35;
}
.export-studio-preview .case-clinical-report { margin-top: 0; }
.export-studio-preview [data-preview-section][hidden] { display: none !important; }

@media (max-width: 880px) {
  .export-studio.panel {
    padding: 0.55rem 0.65rem 0.85rem;
  }
  .export-studio-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
  .export-studio-catalog {
    position: static;
  }
  .export-studio-list {
    max-height: 11rem;
  }
  .export-studio-layout-dock {
    margin-top: 0.15rem;
  }
  .export-studio-preview .case-clinical-report {
    padding: 0.55rem 0.55rem 0.75rem;
    font-size: 0.88rem;
  }
  .export-studio-preview .ccr-title { font-size: 1rem; }
  .export-studio-preview .ccr-meta,
  .export-studio-preview .ccr-water {
    font-size: 0.78rem;
    width: 100%;
  }
  .export-studio-preview .ccr-meta tr,
  .export-studio-preview .ccr-water tr {
    display: grid;
    grid-template-columns: 5.2rem minmax(0, 1fr);
    gap: 0.12rem 0.45rem;
    margin-bottom: 0.4rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid color-mix(in srgb, var(--line, #ddd) 70%, transparent);
  }
  .export-studio-preview .ccr-meta th,
  .export-studio-preview .ccr-meta td,
  .export-studio-preview .ccr-water th,
  .export-studio-preview .ccr-water td {
    display: block;
    width: auto;
    border: none;
    padding: 0;
    background: transparent;
  }
  .export-studio-preview .ccr-meta th,
  .export-studio-preview .ccr-water th {
    color: var(--muted, #666);
    font-weight: 600;
  }
  .export-studio-preview .ccr-meta td,
  .export-studio-preview .ccr-water td {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .export-studio-preview .ccr-block h2,
  .export-studio-preview .ccr-banner {
    font-size: 0.92rem;
    margin: 0.55rem 0 0.28rem;
  }
}

@media print {
  .case-clinical-report,
  .lab-record-en {
    border: none;
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }
  .ccr-meta,
  .ccr-water,
  .lre-meta,
  .lre-water,
  .lre-iso {
    page-break-inside: avoid;
    table-layout: fixed;
    width: 100%;
  }
  .ccr-meta th,
  .ccr-meta td,
  .ccr-water th,
  .ccr-water td,
  .lre-meta th,
  .lre-meta td,
  .lre-water th,
  .lre-water td,
  .lre-iso th,
  .lre-iso td {
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
  }
  .ccr-block,
  .lre-block {
    page-break-inside: auto;
  }
  .ccr-block h2,
  .lre-block h2 {
    page-break-after: avoid;
  }
  .ccr-fig-table tr {
    page-break-inside: avoid;
  }
  .ccr-prose,
  .lre-prose {
    overflow-wrap: anywhere;
  }
  @page {
    size: A4;
    margin: 14mm 12mm;
  }
}


.biochem-mobile {
  max-width: 28rem;
  margin: 0 auto 2rem;
  display: grid;
  gap: 1rem;
}
.biochem-row h2 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
}
.biochem-keys {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
}
.biochem-key {
  min-width: 0;
  min-height: 3rem;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
  padding: 0.25rem 0.15rem;
}
.biochem-key.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}
.biochem-status { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 匯入預覽：略過列 — 主題危險色叉，非 emoji */
.import-rows .col-omit {
  width: 2.4rem;
  text-align: center;
  vertical-align: middle;
}
.row-omit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  margin: 0;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  background: color-mix(in srgb, var(--danger) 6%, var(--surface));
  color: var(--danger);
  position: relative;
}
.row-omit:hover {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
}
.row-omit-input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.row-omit-mark {
  display: flex;
  pointer-events: none;
  opacity: 0.35;
}
.row-omit-input:checked + .row-omit-mark {
  opacity: 1;
}
.row-omit-input:focus-visible + .row-omit-mark {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.import-rows tr.is-skipped td,
.import-rows tr:has(.row-omit-input:checked) td {
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--danger) 50%, transparent);
}
.import-rows tr.is-skipped .col-omit,
.import-rows tr:has(.row-omit-input:checked) .col-omit {
  text-decoration: none;
  opacity: 1;
}
.vocab-row-wide {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.vocab-row-wide input,
.vocab-row-wide select {
  min-width: 5.5rem;
}
.species-ref-hint {
  flex: 1 0 100%;
  margin: 0.15rem 0 0.4rem;
  line-height: 1.45;
}
.species-ref-banner {
  border: 1px solid var(--line);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
}
.species-ref-meta {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0.75rem 0 1rem;
}
.species-ref-meta dt {
  color: var(--muted);
  font-weight: 500;
}
.warn {
  color: var(--ink);
  background: var(--warn-bg);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--warn-line);
  font-size: var(--fs-sm);
}

.case-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0.75rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
}
.case-tabs a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 0.15rem 0;
}
.case-tabs a.is-active {
  color: var(--text);
  border-bottom: 2px solid var(--accent);
}
@media (max-width: 720px) {
  .case-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0;
    border-bottom: none;
    background: transparent;
  }
  .case-tabs a {
    min-height: var(--opt-tile-h);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.35rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: 600;
    box-shadow: none;
  }
  .case-tabs a.is-active {
    border-color: var(--accent);
    border-bottom: 1px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    color: var(--text);
    box-shadow: none;
  }
}
.assay-layers {
  position: sticky;
  top: 3.15rem;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin: 0 0 0.85rem;
  padding: 0.4rem 0;
  background: var(--bg);
  border-bottom: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
}
.assay-layer-chip {
  appearance: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.25rem 0.65rem;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  min-height: 2.1rem;
  cursor: pointer;
}
.assay-layer-chip.is-active {
  border-color: var(--accent);
  background: var(--pill);
  color: var(--text);
}
.assay-layer-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius);
  font-size: 0.75em;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--text);
  vertical-align: middle;
}
.assay-layer-chip.is-active .assay-layer-badge {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}
.pill.soft {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: transparent;
  font-weight: 600;
}
.assay-layer-add-iso {
  display: inline;
  margin: 0;
}

/* —— 試驗分頁：分段清單殼（A+C） —— */
[data-assay-page].is-assay-list-mode .assay-card,
[data-assay-page].is-assay-list-mode .iso-fold {
  display: none !important;
}
[data-assay-page].is-assay-editing .assay-stage-board:not(.is-editing) {
  display: none;
}
/* 編輯中隱藏清單區；回清單用畫面內「完成，回清單」 */
[data-assay-page].is-assay-editing .assay-stage-board.is-editing .assay-stage-board-hint,
[data-assay-page].is-assay-editing .assay-stage-board.is-editing [data-assay-stage-sections] {
  display: none;
}
[data-assay-page].is-assay-editing .assay-stage-board.is-editing .assay-stage-board-head {
  display: none;
}
[data-assay-page].is-assay-editing .assay-card:not(.is-stage-open),
[data-assay-page].is-assay-editing .iso-fold:not(.is-stage-open) {
  display: none !important;
}
[data-assay-page].is-assay-editing .assay-card.is-stage-open:not([hidden]),
[data-assay-page].is-assay-editing .iso-fold.is-stage-open:not([hidden]) {
  display: block !important;
}
/* 切株後舊卡即使曾開過編輯，hidden 仍須勝過 stage-open */
[data-assay-page] .assay-card[hidden],
[data-assay-page] .iso-fold[hidden],
[data-assay-page] [data-assay-layer-owner][hidden] {
  display: none !important;
}
.assay-layers-select {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  margin: 0 0 0.85rem;
  padding: 0;
  border: 0;
  background: transparent;
  position: static;
  backdrop-filter: none;
}
.assay-layer-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  align-items: stretch;
  width: 100%;
}
.assay-layer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.45rem;
  width: 100%;
}
.assay-layer-actions .assay-btn-add-items,
.assay-layer-actions .assay-btn-plan-done {
  flex: 1 1 auto;
  min-height: 2.5rem;
  min-width: 6.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  background: var(--surface);
  color: var(--text);
  padding: 0.35rem 0.75rem;
}
.assay-layer-actions .assay-btn-plan-done {
  border-color: color-mix(in srgb, var(--accent, #2f6fed) 45%, var(--line));
  background: color-mix(in srgb, var(--accent, #2f6fed) 10%, var(--surface));
}
.assay-layer-delete-iso {
  margin: 0;
  flex: 0 0 auto;
}
.assay-layer-delete-iso .btn.danger,
.assay-layer-delete-iso .btn.ghost.danger {
  min-height: 2.5rem;
  border: 1px solid color-mix(in srgb, var(--danger, #b42318) 45%, var(--line));
  border-radius: var(--radius);
  box-shadow: none;
  background: color-mix(in srgb, var(--danger, #b42318) 8%, var(--surface));
  color: var(--danger, #b42318);
  padding: 0.35rem 0.75rem;
}
.assay-layer-delete-iso .btn.danger:hover,
.assay-layer-delete-iso .btn.ghost.danger:hover {
  background: color-mix(in srgb, var(--danger, #b42318) 16%, var(--surface));
}
@media (min-width: 720px) {
  .assay-layer-toolbar {
    grid-template-columns: minmax(14rem, 1fr) auto;
    align-items: end;
  }
  .assay-layer-actions {
    width: auto;
    flex-wrap: nowrap;
  }
  .assay-layer-actions .assay-btn-add-items,
  .assay-layer-actions .assay-btn-plan-done {
    flex: 0 0 auto;
  }
}
.assay-isolate-select-label {
  display: grid;
  gap: 0.25rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  min-width: 0;
  color: var(--text);
}
.assay-isolate-select-label select {
  font: inherit;
  width: 100%;
  min-height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0.35rem 0.55rem;
  box-shadow: none;
  appearance: auto;
}
.assay-layers-select .assay-layer-add-iso {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  align-items: stretch;
  margin: 0;
  margin-left: 0;
  width: 100%;
}
.assay-layers-select .assay-layer-add-iso .assay-copy-prev {
  grid-column: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}
.assay-layers-select .assay-layer-add-iso .btn {
  justify-self: start;
  min-height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none !important;
  background: var(--surface);
  color: var(--text);
  padding: 0.35rem 0.75rem;
}
@media (min-width: 720px) {
  .assay-layer-toolbar {
    grid-template-columns: minmax(14rem, 1fr) auto;
    align-items: end;
  }
  .assay-layers-select .assay-layer-add-iso {
    grid-template-columns: auto auto;
    align-items: center;
    width: auto;
  }
  .assay-layers-select .assay-layer-add-iso .assay-copy-prev {
    align-items: center;
  }
}
.assay-stage-board {
  margin: 0 0 1rem;
  padding: 0;
}
.assay-stage-board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}
.assay-stage-board-hint { margin: 0; }
.assay-stage {
  margin: 0 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.assay-stage > summary.assay-stage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  background: var(--head);
  cursor: pointer;
  list-style: none;
}
.assay-stage > summary.assay-stage-head::-webkit-details-marker { display: none; }
.assay-stage:not([open]) > summary.assay-stage-head { border-bottom: 0; }
.assay-stage-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}
.assay-stage-progress { white-space: nowrap; }
.assay-stage-hint {
  margin: 0;
  padding: 0.35rem 0.75rem 0;
}
.assay-stage-body { margin: 0; }
.assay-stage-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.assay-stage-board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}
/* 檢視模式：不佔勾選欄，清單更乾淨 */
[data-assay-page].is-assay-review-mode .assay-stage-row {
  grid-template-columns: minmax(0, 1fr);
}
[data-assay-page].is-assay-review-mode .assay-stage-row-want {
  display: none;
}
.assay-stage-row.is-pending .assay-stage-row-title,
.assay-stage-row.is-pending .assay-stage-row-summary {
  color: var(--muted);
}
.assay-editor-back { display: none; }
[data-assay-page].is-assay-editing .assay-editor-back {
  display: inline-flex;
  position: sticky;
  top: calc(var(--shell-top-h, 3.15rem) + 0.35rem);
  z-index: 6;
  margin: 0 0 0.55rem;
  background: var(--panel);
}
.assay-stage-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  align-items: stretch;
  border-top: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
}
.assay-stage-row:first-child { border-top: 0; }
.assay-stage-row-want {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.55rem 0.15rem;
  cursor: pointer;
}
.assay-stage-row-want input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
  border-radius: 2px; /* 方角，避免與 pill chip 混用 */
}
.assay-stage-row-want.is-spacer { pointer-events: none; }
.assay-stage-row.is-wanted .assay-stage-row-title {
  font-weight: 700;
}
.assay-stage-row:not(.is-wanted):not(.has-result) .assay-stage-row-title {
  color: var(--muted);
}
.assay-stage-row-main {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 0.35rem 0.75rem;
  align-items: center;
  text-align: left;
  margin: 0;
  padding: 0.7rem 0.75rem 0.7rem 0.25rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  min-height: 2.75rem;
  border-radius: 0; /* 清單列不用圓 pill */
}
.assay-stage-row-main:hover,
.assay-stage-row-main:focus-visible {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  outline: none;
}
.assay-stage-row-title {
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}
.assay-stage-row-badge {
  font-size: 0.72em;
  font-weight: 700;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.assay-stage-row-summary {
  font-size: var(--fs-sm);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assay-stage-row-summary.is-empty,
.assay-stage-row:not(.has-result) .assay-stage-row-summary {
  color: var(--muted);
}
.assay-stage-row.has-result .assay-stage-row-title::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 1px;
  background: var(--accent);
  flex: 0 0 auto;
}
.assay-need-form {
  padding: 0.65rem 0.75rem 0.85rem;
  display: grid;
  gap: 0.55rem;
}
.assay-need-form label {
  display: grid;
  gap: 0.25rem;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.assay-need-form input,
.assay-need-form select,
.assay-need-form textarea {
  font: inherit;
  font-weight: 400;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  padding: 0.4rem 0.5rem;
}
.assay-need-form .actions { margin-top: 0.15rem; }
@media (max-width: 520px) {
  .assay-stage-row-main {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}
.assay-secondary-actions {
  justify-content: flex-start;
}
@media (max-width: 720px) {
  .assay-layers {
    top: 2.85rem;
    gap: 0.3rem;
  }
  .assay-layer-chip {
    min-height: var(--opt-tile-h);
    padding: 0.2rem 0.45rem;
  }
  .narrow .assay-card button[type="submit"].btn-sm,
  .narrow .iso-form button[type="submit"].btn-sm,
  .narrow .assay-add-form button[type="submit"].btn-sm,
  .narrow .assay-layers button[type="submit"] {
    width: auto;
    min-height: 0;
  }
}
.biochem-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  align-items: stretch;
  max-width: 100%;
  min-width: 0;
}
.biochem-item {
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: var(--radius);
  padding: 0.45rem 0.65rem;
  margin: 0;
  flex: 1 1 9.5rem;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.biochem-item legend {
  padding: 0 0.25rem;
  font-weight: 600;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.biochem-item label {
  display: inline-block;
  margin-right: 0.55rem;
  font-size: 0.9rem;
}
@media (min-width: 901px) {
  /* 桌機：生化項左右橫排更密，不要撐破卡片 */
  .biochem-keys {
    gap: 0.5rem 0.65rem;
  }
  .biochem-item {
    flex: 0 1 auto;
    min-width: 8.5rem;
  }
}
.assay-toast {
  margin: 0.35rem 0 0;
  font-size: var(--fs-sm);
  color: var(--muted);
}
.assay-toast.is-ok { color: var(--accent); }
.assay-toast.is-err { color: var(--danger); }
.assay-toast.is-busy { color: var(--ink); }

.assay-card-summary,
.iso-fold-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.15rem 0;
  font-weight: 600;
}
.assay-card-summary::-webkit-details-marker,
.iso-fold-summary::-webkit-details-marker { display: none; }
.assay-card-summary::before,
.iso-fold-summary::before {
  content: "▸ ";
  font-family: var(--font-mono);
  color: var(--muted);
  font-weight: 500;
}
details[open] > .assay-card-summary::before,
details[open] > .iso-fold-summary::before { content: "▾ "; }
.assay-card-title,
.iso-fold-title { flex: 1 1 auto; min-width: 0; }
.assay-save-state {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  max-width: 42%;
  text-align: right;
}
.assay-save-state.is-ok { color: var(--accent); }
.assay-save-state.is-err { color: var(--danger); }
.iso-fold { margin: 0.5rem 0; min-width: 0; max-width: 100%; }
.iso-form.nested { border: 0; padding: 0; margin: 0; background: transparent; }
.assay-card,
.assay-card .fold-body,
.iso-fold .fold-body {
  min-width: 0;
  max-width: 100%;
}
.panel.nested {
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}

@media (max-width: 720px) {
  .assay-card .fold-body,
  .iso-fold .fold-body {
    padding-top: 0.35rem;
  }
  .biochem-keys {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }
  .biochem-item {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.25rem;
    padding: 0.45rem 0.55rem;
  }
  .biochem-item legend {
    float: none;
    width: 100%;
    margin-bottom: 0.15rem;
  }
  .biochem-item label {
    display: inline-flex;
    align-items: center;
    min-height: 2.25rem;
    margin-right: 0.75rem;
  }
  .iso-id-fieldset {
    padding: 0.5rem 0.55rem;
  }
  .iso-form .grid-2 {
    gap: 0.45rem;
  }
  /* 桌機可一次展開多卡；手機預設只開第一張（HTML open），其餘摺起減少滑動 */

}

.assay-card .pill {
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 0.35rem;
}
.assay-media {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
}
.assay-media--smear {
  margin-top: 0.35rem;
  padding-top: 0;
  border-top: 0;
}
.assay-media--smear .media-grid.compact {
  margin-bottom: 0.55rem;
}
.assay-media--smear .media-grid.compact[hidden] {
  display: none;
}

/* 抹片工作台：桌機左圖右欄；平板／手機改直向，避免橫向溢出 */
.smear-workstation {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 0.65rem 0.85rem;
  align-items: stretch;
  margin: 0.35rem 0 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: clip;
}
.smear-workstation--readonly {
  grid-template-columns: 1fr;
}
.smear-workstation-thumbs {
  min-width: 0;
}
.smear-workstation-drop {
  min-width: 0;
}
.smear-workstation-side {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
  max-width: 100%;
}
.smear-reading {
  margin: 0;
  padding: 0 0 0.45rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}
.smear-reading-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.55rem;
}
.smear-reading-hint {
  margin: 0.15rem 0 0;
}
.smear-upload-meta {
  display: grid;
  gap: 0.4rem;
  margin: 0;
}
.smear-desk-only {
  display: block;
}

@media (max-width: 900px) {
  .assay-photos-scope {
    display: none;
  }
  .smear-workstation:not(.smear-workstation--readonly) {
    grid-template-columns: 1fr;
    grid-template-areas:
      "thumbs"
      "reading"
      "drop"
      "meta";
  }
  .smear-workstation:not(.smear-workstation--readonly) .smear-workstation-side {
    display: contents;
  }
  .smear-workstation:not(.smear-workstation--readonly) .smear-workstation-thumbs {
    grid-area: thumbs;
  }
  .smear-workstation:not(.smear-workstation--readonly) .smear-reading {
    grid-area: reading;
    border-bottom: 0;
    padding-bottom: 0;
  }
  .smear-workstation:not(.smear-workstation--readonly) .smear-workstation-drop {
    grid-area: drop;
  }
  .smear-workstation:not(.smear-workstation--readonly) .smear-upload-meta {
    grid-area: meta;
  }
  .smear-reading-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .smear-desk-only,
  .smear-drop-hint-desk {
    display: none;
  }
  .smear-workstation .photo-slot-preview {
    min-height: 9.5rem;
  }
}

.media-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 7rem), 1fr));
  gap: 0.5rem;
}
.assay-upload {
  margin-top: 0.5rem;
  max-width: 28rem;
}
/* 生化工作列（手機序進／雙人分區） */
.wl-shell {
  max-width: 32rem;
  margin: 0 auto;
  padding-bottom: 5.5rem;
}
.wl-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  padding: 0.5rem 0 0.75rem;
}
.wl-status {
  text-align: right;
  flex-shrink: 0;
}
.wl-progress {
  display: block;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.wl-save {
  font-size: 0.8rem;
  color: var(--muted);
}
.wl-save[data-state="dirty"],
.wl-save[data-state="error"] { color: var(--danger); }
.wl-save[data-state="saved"] { color: var(--accent); }
.wl-save[data-state="saving"] { color: var(--muted); }

.wl-ops {
  display: grid;
  gap: 0.65rem;
  margin: 0 0 0.85rem;
  padding: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 88%, var(--bg));
}
.wl-ops-steps { margin: 0; }
.wl-ops-or { margin: 0.1rem 0 0; flex: 1 1 100%; }
.wl-ops-advanced {
  margin: 0;
  padding: 0.35rem 0 0;
  border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
}
.wl-ops-advanced > summary {
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--muted);
  font-weight: 500;
  list-style: none;
}
.wl-ops-advanced > summary::-webkit-details-marker { display: none; }
.wl-ops-advanced[open] > summary {
  color: var(--ink);
  margin-bottom: 0.45rem;
}
.wl-ops-advanced .wl-ops-mode,
.wl-ops-advanced .wl-ops-seat {
  margin-top: 0.35rem;
}
.wl-ops fieldset {
  margin: 0;
  padding: 0;
  border: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  align-items: center;
}
.wl-ops legend {
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 0.35rem;
  padding: 0;
}
.wl-ops-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2.4rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 600;
}
.wl-ops-add {
  display: block;
  width: 100%;
}
.wl-ops-seat.is-hidden,
.wl-assay-all.is-hidden,
#wl-assay-all-wrap.is-hidden { display: none !important; }
.wl-seat-a { border-color: var(--seat-a); }
.wl-seat-b { border-color: var(--seat-b); }
.wl-ops-assay .wl-req { color: var(--danger); font-weight: 700; }
.wl-ops-auto {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.4rem;
  font-weight: 600;
}
.wl-smear-batch {
  display: grid;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.wl-smear-steps {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}
.wl-smear-prep-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  align-items: end;
}
.wl-smear-tech {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  flex: 1 1 10rem;
  margin: 0;
  font-size: var(--fs-sm);
}
.wl-smear-tech span {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.wl-smear-tech select {
  min-height: 2.5rem;
  width: 100%;
}
.wl-smear-prep-row .btn {
  flex: 0 0 auto;
  min-height: 2.5rem;
}
.wl-smear-workstation {
  margin-top: 0.55rem;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-areas:
    "thumbs reading"
    "drop reading";
}
.wl-smear-workstation .smear-workstation-thumbs {
  grid-area: thumbs;
}
.wl-smear-workstation .wl-smear-photo {
  margin-top: 0;
  grid-area: drop;
}
.wl-smear-workstation .smear-workstation-side {
  grid-area: reading;
}
.wl-smear-reading {
  border-bottom: 0;
  padding-bottom: 0;
}
.wl-smear-read-label {
  margin: 0 0 0.35rem;
  font-weight: 600;
}
.wl-smear-workstation .wl-chip-row {
  margin-bottom: 0.45rem;
}
.wl-smear-workstation .wl-gram {
  margin-top: 0;
}

@media (max-width: 900px) {
  .wl-smear-prep-row {
    flex-direction: column;
    align-items: stretch;
  }
  .wl-smear-prep-row .btn {
    width: 100%;
  }
  /* 平板／手機：先看已匯入圖，再判讀，最後才是補傳區 */
  .wl-smear-workstation:not(.smear-workstation--readonly) {
    grid-template-columns: 1fr;
    grid-template-areas:
      "thumbs"
      "reading"
      "drop";
  }
  .wl-smear-workstation .smear-workstation-side {
    display: contents;
  }
  .wl-smear-workstation .smear-workstation-thumbs {
    grid-area: thumbs;
  }
  .wl-smear-workstation .smear-reading {
    grid-area: reading;
  }
  .wl-smear-workstation .smear-workstation-drop {
    grid-area: drop;
  }
}
#wl-swap-banner.is-hidden { display: none; }
#wl-swap-banner { margin: 0; }
.wl-seat-range {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
}
.wl-split-rule {
  flex: 1 1 100%;
  margin: 0.15rem 0 0;
  padding: 0.4rem 0.55rem;
  border-left: 3px solid var(--seat-a);
  background: var(--seat-a-bg);
  color: var(--seat-a-ink);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
}

.wl-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0 1rem;
}
.wl-queue-dot {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.45rem;
  border: 2px solid color-mix(in srgb, var(--text) 22%, transparent);
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}
.wl-queue-dot.seat-a { border-color: var(--seat-a); }
.wl-queue-dot.seat-b { border-color: var(--seat-b); }
.wl-queue-dot.is-current {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
}
.wl-queue-dot.is-partial {
  background: var(--wl-current-bg);
  border-color: var(--wl-current-line);
}
.wl-queue-dot.is-done {
  background: var(--wl-done-bg);
  border-color: var(--wl-done-line);
}
.wl-queue-dot.is-other-seat,
.wl-queue-dot.is-locked {
  opacity: 0.32;
  cursor: not-allowed;
  background: var(--wl-idle-bg);
}
.wl-card.is-locked-card {
  opacity: 0.55;
  pointer-events: none;
}
.wl-card {
  border: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem 1rem;
  background: var(--panel);
}
.wl-card.is-hidden { display: none; }
.wl-card-banner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 0.35rem;
}
.wl-banner-line {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
}
.wl-banner-seat {
  font-weight: 800;
  font-size: 1.05rem;
}
.wl-banner-seat[data-seat="A"] { color: var(--seat-a); }
.wl-banner-seat[data-seat="B"] { color: var(--seat-b); }
.wl-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  margin-bottom: 0.65rem;
}
.wl-ref {
  font-size: 1.35rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.wl-ref .wl-lam {
  color: inherit;
  text-decoration: none;
}
.wl-ref .wl-lam:hover { text-decoration: underline; }
.case-code-primary {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 800;
  letter-spacing: -0.02em;
}
a.case-code-primary {
  font-size: 1.05rem;
  text-decoration: none;
}
a.case-code-primary:hover { text-decoration: underline; }

.wl-peer-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}
.wl-peer-pill {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 0.35rem;
  border: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
  background: var(--wl-peer-bg);
  font-size: 0.85rem;
  font-weight: 600;
}
.wl-peer-pill[data-val="+"] {
  background: var(--wl-done-bg);
  border-color: var(--wl-done-line);
  color: var(--wl-done-ink);
}
.wl-peer-pill[data-val="-"] {
  background: var(--wl-fail-bg);
  border-color: var(--wl-fail-line);
  color: var(--wl-fail-ink);
}
.wl-peer-pill[data-val=""] b,
.wl-peer-pill:not([data-val="+"]):not([data-val="-"]) b {
  color: var(--muted);
  font-weight: 600;
}

.wl-tests {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.wl-test {
  margin: 0;
  /* 用實線框，勿用 inset box-shadow：legend 會跨在上緣被「畫線穿過」 */
  border: 2px solid transparent;
  padding: 0.55rem 0.6rem;
  border-radius: var(--radius);
  background: var(--wl-card-bg);
  min-inline-size: 0;
}
.wl-test.is-focus {
  background: var(--wl-card-focus-bg);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.wl-test.is-dimmed {
  opacity: 0.42;
  filter: grayscale(0.2);
}
/* float 讓 legend 脫離 fieldset 預設「騎在邊框上」的版位 */
.wl-test legend {
  float: left;
  width: 100%;
  box-sizing: border-box;
  font-weight: 700;
  margin: 0 0 0.4rem;
  padding: 0;
  line-height: 1.25;
  color: inherit;
}
.wl-chip-row {
  clear: both;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.wl-chip {
  min-width: 0;
  min-height: 3.4rem;
  font-size: 1.45rem;
  font-weight: 800;
  border-radius: var(--radius);
  border: 2px solid var(--wl-chip-line);
  background: var(--surface);
  color: var(--wl-chip-ink);
  cursor: pointer;
  touch-action: manipulation;
  box-sizing: border-box;
  padding: 0.2rem 0.15rem;
}
.wl-chip-pos { border-color: var(--wl-pos-line); color: var(--wl-pos-ink); }
.wl-chip-neg { border-color: var(--wl-neg-line); color: var(--wl-neg-ink); }
.wl-chip-clear {
  font-size: 0.95rem;
  font-weight: 700;
  border-color: var(--wl-clear-line);
  color: var(--wl-clear-ink);
}
.wl-chip-pos[aria-pressed="true"] {
  background: var(--wl-pos-fill);
  border-color: var(--wl-pos-fill-line);
  color: var(--on-accent);
}
.wl-chip-neg[aria-pressed="true"] {
  background: var(--wl-neg-fill);
  border-color: var(--wl-neg-fill-line);
  color: var(--on-accent);
}
.wl-chip-clear[aria-pressed="true"] {
  background: var(--wl-clear-fill);
  border-color: var(--wl-clear-fill-line);
  color: var(--on-accent);
}
.wl-chip.is-pending {
  box-shadow: inset 0 0 0 2px var(--wl-pending-ring);
  opacity: 0.92;
}
.assay-card .wl-tests {
  margin: 0 0 0.75rem;
}
.assay-card .wl-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}
.assay-card .wl-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.assay-card .wl-chip:has(input:checked).wl-chip-pos {
  background: var(--wl-pos-fill);
  border-color: var(--wl-pos-fill-line);
  color: var(--on-accent);
}
.assay-card .wl-chip:has(input:checked).wl-chip-neg {
  background: var(--wl-neg-fill);
  border-color: var(--wl-neg-fill-line);
  color: var(--on-accent);
}
.assay-card .wl-chip:has(input:checked).wl-chip-clear {
  background: var(--wl-clear-fill);
  border-color: var(--wl-clear-fill-line);
  color: var(--on-accent);
}
/* 晶片已即時存檔：有 JS 時隱藏多餘「儲存」；失敗／未存完才再顯示 */
html.js form[data-lam-chip-autosave] > button[type="submit"],
html.js form[data-lam-chip-autosave] > .btn[type="submit"] {
  display: none;
}
html.js form[data-lam-chip-autosave][data-dirty="1"] > button[type="submit"],
html.js form[data-lam-chip-autosave][data-dirty="1"] > .btn[type="submit"] {
  display: inline-flex;
}
.wl-chip:active {
  transform: scale(0.98);
}
.wl-save[data-state="error"] { text-decoration: underline; }
.wl-gram-fold {
  margin-top: 0.85rem;
  border-top: 1px dashed color-mix(in srgb, var(--text) 14%, transparent);
  padding-top: 0.5rem;
}
.wl-gram-fold summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}
.wl-gram-fold.is-conflict {
  border-top-color: var(--danger);
}
.wl-gram-fold.is-conflict summary { color: var(--danger); }
.wl-gram {
  display: block;
  margin-top: 0.45rem;
}
.wl-gram select {
  width: 100%;
  min-height: 2.75rem;
  font-size: 1rem;
}
.wl-smear-photo {
  margin-top: 0.75rem;
}
.photo-pending-ops {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.photo-pending-ops .photo-fname {
  max-width: none;
  flex: 1 1 auto;
}
.lam-photo-item.is-compact {
  position: relative;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 4.5rem;
}
.lam-photo-item.is-compact > a {
  display: block;
  width: 4.5rem;
  height: 4.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--head);
}
.lam-photo-item.is-compact img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lam-photo-item.is-compact .lam-photo-fname {
  margin: 0.15rem 0 0;
  font-size: 0.68rem;
  line-height: 1.2;
  word-break: break-all;
  display: flex;
  gap: 0.15rem;
  align-items: flex-start;
}
.lam-photo-item.is-compact .lam-photo-fname-file {
  flex: 1 1 auto;
  min-width: 0;
}
.lam-photo-item.is-compact .lam-photo-fname-align.is-ok {
  color: var(--ok, #1f6f5b);
  font-weight: 700;
}
.lam-photo-item.is-compact .lam-photo-fname-align.is-bad {
  color: var(--danger, #a33);
  font-weight: 700;
}
.lam-photo-item.is-compact .lam-photo-item-del {
  position: absolute;
  right: 0.15rem;
  top: 0.15rem;
  padding: 0.08rem 0.32rem;
  font-size: 0.7rem;
  line-height: 1.2;
}
.media-card .photo-ops-btns {
  margin-top: 0.25rem;
}
.wl-smear-thumbs,
.smear-workstation-thumbs.wl-smear-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.45rem;
}
.wl-smear-thumbs:empty { display: none; }
.wl-smear-workstation .smear-workstation-thumbs:empty {
  display: none;
  margin: 0;
}
.wl-smear-photo .photo-slot-preview {
  min-height: 10rem;
}
.assay-smear-photo {
  margin-top: 0.5rem;
}
.wl-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  z-index: 6;
}
.wl-nav .btn {
  flex: 1;
  min-height: 3rem;
  font-size: 1.05rem;
}
.wl-hint { margin-top: 0.75rem; }

@media (max-width: 720px) {
  .wl-ops fieldset {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }
  .wl-ops legend,
  .wl-ops-add,
  .wl-split-rule {
    grid-column: 1 / -1;
  }
  .wl-ops-choice {
    justify-content: center;
    min-height: var(--opt-tile-h);
    text-align: center;
  }
  .wl-tests {
    gap: 0.55rem;
  }
  .wl-test {
    padding: 0.4rem 0.5rem;
  }
  .wl-chip {
    min-height: var(--opt-tile-h);
  }
}

/* 極窄手機：±／空白方鍵改兩欄，避免擠出 */
@media (max-width: 380px) {
  .wl-chip-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }
  .wl-chip {
    min-height: 2.85rem;
    font-size: 1.2rem;
  }
  .wl-chip-clear {
    font-size: 0.85rem;
  }
  .biochem-keys {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .wl-smear-tech {
    flex: 1 1 100%;
  }
}

@media print {
  .top, .foot, .no-print, .lam-busy, .nav-toggle, .theme-toggle, .locale-switch, .chrome-toggles-fixed, .chrome-toggles-nav, .case-tabs, .assay-layers, .assay-module-bar, .bottom-nav, .wl-nav { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .ast-report { border: none; }
}

ul.plain { padding-left: 1.1rem; }
ul.plain li { margin: 0.25rem 0; }
.panel-spaced { margin-top: 0.75rem; }

/* 藥敏統計 /stats */
.stats-filters {
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
}
.stats-filters.nested {
  background: transparent;
  border: none;
  padding: 0 0 0.5rem;
  margin: 0 0 0.5rem;
}
.stats-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: var(--fs-xs);
  color: var(--muted);
  min-width: 8rem;
}
.stats-field select,
.stats-field input {
  min-height: 2.4rem;
  font-size: var(--fs-sm);
  color: var(--ink);
}
.stats-year { min-width: 5.5rem; max-width: 6.5rem; }
.stats-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.85rem 0 1rem;
}
.stats-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
}
.stats-card-label {
  font-size: var(--fs-xs);
  color: var(--muted);
  letter-spacing: 0.02em;
}
.stats-card-value {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 600;
  margin-top: 0.15rem;
  color: var(--ink);
}
.stats-card-note {
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: 0.25rem;
}
.panel-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin-bottom: 0.55rem;
}
.panel-head-row h2 {
  margin: 0;
  font-size: 1.1rem;
}
.stats-table th a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--line);
}
.stats-table th a:hover { color: var(--accent); }
.stats-table tr.is-suppressed td { color: var(--muted); }
.stats-chart-wrap {
  overflow-x: auto;
  margin: 0.4rem 0 0.75rem;
}
.stats-chart {
  width: 100%;
  max-width: 40rem;
  height: auto;
  display: block;
}
.stats-chart-axis {
  stroke: var(--line);
  stroke-width: 1;
}
.stats-chart-line {
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
}
.stats-chart-line.is-dashed {
  stroke-dasharray: 5 4;
  stroke-opacity: 0.65;
}
.stats-chart-dot {
  fill: var(--accent);
  stroke: var(--accent);
}
.stats-chart-dot.is-hollow {
  fill: var(--panel);
  stroke: var(--accent);
  stroke-width: 2;
}
.stats-chart-lbl {
  font-size: 11px;
  fill: var(--muted);
  font-family: var(--font-mono);
}
@media (max-width: 900px) {
  .stats-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .stats-summary { grid-template-columns: 1fr; }
  .stats-field { min-width: 100%; }
  .stats-year { max-width: none; }
}


/* —— 菌株身分（schema 22 UI）：沿用 .pill，不加第二套徽章系統 —— */
.pill.id-rank {
  background: var(--iso-dim);
  color: var(--ink);
  font-weight: 500;
}
.pill.id-evidence {
  background: var(--iso-ok-bg);
  color: var(--ink);
  font-weight: 500;
}
.pill.id-evidence-weak {
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
}
/* 勿對 td 設 display:flex，會讓欄位直向線／表頭對不齊 */
.iso-identity-cell {
  vertical-align: middle;
  line-height: 1.4;
}
.iso-identity-cell .iso-id-label,
.iso-identity-cell .pill {
  display: inline-block;
  vertical-align: middle;
}
.iso-id-label { margin-right: 0.25rem; }
.iso-identity-cell .pill { margin: 0.05rem 0.2rem 0.05rem 0; }
.iso-source {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: transparent;
}
.iso-id-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem 0.75rem;
  margin: 0;
}
.iso-id-fieldset legend {
  padding: 0 0.35rem;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.iso-seq-fields.is-dimmed {
  opacity: 0.45;
}
.iso-seq-fields.is-dimmed input {
  pointer-events: none;
}
.stats-rank-note { margin: 0.35rem 0 0.75rem; }
.stats-source-panel { margin-bottom: 0.75rem; }
.stats-source-summary { margin-top: 0.5rem; }
.stats-card.is-weak {
  border-style: dashed;
}
/* 菌株表：桌機維持 table-cell 對齊；窄螢幕卡片模式才 flex 包徽章 */
.isolates-table th,
.isolates-table td {
  vertical-align: middle;
}
.isolates-table td.col-status {
  white-space: nowrap;
}
.isolates-table .iso-source {
  white-space: nowrap;
}
@media (max-width: 900px) {
  .isolates-table td.iso-identity-cell {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.35rem;
  }
  .isolates-table td.iso-identity-cell .pill {
    margin: 0;
  }
  .isolates-table td.iso-identity-cell::before {
    flex: 0 0 auto;
  }
}

/* 案件一覽：購物／瀏覽器風格單一搜尋殼 */
.case-find {
  --find-radius: 4px;
  --find-h: 2.65rem;
  margin: 0 0 0.85rem;
}
.case-find-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0;
}
.case-find-shell {
  display: flex;
  align-items: stretch;
  min-height: var(--find-h);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--find-radius);
  overflow: hidden;
  transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}
.case-find-shell:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.case-find-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0 0.15rem 0 0.75rem;
  color: var(--muted);
  pointer-events: none;
}
.case-find-q {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  gap: 0;
}
.case-find-q input[type="search"] {
  width: 100%;
  height: 100%;
  min-height: var(--find-h);
  border: 0 !important;
  border-radius: 0;
  background: transparent;
  padding: 0.45rem 0.55rem;
  font-size: var(--fs);
  box-shadow: none !important;
  outline: none !important;
}
.case-find-q input[type="search"]:focus {
  outline: none !important;
  box-shadow: none !important;
  border: 0 !important;
}
.case-find-q input[type="search"]::-webkit-search-decoration,
.case-find-q input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}
.case-find-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex: 0 0 auto;
  margin: 0;
  padding: 0 0.85rem;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.case-find-filter:hover { color: var(--ink); background: var(--head); }
.case-find-filter.is-active,
.case-find-form:has(.case-find-more-check:checked) .case-find-filter {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.case-find-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--accent);
}
.case-find-go {
  flex: 0 0 auto;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  min-width: 4.5rem;
  padding: 0 1.1rem !important;
  background: var(--accent) !important;
  color: var(--on-accent) !important;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.case-find-go:hover { background: var(--accent-hover) !important; }
.case-find-go:active { transform: none; }

.case-find-panel {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.7rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--find-radius);
}
.case-find-form:has(.case-find-more-check:checked) .case-find-panel {
  display: flex;
  animation: case-find-panel-in 0.18s var(--ease-out);
}
@keyframes case-find-panel-in {
  from { opacity: 0; transform: translateY(-0.25rem); }
  to { opacity: 1; transform: translateY(0); }
}
.case-find-panel > select,
.case-find-panel > .lam-combo {
  min-height: 2.1rem;
  padding: 0.25rem 0.45rem;
  font-size: var(--fs-sm);
  color: var(--muted);
  background: var(--input-bg);
  max-width: 9rem;
  flex: 0 1 auto;
  width: auto;
  min-width: 6.75rem;
}
.case-find-panel > .lam-combo {
  padding: 0;
  width: auto;
  min-width: 6.75rem;
  max-width: 9rem;
  flex: 0 1 auto;
}
.case-find-panel > .lam-combo button.lam-combo-trigger {
  min-height: 2.1rem;
  padding: 0.25rem 1.6rem 0.25rem 0.45rem;
  font-size: var(--fs-sm);
  width: 100%;
}
.case-find-panel > select.is-set,
.case-find-panel > .lam-combo:has(select.is-set) button.lam-combo-trigger,
.case-find-years input.is-set {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.case-find-years {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.case-find-years input {
  min-height: 2.1rem;
  padding: 0.25rem 0.3rem;
  font-size: var(--fs-sm);
  color: var(--muted);
  background: var(--input-bg);
  width: 3.35rem;
  min-width: 0;
  max-width: none;
  flex: 0 1 auto;
  text-align: center;
  box-sizing: border-box;
}
.case-find-years-sep {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.case-find-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  flex-wrap: wrap;
  min-height: 1.75rem;
}
.case-find-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.1rem;
  margin: 0;
}
.case-find-tab {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  padding: 0.15rem 0.55rem;
  color: var(--muted);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
}
.case-find-tab:hover {
  color: var(--ink);
}
.case-find-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
  background: transparent;
}
.case-find-tools {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: auto;
}
.case-find-sort {
  display: block;
  margin: 0;
  gap: 0;
}
.case-find-sort select,
.case-find-sort .lam-combo {
  min-height: 1.85rem;
  padding: 0.15rem 0.35rem;
  font-size: var(--fs-xs);
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  max-width: 10rem;
  width: auto;
  min-width: 0;
}
.case-find-sort .lam-combo {
  padding: 0;
  width: auto;
  min-width: 7rem;
  max-width: 10rem;
}
.case-find-sort button.lam-combo-trigger {
  min-height: 1.85rem;
  padding: 0.15rem 1.4rem 0.15rem 0.35rem;
  font-size: var(--fs-xs);
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.case-find-sort button.lam-combo-trigger:hover,
.case-find-sort .lam-combo:hover button.lam-combo-trigger {
  color: var(--ink);
  background: var(--head);
  border-color: var(--line);
}
.case-find-clear {
  font-size: var(--fs-xs);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.case-find-clear:hover { color: var(--accent); text-decoration: underline; }

.th-sort {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.th-sort:hover { color: var(--accent); text-decoration: underline; }
.th-sort.is-active { color: var(--accent); }

@media (max-width: 720px) {
  .case-find { --find-h: var(--touch-min); }
  .case-find-shell { min-height: var(--touch-min); }
  .case-find-q input[type="search"] {
    min-height: var(--touch-min);
    font-size: var(--fs-sm);
  }
  .case-find-filter {
    padding: 0 0.55rem;
    font-size: var(--fs-sm);
  }
  .case-find-go {
    min-width: 3.5rem;
    padding: 0 0.75rem !important;
  }
  .case-find-panel {
    display: none;
    gap: 0.4rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: clip;
  }
  .case-find-form:has(.case-find-more-check:checked) .case-find-panel {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    animation: case-find-panel-in 0.18s var(--ease-out);
  }
  .case-find-panel > select,
  .case-find-panel > .lam-combo {
    width: 100%;
    max-width: none;
    min-width: 0 !important;
    min-height: var(--touch-min);
  }
  .case-find-panel > .lam-combo button.lam-combo-trigger {
    min-height: var(--touch-min);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  /* 年度整列：半欄塞兩個 input 會因預設 size≈20 溢位 */
  .case-find-years {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: var(--touch-min);
    box-sizing: border-box;
  }
  .case-find-years input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: var(--touch-min);
    flex: unset;
    box-sizing: border-box;
  }
  .case-find-years-sep {
    justify-self: center;
  }
  .case-find-meta {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    min-width: 0;
    max-width: 100%;
  }
  .case-find-tabs {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0;
  }
  .case-find-tab {
    flex: 0 0 auto;
    min-height: 2.25rem;
    padding: 0.35rem 0.7rem;
  }
  .case-find-tools {
    margin-left: 0;
    justify-content: space-between;
  }
  .case-find-sort select,
  .case-find-sort .lam-combo,
  .case-find-sort button.lam-combo-trigger {
    min-height: 2.25rem;
    font-size: var(--fs-sm);
  }
}



/* 試驗頁：結果輕量檢視（票 08） */
.assay-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0.5rem 0 0.75rem;
}
.assay-module-presets {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-right: 0.35rem;
}
.assay-module-preset {
  border: 1px solid var(--border, #c9c2b2);
  background: transparent;
  color: inherit;
  border-radius: var(--radius, 4px);
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.assay-module-preset:hover {
  background: color-mix(in srgb, var(--accent, #2a6f6a) 12%, transparent);
}
[data-assay-page].is-assay-results-view .assay-result-summary {
  display: block;
}
[data-assay-page] .assay-result-summary {
  display: none;
  padding: 0.35rem 0 0.6rem;
  line-height: 1.45;
}
[data-assay-page].is-assay-results-view .fold-body > :not(.assay-result-summary) {
  display: none !important;
}
.assay-result-pill {
  display: inline-block;
  margin: 0.1rem 0.35rem 0.1rem 0;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius, 4px);
  background: color-mix(in srgb, var(--accent, #2a6f6a) 10%, transparent);
  font-size: 0.85rem;
}


/* MIC 格子（票 09） */
.mic-table {
  display: grid;
  gap: 0.35rem 0.75rem;
  margin: 0.5rem 0 0.75rem;
}
.mic-head,
.mic-row {
  display: grid;
  grid-template-columns: minmax(min(100%, 7rem), 1fr) minmax(min(100%, 5.5rem), 8rem);
  align-items: center;
  gap: 0.5rem;
}
.mic-head {
  font-size: 0.8rem;
  color: var(--muted, #6b6560);
}
.mic-row input {
  width: 100%;
  max-width: 8rem;
}

.wl-iso-tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--border, #c9c2b8);
  border-radius: 0.25rem;
  font-size: 0.8em;
  color: var(--muted, #666);
}


/* 試驗頁：原始編號靠左就地編輯（貼株層切換，勿彈窗／勿大卡） */
.iso-work-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.35rem 0.85rem;
  margin: 0 0 0.65rem;
  padding: 0.15rem 0 0.45rem;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 0;
  background: transparent;
}
/* 編輯某一檢驗卡時，株頭仍可留著改原始編號 */
[data-assay-page].is-assay-editing .iso-work-head:not([hidden]) {
  display: flex;
}
.iso-work-title {
  flex: 1 1 8rem;
  min-width: 8rem;
  margin: 0 0 0.15rem;
  font-size: 0.95rem;
  font-weight: 600;
  order: 2;
  color: var(--muted);
}
.iso-source-inline {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 8rem;
  flex: 0 1 12rem;
  margin: 0;
  font-size: 0.9rem;
  order: 1;
}
.iso-source-inline-label {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink);
}
.iso-source-inline input {
  max-width: 12rem;
  min-width: 7rem;
  width: 100%;
}
.iso-source-inline input:focus {
  outline: 2px solid var(--focus-ring-strong, var(--accent));
  outline-offset: 1px;
}
.iso-work-head .assay-save-state {
  align-self: center;
  order: 3;
  margin-left: auto;
}
.culture-media-fieldset {
  margin-top: 0.65rem;
}
.culture-media-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0.35rem 0 0.15rem;
}
.culture-media-add-row input {
  flex: 1 1 10rem;
  min-width: 8rem;
  max-width: 18rem;
}
.check-item.is-custom-media {
  border-style: dashed;
}
.assay-layer-add-iso {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
}
.assay-copy-prev {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  color: var(--muted, #666);
}
.assay-add-more {
  margin: 0.75rem 0 1rem;
}
.assay-add-more > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted, #666);
}
.iso-fold:not([open]) {
  margin-bottom: 0.85rem;
}


/* 試驗頁精簡：關起來的卡仍顯示結果摘要；點開才編輯表單 */
.assay-toolbar[hidden] { display: none !important; }
.iso-work-actions { margin: 0.25rem 0 0; }
.iso-work-actions .btn.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent, #2a6f6a);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
details.assay-card:not([open]) > .fold-body {
  display: block !important;
  padding-top: 0;
}
details.assay-card:not([open]) > .fold-body > :not(.assay-result-summary) {
  display: none !important;
}
details.assay-card:not([open]) > .fold-body > .assay-result-summary {
  display: block !important;
  padding: 0.35rem 0 0.15rem;
  border: 0;
}
details.assay-card[open] > .fold-body > .assay-result-summary {
  display: none; /* 編輯時看表單，摘要留在關起來時掃讀 */
}
.assay-card-summary {
  cursor: pointer;
}


/* 菌株／抹片革蘭氏：緊湊下拉，不用生化 chip 列 */
.iso-gram-select {
  display: grid;
  gap: 0.25rem;
  margin: 0.35rem 0 0.65rem;
  max-width: 18rem;
}
.iso-gram-select select {
  width: 100%;
  max-width: 14rem;
}

/* 本頁圖片燈箱：桌面化瀏覽器不開新分頁 */
html.lam-lightbox-open {
  overflow: hidden;
}
.lam-lightbox {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: rgba(12, 16, 20, 0.92);
  color: #f4f6f5;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
.lam-lightbox[hidden] {
  display: none !important;
}
.lam-lb-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 0.35rem;
  background: rgba(0, 0, 0, 0.45);
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.lam-lb-toolbar {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 3.5rem 0.35rem;
  flex: 0 0 auto;
}
.lam-lb-toolbar .btn {
  min-width: 2.4rem;
  color: #f4f6f5;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.35);
}
.lam-lb-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.lam-lb-stage:active {
  cursor: grabbing;
}
.lam-lb-stage img {
  max-width: min(96vw, 100%);
  max-height: calc(100vh - 6.5rem);
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.lam-lb-hint {
  flex: 0 0 auto;
  text-align: center;
  margin: 0;
  padding: 0.35rem 1rem 0.75rem;
  color: rgba(244, 246, 245, 0.7);
}
a[data-lam-lightbox] {
  cursor: zoom-in;
}

/* —— 0.22.122 核簽匣／批次預覽（桌機＋手機） —— */
.preview-shell {
  max-width: 56rem;
  margin: 0 auto;
}
.preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.75rem;
}
.preview-head h1 { margin: 0 0 0.2rem; }
.preview-head-text .muted { margin: 0; }
.preview-assay-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.preview-assay-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  flex: 1 1 auto;
  min-width: 0;
  padding-bottom: 0.1rem;
}
.preview-assay-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex: 0 0 auto;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: var(--fs-sm);
  cursor: pointer;
  white-space: nowrap;
}
.preview-assay-chip input { margin: 0; }
.preview-assay-chip.is-on {
  border-color: var(--accent);
  background: var(--pill);
  color: var(--accent);
  font-weight: 600;
}
.preview-bulk-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin-bottom: 0.35rem;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 70%, transparent);
}
.preview-bulk-hint { margin: 0 0 0.65rem; }
.preview-case-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.preview-case-card {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.preview-case-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.45rem 0.55rem;
  align-items: start;
}
.preview-case-check {
  padding-top: 0.15rem;
}
.preview-case-check input {
  width: 1.15rem;
  height: 1.15rem;
}
.preview-case-id {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.45rem;
  align-items: center;
  min-width: 0;
}
.preview-case-code {
  font-family: var(--font-mono);
  font-weight: 600;
  text-decoration: none;
}
.preview-case-body {
  display: grid;
  gap: 0.35rem;
  margin: 0.55rem 0 0;
  padding-left: 1.7rem;
}
.preview-field {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.35rem 0.55rem;
  align-items: baseline;
  font-size: var(--fs-sm);
}
.preview-field-label {
  color: var(--muted);
  font-weight: 600;
}
.preview-biochem-vals,
.preview-other-vals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.65rem;
}
.preview-case-card .preview-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.preview-case-card .preview-thumbs img {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.review-shell {
  max-width: 58rem;
  margin: 0 auto;
}
.review-shell-head {
  margin-bottom: 0.75rem;
}
.review-shell-head h1 { margin: 0 0 0.2rem; }
.review-shell-head .muted { margin: 0; max-width: 40rem; }
.review-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0 0 0.75rem;
}
.review-kpi-tile {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.review-kpi-tile:hover {
  border-color: var(--line-strong);
  background: var(--head);
}
.review-kpi-tile strong {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.1;
}
.review-kpi-tile span {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 500;
}
.review-kpi-tile.is-hot {
  border-color: var(--accent);
  background: var(--pill);
}
.review-kpi-tile.is-hot strong { color: var(--accent); }
.review-status-chips {
  margin-bottom: 0.65rem;
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
}
.review-search {
  margin: 0 0 1rem;
}
.review-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.review-search-row input[type="search"] {
  flex: 1 1 12rem;
  min-width: 0;
}
.review-search-more {
  margin-top: 0.45rem;
}
.review-search-more > summary {
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.review-search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.4rem;
  margin-top: 0.45rem;
}
.review-attention {
  margin: 0 0 1.1rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--pill) 55%, var(--surface));
}
.review-attention h2 {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
}
.review-attention-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: stretch;
}
.review-attn-block {
  flex: 1 1 16rem;
  min-width: min(100%, 16rem);
  box-sizing: border-box;
}
.review-attn-block.is-empty {
  display: none;
}
.review-attention:not(:has(.review-attn-block:not(.is-empty))) {
  display: none;
}
.review-attn-block h3 {
  margin: 0 0 0.35rem;
  font-size: var(--fs-sm);
}
.review-attn-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.review-attn-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.45rem;
  align-items: center;
  font-size: var(--fs-sm);
}
.review-batches h2 {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
}
.review-batch-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.review-batch-tile {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.review-batch-tile-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.55rem;
}
.review-batch-tile-title {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: baseline;
  min-width: 0;
}
.review-batch-tile-title h3 {
  margin: 0;
  font-size: 1.05rem;
}
.review-batch-tile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.review-batch-cases {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.review-batch-cases li {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.25rem 0.45rem;
  align-items: center;
  padding: 0.35rem 0.4rem;
  border-radius: var(--radius);
  background: var(--bg);
  font-size: var(--fs-sm);
}
.review-batch-code {
  font-family: var(--font-mono);
  font-weight: 600;
  text-decoration: none;
}
.review-batch-meta {
  grid-column: 1 / -1;
  font-size: var(--fs-xs);
}

@media (min-width: 900px) {
  .preview-case-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .preview-case-card .preview-thumbs {
    grid-column: 1 / -1;
  }
  .review-batch-cases li {
    grid-template-columns: 8.5rem auto 1fr;
  }
  .review-batch-meta {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .preview-head {
    flex-direction: column;
    align-items: stretch;
  }
  .preview-head-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }
  .preview-bulk-bar {
    top: env(safe-area-inset-top, 0);
  }
  .preview-case-top {
    grid-template-columns: auto 1fr;
  }
  .preview-case-open {
    grid-column: 2;
    justify-self: start;
  }
  .preview-case-body {
    padding-left: 0;
  }
  .preview-field {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
  .review-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .review-batch-tile-actions {
    width: 100%;
  }
  .review-batch-tile-actions .btn {
    flex: 1 1 auto;
    text-align: center;
  }
  .review-batch-cases li {
    grid-template-columns: 1fr auto;
  }
}

/* 桌機／寬螢：左右邊緣歷程鈕（游標靠近彈出並跟隨垂直位置） */
.hist-edges {
  display: none;
}
.hist-edge {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 0.85rem;
  z-index: 40; /* 低於對話框／燈箱；勿蓋住表單操作 */
  pointer-events: none;
  --hist-y: 50%;
}
.hist-edge-left { left: 0; }
.hist-edge-right { right: 0; }
/* 開啟時仍不拉寬整條側欄，只讓按鈕可點，避免擋住旁邊的選取框／下拉 */
.hist-edge.is-open {
  width: 0.85rem;
  pointer-events: none;
}
.hist-edge-btn {
  pointer-events: auto;
  position: absolute;
  top: var(--hist-y);
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 2.5rem;
  max-width: 6.5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--ink) 10%, transparent);
  backdrop-filter: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
  opacity: 0;
}
.hist-edge-left .hist-edge-btn {
  left: 0;
  border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  transform: translate(-100%, -50%);
}
.hist-edge-right .hist-edge-btn {
  right: 0;
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  transform: translate(100%, -50%);
}
.hist-edge.is-open .hist-edge-btn,
.hist-edge-btn:focus-visible {
  opacity: 1;
}
.hist-edge-left.is-open .hist-edge-btn,
.hist-edge-left .hist-edge-btn:focus-visible {
  transform: translate(0, -50%);
}
.hist-edge-right.is-open .hist-edge-btn,
.hist-edge-right .hist-edge-btn:focus-visible {
  transform: translate(0, -50%);
}
.hist-edge-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.hist-edge-label {
  max-width: 4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 721px) {
  .hist-edges {
    display: block;
  }
  /* 觸控平板：邊緣常駐細條，點一下即可，不必靠游標 */
  @media (pointer: coarse) {
    .hist-edge {
      width: 2rem;
      pointer-events: none;
    }
    .hist-edge-btn {
      opacity: 0.5;
      pointer-events: auto;
    }
    .hist-edge-left .hist-edge-btn {
      transform: translate(0, -50%);
      padding-left: 0.3rem;
      padding-right: 0.35rem;
    }
    .hist-edge-right .hist-edge-btn {
      transform: translate(0, -50%);
      padding-right: 0.3rem;
      padding-left: 0.35rem;
    }
    .hist-edge.is-open .hist-edge-btn,
    .hist-edge-btn:active {
      opacity: 1;
    }
  }
}

@media print {
  .hist-edges { display: none !important; }
}

/* 案件一覽：外單位編號預設單行折疊，點開看全部 */
.ext-ref-fold {
  margin: 0;
}
.ext-ref-fold > summary {
  list-style: none;
  cursor: pointer;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  max-width: 16rem;
  line-height: 1.35;
}
.ext-ref-fold > summary::-webkit-details-marker { display: none; }
.ext-ref-fold > summary::after {
  content: " ▾";
  color: var(--muted, #888);
  font-size: 0.85em;
}
.ext-ref-fold[open] > summary {
  display: block;
  -webkit-line-clamp: unset;
  white-space: normal;
  overflow: visible;
  max-width: 22rem;
}
.ext-ref-fold[open] > summary::after {
  content: " ▴";
}
@media (max-width: 720px) {
  .ext-ref-fold > summary {
    max-width: none;
    -webkit-line-clamp: 2;
  }
}

.photo-upload-state {
  display: inline-block;
  min-height: 1.2em;
}
.photo-upload-state[data-state="uploading"],
.photo-upload-state[data-state="queued"],
.photo-upload-state[data-state="pending-save"] {
  color: var(--ink);
  font-weight: 600;
}
.photo-upload-state[data-state="done"] {
  color: var(--accent);
}
.photo-upload-state[data-state="error"] {
  color: var(--danger);
  text-decoration: underline;
  cursor: pointer;
}
.photo-slot[data-upload-state="uploading"] .photo-dropzone,
.photo-slot[data-upload-state="queued"] .photo-dropzone {
  outline: 1px dashed var(--muted);
}
.photo-slot[data-upload-state="done"] .photo-dropzone {
  outline: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}

.photo-slot-preview.has-image img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #111;
}

.seq-orders-all { margin-bottom: 0.75rem; }
.seq-order-card-batch {
  border-color: color-mix(in srgb, var(--accent, #0d6e6e) 35%, var(--border, #ddd));
  background: color-mix(in srgb, var(--accent, #0d6e6e) 4%, transparent);
}
.seq-case-overview { margin: 0.5rem 0 0.85rem; }
.seq-row-on-list td { opacity: 0.92; }
.seq-row-current td { background: color-mix(in srgb, var(--accent, #0d6e6e) 6%, transparent); }
.seq-batch-table-overview td,
.seq-batch-table-overview th { font-size: 0.9rem; }

.seq-order-card-void {
  opacity: 0.78;
  border-style: dashed;
}
.seq-orders-voided {
  margin-top: 0.75rem;
}
.seq-orders-voided > summary {
  cursor: pointer;
  list-style: none;
}
.seq-orders-voided > summary::-webkit-details-marker { display: none; }
.btn.danger-text { color: var(--danger); }

/* 檢驗卡：縮圖下就地編輯照片資訊（圖名／培養基・技術／說明） */
.lam-photo-meta-wrap {
  display: grid;
  gap: 0.35rem;
  padding: 0.45rem 0.55rem 0.6rem;
}
.lam-photo-edit-toggle {
  justify-self: start;
}
.lam-photo-meta-editor {
  display: grid;
  gap: 0.45rem;
}
.lam-photo-meta-editor[hidden] {
  display: none;
}
.lam-photo-meta-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.lam-photo-meta-actions .photo-save-state.is-ok {
  color: var(--ok, #2a7);
}

/* 檢驗卡：同案照片帶入（details 收合，手機優先） */
.lam-photo-import {
  margin: 0.35rem 0 0.5rem;
}
.lam-photo-import > summary {
  cursor: pointer;
}
.lam-photo-import-list {
  list-style: none;
  margin: 0.4rem 0;
  padding: 0;
  max-height: 16rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.lam-photo-import-list li + li {
  border-top: 1px solid var(--line);
}
.lam-photo-import-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
}
.lam-photo-import-list img {
  width: 2.75rem;
  height: 2.75rem;
  object-fit: cover;
  border-radius: 4px;
  flex: none;
  background: var(--photo-letterbox, #e8e3da);
}
.lam-photo-import-list span {
  font-size: 0.85rem;
}

/* 檢驗頁：分離出新菌株（母株標籤＋新株標籤＋複製勾選） */
.assay-split-iso {
  display: grid;
  gap: 0.4rem;
}
.assay-split-form {
  display: grid;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.assay-split-form[hidden] {
  display: none;
}
.assay-split-form .checkline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* 藥敏紙錠詞表（/vocab/assays）：編輯列藥組／判讀段落各佔整列、可換行 */
.ast-disk-subrow {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  align-items: center;
}
.ast-disk-subrow input {
  min-width: 2.6rem;
  max-width: 3.6rem;
}
.ast-disk-code {
  min-width: 3.2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ast-disk-head {
  margin: 0.6rem 0 0.2rem;
}
