/* 西文字体在桌面便签项目里，跨项目相对引用，不复制 */
@font-face { font-family: "OC Inter"; src: url("../desktop-moodboard-generator/fonts/Inter-Latin.woff2") format("woff2");
  font-style: normal; font-weight: 100 900; font-display: swap; }
@font-face { font-family: "OC Cormorant"; src: url("../desktop-moodboard-generator/fonts/CormorantGaramond-Latin.woff2") format("woff2");
  font-style: normal; font-weight: 300 700; font-display: swap; }

/* 西文全部本地：Archivo 与 Spline Mono 在吊牌项目里，跨项目相对引用。
   中文两款：思源黑体做门户与夜读，思源宋体做日报与杂志——新闻这一类
   宋体标题是真实存在的版面语言，不是装饰，所以两款都要。 */
:root {
  color-scheme: light;
  --ui-accent: #2f5c7a;
  --ui-accent-dark: #23465d;
  --ui-accent-soft: #e3edf3;
  --ui-bg: #e6e8ea;
  --ui-panel: #f6f8f9;
  --ui-card: #fcfdfd;
  --ui-line: #ccd2d6;
  --ui-line-strong: #a9b0b5;
  --ui-text: #1f2529;
  --ui-muted: #626b71;
  --topbar-height: 64px;
  --font-ui: "OC Archivo","OC Noto Sans SC","PingFang SC","Microsoft YaHei",sans-serif;
  --font-serif: "Huiwen-Fangsong","OC Noto Sans SC",serif;
  --font-mono: "OC Spline Mono",Consolas,"Courier New",monospace;
  font-family: var(--font-ui);
}
* { box-sizing: border-box; }
html { height: 100%; overflow: hidden; }
body { width: 100%; height: 100vh; height: 100dvh; min-width: 320px; margin: 0; overflow: hidden; display: grid; grid-template-rows: var(--topbar-height) minmax(0,1fr); color: var(--ui-text); background: var(--ui-bg); }
body.is-export-busy,body.is-export-busy button { cursor: progress; }
button,input,textarea,select { font: inherit; color: inherit; }
button,.file-button { -webkit-tap-highlight-color: transparent; }
button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,[tabindex]:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
button:active,.file-button:active { transform: translateY(1px); }
[hidden] { display: none !important; }

.topbar { height: 100%; display: flex; align-items: center; gap: 14px; padding: 0 16px; border-bottom: 1px solid var(--ui-line); background: rgba(252,251,250,.98); position: relative; z-index: 20; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 250px; color: inherit; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 3px; background: var(--ui-accent); color: #fff; font-family: var(--font-serif); font-size: 22px; font-weight: 800; box-shadow: 4px 4px 0 #ccd4d9; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy b { font-family: var(--font-serif); font-size: 17px; line-height: 1.2; }
.brand-copy small { color: var(--ui-muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.project-field { flex: 1; max-width: 420px; display: grid; grid-template-columns: auto minmax(160px,1fr); align-items: center; gap: 8px; }
.project-field span { color: var(--ui-muted); font-size: 12px; font-weight: 700; }
.project-field input { height: 40px; min-width: 0; padding: 0 12px; border: 1px solid var(--ui-line); border-radius: 6px; background: #fff; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.button,.preview-actions button { min-height: 38px; padding: 0 13px; border: 1px solid var(--ui-line); border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; font-weight: 750; white-space: nowrap; }
.button:hover,.preview-actions button:hover { border-color: var(--ui-accent); }
.button.primary { border-color: var(--ui-accent); background: var(--ui-accent); color: #fff; }
.button.quiet { background: transparent; }
.button.compact { min-height: 34px; padding-inline: 10px; font-size: 12px; }
.button:disabled { opacity: .4; cursor: default; }
.file-button { position: relative; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; }
.file-button input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.text-button { padding: 4px 0; border: 0; background: transparent; color: var(--ui-accent-dark); cursor: pointer; font-size: 12px; font-weight: 750; }
.workspace { min-height: 0; display: grid; grid-template-columns: 356px minmax(430px,1fr) 372px; }
.editor-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr); background: var(--ui-panel); }
.content-panel { border-right: 1px solid var(--ui-line); }
.style-panel { border-left: 1px solid var(--ui-line); }
.panel-heading { min-height: 70px; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--ui-line); background: #f9fbfb; }
.panel-heading > span { padding: 4px 8px; border-radius: 4px; background: var(--ui-accent-soft); color: var(--ui-accent-dark); font-size: 10px; font-weight: 850; letter-spacing: .1em; }
.panel-heading h1 { margin: 0; font-family: var(--font-serif); font-size: 17px; }
.panel-heading p { margin: 2px 0 0; color: var(--ui-muted); font-size: 11px; }
.panel-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px; scrollbar-gutter: stable; }
.editor-card { margin-bottom: 14px; padding: 14px; border: 1px solid var(--ui-line); border-radius: 8px; background: var(--ui-card); box-shadow: 0 1px 0 rgba(38,36,33,.03); }
.card-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title h2 { margin: 0; font-family: var(--font-serif); font-size: 15px; }
.card-title p { margin: 3px 0 0; color: var(--ui-muted); font-size: 11px; line-height: 1.5; }
.card-title > span { padding: 3px 7px; border: 1px solid var(--ui-line); border-radius: 4px; color: var(--ui-muted); font-size: 9px; font-weight: 850; letter-spacing: .1em; }
.field { min-width: 0; display: grid; gap: 5px; margin-bottom: 10px; }
.field > span { color: var(--ui-muted); font-size: 11px; font-weight: 750; }
.field input,.field select,.field textarea { min-height: 38px; min-width: 0; padding: 8px 10px; border: 1px solid var(--ui-line); border-radius: 5px; background: #fff; font-size: 13px; }
.field textarea { min-height: 66px; line-height: 1.6; resize: vertical; }
.field-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.image-control { display: grid; grid-template-columns: 66px minmax(0,1fr); align-items: center; gap: 11px; margin-bottom: 10px; }
.image-control p { margin: 3px 0 6px; color: var(--ui-muted); font-size: 11px; line-height: 1.5; }
.upload-preview { width: 66px; height: 66px; display: grid; place-items: center; overflow: hidden; border: 1px dashed var(--ui-line-strong); border-radius: 8px; background: #eef0f1; color: var(--ui-muted); font-size: 10px; }
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.inline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.style-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.style-button { min-width: 0; min-height: 58px; display: grid; grid-template-columns: 30px minmax(0,1fr); align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--ui-line); border-radius: 6px; background: #fff; text-align: left; cursor: pointer; }
.style-button.active { border-color: var(--ui-accent); background: var(--ui-accent-soft); }
.style-swatch { width: 30px; height: 40px; border: 1px solid rgba(0,0,0,.15); border-radius: 3px; background: linear-gradient(180deg,var(--sw-surface) 0 44%,var(--sw-accent) 44% 68%,var(--sw-warn) 68% 82%,var(--sw-line) 82%); }
.style-button b { display: block; font-size: 11.5px; line-height: 1.35; }
.style-button small { display: block; margin-top: 2px; color: var(--ui-muted); font-size: 9px; line-height: 1.32; }
.color-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.color-field { min-width: 0; display: grid; grid-template-columns: 24px minmax(0,1fr); align-items: center; gap: 6px; padding: 6px; border: 1px solid var(--ui-line); border-radius: 5px; background: #fff; }
.color-field > span { font-size: 10.5px; font-weight: 750; }
.color-field .clr-field { width: 100%; }
.color-field input { width: 100%; min-width: 0; height: 30px; border: 0; background: transparent; }
.check-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.check-row label,.check-field { min-height: 38px; display: flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--ui-line); border-radius: 5px; background: #fff; font-size: 12px; font-weight: 700; }
.check-field { margin-top: 8px; }
.check-row input,.check-field input { accent-color: var(--ui-accent); }
.range-row { display: grid; grid-template-columns: minmax(0,1fr) 56px; align-items: center; gap: 10px; margin-bottom: 10px; }
.range-row.labeled { grid-template-columns: 44px minmax(0,1fr) 56px; }
.range-row.labeled > span { color: var(--ui-muted); font-size: 11px; font-weight: 750; }
.range-row input[type="range"] { width: 100%; accent-color: var(--ui-accent); }
.range-row output { text-align: right; color: var(--ui-muted); font-size: 11px; font-weight: 750; }
.segment-control { display: grid; gap: 7px; }
.segment-control > span { color: var(--ui-muted); font-size: 11px; font-weight: 750; }
.segment-switch { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); }
.segment-switch button { min-height: 36px; border: 1px solid var(--ui-line); border-right: 0; background: #fff; cursor: pointer; font-size: 12px; font-weight: 800; }
.segment-switch button:first-child { border-radius: 6px 0 0 6px; }
.segment-switch button:last-child { border-right: 1px solid var(--ui-line); border-radius: 0 6px 6px 0; }
.segment-switch button.active { border-color: var(--ui-accent); background: var(--ui-accent); color: #fff; }
.hint-note { margin: 8px 0 0; padding: 8px 10px; border-left: 3px solid var(--ui-line-strong); background: #eff2f3; color: var(--ui-muted); font-size: 11px; line-height: 1.6; }
.hint-note.warn { border-left-color: var(--ui-accent); background: var(--ui-accent-soft); color: var(--ui-accent-dark); font-weight: 700; }
.empty-note { margin: 4px 0; color: var(--ui-muted); font-size: 11px; }
.export-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.export-grid .button { min-height: 42px; }
.export-grid > .oc-pw-export-button { order: 99; grid-column: 1 / -1; }
.export-grid > .button:only-child { grid-column: 1 / -1; }
.preview-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: 48px minmax(0,1fr); background: #d6dadd; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 0 11px; border-bottom: 1px solid var(--ui-line); background: #f4f6f7; }
.preview-toolbar > div { display: flex; align-items: center; gap: 6px; }
.preview-toolbar strong { font-size: 13px; }
.preview-toolbar #save-state { color: var(--ui-muted); font-size: 11px; }
.preview-actions button { min-height: 32px; padding: 0 9px; font-size: 12px; }
.preview-actions button.active { border-color: var(--ui-accent); background: var(--ui-accent); color: #fff; }
.page-badge { min-width: 66px; text-align: center; font: 700 11px/1 var(--font-mono); color: var(--ui-muted); }
.preview-viewport { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.preview-stage { position: relative; margin: 26px auto; box-shadow: 0 12px 34px rgba(28,34,38,.22); }

/* ================= 单据基座 =================
   一套标记，五套机构风格靠 [data-style] 覆盖；八种单据靠 [data-doc]。
   六个色槽：纸 --surface / 文 --ink / 强 --accent / 次 --muted / 线 --line / 异 --warn
   宽固定 794（A4 @96dpi），高随内容长，超一页自动分页。 */
.rec { position: relative; width: 794px; min-height: 1123px; flex: none; box-sizing: border-box;
  transform-origin: top left;
  padding: 52px 58px 46px; overflow: hidden;
  background: var(--surface); color: var(--ink);
  font-family: var(--cjk); font-size: calc(14px * var(--tscale,1)); line-height: 1.75;
  --surface: #ffffff; --ink: #1c2024; --accent: #2f5c7a; --muted: #79828a; --line: #ccd3d9; --warn: #c0392b;
  --warn-ink: #ffffff;
  --cjk: "OC Noto Sans SC","PingFang SC",sans-serif;
  --fang: "Huiwen-Fangsong",serif;
  --kai: "Huiwen-ZhengKai",serif;
  --tw: "ZhaohuaTypeWriter Light",monospace;
  --mono: "OC Spline Mono",monospace;
  --lat: "OC Archivo",sans-serif; }

/* ---- 页眉 ---- */
.rec-head { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 10px; border-bottom: 2px solid var(--accent); }
.rec-org { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rec-logo { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 1.071em; font-weight: 800; overflow: hidden; }
.rec-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rec-org b { display: block; font-size: 1.214em; font-weight: 800; letter-spacing: .04em; line-height: 1.3; }
.rec-org small { display: block; color: var(--muted); font: 400 0.679em/1.4 var(--lat); letter-spacing: .16em; }
.rec-no { margin-left: auto; text-align: right; color: var(--muted); font: 400 0.786em/1.6 var(--mono); white-space: nowrap; }
.rec-no b { display: block; color: var(--ink); font-weight: 700; }
.rec-title { margin: 18px 0 4px; text-align: center; font-size: 1.5em; font-weight: 800; letter-spacing: .3em; text-indent: .3em; }
.rec-sub { margin: 0 0 14px; text-align: center; color: var(--muted); font: 400 0.75em/1.5 var(--lat); letter-spacing: .22em; }

/* ---- 栏位表：所有单据共用的患者信息区 ---- */
.rec-meta { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0;
  border: 1px solid var(--line); border-right: 0; border-bottom: 0; margin-bottom: 14px; }
.rec-meta .kv { display: flex; min-width: 0; margin: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.rec-meta .kv.wide { grid-column: span 2; }
.rec-meta .kv.full { grid-column: 1 / -1; }
.rec-meta dt { flex: none; width: 5.5em; display: flex; align-items: center; white-space: nowrap; padding: .5em .6em; background: color-mix(in srgb,var(--accent) 7%,transparent);
  color: var(--muted); font-size: 0.857em; }
.rec-meta dd { flex: 1; min-width: 0; display: flex; align-items: center; margin: 0; padding: .48em .72em; font-size: 0.893em; }
/* 自己填的值放得下两行：一行装得下就一行，装不下折第二行，再多才省略 */
.rec-meta dd span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; line-height: 1.45; }

/* ---- 段落式正文：病历、影像报告 ---- */
.sec { margin-top: 14px; break-inside: avoid; }
.sec-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px;
  font-size: 0.964em; font-weight: 800; color: var(--accent); }
.sec-h::before { content: ""; width: 3px; height: 12px; background: var(--accent); flex: none; }
.sec-b { font-size: 0.964em; line-height: 1.9; text-align: justify; }
.sec-b p { margin: 0 0 5px; }

/* ---- 化验表 ---- */
.lab { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 0.893em; }
.lab th { padding: 6px 8px; background: color-mix(in srgb,var(--accent) 10%,transparent);
  border-bottom: 1.5px solid var(--accent); color: var(--ink); font-weight: 700; text-align: left; white-space: nowrap; }
.lab td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.lab .v { font-family: var(--mono); font-weight: 700; text-align: right; white-space: nowrap; }
.lab .ar { width: 3.6em; padding-inline: 5px; white-space: nowrap;
  text-align: center; font-weight: 800; color: var(--warn); }
.lab .u,.lab .ref { color: var(--muted); font-family: var(--mono); font-size: 0.821em; white-space: nowrap; }
.lab tr.ab .v,.lab tr.ab td:first-child { color: var(--warn); font-weight: 700; }
.lab tr.crit { background: color-mix(in srgb,var(--warn) 9%,transparent); }
.lab tr.crit td:first-child::before { content: "! "; color: var(--warn); font-weight: 800; }
.lab-note { margin-top: 8px; color: var(--muted); font-size: 0.786em; line-height: 1.6; }

/* ---- 处方 ---- */
.rp { margin: 10px 0 2px; font: 800 1.429em/1 var(--lat); letter-spacing: .06em; }
.rx { margin: 0; padding: 0 0 0 4px; list-style: none; counter-reset: rx; }
.rx li { position: relative; padding: 7px 0 7px 24px; border-bottom: 1px dashed var(--line); counter-increment: rx; }
.rx li::before { content: counter(rx) "."; position: absolute; left: 0; top: 7px;
  color: var(--muted); font: 700 0.857em/1.7 var(--mono); }
.rx b { font-size: 0.964em; font-weight: 700; }
.rx .spec { margin-left: 8px; color: var(--muted); font: 400 0.821em/1 var(--mono); }
.rx .qty { float: right; font: 700 0.893em/1.7 var(--mono); }
.rx .use { display: block; margin-top: 2px; color: var(--muted); font-size: 0.857em; font-style: normal; }
.rx-sum { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line);
  display: flex; gap: 18px; color: var(--muted); font-size: 0.821em; }

/* ---- 心理量表因子条 ---- */
.factors { display: grid; gap: 7px; margin-top: 8px; }
.factor { display: grid; grid-template-columns: 88px minmax(0,1fr) 46px 66px; align-items: center; gap: 10px; font-size: 0.893em; }
.factor .bar { position: relative; height: 12px; background: color-mix(in srgb,var(--ink) 7%,transparent); border-radius: 2px; overflow: hidden; }
.factor .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: var(--p,0%);
  background: var(--accent); border-radius: 2px; }
.factor.over .bar i { background: var(--warn); }
.factor .sc { font: 700 0.929em/1 var(--mono); text-align: right; }
.factor.over .sc { color: var(--warn); }
.factor .nm { color: var(--muted); font: 400 0.786em/1 var(--mono); text-align: right; }
.scale-total { margin-top: 12px; padding: 9px 12px; display: flex; align-items: baseline; gap: 14px;
  border: 1px solid var(--line); background: color-mix(in srgb,var(--accent) 5%,transparent); }
.scale-total b { font: 800 1.571em/1 var(--mono); color: var(--accent); }
.scale-total span { color: var(--muted); font-size: 0.821em; }

/* ---- 影像图位 ---- */
.films { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin-top: 8px; }
.film { position: relative; height: 168px; overflow: hidden; background: #0d1114;
  border: 1px solid var(--line); }
.film img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.film::after { content: ""; position: absolute; left: 18%; top: 22%; width: 64%; height: 56%;
  border-radius: 50% 50% 46% 46%; background: radial-gradient(circle at 42% 38%,rgba(255,255,255,.5),rgba(255,255,255,.12) 60%,transparent 72%); }
.film.has-img::after { display: none; }
.film span { position: absolute; left: 6px; bottom: 5px; z-index: 2; color: rgba(255,255,255,.82);
  font: 400 0.714em/1 var(--mono); letter-spacing: .06em; }

/* ---- 签署行 ---- */
.rec-sign { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-top: 16px;
  padding-top: 10px; border-top: 1px solid var(--line); }
.rec-sign .sg { min-width: 0; font-size: 0.821em; color: var(--muted); }
.rec-sign .sg b { display: block; margin-top: 3px; min-height: 22px; color: var(--ink);
  font-family: var(--kai); font-size: 1.071em; font-weight: 400; }
.rec-foot { margin-top: 14px; padding-top: 8px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 12px;
  color: var(--muted); font: 400 0.714em/1.6 var(--mono); }

/* ---- 住院腕带：按实物尺寸排在 A4 上，可裁 ---- */
.bands { display: grid; gap: 0; margin-top: 10px; }
.band { position: relative; height: 76px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; border: 1px dashed var(--line); }
.band + .band { border-top: 0; }
.band .bc { flex: none; width: 34px; height: 46px; background:
  repeating-linear-gradient(90deg,var(--ink) 0 1.5px,transparent 1.5px 3px,var(--ink) 3px 4.5px,transparent 4.5px 7px); }
.band .who { flex: 1; min-width: 0; }
.band .who b { display: block; font-size: 1.143em; font-weight: 800; letter-spacing: .04em; }
.band .who small { display: block; color: var(--muted); font: 400 0.75em/1.7 var(--mono); }
.band .ward { flex: none; padding: 3px 9px; background: var(--accent); color: #fff;
  font-size: 0.821em; font-weight: 700; }
.band .cut { position: absolute; right: -1px; top: -1px; bottom: -1px; width: 24px;
  border-left: 1px dashed var(--line); }
.bands-note { margin-top: 8px; color: var(--muted); font-size: 0.786em; }

/* ---- 疫苗接种本：小开本排在 A4 上 ---- */
.vax-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 10px;
  border: 1px dashed var(--line); }
.vax-page { padding: 16px 18px; min-height: 300px; }
.vax-page + .vax-page { border-left: 1px dashed var(--line); }
.vax-cover { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; }
.vax-cover .seal { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid var(--accent); color: var(--accent); font-size: 1.429em; font-weight: 800; }
.vax-cover b { font-size: 1.214em; font-weight: 800; letter-spacing: .2em; text-indent: .2em; }
.vax-cover small { color: var(--muted); font: 400 0.714em/1.7 var(--lat); letter-spacing: .16em; }
.vax-cover .own { margin-top: 8px; width: 100%; display: grid; gap: 5px; font-size: 0.821em; text-align: left; }
.vax-cover .own span { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.vax-cover .own i { color: var(--muted); font-style: normal; flex: none; }
.vax-tab { width: 100%; border-collapse: collapse; font-size: 0.75em; }
.vax-tab th { padding: 4px 5px; border: 1px solid var(--line);
  background: color-mix(in srgb,var(--accent) 9%,transparent); font-weight: 700; }
.vax-tab td { padding: 5px; border: 1px solid var(--line); height: 26px; }
.vax-tab .lot { font-family: var(--mono); font-size: 0.679em; }
.vax-tab .sg { font-family: var(--kai); font-size: 0.857em; }
.vax-h { margin: 0 0 6px; font-size: 0.857em; font-weight: 800; letter-spacing: .1em; }

/* ---- 印章 ---- */
.seals { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.seal-mark { position: absolute; display: grid; place-items: center; text-align: center;
  border: 2px solid currentColor; border-radius: 3px; font-weight: 800; opacity: .82;
  transform: rotate(var(--r,-8deg)); }
.seal-round { border-radius: 50%; border-width: 2.5px; }

/* ================= 01 现代医院 ================= */
.rec[data-style="hosp"] { --surface: #ffffff; --ink: #1c2024; --accent: #2f5c7a; --muted: #79828a; --line: #ccd3d9; --warn: #c0392b; }

/* ================= 02 针式打印 ================= */
.rec[data-style="dot"] { --surface: #fbfaf5; --ink: #26221c; --accent: #26221c; --muted: #6f685c; --line: #b8b1a2; --warn: #26221c;
  --cjk: "ZhaohuaTypeWriter Light",monospace; font-size: 0.964em; letter-spacing: .02em; }
.rec[data-style="dot"] .rec-head { border-bottom: 1px solid var(--ink); }
.rec[data-style="dot"] .rec-logo { border-radius: 0; background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.rec[data-style="dot"] .rec-title { letter-spacing: .5em; text-indent: .5em; font-weight: 400; font-size: 1.286em; }
.rec[data-style="dot"] .rec-meta { border-color: var(--line); }
.rec[data-style="dot"] .rec-meta dt { background: transparent; }
.rec[data-style="dot"] .lab th { background: transparent; border-bottom: 1px solid var(--ink); font-weight: 400; }
.rec[data-style="dot"] .lab td { border-bottom: 1px dotted var(--line); }
.rec[data-style="dot"] .lab tr.ab .v,.rec[data-style="dot"] .lab tr.ab td:first-child { font-weight: 700; }
.rec[data-style="dot"] .lab .ar { color: var(--ink); }
.rec[data-style="dot"] .lab tr.crit { background: transparent; }
.rec[data-style="dot"] .lab tr.crit td:first-child::before { content: "!! "; }
.rec[data-style="dot"] .sec-h { color: var(--ink); }
.rec[data-style="dot"] .sec-h::before { display: none; }
.rec[data-style="dot"] .sec-h::after { content: ""; flex: 1; height: 0; border-top: 1px dashed var(--line); }
.rec[data-style="dot"] .factor .bar { border-radius: 0; }
.rec[data-style="dot"] .factor .bar i { border-radius: 0; background:
  repeating-linear-gradient(90deg,var(--ink) 0 2px,transparent 2px 4px); }
.rec[data-style="dot"] .band .ward { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
/* 连续纸的两侧齿孔 */
.rec[data-style="dot"]::before,.rec[data-style="dot"]::after { content: ""; position: absolute; top: 0; bottom: 0; width: 22px;
  background: radial-gradient(circle 3.2px at 11px 12px,var(--surface) 3.2px,transparent 3.3px) 0 0/22px 24px,
  color-mix(in srgb,var(--ink) 8%,transparent);
  border-inline: 1px dashed var(--line); }
.rec[data-style="dot"]::before { left: 0; }
.rec[data-style="dot"]::after { right: 0; }

/* ================= 03 制式表单 ================= */
.rec[data-style="form"] { --surface: #fbfaf4; --ink: #1f1d18; --accent: #3d4a3a; --muted: #6d6a5e; --line: #9c988a; --warn: #a33228;
  --cjk: "Huiwen-Fangsong",serif; }
.rec[data-style="form"] .rec-head { border-bottom: 3px double var(--ink); }
.rec[data-style="form"] .rec-logo { border-radius: 0; }
.rec[data-style="form"] .rec-title { font-weight: 400; letter-spacing: .42em; text-indent: .42em; }
.rec[data-style="form"] .rec-meta { border: 1.5px solid var(--ink); border-right: 0; border-bottom: 0; }
.rec[data-style="form"] .rec-meta .kv { border-color: var(--ink); }
.rec[data-style="form"] .rec-meta dt { background: transparent; color: var(--ink); }
.rec[data-style="form"] .lab { border: 1.5px solid var(--ink); }
.rec[data-style="form"] .lab th { background: var(--ink); color: var(--surface); border: 1px solid var(--ink); font-weight: 400; }
.rec[data-style="form"] .lab td { border: 1px solid var(--ink); }
.rec[data-style="form"] .sec-h::before { display: none; }
.rec[data-style="form"] .sec-h { border-bottom: 1px solid var(--ink); padding-bottom: 2px; font-weight: 400; letter-spacing: .1em; }
.rec[data-style="form"] .rx li { border-bottom: 1px solid var(--line); }
.rec[data-style="form"] .factor .bar { border: 1px solid var(--ink); border-radius: 0; background: transparent; }
.rec[data-style="form"] .factor .bar i { border-radius: 0; }
.rec[data-style="form"] .vax-tab th { background: var(--ink); color: var(--surface); }

/* ================= 04 手写病历 ================= */
.rec[data-style="hand"] { --surface: #f6f1e4; --ink: #2b2a24; --accent: #2f4d80; --muted: #7d7663; --line: #b9b09a; --warn: #a8382c;
  --cjk: "Huiwen-Fangsong",serif; }
.rec[data-style="hand"] .rec-head { border-bottom: 1.5px solid var(--ink); }
.rec[data-style="hand"] .rec-logo { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.rec[data-style="hand"] .rec-title { letter-spacing: .36em; text-indent: .36em; font-weight: 400; }
/* 框线与标签是印刷体，填进去的内容是手写体——真实手写病历就是这样 */
.rec[data-style="hand"] .rec-meta dd,
.rec[data-style="hand"] .sec-b,
.rec[data-style="hand"] .lab .v,
.rec[data-style="hand"] .rx b,
.rec[data-style="hand"] .rx .use { font-family: var(--kai); }
.rec[data-style="hand"] .sec-b { font-size: 1.071em; line-height: 1.95; }
.rec[data-style="hand"] .rec-meta dd { font-size: 1em; }
.rec[data-style="hand"] .lab .v { font-size: 1em; }
.rec[data-style="hand"] .sec-h { color: var(--ink); font-weight: 400; letter-spacing: .08em; }
.rec[data-style="hand"] .sec-h::before { background: var(--ink); }
/* 印刷横格 */
.rec[data-style="hand"] .sec-b { background: repeating-linear-gradient(180deg,transparent 0 28px,color-mix(in srgb,var(--line) 55%,transparent) 28px 29px); }
.rec[data-style="hand"] .rec-sign .sg b { font-size: 1.214em; }

/* ================= 05 心理机构 ================= */
.rec[data-style="psy"] { --surface: #fbfaf9; --ink: #2c2a33; --accent: #6b6396; --muted: #857f92; --line: #ded9e4; --warn: #b4694a; }
.rec[data-style="psy"] { padding: 56px 62px 50px; }
.rec[data-style="psy"] .rec-head { border-bottom: 1px solid var(--line); }
.rec[data-style="psy"] .rec-logo { border-radius: 10px; }
.rec[data-style="psy"] .rec-title { letter-spacing: .16em; text-indent: .16em; font-size: 1.429em; }
.rec[data-style="psy"] .rec-meta { border: 0; gap: 1px; background: var(--line); }
.rec[data-style="psy"] .rec-meta .kv { border: 0; background: var(--surface); }
.rec[data-style="psy"] .rec-meta dt { background: transparent; }
.rec[data-style="psy"] .sec-h { color: var(--accent); }
.rec[data-style="psy"] .sec-h::before { border-radius: 2px; }
.rec[data-style="psy"] .factor .bar { height: 14px; border-radius: 7px; }
.rec[data-style="psy"] .factor .bar i { border-radius: 7px; }
.rec[data-style="psy"] .scale-total { border: 0; border-radius: 10px; }
.rec[data-style="psy"] .lab th { border-bottom: 1px solid var(--line); background: transparent; color: var(--muted); }

/* ---- 分页：页边界线与续页页眉页脚 ---- */
.rec.paged { background-image: repeating-linear-gradient(180deg,
  transparent 0 calc(1123px - 1px), color-mix(in srgb,var(--warn) 42%,transparent) calc(1123px - 1px) 1123px); }
.page-runner { position: absolute; z-index: 4;
  color: var(--muted); font: 400 0.714em/1.6 var(--mono); pointer-events: none; }
.page-runner-foot { text-align: center; }
/* 续页抬头：第一页那条抬头的压缩版，连下边那道强调色线一起带过来 */
.page-runner-head { display: flex; align-items: center; gap: 10px;
  padding-bottom: 5px; border-bottom: 1.5px solid var(--accent); }
.page-runner-head .rh-org { display: flex; align-items: center; gap: 5px; flex: none;
  color: var(--ink); font-family: var(--cjk); font-size: 1.1em; font-weight: 800; letter-spacing: .02em; }
.page-runner-head .rh-org i { width: 1.35em; height: 1.35em; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent); color: #fff; font-size: .8em; font-style: normal; font-weight: 700; }
.page-runner-head .rh-doc { flex: 1; min-width: 0; font-family: var(--cjk);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-runner-head .rh-no { flex: none; white-space: nowrap; }


/* ---- 小画布：腕带与接种本各按实物尺寸，不再排到 A4 上 ---- */
.rec[data-size="band"] { width: 945px; min-height: 94px; height: 94px; padding: 0; display: flex; align-items: stretch; }
.rec[data-size="band"] .band-face { flex: 1; display: flex; align-items: center; gap: 14px; padding: 0 18px; min-height: 94px; }
.rec[data-size="band"] .bc { flex: none; width: 40px; height: 56px; background:
  repeating-linear-gradient(90deg,var(--ink) 0 1.5px,transparent 1.5px 3px,var(--ink) 3px 4.5px,transparent 4.5px 7px); }
.rec[data-size="band"] .who { flex: 1; min-width: 0; }
.rec[data-size="band"] .who b { display: block; font-size: 1.357em; font-weight: 800; letter-spacing: .06em; line-height: 1.25; }
.rec[data-size="band"] .who small { display: block; color: var(--muted); font: 400 0.75em/1.6 var(--mono); }
.rec[data-size="band"] .ward { flex: none; padding: 5px 11px; background: var(--accent); color: #fff; text-align: center; }
.rec[data-size="band"] .ward b { display: block; font-size: 0.929em; font-weight: 800; }
.rec[data-size="band"] .ward small { display: block; font: 400 0.714em/1.4 var(--mono); opacity: .85; }
/* 腕带两端是扣合用的空白，不印内容 */
.rec[data-size="band"] .tail { flex: none; width: 96px; border-left: 1px dashed var(--line); }
.rec[data-size="band"][data-style="dot"] .ward { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.rec[data-size="band"][data-style="dot"]::before,
.rec[data-size="band"][data-style="dot"]::after { display: none; }

.rec[data-size="vax"] { width: 397px; min-height: 559px; padding: 26px 24px; }
.rec[data-size="vax"] .vax-cover { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 9px; }
.rec[data-size="vax"] .vax-tab th { padding: 4px 4px; font-size: 0.714em; }
.rec[data-size="vax"] .vax-tab td { padding: 4px; height: 22px; font-size: 0.75em; }
.rec[data-size="vax"] .vax-tab .lotrow td { height: auto; padding: 2px 4px 4px; border-top: 0; }
.rec[data-size="vax"] .vax-tab .lot { color: var(--muted); font-size: 0.643em; }

/* ================= 来源卡 / 块清单 ================= */
.cast-list,.msg-list,.sticker-list { display: grid; gap: 6px; }
.cast-row,.msg-row,.sticker-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 9px;
  padding: 7px 9px; border: 1px solid var(--ui-line); border-radius: 5px; background: #fff; cursor: pointer; text-align: left; }
.message-add-bottom { width: 100%; min-height: 38px; margin-top: 9px; border-style: dashed; color: var(--ui-accent-dark); }
.message-add-bottom:hover { border-color: var(--ui-accent); background: var(--ui-accent-soft); }
.msg-row { position: relative; grid-template-columns: 27px auto minmax(0,1fr) auto; transition: border-color .14s ease, box-shadow .14s ease, opacity .14s ease, transform .14s ease; }
.msg-drag-handle { width: 27px; height: 31px; padding: 0; display: grid; place-items: center; border: 1px solid var(--ui-line);
  border-radius: 5px; background: #fff; color: var(--ui-muted); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.msg-drag-handle::before { content: ""; width: 12px; height: 18px; opacity: .8;
  background: radial-gradient(circle, currentColor 1.35px, transparent 1.6px) 0 0 / 6px 6px; }
.msg-drag-handle:hover,.msg-drag-handle:focus-visible { border-color: var(--ui-accent); color: var(--ui-accent-dark); outline: none; }
.msg-drag-handle:active { cursor: grabbing; }
.msg-row.is-dragging { opacity: .46; transform: scale(.985); }
.msg-row.is-drop-before { box-shadow: inset 0 3px 0 var(--ui-accent); }
.msg-row.is-drop-after { box-shadow: inset 0 -3px 0 var(--ui-accent); }
body.is-message-sorting { user-select: none; -webkit-user-select: none; }
.cast-row.active,.msg-row.active,.sticker-row.active { border-color: var(--ui-accent); background: var(--ui-accent-soft); }
.cast-row b,.msg-row b,.sticker-row b { display: block; overflow: hidden; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.cast-row small,.msg-row small,.sticker-row small { display: block; margin-top: 2px; color: var(--ui-muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-ava { width: 28px; height: 28px; flex: none; border-radius: 5px; display: grid; place-items: center; overflow: hidden;
  background: var(--ui-accent); color: #fff; font-size: 12px; font-weight: 700; }
.mini-ava img { width: 100%; height: 100%; object-fit: cover; }
.row-actions { display: flex; gap: 4px; }
.row-actions button,.row-item .row-del { min-height: 26px; padding: 0 8px; display: grid; place-items: center; border: 1px solid var(--ui-line);
  border-radius: 5px; background: #fff; cursor: pointer; font-size: 11px; font-weight: 700; white-space: nowrap; color: var(--ui-muted); }
.row-actions button:hover,.row-item .row-del:hover { border-color: var(--ui-accent); color: var(--ui-text); }
.row-actions button.on { border-color: var(--ui-accent); background: var(--ui-accent-soft); color: var(--ui-accent-dark); }
.cast-row[role="button"] { cursor: pointer; }
.msg-kind { flex: none; min-width: 40px; padding: 2px 5px; border-radius: 3px; background: var(--ui-accent-soft);
  color: var(--ui-accent-dark); font-size: 9.5px; font-weight: 800; text-align: center; }
/* 逐条填写：左边一个大字、右边一个小字、行尾一个删；底下一个「加一条」 */
.row-list { display: grid; gap: 6px; }
.row-item { display: grid; grid-template-columns: 78px minmax(0,1fr) 34px; gap: 6px; align-items: center; }
.row-item input { min-height: 36px; min-width: 0; padding: 7px 9px; border: 1px solid var(--ui-line); border-radius: 5px; background: #fff; font-size: 13px; }
.row-item .row-del { min-height: 36px; padding: 0; }
.button.row-add { width: 100%; min-height: 36px; border-style: dashed; color: var(--ui-accent-dark); }
.button.row-add:hover { border-color: var(--ui-accent); background: var(--ui-accent-soft); }
.editor-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--ui-line); }

/* ================= 贴纸 ================= */
.sticker-layer { position: absolute; inset: 0; z-index: 12; pointer-events: none; }
.canvas-sticker { position: absolute; left: var(--x); top: var(--y); width: var(--w); min-height: var(--h);
  transform: translate(-50%,-50%) rotate(var(--r)); display: grid; pointer-events: auto; cursor: grab; touch-action: none; }
.canvas-sticker.is-locked { cursor: default; }
.canvas-sticker.is-hidden { display: none; }
.canvas-sticker.is-selected { outline: 1.5px dashed var(--ui-accent); outline-offset: 2px; }
.sticker-body { width: 100%; min-height: 100%; display: flex; align-items: center; overflow: hidden; box-sizing: border-box; word-break: break-word; }
.sticker-body img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sticker-body.fit-cover img { object-fit: cover; }
.sticker-body.fit-stretch img { object-fit: fill; }
.sticker-font-sans { font-family: "OC Noto Sans SC","PingFang SC",sans-serif; }
.sticker-font-serif { font-family: "Huiwen-Fangsong","Songti SC",serif; }
.sticker-font-kai { font-family: "Huiwen-ZhengKai","Kaiti SC",serif; }
.sticker-font-mono { font-family: "OC Spline Mono",monospace; }
.sticker-handle { position: absolute; z-index: 3; width: 16px; height: 16px; border: 2px solid var(--ui-accent); border-radius: 50%;
  background: #fff; opacity: 0; pointer-events: none; touch-action: none; }
.sticker-handle::before { content: ""; position: absolute; inset: -7px; border-radius: 50%; }
.canvas-sticker.is-selected .sticker-handle { opacity: 1; pointer-events: auto; }
.canvas-sticker.is-locked .sticker-handle { display: none; }
.resize-handle { right: -10px; bottom: -10px; cursor: nwse-resize;
  transform: scale(var(--preview-inverse-scale,1)); transform-origin: 50% 50%; }
.rotate-handle { left: 50%; top: -28px; margin-left: -8px; cursor: grab;
  transform: scale(var(--preview-inverse-scale,1)); transform-origin: 50% 50%; }
.rotate-handle::after { content: ""; position: absolute; left: 6px; top: 14px; width: 2px; height: 14px; background: var(--ui-accent); }
.rec.is-exporting .canvas-sticker { outline: 0 !important; }
.rec.is-exporting .sticker-handle { display: none !important; }
@media (max-width:900px) {
  .sticker-handle { width: 28px; height: 28px; border-width: 3px; }
  .sticker-handle::before { inset: -8px; }
  .resize-handle { right: -16px; bottom: -16px; }
  .rotate-handle { top: -44px; margin-left: -14px; }
  .rotate-handle::after { left: 11px; top: 25px; width: 3px; height: 18px; }
}
.preset-sticker-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; margin-top: 10px; }
.preset-sticker-grid button { min-height: 32px; padding: 0 6px; border: 1px solid var(--ui-line); border-radius: 5px;
  background: #fff; cursor: pointer; font-size: 11px; font-weight: 700; }
.preset-sticker-grid button:hover { border-color: var(--ui-accent); }
.sticker-editor-actions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; margin-top: 10px; }

/* ================= 弹窗：裁切与类型选择 ================= */
.crop-modal { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 16px; }
.crop-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(30,27,24,.72); backdrop-filter: blur(4px); cursor: default; }
.crop-dialog { position: relative; width: min(720px,100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 18px; border-radius: 12px; background: var(--ui-card); box-shadow: 0 24px 90px rgba(0,0,0,.4); }
.crop-dialog header,.crop-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crop-dialog header small { color: var(--ui-accent); font: 800 9px/1 var(--font-mono); letter-spacing: .12em; }
.crop-dialog h2 { margin: 4px 0 0; font-family: var(--font-serif); font-size: 18px; }
.crop-dialog > p { margin: 10px 0 14px; color: var(--ui-muted); font-size: 12px; line-height: 1.6; }
.crop-stage { position: relative; display: grid; place-items: center; min-height: 180px; overflow: hidden; border: 1px solid var(--ui-line-strong); border-radius: 10px; background: #22262a; }
.crop-stage canvas { display: block; width: 100%; max-height: min(56dvh,560px); object-fit: contain; cursor: grab; touch-action: none; }
.crop-stage canvas:active { cursor: grabbing; }
.crop-stage > span { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); padding: 5px 8px; border-radius: 999px; background: rgba(20,24,21,.72); color: #fff; font-size: 10px; pointer-events: none; }
.crop-zoom { display: grid; grid-template-columns: 108px 1fr; align-items: center; gap: 12px; margin: 14px 0; font-size: 11px; font-weight: 750; }
.crop-zoom output { display: block; margin-top: 4px; color: var(--ui-accent); font: 800 10px/1 var(--font-mono); }
.crop-zoom input { width: 100%; accent-color: var(--ui-accent); }
.crop-dialog footer { justify-content: flex-end; }
body.crop-modal-open { overflow: hidden; }
.type-dialog { width: min(560px,100%); }
.type-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.type-grid button { min-height: 58px; padding: 9px 11px; border: 1px solid var(--ui-line); border-radius: 6px; background: #fff; cursor: pointer; text-align: left; }
.type-grid button:hover { border-color: var(--ui-accent); background: var(--ui-accent-soft); }
.type-grid b { display: block; font-size: 13px; }
.type-grid small { display: block; margin-top: 3px; color: var(--ui-muted); font-size: 11px; line-height: 1.45; }

.mobile-resizer,.mobile-main-tabs { display: none; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 140; max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 6px; background: var(--ui-accent-dark); color: #fff; font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%,16px); transition: .16s ease; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width:900px) {
  :root { --topbar-height:62px; }
  .topbar { gap:8px; padding:0 10px; }
  .brand { min-width:44px; }
  .brand-copy,.project-field,.desktop-action { display:none; }
  .brand-mark { width:40px; height:40px; }
  .top-actions { width:calc(100% - 50px); justify-content:flex-end; gap:6px; }
  .top-actions .button { min-height:40px; padding:0 12px; }
  .workspace { --mobile-preview-height:46%; height:auto; min-height:0; grid-template-columns:1fr; grid-template-rows:var(--mobile-preview-height) 20px 48px minmax(0,1fr); grid-template-areas:"preview" "resizer" "tabs" "panel"; }
  .preview-panel { grid-area:preview; grid-template-rows:42px minmax(0,1fr); border-bottom:0; }
  .preview-toolbar { padding:0 8px; }
  .preview-actions button { padding:0 7px; }
  .preview-viewport { overflow:auto; }
  .preview-stage { margin:0 auto; }
  .mobile-resizer { grid-area:resizer; display:grid; place-items:center; border-top:1px solid var(--ui-line); border-bottom:1px solid var(--ui-line); background:#f0efed; cursor:row-resize; touch-action:none; user-select:none; z-index:12; }
  .mobile-resizer span { width:112px; height:5px; border-radius:4px; background:var(--ui-line-strong); pointer-events:none; }
  .mobile-main-tabs { grid-area:tabs; display:grid; grid-template-columns:1fr 1fr; border-top:1px solid var(--ui-line); border-bottom:1px solid var(--ui-line); background:#f7f6f4; z-index:14; }
  .mobile-main-tabs button { border:0; border-right:1px solid var(--ui-line); background:transparent; font-size:13px; font-weight:850; }
  .mobile-main-tabs button:last-child { border-right:0; }
  .mobile-main-tabs button.active { background:var(--ui-accent-soft); box-shadow:inset 0 -3px var(--ui-accent); }
  .editor-panel { grid-area:panel; min-height:0; border:0; display:grid; grid-template-rows:minmax(0,1fr); }
  .panel-heading { display:none; }
  .panel-scroll { padding:12px 10px calc(20px + env(safe-area-inset-bottom)); scrollbar-gutter:auto; }
  body[data-active-mobile-panel="content"] .style-panel,body[data-active-mobile-panel="style"] .content-panel { display:none; }
  .editor-card { padding:13px; }
  .field input,.field select,.field textarea { min-height:42px; }
  .row-fields input,.row-fields select,.row-fields textarea { min-height:42px; }
  .row-fields textarea { min-height:66px; }
  .row-drag { width:30px; height:34px; }
  .row-actions button,.button.row-add { min-height:34px; }
  .row-item .row-del,.button.row-add { min-height:42px; }
  .toast { bottom:calc(20px + env(safe-area-inset-bottom)); }
}
@media (max-width:600px) {
  .crop-dialog { padding:14px; }
  .crop-stage canvas { max-height:50dvh; }
  .crop-zoom { grid-template-columns:1fr; gap:6px; }
  .type-grid { grid-template-columns:1fr; }
}
@media (max-width:520px) {
  .top-actions .button { padding-inline:9px; font-size:12px; }
  .field-grid,.style-grid,.check-row,.export-grid { grid-template-columns:1fr; }
  .color-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { transition-duration:.01s !important; animation-duration:.01s !important; scroll-behavior:auto !important; } }


/* ================= 医疗项目自己加的界面件 ================= */
.doc-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.doc-button { min-width: 0; min-height: 46px; padding: 8px 10px; border: 1px solid var(--ui-line); border-radius: 6px;
  background: #fff; text-align: left; cursor: pointer; }
.doc-button.active { border-color: var(--ui-accent); background: var(--ui-accent-soft); }
.doc-button b { display: block; font-size: 12.5px; }
.doc-button small { display: block; margin-top: 2px; color: var(--ui-muted); font-size: 9.5px; line-height: 1.35; }
.doc-button .cv { display: inline-block; margin-top: 3px; padding: 1px 5px; border-radius: 3px;
  background: var(--ui-accent-soft); color: var(--ui-accent-dark); font: 700 8.5px/1.5 var(--font-mono); letter-spacing: .06em; }
.doc-button.active .cv { background: #fff; }
.check-inline { display: inline-flex; align-items: center; gap: 5px; padding: 0 6px; color: var(--ui-muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.check-inline input { accent-color: var(--ui-accent); }
.list-block { margin-bottom: 16px; }
.list-block:last-child { margin-bottom: 0; }
.list-block > h3 { margin: 0 0 3px; font-size: 12.5px; font-weight: 800; }
.list-block > p { margin: 0 0 8px; color: var(--ui-muted); font-size: 11px; line-height: 1.55; }
/* 逐条填：每条一块，字段竖着排，行尾一排小按钮 */
.row-card { margin-bottom: 7px; padding: 9px 10px; border: 1px solid var(--ui-line); border-radius: 5px; background: #fff; }
.row-card.active { border-color: var(--ui-accent); background: var(--ui-accent-soft); }
.row-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.row-card-top .no { flex: none; min-width: 20px; padding: 1px 5px; border-radius: 3px; background: var(--ui-accent-soft);
  color: var(--ui-accent-dark); font: 800 10px/1.7 var(--font-mono); text-align: center; }
.row-card.active .row-card-top .no { background: #fff; }
.row-card-top .sum { flex: 1; min-width: 0; overflow: hidden; font-size: 11.5px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.row-fields { display: grid; gap: 7px; }
.row-fields .fx { display: grid; gap: 4px; min-width: 0; }
.row-fields .fx > span { color: var(--ui-muted); font-size: 10.5px; font-weight: 700; }
.row-fields input,.row-fields select,.row-fields textarea { min-height: 34px; min-width: 0; padding: 6px 8px;
  border: 1px solid var(--ui-line); border-radius: 5px; background: #fff; font-size: 12.5px; }
.row-fields textarea { min-height: 60px; line-height: 1.6; resize: vertical; }
.row-fields.cols2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.row-fields.cols3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.row-fields .span2 { grid-column: span 2; }
.row-fields .span-all { grid-column: 1 / -1; }
.row-add { width: 100%; min-height: 36px; border-style: dashed; color: var(--ui-accent-dark); }
.row-add:hover { border-color: var(--ui-accent); background: var(--ui-accent-soft); }
.row-drag { width: 24px; height: 26px; flex: none; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--ui-line); border-radius: 5px; background: #fff; color: var(--ui-muted);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.row-drag::before { content: ""; width: 11px; height: 15px; opacity: .8;
  background: radial-gradient(circle, currentColor 1.3px, transparent 1.5px) 0 0 / 5.5px 5.5px; }
.row-drag:hover,.row-drag:focus-visible { border-color: var(--ui-accent); color: var(--ui-accent-dark); outline: none; }
.row-card.is-dragging { opacity: .45; }
.row-card.is-drop-before { box-shadow: inset 0 3px 0 var(--ui-accent); }
.row-card.is-drop-after { box-shadow: inset 0 -3px 0 var(--ui-accent); }
.lab-flag { display: inline-block; min-width: 15px; padding: 0 4px; border-radius: 3px; text-align: center;
  font: 800 10px/1.7 var(--font-mono); }
.lab-flag.up,.lab-flag.down { background: #f6e2e0; color: #9c332a; }
.lab-flag.crit { background: #9c332a; color: #fff; }
.lab-flag.ok { background: #e6ebe7; color: #4a6553; }
.film-slot { margin-bottom: 10px; }

/* 手机端触控尺寸：这一段必须放在文件最后，
   因为上面「新增界面件」里的基础规则和媒体查询同特异度，谁在后面谁赢。 */
@media (max-width:900px) {
  .row-fields input,.row-fields select { min-height: 42px; }
  .row-fields textarea { min-height: 66px; }
  .row-drag { width: 30px; height: 38px; }
  .row-card .row-actions button { min-height: 34px; }
  .doc-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .doc-button { min-height: 52px; }
}


/* ================= 06 英文 · 医院系统 =================
   现代 EMR 打印：Inter、全大写栏位名、只留横线不留竖线。 */
.rec[data-style="emr"] { --surface: #ffffff; --ink: #16202b; --accent: #14607a; --muted: #6b7885; --line: #d3dbe2; --warn: #c62828;
  --cjk: "OC Inter","OC Noto Sans SC",sans-serif; }
.rec[data-style="emr"] .rec-head { border-bottom: 1px solid var(--ink); }
.rec[data-style="emr"] .rec-logo { border-radius: 3px; }
.rec[data-style="emr"] .rec-org b { font-weight: 700; letter-spacing: -.01em; }
.rec[data-style="emr"] .rec-title { font-size: 1.12em; font-weight: 700; letter-spacing: .2em; text-indent: .2em; margin: 16px 0 10px; }
.rec[data-style="emr"] .rec-meta { border: 0; border-top: 1px solid var(--line); }
.rec[data-style="emr"] .rec-meta .kv { border-right: 0; }
.rec[data-style="emr"] .rec-meta dt { background: transparent; text-transform: uppercase; letter-spacing: .08em; font-size: .64em; }
.rec[data-style="emr"] .sec-h { text-transform: uppercase; letter-spacing: .12em; font-size: .8em;
  padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.rec[data-style="emr"] .sec-h::before { display: none; }
.rec[data-style="emr"] .lab th { background: transparent; border-bottom: 1px solid var(--ink);
  text-transform: uppercase; letter-spacing: .07em; font-size: .8em; font-weight: 600; }
.rec[data-style="emr"] .lab tr.crit { background: color-mix(in srgb,var(--warn) 7%,transparent); }
.rec[data-style="emr"] .rec-sign .sg { text-transform: uppercase; letter-spacing: .08em; font-size: .68em; }
.rec[data-style="emr"] .rec-sign .sg b { font-family: var(--cjk); font-size: .95em; font-weight: 500; }
.rec[data-style="emr"] .rec-foot { text-transform: uppercase; letter-spacing: .06em; font-size: .62em; }
.rec[data-style="emr"] .rp { font-family: "OC Inter",sans-serif; }
.rec[data-style="emr"] .vax-tab th { background: transparent; border-bottom: 1px solid var(--ink);
  text-transform: uppercase; letter-spacing: .06em; }

/* ================= 07 英文 · 诊所信笺 =================
   居中信笺头、Cormorant 衬线正文、栏位名用 Inter 小号大写。 */
.rec[data-style="chart"] { --surface: #fbf9f4; --ink: #23201b; --accent: #3f5540; --muted: #7a7466; --line: #cfc7b4; --warn: #a03828;
  --cjk: "OC Cormorant","Huiwen-Fangsong",serif; font-size: calc(15.5px * var(--tscale,1)); }
.rec[data-style="chart"] .rec-head { flex-direction: column; align-items: center; text-align: center; gap: 3px;
  padding-bottom: 12px; border-bottom: 1px solid var(--accent); }
.rec[data-style="chart"] .rec-org { flex-direction: column; gap: 6px; }
.rec[data-style="chart"] .rec-org b { font-size: 1.6em; font-weight: 600; letter-spacing: .05em; line-height: 1.2; }
.rec[data-style="chart"] .rec-org small { font-family: "OC Inter",sans-serif; letter-spacing: .3em; font-size: .5em; }
.rec[data-style="chart"] .rec-logo { border-radius: 50%; width: 30px; height: 30px; }
.rec[data-style="chart"] .rec-no { margin-left: 0; text-align: center; font-family: "OC Inter",sans-serif; font-size: .58em; letter-spacing: .06em; }
.rec[data-style="chart"] .rec-no b { display: inline; margin-right: 8px; }
.rec[data-style="chart"] .rec-title { font-weight: 400; font-style: italic; font-size: 1.24em; letter-spacing: .04em; text-indent: 0; }
.rec[data-style="chart"] .rec-meta { border-color: var(--line); }
.rec[data-style="chart"] .rec-meta dt { background: transparent; font-family: "OC Inter",sans-serif;
  font-size: .56em; text-transform: uppercase; letter-spacing: .1em; }
.rec[data-style="chart"] .sec-h { font-family: "OC Inter",sans-serif; font-size: .66em;
  text-transform: uppercase; letter-spacing: .14em; }
.rec[data-style="chart"] .sec-h::before { height: 9px; }
.rec[data-style="chart"] .lab th { background: transparent; font-family: "OC Inter",sans-serif;
  font-size: .66em; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--accent); }
.rec[data-style="chart"] .rec-sign .sg { font-family: "OC Inter",sans-serif; font-size: .6em;
  text-transform: uppercase; letter-spacing: .08em; }
.rec[data-style="chart"] .rec-sign .sg b { font-family: var(--cjk); font-size: 1.05em; font-style: italic; }
.rec[data-style="chart"] .rec-foot { font-family: "OC Inter",sans-serif; font-size: .56em; letter-spacing: .06em; }
.rec[data-style="chart"] .vax-tab th { background: transparent; font-family: "OC Inter",sans-serif;
  font-size: .6em; text-transform: uppercase; }

/* 英文栏位名比中文长，标签栏放宽一点；两行截断照旧 */
.rec[data-lang="en"] .rec-meta dt { width: 6.6em; }
.rec[data-lang="en"] .page-runner-head .rh-org,
.rec[data-lang="en"] .page-runner-head .rh-doc { font-family: inherit; }


/* 姓名不设字数限制，给它三行；其余值仍是两行 */
.rec-meta .kv-name dd span { -webkit-line-clamp: 3; }
