/* OCR识别 — 视觉令牌对齐 GroundingPI Studio。全部本地资源，无外链字体/图标。 */

:root {
  color-scheme: light;
  --brand: #3d5afe;
  --brand-strong: #2f47d6;
  --brand-soft: #eef1ff;
  --accent: #00b4a6;
  --accent-soft: #e4f8f6;
  --bg: #f4f6fa;
  --bg-grad-1: rgba(61, 90, 254, 0.07);
  --bg-grad-2: rgba(0, 180, 166, 0.06);
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --surface-3: #f1f4f9;
  --border: #e3e8f0;
  --border-strong: #d3dae6;
  --text: #16202e;
  --text-2: #55637a;
  --text-3: #8695aa;
  --ok: #10a37f;
  --ok-soft: #e6f7f1;
  --warn: #d98324;
  --warn-soft: #fdf3e5;
  --err: #e0475f;
  --err-soft: #fdecef;
  --info: #3d7efe;
  --shadow-xs: 0 1px 2px rgba(20, 32, 54, 0.05);
  --shadow-sm: 0 2px 8px rgba(20, 32, 54, 0.06), 0 1px 2px rgba(20, 32, 54, 0.04);
  --shadow-md: 0 10px 30px rgba(20, 32, 54, 0.09), 0 2px 6px rgba(20, 32, 54, 0.04);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
    "Noto Sans CJK SC", "WenQuanYi Micro Hei", Roboto, Arial, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;
  --stage-h: 520px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --brand: #7d93ff;
  --brand-strong: #98a9ff;
  --brand-soft: rgba(125, 147, 255, 0.14);
  --accent: #3fd6c6;
  --accent-soft: rgba(63, 214, 198, 0.14);
  --bg: #0c1017;
  --bg-grad-1: rgba(125, 147, 255, 0.1);
  --bg-grad-2: rgba(63, 214, 198, 0.07);
  --surface: #141a24;
  --surface-2: #171e2a;
  --surface-3: #1d2532;
  --border: #242e3d;
  --border-strong: #334052;
  --text: #eef2f8;
  --text-2: #9fadc2;
  --text-3: #6d7c92;
  --ok: #35d5a5;
  --ok-soft: rgba(53, 213, 165, 0.13);
  --warn: #f0b263;
  --warn-soft: rgba(240, 178, 99, 0.13);
  --err: #ff7189;
  --err-soft: rgba(255, 113, 137, 0.13);
  --info: #79a0ff;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html {
  margin: 0;
  min-height: 100%;
  /* 预留纵向滚动条槽，避免内容变高时整页左右晃动 */
  overflow-y: scroll;
  scrollbar-gutter: stable;
}
body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 620px at 8% -10%, var(--bg-grad-1), transparent 62%),
    radial-gradient(900px 520px at 96% 0%, var(--bg-grad-2), transparent 58%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 650; letter-spacing: -0.01em; }
button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
.hidden, [hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 26px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px; color: #fff;
  background: linear-gradient(140deg, var(--brand) 8%, var(--accent) 118%);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 34%, transparent);
}
.brand-mark .ic { width: 21px; height: 21px; stroke-width: 1.9; }
.brand-text h1 { font-size: 17px; line-height: 1.25; }
.brand-text p { font-size: 12px; color: var(--text-3); letter-spacing: 0.01em; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  font-size: 12.5px; font-weight: 550;
  box-shadow: var(--shadow-xs);
  transition: all 0.18s var(--ease);
}
.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-3) 18%, transparent);
}
.status-pill.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.status-pill.ok .dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent);
  animation: pulse 2.4s var(--ease) infinite;
}
.status-pill.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); color: var(--warn); }
.status-pill.warn .dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 20%, transparent);
}
.status-pill.err { border-color: color-mix(in srgb, var(--err) 38%, var(--border)); color: var(--err); }
.status-pill.err .dot {
  background: var(--err);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 20%, transparent);
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 4%, transparent); }
}

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); box-shadow: var(--shadow-xs);
  transition: all 0.16s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }
.icon-btn:active { transform: scale(0.96); }

/* 页面骨架 */
.page { max-width: 1320px; margin: 0 auto; padding: 20px 26px 48px; }
.task-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.seg {
  display: inline-flex; gap: 4px; padding: 4px;
  border-radius: var(--r-md); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-xs);
}
.seg-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 600; transition: all 0.16s var(--ease);
}
.seg-item .ic { width: 15px; height: 15px; }
.seg-item:hover { color: var(--text); background: var(--surface-3); }
.seg-item.active {
  background: var(--brand-soft); color: var(--brand);
  box-shadow: var(--shadow-xs);
}
.task-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: all 0.16s var(--ease); box-shadow: var(--shadow-xs);
}
.btn .ic { width: 16px; height: 16px; }
.btn:hover { border-color: var(--border-strong); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 32%, transparent);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand) 100%);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 40%, transparent);
  border-color: transparent; color: #fff;
}
.btn-ghost { background: var(--surface-2); }
.btn.tiny { padding: 5px 11px; font-size: 12px; gap: 5px; }
.btn.tiny .ic { width: 13px; height: 13px; }

.workspace {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* 字段定义条 */
.schema-bar {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 10px;
}
.schema-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.schema-head h2 { font-size: 13px; }
.schema-head p { font-size: 12px; color: var(--text-2); margin-top: 2px; max-width: 52rem; }
.field-list { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: grid; grid-template-columns: minmax(140px, 0.9fr) minmax(180px, 1.4fr) auto; gap: 8px; align-items: center; }
.input {
  width: 100%; padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 13px; outline: none; transition: all 0.16s var(--ease);
}
.input:hover { border-color: var(--border-strong); }
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}
textarea.input { resize: vertical; min-height: 88px; font-family: var(--mono); font-size: 12px; line-height: 1.55; }
.schema-json { margin-top: 2px; }
.schema-json summary {
  cursor: pointer; font-size: 12px; color: var(--text-2); font-weight: 600;
  width: fit-content; user-select: none;
}
.schema-json summary:hover { color: var(--text); }
.schema-json .json-hint { font-weight: 400; color: var(--text-3); margin-left: 8px; }
.schema-error { font-size: 12px; color: var(--err); min-height: 1em; }

/* 左右工作台 */
.stage { display: grid; grid-template-columns: 1fr 1fr; height: var(--stage-h); min-height: 0; overflow: hidden; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pane + .pane { border-left: 1px solid var(--border); }
.pane-hd {
  flex: none; height: 50px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-bottom: 1px solid var(--border); gap: 8px;
}
.pane-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; }
.step { font-family: var(--mono); font-size: 10px; color: var(--text-3); font-weight: 500; }
.badge {
  font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--text-3); background: var(--surface-3);
  padding: 3px 6px; border-radius: 4px;
}
.badge.brand { color: var(--brand); background: var(--brand-soft); }
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
.badge.err { color: var(--err); background: var(--err-soft); }
.pane-actions { display: flex; align-items: center; gap: 6px; }
.caption {
  flex: none; height: 36px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface-3); color: var(--text-2); font-size: 12px;
}
.caption-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); }
.caption-meta { font-family: var(--mono); font-size: 10px; color: var(--text-3); white-space: nowrap; }

/* 左侧预览 / 拖拽区 */
.art-body {
  flex: 1; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  background-image: radial-gradient(var(--border-strong) 0.7px, transparent 0.7px);
  background-size: 14px 14px;
  overflow: hidden;
}
.dropzone {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 24px; text-align: center; cursor: pointer;
  transition: all 0.18s var(--ease);
}
.dropzone .dropzone-ic { width: 32px; height: 32px; color: var(--brand); margin-bottom: 4px; }
.dropzone strong { font-size: 14px; font-weight: 620; }
.dropzone span { font-size: 12px; color: var(--text-3); }
.art-body.has-file .dropzone { display: none; }
.art-body.dragging {
  outline: 2px dashed var(--brand); outline-offset: -6px;
  background-color: var(--brand-soft);
}

/* 预览框铺满左侧工作区。图片用绝对定位 + object-fit:contain 完整缩入，
   避免作为 flex 子项时 min-width:auto 按原始像素宽度无法收缩、被 overflow 裁切。 */
.preview-frame {
  display: none;
  position: absolute;
  inset: 16px;
  overflow: hidden;
}
.art-body.has-file .preview-frame {
  display: block;
}
.preview-frame img:not([hidden]),
.preview-frame iframe:not([hidden]) {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  box-sizing: border-box;
}
.preview-frame iframe { background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.preview-pdf {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; width: min(320px, 100%); min-height: 200px; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm); color: var(--text-2);
}
.preview-pdf .ic { width: 36px; height: 36px; color: var(--brand); }
.preview-pdf strong { color: var(--text); font-size: 13px; word-break: break-all; text-align: center; }

/* 扫描光带：从上到下循环，直到请求返回 */
.scan-overlay {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
  opacity: 0; visibility: hidden; border-radius: 6px;
  transition: opacity 0.2s var(--ease);
}
.preview-frame.scanning .scan-overlay { opacity: 1; visibility: visible; }
.scan-dim {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
}
.scan-beam {
  position: absolute; left: -8%; right: -8%; height: 120px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--brand) 35%, transparent) 36%,
    color-mix(in srgb, var(--accent) 85%, #fff) 50%,
    color-mix(in srgb, var(--brand) 35%, transparent) 64%,
    transparent 100%
  );
  box-shadow: 0 0 28px color-mix(in srgb, var(--accent) 70%, transparent);
  animation: scan-sweep 1.7s ease-in-out infinite;
}
.scan-beam::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 50%; height: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent), 0 0 22px color-mix(in srgb, var(--brand) 80%, transparent);
}
@keyframes scan-sweep {
  0% { top: -120px; }
  100% { top: 100%; }
}

.pane-foot {
  flex: none; min-height: 40px; padding: 8px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2);
}
.status-msg {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0;
}
.status-msg .led {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none;
}
.status-msg.idle .led { background: var(--text-3); }
.status-msg.ready .led { background: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.status-msg.busy .led { background: var(--warn); animation: blink 1s steps(2) infinite; }
.status-msg.ok .led { background: var(--ok); }
.status-msg.err .led { background: var(--err); }
.status-msg.busy { color: var(--warn); }
.status-msg.ok { color: var(--ok); }
.status-msg.err { color: var(--err); }
@keyframes blink { 50% { opacity: 0.35; } }

/* 右侧结果 */
.res-toolbar {
  flex: none; height: 36px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.format-note { font-size: 11px; color: var(--text-3); }
.res-body {
  flex: 1; min-height: 0; overflow: auto; padding: 16px 20px;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.res-empty {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 8px;
  color: var(--text-3); padding: 20px;
}
.res-empty .ic { width: 36px; height: 36px; color: var(--brand); opacity: 0.7; }
.res-empty h3 { font-size: 15px; color: var(--text); font-weight: 600; }
.res-empty p { font-size: 12px; line-height: 1.8; }
.res-busy {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; color: var(--text-2);
}
.res-busy .spin {
  width: 22px; height: 22px; border: 2px solid var(--border-strong);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.res-content { display: none; animation: fade-in 0.25s var(--ease); }
.res-content.show { display: block; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.md-view { font-size: 13.5px; line-height: 1.75; overflow-wrap: anywhere; }
.md-view h1, .md-view h2, .md-view h3, .md-view h4 { line-height: 1.4; margin: 0.85em 0 0.4em; }
.md-view h1 { font-size: 1.25em; }
.md-view h2 { font-size: 1.15em; }
.md-view h3 { font-size: 1.05em; }
.md-view p { margin: 0.5em 0; }
.md-view ul, .md-view ol { padding-left: 1.4em; margin: 0.4em 0; }
.md-view pre {
  margin: 10px 0; padding: 12px 14px; overflow: auto;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-family: var(--mono); font-size: 12px; line-height: 1.6;
  white-space: pre-wrap;
}
.md-view code { font-family: var(--mono); font-size: 0.92em; }
.md-view p code, .md-view li code {
  background: var(--surface-3); padding: 1px 5px; border-radius: 4px;
}
.md-view table { border-collapse: collapse; width: 100%; font-size: 12px; margin: 12px 0; }
.md-view th, .md-view td { border: 1px solid var(--border); padding: 7px 9px; text-align: left; }
.md-view th { background: var(--surface-3); font-weight: 650; }
.md-view blockquote {
  margin: 10px 0; padding: 8px 12px;
  border-left: 3px solid var(--brand); background: var(--brand-soft);
}
.md-view a { color: var(--brand); }
.raw-view {
  margin: 0; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--mono); font-size: 12px; line-height: 1.7; color: var(--text);
}
.kv-list { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.kv-row { display: grid; grid-template-columns: 140px 1fr; gap: 0; border-top: 1px solid var(--border); }
.kv-row:first-child { border-top: 0; }
.kv-row dt {
  padding: 9px 12px; background: var(--surface-3); color: var(--text-2);
  font-size: 12px; font-weight: 650; word-break: break-all;
}
.kv-row dd { padding: 9px 12px; margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.kv-row dd.null { color: var(--text-3); font-style: italic; }

/* API 说明 */
.api-page { padding: 20px 22px 28px; display: flex; flex-direction: column; gap: 16px; }
.api-intro h2 { font-size: 16px; }
.api-intro p { margin-top: 6px; color: var(--text-2); font-size: 13px; }
.api-intro code, .api-card code, .curl-box code {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-3); padding: 1px 5px; border-radius: 4px;
}
.api-card {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); overflow: hidden;
}
.api-card-hd {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.method {
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 999px; color: #fff;
  background: var(--brand);
}
.method.get { background: var(--ok); }
.api-path { font-family: var(--mono); font-size: 13px; font-weight: 650; }
.api-card-bd { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.api-card h3 { font-size: 12px; color: var(--text-2); font-weight: 650; }
.param-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.param-table th, .param-table td {
  text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top;
}
.param-table th { font-size: 11px; color: var(--text-3); font-weight: 650; }
.curl-box, .resp-box {
  margin: 0; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: 12px; line-height: 1.65;
  white-space: pre-wrap; overflow: auto; color: var(--text);
}
.api-copy-row { display: flex; justify-content: flex-end; }

@media (max-width: 900px) {
  .page { padding: 16px 14px 36px; }
  .topbar { padding: 12px 14px; }
  .stage { grid-template-columns: 1fr; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--border); }
  .pane { min-height: 380px; }
  .field-row { grid-template-columns: 1fr; }
  .status-pill.compact-hide { display: none; }
}

/* 悬浮预览按钮：仅在鼠标悬停（或焦点）时显示，离开即隐藏 */
.preview-hover {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s var(--ease);
}
.preview-frame:hover .preview-hover,
.preview-frame:has(.preview-btn:focus-visible) .preview-hover {
  opacity: 1;
}
.preview-btn {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(20, 32, 54, 0.12);
  color: #16202e;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s var(--ease), transform 0.18s var(--ease), color 0.18s var(--ease);
}
.preview-btn:hover {
  background: rgba(255, 255, 255, 0.72);
}
.preview-btn:active { transform: scale(0.98); }
.preview-btn-run {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 33.333%;
  height: 33.333%;
  transform: translate(-50%, -50%);
  border-radius: 16px;
}
.preview-btn-run:active { transform: translate(-50%, -50%) scale(0.98); }
.preview-btn-run .ic {
  width: 40%;
  height: 40%;
  max-width: 56px;
  max-height: 56px;
  stroke-width: 1.8;
}
.preview-btn-zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
.preview-btn-zoom .ic { width: 18px; height: 18px; }
.preview-frame:not(.is-image) .preview-btn-zoom { display: none; }

/* 原图查看：按图片原始像素显示，超出时在遮罩内滚动，不改 body overflow，避免整页晃动 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 18, 28, 0.55);
  overflow: auto;
  overscroll-behavior: contain;
}
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 81;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 10px;
  color: #16202e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.lightbox-close .ic { width: 18px; height: 18px; }
.lightbox-close:hover { background: rgba(255, 255, 255, 0.72); }
.lightbox-stage {
  box-sizing: border-box;
  min-width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 24px;
}
.lightbox-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  box-shadow: var(--shadow-md);
  background: #fff;
}

@media (hover: none) {
  .art-body.has-file .preview-hover { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .preview-frame.scanning .scan-beam { top: 42%; }
  .preview-frame.scanning .scan-overlay { opacity: 1; visibility: visible; }
}

/* 识别结果：扫描时长、表格横向滚动、font 行内片段 */
.res-toolbar .scan-time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 650;
  color: var(--text-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.res-toolbar .scan-time[hidden] { display: none; }
.res-toolbar .format-note { margin-left: 0; }
.md-view { overflow-x: auto; }
.md-view table {
  width: max-content;
  max-width: none;
  min-width: 100%;
}
.md-view tr:first-child td { font-weight: 650; background: var(--surface-3); }
.ocr-line {
  display: block;
  margin: 0;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.ocr-font { display: inline; }
.md-view.streaming .ocr-caret::after {
  content: "▍";
  color: var(--brand);
  animation: blink 1s steps(2) infinite;
}
