/* =====================================================================
   心电图报告通俗化阅读工具（本地版）
   UI 设计语言参照 shadcn/ui（new-york 风格：中性色 + 细边框 + 8px 圆角）
   适老化要求：正文 ≥16px、对比度 ≥ WCAG 2.1 AA、支持系统字体缩放
   ===================================================================== */

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 8%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 8%;
  --popover: 0 0% 100%;
  --muted: 240 5% 96%;
  --muted-foreground: 240 4% 42%;
  --accent: 240 5% 96%;
  --border: 240 6% 90%;
  --input: 240 6% 90%;
  --ring: 175 84% 26%;
  --primary: 175 84% 26%;
  --primary-foreground: 0 0% 100%;
  --secondary: 240 5% 96%;
  --secondary-foreground: 240 6% 10%;
  --destructive: 0 72% 45%;
  --destructive-foreground: 0 0% 100%;
  --success: 152 60% 30%;
  --warning-bg: 45 96% 90%;
  --warning-border: 38 92% 50%;
  --warning-fg: 26 90% 27%;
  --info-bg: 199 95% 94%;
  --info-border: 199 89% 48%;
  --info-fg: 199 89% 22%;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 12px -2px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
}

:root.dark {
  --background: 240 10% 4%;
  --foreground: 0 0% 98%;
  --card: 240 8% 8%;
  --card-foreground: 0 0% 98%;
  --popover: 240 8% 8%;
  --muted: 240 5% 15%;
  --muted-foreground: 240 5% 68%;
  --accent: 240 5% 15%;
  --border: 240 4% 18%;
  --input: 240 4% 20%;
  --ring: 172 66% 50%;
  --primary: 172 66% 42%;
  --primary-foreground: 240 10% 6%;
  --secondary: 240 5% 15%;
  --secondary-foreground: 0 0% 98%;
  --destructive: 0 62% 48%;
  --destructive-foreground: 0 0% 100%;
  --success: 152 55% 45%;
  --warning-bg: 38 60% 16%;
  --warning-border: 38 92% 45%;
  --warning-fg: 43 96% 80%;
  --info-bg: 199 60% 15%;
  --info-border: 199 89% 45%;
  --info-fg: 199 90% 82%;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 14px -2px rgb(0 0 0 / 0.5);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.011em; line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
p { margin: 0; }
a { color: hsl(var(--primary)); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 0.8125rem; }

::selection { background: hsl(var(--primary) / 0.18); }

:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------- 布局 */
.app { display: flex; min-height: 100vh; flex-direction: column; }

.disclaimer-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: #b91c1c;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.12);
  text-align: center;
}
.disclaimer-bar svg { flex: 0 0 auto; }

.topbar {
  position: sticky;
  top: 41px;
  z-index: 30;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.92);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 9px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.brand-title { font-size: 1rem; font-weight: 650; line-height: 1.2; }
.brand-sub { font-size: 0.75rem; color: hsl(var(--muted-foreground)); line-height: 1.2; }

.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }

.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font: inherit;
  font-size: 0.9375rem;
  padding: 8px 12px;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

/* 带文字的顶栏按钮（修改密码 / 退出登录）：图标 + 文字，点击区域更明确 */
.nav-btn-text {
  width: auto;
  padding: 0 10px;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
}

.nav-btn-text svg { flex: none; }

@media (max-width: 720px) {
  .nav-btn-text span { display: none; }
  .nav-btn-text { width: 36px; padding: 0; justify-content: center; }
}
.nav-btn:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.nav-btn[aria-current="true"] {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  font-weight: 600;
}

.main {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 80px;
  flex: 1;
}

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ------------------------------------------------------------- 卡片 */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header { padding: 18px 20px 0; display: flex; flex-direction: column; gap: 6px; }
.card-title { font-size: 1.0625rem; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-desc { font-size: 0.875rem; color: hsl(var(--muted-foreground)); }
.card-content { padding: 16px 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: hsl(var(--muted) / 0.4);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ------------------------------------------------------------- 按钮 */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s, transform 0.06s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover:not(:disabled) { background: hsl(var(--primary) / 0.88); }

.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover:not(:disabled) { background: hsl(var(--secondary) / 0.75); }

.btn-outline { border-color: hsl(var(--border)); background: hsl(var(--card)); color: hsl(var(--foreground)); }
.btn-outline:hover:not(:disabled) { background: hsl(var(--accent)); }

.btn-ghost { background: transparent; color: hsl(var(--foreground)); }
.btn-ghost:hover:not(:disabled) { background: hsl(var(--accent)); }

.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-destructive:hover:not(:disabled) { background: hsl(var(--destructive) / 0.9); }

.btn-sm { height: 32px; padding: 0 11px; font-size: 0.875rem; border-radius: 6px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 1rem; }
.btn-icon { width: 40px; padding: 0; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------- 表单 */
.label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 6px; }
.label .req { color: hsl(var(--destructive)); }

.input, .textarea, .select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  padding: 9px 12px;
  min-height: 42px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground) / 0.85); }

.field { display: flex; flex-direction: column; min-width: 0; }
.field-hint { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-top: 5px; }

.field-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field-row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.field-warn .input {
  border-color: hsl(var(--warning-border));
  background: hsl(var(--warning-bg));
  color: hsl(var(--warning-fg));
}

.field-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------- 徽标/标签 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-default { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); border-color: hsl(var(--border)); }
.badge-outline { border-color: hsl(var(--border)); color: hsl(var(--muted-foreground)); }
.badge-warn { background: hsl(var(--warning-bg)); color: hsl(var(--warning-fg)); border-color: hsl(var(--warning-border)); }
.badge-success { background: hsl(var(--success) / 0.12); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.35); }
.badge-danger { background: hsl(var(--destructive) / 0.1); color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / 0.3); }
.badge-info { background: hsl(var(--info-bg)); color: hsl(var(--info-fg)); border-color: hsl(var(--info-border) / 0.5); }

/* ------------------------------------------------------------- 提示块 */
.alert {
  display: flex;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.6);
  font-size: 0.9375rem;
  align-items: flex-start;
}
.alert svg { flex: 0 0 auto; margin-top: 2px; }
.alert-title { font-weight: 650; margin-bottom: 2px; }
.alert-danger { background: hsl(var(--destructive) / 0.07); border-color: hsl(var(--destructive) / 0.35); color: hsl(var(--destructive)); }
.alert-warn { background: hsl(var(--warning-bg)); border-color: hsl(var(--warning-border)); color: hsl(var(--warning-fg)); }
.alert-info { background: hsl(var(--info-bg)); border-color: hsl(var(--info-border) / 0.55); color: hsl(var(--info-fg)); }
.alert-success { background: hsl(var(--success) / 0.08); border-color: hsl(var(--success) / 0.35); color: hsl(var(--success)); }
.alert-plain { background: hsl(var(--card)); }

/* ------------------------------------------------------------- 上传区 */
.dropzone {
  border: 1.5px dashed hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--muted) / 0.35);
  padding: 26px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.05);
}
.dropzone-icon {
  width: 46px; height: 46px;
  margin: 0 auto 10px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}
.dropzone-title { font-weight: 650; margin-bottom: 4px; }
.dropzone-desc { font-size: 0.875rem; color: hsl(var(--muted-foreground)); }

/* ------------------------------------------------------------- 原图对照 */
.compare {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
  background: hsl(var(--card));
}
.compare-pane { min-width: 0; display: flex; flex-direction: column; }
.compare-pane + .compare-pane { border-left: 1px solid hsl(var(--border)); }
.compare-head {
  padding: 8px 12px;
  font-size: 0.8125rem;
  font-weight: 650;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.5);
  display: flex; align-items: center; gap: 6px;
}
.compare-body { padding: 12px; overflow: auto; max-height: 460px; }
.compare-body img, .compare-body iframe {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: #fff;
  display: block;
}
.ocr-lines { display: flex; flex-direction: column; gap: 3px; font-size: 0.8125rem; }
.ocr-line {
  display: flex; gap: 8px; justify-content: space-between;
  padding: 3px 6px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ocr-line.low { background: hsl(var(--warning-bg)); color: hsl(var(--warning-fg)); }
.ocr-line .score { color: hsl(var(--muted-foreground)); white-space: nowrap; }

/* ------------------------------------------------------------- 分级提示 */
.level-list { display: flex; flex-direction: column; gap: 12px; }
.level-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-left-width: 5px;
}
.level-1 { border-left-color: #0f766e; }
.level-2 { border-left-color: #ca8a04; }
.level-3 { border-left-color: #ea580c; }
.level-4 { border-left-color: #b91c1c; }
.level-0 { border-left-color: #6b7280; background: hsl(var(--muted) / 0.6); }
.level-num {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
.level-text { font-size: 0.9375rem; }
.level-meta { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-top: 4px; }

/* ------------------------------------------------------------- 术语卡 */
.term-card { border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); overflow: hidden; }
.term-head {
  padding: 14px 16px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.4);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.term-name { font-weight: 650; font-size: 1rem; }
.term-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.term-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
  text-transform: none;
  margin-bottom: 3px;
}
.term-source {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  border-top: 1px dashed hsl(var(--border));
  padding-top: 10px;
}

/* ------------------------------------------------------------- 紧急清单 */
.emergency { border-color: hsl(var(--destructive) / 0.35); }
.emergency .card-header { border-left: 4px solid hsl(var(--destructive)); padding-left: 16px; }
.emergency ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 0.9375rem; }

/* ------------------------------------------------------------- 表格 */
.table-wrap { overflow: auto; border: 1px solid hsl(var(--border)); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid hsl(var(--border)); vertical-align: top; }
.table th {
  font-size: 0.8125rem; font-weight: 650; color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.55); white-space: nowrap; position: sticky; top: 0;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: hsl(var(--accent) / 0.6); }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- 对话框 */
.dialog-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgb(0 0 0 / 0.5);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade 0.12s ease-out;
}
.dialog {
  width: min(680px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 24px 48px -12px rgb(0 0 0 / 0.35);
  animation: pop 0.14s ease-out;
}
.dialog-lg { width: min(900px, 100%); }
.dialog-header { padding: 20px 22px 0; }
.dialog-title { font-size: 1.125rem; font-weight: 650; }
.dialog-desc { font-size: 0.875rem; color: hsl(var(--muted-foreground)); margin-top: 4px; }
.dialog-body { padding: 16px 22px; }
.dialog-footer { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- Toast */
.toast-wrap {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(420px, calc(100vw - 40px));
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  box-shadow: var(--shadow-md);
  font-size: 0.9375rem;
  display: flex; gap: 10px; align-items: flex-start;
  animation: pop 0.14s ease-out;
}
.toast-success { border-left: 4px solid hsl(var(--success)); }
.toast-error { border-left: 4px solid hsl(var(--destructive)); }
.toast-info { border-left: 4px solid hsl(var(--primary)); }

/* ------------------------------------------------------------- 其它 */
.separator { height: 1px; background: hsl(var(--border)); border: 0; margin: 4px 0; }
.separator-v { width: 1px; align-self: stretch; background: hsl(var(--border)); }

.kv { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 8px 14px; font-size: 0.9375rem; }
.kv dt { color: hsl(var(--muted-foreground)); font-size: 0.875rem; }
.kv dd { margin: 0; word-break: break-all; }

.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: 0.8125rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8125rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid hsl(var(--primary-foreground) / 0.4);
  border-top-color: hsl(var(--primary-foreground));
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-dark {
  border-color: hsl(var(--primary) / 0.25);
  border-top-color: hsl(var(--primary));
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, hsl(var(--muted)) 25%, hsl(var(--accent)) 37%, hsl(var(--muted)) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: 6px;
  height: 14px;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9375rem; }
.checkline input[type="checkbox"] { width: 20px; height: 20px; margin-top: 2px; accent-color: hsl(var(--primary)); flex: 0 0 auto; }

.scroll-list { max-height: 380px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }

.hist-item {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  background: hsl(var(--card));
  flex-wrap: wrap;
}
.hist-item:hover { background: hsl(var(--accent) / 0.5); }
.hist-main { min-width: 0; }
.hist-title { font-weight: 600; font-size: 0.9375rem; }

.tabs { display: inline-flex; gap: 2px; padding: 3px; background: hsl(var(--muted)); border-radius: calc(var(--radius) - 2px); }
.tab {
  appearance: none; border: 0; background: transparent; font: inherit; font-size: 0.875rem;
  padding: 6px 12px; border-radius: 5px; cursor: pointer; color: hsl(var(--muted-foreground));
}
.tab[aria-selected="true"] { background: hsl(var(--background)); color: hsl(var(--foreground)); font-weight: 600; box-shadow: var(--shadow-sm); }

.consent-screen {
  position: fixed; inset: 0; z-index: 300;
  background: hsl(var(--background));
  overflow: auto;
  padding: 28px 18px;
}
.consent-card { max-width: 720px; margin: 0 auto; }

.progress { height: 6px; border-radius: 999px; background: hsl(var(--muted)); overflow: hidden; }
.progress > div { height: 100%; background: hsl(var(--primary)); transition: width 0.2s; }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }

.help-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 0.9375rem; }

.tag-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }

/* ------------------------------------------------------------- 响应式 */
@media (max-width: 1020px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  body { font-size: 16px; }
  .main { padding: 16px 14px 70px; }
  .topbar-inner { padding: 8px 14px; gap: 10px; }
  .nav { width: 100%; margin-left: 0; overflow-x: auto; padding-bottom: 2px; }
  .field-row, .field-row-2 { grid-template-columns: minmax(0, 1fr); }
  .compare { grid-template-columns: minmax(0, 1fr); }
  .compare-pane + .compare-pane { border-left: 0; border-top: 1px solid hsl(var(--border)); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dt { margin-top: 8px; }
  .disclaimer-bar { font-size: 0.875rem; padding: 9px 12px; }
  .toast-wrap { right: 12px; left: 12px; bottom: 12px; max-width: none; }
  .dialog-body, .dialog-header, .dialog-footer { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 400px) {
  h1 { font-size: 1.25rem; }
  .btn { padding: 0 12px; }
  .card-content { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

@media print {
  .topbar, .disclaimer-bar, .nav, .toast-wrap, .btn { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------------------------------------------------------------------
   语音播报按钮（逐条术语 / 整篇解读）
   播报中：三根音量条跳动 + 外圈脉冲环 + 文案改为“播报中”，
   让用户一眼看出“正在播哪一条”，而不是只听到声音。
   --------------------------------------------------------------------- */
.speak-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 11px 0 9px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 550;
  cursor: pointer;
  position: relative;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.speak-btn:hover { background: hsl(var(--accent)); border-color: hsl(var(--primary) / .45); }
.speak-btn:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }

/* 音量条：静止时略有起伏，播报时上下跳动 */
.eq { display: inline-flex; align-items: flex-end; gap: 2px; width: 14px; height: 14px; }
.eq i { display: block; width: 3px; border-radius: 1.5px; background: currentColor; height: 45%; opacity: .8; }
.eq i:nth-child(1) { height: 45%; }
.eq i:nth-child(2) { height: 85%; }
.eq i:nth-child(3) { height: 60%; }

.speak-btn.speaking {
  color: hsl(var(--primary));
  border-color: hsl(var(--primary) / .6);
  background: hsl(var(--primary) / .08);
}
.speak-btn.speaking .eq i { animation: eq-bounce .85s ease-in-out infinite; }
.speak-btn.speaking .eq i:nth-child(2) { animation-delay: .14s; }
.speak-btn.speaking .eq i:nth-child(3) { animation-delay: .28s; }

/* 外圈脉冲环：扩散两次后继续，提示“正在进行” */
.speak-btn.speaking::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  border: 2px solid hsl(var(--primary) / .5);
  animation: speak-ring 1.5s ease-out infinite;
  pointer-events: none;
}

@keyframes eq-bounce {
  0%, 100% { height: 30%; }
  25% { height: 100%; }
  50% { height: 50%; }
  75% { height: 88%; }
}
@keyframes speak-ring {
  0% { transform: scale(1); opacity: .9; }
  70% { transform: scale(1.14); opacity: 0; }
  100% { transform: scale(1.14); opacity: 0; }
}

/* 尊重“减少动态效果”系统设置：改为静态高亮 + 文字提示，不做动画 */
@media (prefers-reduced-motion: reduce) {
  .speak-btn.speaking .eq i { animation: none; height: 80%; }
  .speak-btn.speaking::after { animation: none; opacity: .45; }
  .speak-btn { transition: none; }
}

/* 窄屏：只留音量条与短文案，避免挤压术语标题 */
@media (max-width: 560px) {
  .speak-btn { padding: 0 9px; }
  .speak-btn .speak-label { font-size: 0.75rem; }
}

/* 结果页顶部的“下一步”卡片：读下一份报告的入口，视觉上比普通卡片略突出 */
.next-report {
  border-color: hsl(var(--primary) / .35);
  background: hsl(var(--primary) / .04);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 560px) {
  .next-report .card-content { flex-direction: column; align-items: stretch; }
  .next-report .row { width: 100%; }
  .next-report .row .btn { flex: 1; justify-content: center; }
}

/* ---------------------------------------------------------------------
   移动端（手机 / 微信内置浏览器）
   目标：单手可操作、触摸目标够大、拍照入口显眼、避开刘海与底部手势条。
   --------------------------------------------------------------------- */

/* 拍照主按钮：手机上应该是第一步最显眼的动作 */
.btn-camera {
  width: 100%;
  height: 56px;
  font-size: 1.0625rem;
  gap: 10px;
  box-shadow: 0 6px 18px hsl(var(--primary) / .25);
}
.btn-camera svg { width: 24px; height: 24px; }

/* 拍摄引导：四条要点，短到能一眼扫完 */
.camera-tips {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--secondary) / .5);
  border-radius: var(--radius);
  padding: 10px 12px;
  line-height: 1.55;
}
.camera-tips b { display: block; margin-bottom: 4px; color: hsl(var(--foreground)); font-weight: 600; }
.camera-tips .help-list { margin: 0; padding-left: 1.1em; }
.camera-tips .help-list li { margin: 2px 0; }

@media (max-width: 720px) {
  /* iOS 上小于 16px 的输入框会触发自动放大，破坏整页布局 */
  input, select, textarea { font-size: 16px; }

  /* 触摸目标不小于 44px（苹果与 Material 的共同下限）。
     .btn 系列用的是固定 height，写 min-height 不会生效，必须改 height。 */
  .btn { height: 44px; }
  .btn-sm { height: 44px; }
  .btn-lg { height: 50px; }
  .btn-icon { width: 44px; }
  .nav-btn { min-height: 44px; }
  /* 播报按钮原本 30px 高，手机上点起来太窄 */
  .speak-btn { height: 44px; padding: 0 14px 0 12px; font-size: 0.875rem; }
  .dropzone { padding: 26px 16px; }

  /* 底部操作区跟随安全区，避免被 iPhone 手势条盖住 */
  .card-footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
  }
  .card-footer .btn { flex: 1 1 46%; justify-content: center; }
  .card-footer .spacer { display: none; }

  /* 结果页两栏在手机上纵向堆叠：原件图片很长，若整页展开会把
     "识别文本"挤到很下面，改为面板内滚动（约半屏高） */
  .compare-body { max-height: 46vh; overflow: auto; }
  .compare-pane { min-width: 0; }

  /* 顶部保存/状态条更紧凑 */
  .topbar-inner { position: sticky; top: 0; }
}

@media (max-width: 420px) {
  .btn-camera { height: 52px; font-size: 1rem; }
  .card-title { font-size: 1rem; }
  .ocr-line { font-size: 0.8125rem; }
}
