/* ==========================================================================
   联签 · 设计令牌
   版式概念：台面上一叠纸——文档永远是画面里最亮、最浮起的物体，工具退到边上。
   配色取自签署这个行当本身的材料：钢笔墨蓝、朱砂印泥、档案纸与冷灰台面。
   ========================================================================== */

@font-face {
  font-family: "Plex Sans";
  src: url("/fonts/plex-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plex Sans";
  src: url("/fonts/plex-sans-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Plex Sans";
  src: url("/fonts/plex-sans-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* 文档字段可选的四种字体，和写进 PDF 的是同一款。先用本机已装的，没有才从服务端下载。 */
@font-face {
  font-family: "LqHei";
  src: local("SimHei"), local("黑体"), url("/doc-font/hei.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "LqFang";
  src: local("FangSong"), local("仿宋"), local("SimFang"), url("/doc-font/fang.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "LqKai";
  src: local("KaiTi"), local("楷体"), local("SimKai"), url("/doc-font/kai.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "LqDocHand";
  src: local("STXingkai"), local("华文行楷"), url("/doc-font/hand.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: only light;
  --canvas: #f3f5f8;
  --canvas-deep: #e8ecf1;
  --surface: #fafbfc;
  --surface-2: #ffffff;
  --paper: #ffffff;
  --text: #172033;
  --text-soft: #3a4558;
  --muted: #5a6578;
  --muted-2: #647084;
  --border: #dde2ea;
  --border-strong: #c4ccd8;
  --accent: #1b4fb5;
  --accent-top: #2a62c9;
  --accent-deep: #143f94;
  --accent-soft: #e8eefb;
  /* 签名位用主色的深阶，不再和错误红共用 */
  --sign: var(--accent-deep);
  /* 旧变量保留兼容；新代码用 --danger / --sign */
  --seal: var(--danger);
  --seal-soft: var(--danger-soft);
  --ok: #1f7a4d;
  --ok-soft: #e6f4ec;
  --warn: #9a5b00;
  --warn-soft: #fdf3e0;
  --danger: #b42318;
  --danger-soft: #fdeceb;

  --font-sans: "Plex Sans", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  /* 实用优先：标题与正文同一套无衬线，层级靠字号、字重和分隔线 */
  --font-display: var(--font-sans);
  --font-mono: "Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.375rem;
  --text-5xl: 3.25rem;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  /* --sp-5 是 20px：result.css / summary.css 早就在用它，但这一档一直没定义，
     整条 padding 声明会因此作废（浏览器把未知变量算成 invalid），
     表现就是「写了内边距却不生效」。 */
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-24: 96px;

  /* 小圆角；阴影只给浮层，不做渐变，层级仍靠 1px 线和底色差 */
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;

  --shadow-rgb: 23 32 51;
  --elev-1: none;
  --elev-2: none;
  --elev-3: none;
  --shadow-pop: 0 8px 24px rgb(23 32 51 / 0.14), 0 1px 3px rgb(23 32 51 / 0.1);
  --hairline: var(--border);
  --glass: var(--surface);

  --dur-1: 120ms;
  --dur-2: 180ms;
  --dur-3: 260ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.2, 0, 0, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* hidden 属性必须永远生效：组件的 display 规则不能把它盖掉 */
[hidden] {
  display: none !important;
}

html {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  color: var(--text);
  font: 400 var(--text-base) / 1.6 var(--font-sans);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p {
  margin: 0;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.num {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: var(--text-sm);
}
.tiny {
  font-size: var(--text-xs);
}
.strong {
  font-weight: 600;
}
.nowrap {
  white-space: nowrap;
}
.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;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.row {
  display: flex;
  align-items: center;
  min-width: 0;
}
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--text-soft);
}
.notice.warn {
  border-color: color-mix(in oklab, var(--warn) 35%, var(--border));
  background: var(--warn-soft);
  color: var(--warn);
}
.notice.danger {
  border-color: color-mix(in oklab, var(--danger) 35%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

/* ------------------------------------------------------------------ 骨架 */

.shell {
  position: relative;
  z-index: 1;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: none;
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  height: 58px;
  padding: 0 var(--sp-6);
  background: var(--paper);
  border-bottom: 1px solid var(--border-strong);
}

.topbar-compact {
  padding: 0 var(--sp-4);
  height: 54px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  flex: none;
}
.brand:hover {
  text-decoration: none;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  letter-spacing: 0.02em;
}
.brand-sub {
  color: var(--muted);
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.brand-sub:empty {
  display: none;
}

.brand-logo {
  display: block;
  flex: none;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.logo {
  display: inline-block;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 6px;
  background: url("/brand/logo.svg") center / contain no-repeat;
  color: transparent;
  font-size: 0;
  line-height: 0;
  user-select: none;
  overflow: hidden;
}
.logo.lg {
  width: 44px;
  height: 44px;
  border-radius: 9px;
}

.topbar-spacer {
  flex: 1;
}

/* lucide 图标：用 mask 取 currentColor，尺寸由内联样式给 */
.icon {
  display: inline-block;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat;
  mask: var(--i) center / contain no-repeat;
  vertical-align: -0.15em;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--text-sm);
}
.user-chip .avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}
.container-narrow {
  max-width: 720px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-8) 0 var(--sp-4);
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: var(--text-2xl);
  letter-spacing: -0.015em;
}
.page-head .sub {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-top: 6px;
}

/* ------------------------------------------------------------------ 按钮 */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 500 var(--text-sm) / 1 var(--font-sans);
  letter-spacing: 0.01em;
  text-decoration: none;
  vertical-align: middle;
  cursor: pointer;
  /* 文字永不换行；宽度不够时由外层省略或收缩，不允许把按钮撑成两行高 */
  white-space: nowrap;
  /* 作为 flex/grid 子项时不被内容压扁或撑大：同一行的按钮高度才对得齐 */
  flex: none;
  min-width: 0;
  box-sizing: border-box;
  transition:
    background var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.btn:hover:not([disabled]):not(.is-disabled) {
  text-decoration: none;
  background: color-mix(in oklab, var(--btn-bg) 92%, var(--text) 8%);
}
.btn:active:not([disabled]):not(.is-disabled) {
  transform: none;
  background: color-mix(in oklab, var(--btn-bg) 84%, var(--text) 16%);
}
.btn[disabled],
.btn.is-disabled {
  cursor: not-allowed;
  transform: none;
  /* 之前用「半透明原色」表达禁用：主按钮是白字蓝底，半透明后成了白字浅底，
     远看就是一个空白按钮。改成统一的灰底灰字，禁用一眼可读 */
  opacity: 1;
  --btn-bg: var(--surface, #f7f8f3);
  --btn-fg: color-mix(in oklab, var(--muted, #65716f) 85%, transparent);
  --btn-bd: var(--border, #d7dbd3);
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: none;
}
.btn-primary {
  --btn-fg: #fff;
  --btn-bd: var(--accent-deep);
  /* 颜色走 --btn-bg 变量，禁用态才能整体换成灰底灰字 */
  --btn-bg: var(--accent);
}
.btn-primary:hover:not([disabled]):not(.is-disabled) {
  --btn-bg: var(--accent-top);
}
.btn-ghost {
  --btn-bg: transparent;
  --btn-bd: transparent;
  box-shadow: none;
}
.btn-ghost:hover:not([disabled]):not(.is-disabled) {
  background: color-mix(in oklab, var(--text) 6%, transparent);
}
.btn-outline {
  --btn-bg: transparent;
  --btn-bd: var(--border-strong);
  box-shadow: none;
}
.btn-danger {
  --btn-fg: var(--danger);
  --btn-bd: color-mix(in oklab, var(--danger) 30%, var(--border));
  --btn-bg: var(--surface-2);
}
.btn-lg {
  height: 44px;
  padding: 0 22px;
  font-size: var(--text-lg);
  border-radius: var(--radius-md);
}
.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: var(--text-xs);
}
.btn-block {
  width: 100%;
}
/* 图标按钮：与同行普通按钮保持完全一致的高度，防止高低不齐 */
.btn-icon {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  flex: none;
}
.btn-sm.btn-icon {
  width: 30px;
  min-width: 30px;
  height: 30px;
}
.btn .icon,
.btn .ico {
  vertical-align: middle;
  flex: none;
}

/* ------------------------------------------------------------------ 表单 */

.label {
  display: block;
  margin-bottom: 5px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font: 400 var(--text-base) / 1.45 var(--font-sans);
  box-shadow: inset 0 1px 2px rgb(var(--shadow-rgb) / 0.03);
  transition:
    border-color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(29 63 94 / 0.12);
}
.input[readonly] {
  background: color-mix(in oklab, var(--surface) 70%, var(--canvas));
  color: var(--text-soft);
}
.textarea {
  resize: vertical;
  min-height: 84px;
}
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.input-sm {
  height: 32px;
  min-height: 32px;
  padding: 5px 9px;
  font-size: var(--text-sm);
}

.hint {
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.5;
}
.error-text {
  font-size: var(--text-xs);
  color: var(--danger);
}

/* ------------------------------------------------------------------ 面板与纸 */

.panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-1);
}
.panel-pad {
  padding: var(--sp-6);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.panel-head h2 {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.panel-body {
  padding: var(--sp-6);
}

.sheet {
  position: relative;
  background: var(--paper);
  border: 1px solid rgb(var(--shadow-rgb) / 0.1);
  border-radius: 2px;
  box-shadow:
    0 1px 2px rgb(var(--shadow-rgb) / 0.08),
    0 22px 44px -30px rgb(var(--shadow-rgb) / 0.45);
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: var(--sp-4) 0;
}

/* 章节标题：中文工具界面里的“小标题”，只靠字号和字重；中文没有大小写，不加字距、不做装饰线 */
.section-title {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-soft);
}

/* ------------------------------------------------------------------ 桌面 */

.workbench {
  padding: var(--sp-8) 0 var(--sp-16);
}

/* 上传区 */
.dropzone {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-6);
  border: 1px dashed color-mix(in oklab, var(--accent) 34%, var(--border));
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  cursor: pointer;
  transition:
    border-color var(--dur-2) var(--ease-out),
    background var(--dur-2) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out);
}
.dropzone:hover,
.dropzone.is-drag {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: var(--elev-2);
}
.dropzone.is-drag {
  outline: 3px solid rgb(29 63 94 / 0.1);
}
.dropzone-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
}
.dropzone h3 {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: 0;
}
.dropzone p {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-top: 3px;
}

/* ------------------------------------------------------------------ 文档列表（账册式） */

.doc-title {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  letter-spacing: 0.01em;
  color: var(--text);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-title:hover {
  color: var(--accent);
  text-decoration: none;
}
.doc-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--text-xs);
}
.sep-dot::before {
  content: "·";
  margin-right: 10px;
  color: var(--muted-2);
}

/* ------------------------------------------------------------------ 状态标记 */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
/* 状态只有一种中性样式：状态之间的区别靠文字，不靠颜色 */
.dot {
  width: 6px;
  height: 6px;
  background: currentColor;
  flex: none;
}
.dot-live {
  background: var(--seal);
}

.fingerprint {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ 空状态 */

.empty {
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--surface-2) 55%, transparent);
}
.empty h3 {
  font-size: var(--text-lg);
  color: var(--text-soft);
  margin-bottom: 6px;
}

/* ------------------------------------------------------------------ 提示条 */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 460px);
  padding: 10px 16px;
  background: #1b2423;
  color: #f4f6f1;
  font-size: var(--text-sm);
  box-shadow: var(--elev-3);
  animation: toast-in 220ms var(--ease-out);
}
.toast.err {
  background: #5a211a;
}
.toast.ok {
  background: #1c3f31;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ------------------------------------------------------------------ 弹层 */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgb(18 26 25 / 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-2) var(--ease-out);
}
.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  z-index: 71;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -48%);
  width: min(92vw, 560px);
  max-height: 88vh;
  overflow: auto;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--elev-3);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--dur-2) var(--ease-out),
    transform var(--dur-2) var(--ease-out);
}
.modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.modal-body {
  padding: var(--sp-6);
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
}

/* 右侧抽屉：预览用 */
.drawer {
  position: fixed;
  z-index: 71;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(760px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  border-left: 1px solid var(--border);
  box-shadow: var(--elev-3);
  transform: translateX(100%);
  transition: transform var(--dur-3) var(--ease-out);
}
.drawer.open {
  transform: none;
}
.drawer-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.drawer-body {
  flex: 1;
  overflow: auto;
  padding: var(--sp-6);
}

/* ------------------------------------------------------------------ 加载 */

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in oklab, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.skeleton {
  background: linear-gradient(
    90deg,
    color-mix(in oklab, var(--text) 6%, transparent),
    color-mix(in oklab, var(--text) 3%, transparent),
    color-mix(in oklab, var(--text) 6%, transparent)
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------------------------------------------------------------- 全屏加载页 */
/* 阶段和百分比都来自真实工作量；拿不到比例时用流动条，不编数字。 */
.loader {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: var(--canvas);
}
.loader.is-fixed {
  position: fixed;
  z-index: 100;
}
.loader[hidden] {
  display: none;
}
.loader-card {
  width: min(380px, 100%);
  padding: var(--sp-6);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-pop);
}
.loader-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--sp-6);
}
.loader-title {
  font-size: var(--text-lg);
}
.loader-sub {
  min-height: 1.6em;
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-sm);
}
.meter {
  position: relative;
  height: 6px;
  margin-top: var(--sp-4);
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width var(--dur-3) var(--ease-out);
}
.meter.is-wait::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 28%;
  background: rgb(255 255 255 / 0.4);
  animation: meter-wait 1.1s var(--ease-in-out) infinite;
}
@keyframes meter-wait {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(360%);
  }
}
.loader-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: 8px;
  color: var(--muted);
  font-size: var(--text-xs);
}
.loader-row .mono {
  color: var(--text);
  font-size: var(--text-sm);
}
.loader-steps {
  margin: var(--sp-4) 0 0;
  padding: var(--sp-3) 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
  display: grid;
  gap: 7px;
}
.loader-steps li {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 8px;
  align-items: center;
  color: var(--muted-2);
  font-size: var(--text-sm);
}
.loader-steps li::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
}
.loader-steps li.is-active {
  color: var(--text);
  font-weight: 500;
}
.loader-steps li.is-active::before {
  border: 2px solid var(--accent);
}
.loader-steps li.is-done {
  color: var(--text-soft);
}
.loader-steps li.is-done::before {
  content: "✓";
  display: grid;
  place-items: center;
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
  font-size: 9px;
  line-height: 1;
}
.loader-steps li small {
  color: var(--muted);
  font: 11px/1 var(--font-mono);
}
.loader-hint {
  margin-top: var(--sp-4);
}
.loader-hint .btn {
  margin-top: 8px;
}
.loader.is-error .meter > i {
  background: var(--danger);
}
@media (prefers-reduced-motion: reduce) {
  .meter.is-wait::after {
    animation: none;
  }
  .meter > i {
    transition: none;
  }
}

/* ------------------------------------------------------------------ 响应式 */

@media (max-width: 900px) {
  .container {
    padding: 0 var(--sp-4);
  }
  .topbar {
    padding: 0 var(--sp-4);
  }
  .brand-sub {
    display: none;
  }
}

/* ------------------------------------------------------------------ 签署模板中心全局样式 */
.tpl-modal {
  width: min(92vw, 560px);
}
.tpl-library-modal {
  width: min(94vw, 760px);
  max-height: 84vh;
}
.tpl-summary-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px);
  background: var(--surface, #fafbfc);
}
.tpl-summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tpl-file-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tpl-file-meta strong {
  font-size: var(--text-sm, 13px);
  color: var(--text, #172033);
}
.tpl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.tpl-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-2, #ffffff);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-soft, #475467);
}

.tpl-list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 160px;
  max-height: 58vh;
  overflow-y: auto;
  padding: 2px;
}
.tpl-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 140px;
  color: var(--muted, #667085);
  font-size: 13px;
}
.tpl-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  text-align: center;
  color: var(--muted, #667085);
  gap: 8px;
}
.tpl-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px);
  background: var(--surface-2, #ffffff);
  transition: border-color var(--dur-1, 0.15s) var(--ease-out), box-shadow var(--dur-1, 0.15s) var(--ease-out);
}
.tpl-card:hover {
  border-color: color-mix(in oklab, var(--accent) 40%, var(--border));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.tpl-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.tpl-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #172033);
  line-height: 1.3;
}
.tpl-card-time {
  font-size: 11.5px;
  color: var(--muted-2, #8b95a5);
  white-space: nowrap;
}
.tpl-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-card-file {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-soft, #344054);
}
.tpl-card-specs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted, #667085);
}
.tpl-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

@media (max-width: 640px) {
  .page-head {
    padding-top: var(--sp-6);
  }
  /* 各弹窗自己的 width: min(94vw, …) 在后加载的页面样式里，会盖掉这里的全宽，
     让底部抽屉右边露出一条缝。叠一层 .modal 提高优先级，手机上一律贴边全宽。 */
  .modal.modal {
    width: 100vw;
    max-width: 100vw;
    left: 0;
    right: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal {
    width: 100vw;
    max-height: 92vh;
    top: auto;
    bottom: 0;
    left: 0;
    transform: translateY(12px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal.open {
    transform: none;
  }
  .drawer {
    width: 100vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 微信内置浏览器的下载引导层。
   微信不允许存盘，点下载只会毫无反应；这层告诉用户怎么改用浏览器打开，
   并给出可直接复制的临时下载链接。外层用全站通用的 .overlay / .modal，
   这里只补几个内容区的细节。 */
.wx-dl-lead {
  margin: 0 0 var(--sp-4);
}
.wx-dl-steps {
  margin: 0 0 var(--sp-4);
  padding-left: 1.25em;
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text-soft);
}
.wx-dl-steps li + li {
  margin-top: 6px;
}
.wx-dl-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-2);
}
.wx-dl-link {
  min-width: 0;
  font-size: 11.5px;
}
.wx-dl-status {
  margin: var(--sp-3) 0 0;
  min-height: 18px;
  line-height: 1.6;
}


/* TOUCH44: 窄屏上所有可点的按钮至少 44×44 CSS px。
   手指比鼠标粗得多，30px 高的按钮在手机上经常点不中；
   这条放在文件末尾，用同等特异性覆盖前面各页面的 btn-sm 尺寸。 */
@media (max-width: 820px) {
  .btn,
  .btn-sm,
  .tool-btn,
  button.btn,
  a.btn {
    min-height: 44px;
  }
  .modal .btn-sm,
  .sheet .btn-sm {
    padding-top: 10px;
    padding-bottom: 10px;
  }
  /* 「填写人 0」「字段 1」这类可折叠标题本身也是按钮，同样要能点中 */
  .insp-title-btn {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* ==========================================================================
   分段切换（js/segmented.js）：选项等分一行，白色滑块跟着滑；可点、可拖、可划
   ========================================================================== */
.seg {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(var(--seg-count, 3), minmax(0, 1fr));
  padding: 3px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--border) 55%, var(--canvas));
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.seg-thumb {
  position: absolute;
  z-index: -1;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / var(--seg-count, 3));
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.14), 0 1px 1px rgba(16, 24, 40, 0.06);
  transform: translateX(calc(var(--seg-index, 0) * 100%));
  transition: transform 220ms cubic-bezier(0.3, 0.7, 0.2, 1);
}
.seg.is-dragging .seg-thumb {
  transform: translateX(var(--seg-drag, 0));
  transition: none;
}
.seg.is-dragging {
  cursor: grabbing;
}
.seg-btn {
  min-width: 0;
  height: 32px;
  padding: 0 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: 500 13px/1 var(--font-sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: color 160ms;
  -webkit-tap-highlight-color: transparent;
}
.seg-btn:hover {
  color: var(--text);
}
.seg-btn.is-active,
.seg.is-dragging .seg-btn.is-near {
  color: var(--text);
  font-weight: 600;
}
.seg.is-dragging .seg-btn.is-active:not(.is-near) {
  color: var(--muted);
  font-weight: 500;
}
.seg-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
@media (prefers-reduced-motion: reduce) {
  .seg-thumb {
    transition: none;
  }
}

/* ==========================================================================
   拖动排序（js/sortable.js）：其他行让位时滑动，被拖的行浮起来跟手
   ========================================================================== */
.is-sorting {
  user-select: none;
  -webkit-user-select: none;
}
.is-sorting .sort-item {
  transition: transform 180ms cubic-bezier(0.3, 0.7, 0.2, 1);
}
.is-sorting .sort-item.is-dragging {
  position: relative;
  z-index: 5;
  transition: none;
  background: var(--surface, #fff);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16), 0 2px 6px rgba(16, 24, 40, 0.08);
  border-radius: var(--radius-md, 8px);
}
.is-sorting .sort-item.is-dragging.is-settling {
  transition: transform 180ms cubic-bezier(0.3, 0.7, 0.2, 1), box-shadow 180ms;
  box-shadow: none;
}
.sort-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}
.sort-handle:hover {
  color: var(--text-soft);
  background: var(--surface-2);
}
.is-sorting .sort-handle {
  cursor: grabbing;
}
@media (prefers-reduced-motion: reduce) {
  .is-sorting .sort-item,
  .is-sorting .sort-item.is-dragging.is-settling {
    transition: none;
  }
}

/* 整行可拖：鼠标在行上显示抓手；手指按住时行轻轻下沉，提示「再按一下就能拖」 */
.sort-rows .sort-item {
  cursor: grab;
}
.sort-rows .sort-item button,
.sort-rows .sort-item input {
  cursor: pointer;
}
.sort-rows .sort-item.is-pressing {
  background: var(--surface-2, #f3f5f8);
  transition: background 300ms;
}

/* --------------------------------------------------------------------------
   全站页脚：ICP 备案号。
   挂在每个页面最外层容器（.shell / body）的最后一个子项上，flex:none，
   高度很薄，内容区自己 flex:1 收缩，所以不会把页面顶出屏幕。
   -------------------------------------------------------------------------- */
.icp-footer {
  flex: none;
  align-self: stretch;
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 12px calc(4px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
  text-align: center;
}
.icp-footer a {
  color: var(--muted);
  white-space: nowrap;
}
.icp-footer a:hover {
  color: var(--text);
}
/* 矮屏（横屏手机等）再压薄一点，别挤占操作用的高度 */
@media (max-height: 640px) {
  .icp-footer {
    min-height: 22px;
    padding-block: 2px;
  }
}

/* --------------------------------------------------------------------------
   页脚单音彩蛋：点击非链接区域时在点击处轻飘一个淡色音符后消失，不改页脚原有外观。
   -------------------------------------------------------------------------- */
.icp-footer {
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.fegg-note {
  position: absolute;
  z-index: 60;
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  transform: translate(-50%, -50%);
  animation: fegg-float 680ms var(--ease-out) forwards;
}

@keyframes fegg-float {
  0% {
    opacity: 0.78;
    transform: translate(-50%, -50%) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-50% - 22px)) scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fegg-note {
    animation-duration: 240ms;
  }
  @keyframes fegg-float {
    0% {
      opacity: 0.7;
      transform: translate(-50%, -50%);
    }
    100% {
      opacity: 0;
      transform: translate(-50%, -50%);
    }
  }
}
