:root {
  --bg: #fffbeb;
  --surface: #fffff8;
  --surface2: #fef9d7;
  --border: #e5d97a;
  --accent: #92400e;
  --accent2: #b45309;
  --gold: #b45309;
  --gold2: #d97706;
  --text: #1c1611;
  --text2: #3d2c0f;
  --text3: #7c6343;
  --green: #166534;
  --red: #b91c1c;
  --amber: #d97706;
  --purple: #6d28d9;
  --tag-a: #1e40af;
  --tag-b: #065f46;
  --tag-c: #5b21b6;
  --tag-d: #78350f;
  --tag-e: #9f1239;
  --tag-f: #0e7490;
  --radius: 8px;
  --radius-lg: 14px;

  /* ── Spacing scale (8px rhythm) — additive, #13 ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-8: 48px;

  /* ── Elevation: warm near-black tinted shadows (not pure black) ── */
  --shadow-xs: 0 1px 2px rgba(28,22,17,0.06);
  --shadow-sm: 0 2px 6px rgba(28,22,17,0.08);
  --shadow-md: 0 6px 16px -4px rgba(28,22,17,0.10);
  --shadow-lg: 0 16px 32px -8px rgba(28,22,17,0.12);

  /* ── Type scale ── */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 26px;

  /* ── Motion ── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 0.15s;
  --dur: 0.2s;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  /* 正文走系统中文字体栈（零网络延迟，境内首屏不再等 Google Fonts）；
     远程 Noto Serif SC / JetBrains Mono 仅用于标题与等宽，异步加载。 */
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Noto Sans SC', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Background grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(180,83,9,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180,83,9,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

body.guest .header,
body.guest .layout {
  display: none;
}

body.authenticated .login-welcome {
  display: none;
}

.login-welcome {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 44px;
  display: flex;
  align-items: center;
  background:
    linear-gradient(120deg, rgba(255,251,235,0.95), rgba(255,248,238,0.98)),
    repeating-linear-gradient(90deg, rgba(146,64,14,0.05) 0 1px, transparent 1px 96px);
}

.welcome-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 430px;
  gap: 48px;
  align-items: center;
}

.welcome-copy {
  padding: 28px 0;
}

.welcome-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: rgba(255,255,248,0.78);
  border: 1px solid rgba(146,64,14,0.16);
  border-radius: 8px;
  margin-bottom: 34px;
}

.welcome-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #1c1611;
  color: #fef3c7;
  font-family: 'Noto Serif SC', serif;
  font-weight: 700;
  font-size: 20px;
}

.welcome-brand strong,
.welcome-brand span {
  display: block;
}

.welcome-brand strong {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
}

.welcome-brand span {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.4px;
}

.welcome-kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 18px;
}

.welcome-copy h1 {
  max-width: 720px;
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text);
}

.welcome-lead {
  max-width: 680px;
  margin-top: 22px;
  color: var(--text2);
  font-size: 16px;
  line-height: 1.9;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.welcome-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 42px;
  max-width: 760px;
}

.welcome-flow div {
  background: rgba(255,255,248,0.72);
  border: 1px solid rgba(146,64,14,0.14);
  border-radius: 8px;
  padding: 16px;
}

.welcome-flow span,
.welcome-flow strong,
.welcome-flow small {
  display: block;
}

.welcome-flow span {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent2);
  font-size: 11px;
  margin-bottom: 10px;
}

.welcome-flow strong {
  font-size: 14px;
  margin-bottom: 4px;
}

.welcome-flow small {
  color: var(--text3);
  font-size: 12px;
  line-height: 1.5;
}

.welcome-auth-card {
  background: rgba(255,255,248,0.94);
  border: 1px solid rgba(146,64,14,0.18);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

.welcome-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.welcome-card-head strong,
.welcome-card-head span {
  display: block;
}

.welcome-card-head strong {
  font-family: 'Noto Serif SC', serif;
  font-size: 22px;
}

.welcome-card-head span {
  color: var(--text3);
  font-size: 12px;
  margin-top: 4px;
}

.welcome-status {
  font-size: 12px;
  color: var(--green);
  background: rgba(22,101,52,0.08);
  border: 1px solid rgba(22,101,52,0.18);
  border-radius: 999px;
  padding: 6px 10px;
  white-space: nowrap;
}

.welcome-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 20px 0;
  background: #fff8ee;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}

.welcome-tabs button {
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 10px;
  font: inherit;
  cursor: pointer;
  color: var(--text3);
}

.welcome-tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
}

.welcome-panel {
  display: none;
}

.welcome-panel.active {
  display: block;
}

.welcome-panel label {
  display: block;
  margin: 12px 0 6px;
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
}

.welcome-panel input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
  font: inherit;
  color: var(--text);
}

.welcome-panel input:focus {
  outline: none;
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(180,83,9,0.12);
}

.welcome-submit {
  width: 100%;
  margin-top: 18px;
}

.welcome-demo {
  width: 100%;
  margin-top: 10px;
}

.welcome-forgot-link {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 6px 0;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 13px;
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  border-radius: var(--radius-sm, 8px);
  transition: color var(--dur, 0.2s) var(--ease-out, ease), background var(--dur, 0.2s) var(--ease-out, ease);
}
.welcome-forgot-link:hover {
  color: var(--accent2);
  background: #fef3e2;
}
.welcome-forgot-link:focus-visible {
  outline: none;
  color: var(--accent2);
  box-shadow: 0 0 0 2px rgba(180,83,9,0.22);
}
.welcome-forgot-link:active { transform: translateY(1px); }

.welcome-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--text3);
  font-size: 12px;
  line-height: 1.7;
}

/* HEADER */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(253,248,240,0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.header-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.5px;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn {
  padding: 7px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  font-family: 'Noto Sans SC', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  min-height: 36px;
  white-space: nowrap;
}

/* ── Tactile press feedback (#13) ── */
.btn:active,
.btn-primary:active,
.btn-gold:active,
.btn-green:active,
.btn-danger:active,
.btn-ghost:active {
  transform: translateY(1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: #fef3e2; color: var(--text); border-color: #c8b89a; }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: #1e40af; }

.btn-gold {
  background: linear-gradient(135deg, #b45309, #d97706);
  color: white;
  font-weight: 600;
}
.btn-gold:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-green {
  background: var(--green);
  color: white;
}
.btn-green:hover { background: #166534; }
.btn-danger {
  background: rgba(185,28,28,0.08);
  color: var(--red);
  border: 1px solid rgba(185,28,28,0.22);
}
.btn-danger:hover { background: rgba(185,28,28,0.14); }

/* LAYOUT */
.layout {
  display: flex;
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 60px);
}

/* SIDEBAR */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: #fff8ee;
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  padding: 0 16px;
  margin-bottom: 24px;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
  padding: 0 4px;
}

.case-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.case-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.case-item:hover { background: #fef3e2; }
.case-item.active { background: rgba(29,78,216,0.08); border-color: rgba(29,78,216,0.25); }

.case-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 3px;
}

.case-item-meta {
  font-size: 11px;
  color: var(--text3);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.case-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.tag-A { background: rgba(29,78,216,0.1); color: #1d4ed8; border: 1px solid rgba(29,78,216,0.2); }
.tag-B { background: rgba(15,118,110,0.1); color: #0f766e; border: 1px solid rgba(15,118,110,0.2); }
.tag-C { background: rgba(124,58,237,0.1); color: #7c3aed; border: 1px solid rgba(124,58,237,0.2); }
.tag-D { background: rgba(180,83,9,0.1); color: #b45309; border: 1px solid rgba(180,83,9,0.2); }
.tag-E { background: rgba(190,18,60,0.1); color: #be123c; border: 1px solid rgba(190,18,60,0.2); }
.tag-F { background: rgba(14,116,144,0.1); color: #0e7490; border: 1px solid rgba(14,116,144,0.2); }

.progress-ring {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text3);
}

.progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}
.progress-dot.incomplete { background: var(--text3); }
.progress-dot.error { background: var(--red); }

.feature-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feature-nav-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text2);
  cursor: pointer;
  font-family: 'Noto Sans SC', sans-serif;
  transition: all 0.15s;
}

.feature-nav-item:hover { border-color: var(--accent); background: #fef3e2; }
.feature-nav-item span { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.feature-nav-item small { display: block; font-size: 11px; color: var(--text3); margin-top: 2px; line-height: 1.4; }

.folder-quick-filter {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}

.folder-quick-filter button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text3);
  border-radius: 6px;
  padding: 5px 0;
  font-size: 11px;
  font-family: 'Noto Sans SC', sans-serif;
  cursor: pointer;
}

.folder-quick-filter button.active,
.folder-quick-filter button:hover {
  color: var(--accent2);
  border-color: var(--accent);
  background: #fef3e2;
}

.case-tag-muted {
  background: rgba(124,99,67,0.08);
  color: var(--text3);
  border: 1px solid rgba(124,99,67,0.14);
}

.case-tag-accent {
  background: rgba(29,78,216,0.1);
  color: var(--tag-a);
  border: 1px solid rgba(29,78,216,0.18);
}

.case-tag-success {
  background: rgba(22,163,74,0.1);
  color: var(--green);
  border: 1px solid rgba(22,163,74,0.18);
}

.case-tag-danger {
  background: rgba(220,38,38,0.1);
  color: var(--red);
  border: 1px solid rgba(220,38,38,0.18);
}

.case-tag-ai {
  background: rgba(139,92,246,0.15);
  color: #7c3aed;
  border: 1px solid rgba(139,92,246,0.22);
}

.case-progress-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text3);
}

.case-progress-chip.complete { color: var(--green); }

/* MAIN */
.main {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
  max-width: calc(100vw - 260px);
}

/* PAGE VIEWS */
.page { display: none; }
.page.active { display: block; }

/* MODULE SELECTOR */
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--accent));
  opacity: 0;
  transition: opacity 0.2s;
}

.module-card:hover { border-color: var(--card-color, var(--accent)); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.module-card:hover::before { opacity: 1; }
.module-card.selected { border-color: var(--card-color, var(--accent)); background: #fef9f0; }
.module-card.selected::before { opacity: 1; }

.module-card .module-icon { font-size: 28px; margin-bottom: 10px; }
.module-card .module-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.module-card .module-name {
  font-size: 15px;
  font-weight: 600;
  font-family: 'Noto Serif SC', serif;
  color: var(--text);
  margin-bottom: 6px;
}
.module-card .module-desc { font-size: 12px; color: var(--text3); line-height: 1.5; }
.module-card .module-count { font-size: 11px; color: var(--text3); margin-top: 10px; font-family: 'JetBrains Mono', monospace; }

/* FORM */
.form-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.form-title-block {}
.form-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.form-subtitle { font-size: 13px; color: var(--text3); }

/* 病例表单返回按钮（移动端核心导航：← 返回总览，配合左滑手势） */
.entry-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
  padding: 8px 14px 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent2);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur, 0.2s) var(--ease-out, ease), color var(--dur, 0.2s) var(--ease-out, ease), transform var(--dur-fast, 0.15s) var(--ease-out, ease);
}
.entry-back-btn .entry-back-arrow {
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
}
.entry-back-btn:hover { background: #fef3e2; }
.entry-back-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(180,83,9,0.22);
}
.entry-back-btn:active { transform: translateX(-2px); }

/* 移动端：返回按钮吸顶常驻，始终可点（手势之外的稳妥入口） */
@media (max-width: 699px) {
  .entry-back-btn {
    position: sticky;
    top: 8px;
    z-index: 90;
    width: 100%;
    justify-content: center;
    padding-top: 10px;
    padding-bottom: 10px;
    font-size: 15px;
    box-shadow: var(--shadow-sm);
  }
}

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}

.entry-eyebrow {
  font-size: 12px;
  color: var(--accent2);
  font-weight: 700;
  margin-bottom: 4px;
}

.entry-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 23px;
  font-weight: 700;
  color: var(--text);
}
.pii-reveal-title { cursor: pointer; }

.entry-subtitle {
  color: var(--text3);
  font-size: 12px;
  margin-top: 5px;
}

.entry-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.autosave-indicator {
  align-self: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg2);
  color: var(--text3);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  line-height: 1;
  white-space: nowrap;
}
.autosave-indicator.saving {
  color: var(--amber);
  border-color: rgba(217,119,6,0.25);
  background: rgba(217,119,6,0.08);
}
.autosave-indicator.saved {
  color: var(--green);
  border-color: rgba(22,101,52,0.24);
  background: rgba(22,101,52,0.08);
}

.entry-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.entry-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.entry-summary-card span,
.entry-summary-card small {
  display: block;
  color: var(--text3);
  font-size: 11px;
  line-height: 1.45;
}

.entry-summary-card strong {
  display: block;
  color: var(--text);
  font-size: 16px;
  font-family: 'JetBrains Mono', 'Noto Sans SC', sans-serif;
  margin: 4px 0;
}

.phase-progress-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.phase-progress-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text2);
  box-shadow: var(--shadow-xs);
}
.phase-progress-card.active {
  border-color: var(--accent);
  background: rgba(180,83,9,0.07);
}
.phase-progress-card.done strong { color: var(--green); }
.phase-progress-card span {
  display: block;
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 4px;
}
.phase-progress-card strong {
  display: block;
  font-size: 15px;
  color: var(--text);
  font-family: 'JetBrains Mono', 'Noto Sans SC', sans-serif;
}
.phase-progress-card i {
  display: block;
  height: 4px;
  margin-top: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.phase-progress-card b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.mini-progress {
  height: 5px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.mini-progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 3px;
}

.field-input-wrap { position: relative; }
.field-input.has-unit { padding-right: 48px; }
.field-unit {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
  pointer-events: none;
}

.entry-workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 290px;
  gap: 12px;
  align-items: start;
}

.entry-nav-panel,
.entry-form-panel,
.entry-assistant-panel {
  min-width: 0;
}

.entry-nav-panel,
.entry-assistant-panel {
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-panel-heading,
.entry-panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.entry-panel-heading strong,
.entry-panel-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.entry-panel-heading span {
  display: block;
  color: var(--text3);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.5;
}

.phase-missing-panel {
  background: #fffdf2;
  border: 1px solid rgba(217,119,6,0.2);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.phase-missing-panel.ok {
  background: rgba(22,101,52,0.06);
  border-color: rgba(22,101,52,0.2);
}
.phase-missing-panel strong,
.phase-missing-panel span {
  display: block;
}
.phase-missing-panel strong {
  font-size: 13px;
  color: var(--text);
}
.phase-missing-panel span {
  font-size: 12px;
  color: var(--text3);
  margin-top: 3px;
}
.phase-missing-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.phase-missing-chip {
  border: 1px solid rgba(217,119,6,0.22);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--accent2);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
.phase-missing-chip:hover { background: #fef3e2; }
.phase-missing-more {
  align-self: center;
  font-size: 12px;
  color: var(--text3);
}
.phase-reject-note {
  margin-top: 10px;
  border: 1px solid rgba(185,28,28,0.18);
  background: rgba(185,28,28,0.06);
  border-radius: var(--radius);
  padding: 9px;
}
.phase-reject-note b {
  display: block;
  color: var(--red);
  font-size: 12px;
  margin-bottom: 3px;
}
.media-slot-group.is-current-missing {
  outline: 2px solid rgba(217,119,6,0.45);
  outline-offset: 3px;
  border-radius: var(--radius);
}

.entry-section-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}

.entry-section-nav button {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 7px;
  align-items: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
  font-family: 'Noto Sans SC', sans-serif;
  color: var(--text2);
}

.entry-section-nav button:hover {
  background: #fef3e2;
  border-color: var(--border);
}

.entry-section-nav button strong {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.entry-action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.auto-status-note {
  color: var(--text3);
  background: #fffdf2;
  border: 1px solid rgba(146,64,14,0.12);
  border-radius: var(--radius);
  padding: 8px;
  font-size: 12px;
  line-height: 1.55;
  margin: 8px 0;
}

.review-action-panel {
  border-color: rgba(14,116,144,0.18);
  background: #fffdf2;
}

.review-state-box {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px;
  margin: 10px 0;
}

.review-state-box span,
.review-state-box small {
  display: block;
  color: var(--text3);
  font-size: 11px;
  line-height: 1.45;
}

.review-state-box strong {
  display: block;
  color: var(--text);
  font-size: 18px;
  margin: 3px 0;
}

.review-reason {
  color: var(--red);
  background: rgba(185,28,28,0.07);
  border: 1px solid rgba(185,28,28,0.16);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 10px;
}

.review-action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.review-action-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text2);
  padding: 9px 10px;
  font-size: 12px;
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.review-action-btn:hover { background: #fef3e2; border-color: var(--accent); }
.review-action-btn.primary { color: var(--accent2); border-color: rgba(180,83,9,0.24); background: rgba(180,83,9,0.07); }
.review-action-btn.success { color: var(--green); border-color: rgba(22,101,52,0.24); background: rgba(22,101,52,0.07); }
.review-action-btn.warning { color: var(--amber); border-color: rgba(217,119,6,0.24); background: rgba(217,119,6,0.07); }
.review-action-btn.danger { color: var(--red); border-color: rgba(185,28,28,0.22); background: rgba(185,28,28,0.07); }

.section-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.section-header:hover { background: #fef3e2; }

.section-icon { font-size: 18px; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
.section-progress {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text3);
}
.section-chevron {
  color: var(--text3);
  font-size: 12px;
  transition: transform 0.2s;
}
.section-chevron.open { transform: rotate(180deg); }

.section-body { padding: 16px; display: none; }
.section-body.open {
  display: block;
  animation: sectionFadeIn 0.18s ease;
}
@keyframes sectionFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.form-full { grid-column: 1 / -1; }

.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: 0;
}

.field-required { color: var(--red); margin-left: 2px; }

.field-level {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.level-core {
  color: var(--red);
  background: rgba(185,28,28,0.08);
  border: 1px solid rgba(185,28,28,0.16);
}

.level-recommended {
  color: var(--amber);
  background: rgba(217,119,6,0.08);
  border: 1px solid rgba(217,119,6,0.16);
}

.level-optional {
  color: var(--text3);
  background: rgba(124,99,67,0.08);
  border: 1px solid rgba(124,99,67,0.12);
}

.field-input {
  background: #fffdf8;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 11px;
  font-size: 13px;
  font-family: 'Noto Sans SC', sans-serif;
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  width: 100%;
  min-height: 38px;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(146,64,14,0.22);
}

.field-input::placeholder { color: var(--text3); }

.btn:disabled,
.btn-primary:disabled,
.btn-gold:disabled,
.btn-green:disabled,
.btn-danger:disabled,
.btn-ghost:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ── Inline validation (#13) ── */
.field-input.is-invalid {
  border-color: var(--red);
}
.field-input.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(185,28,28,0.22);
}
.field-error {
  font-size: var(--text-xs);
  color: var(--red);
  margin-top: var(--space-1);
  line-height: 1.4;
}
.field-group.is-current-missing {
  border-radius: var(--radius);
  background: rgba(217,119,6,0.07);
  box-shadow: 0 0 0 1px rgba(217,119,6,0.18);
  padding: 8px;
  margin: -8px;
}

select.field-input { cursor: pointer; }

textarea.field-input {
  resize: vertical;
  min-height: 74px;
  max-height: 220px;
  line-height: 1.6;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: #fffdf8;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 12px;
  color: var(--text2);
}
.checkbox-item:hover { border-color: var(--accent); color: var(--text); }
.checkbox-item input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }
.checkbox-item.checked { border-color: rgba(29,78,216,0.4); background: rgba(29,78,216,0.07); color: var(--text); }

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.score-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.score-label { font-size: 11px; color: var(--text3); margin-bottom: 8px; }
.score-value { font-size: 24px; font-weight: 700; font-family: 'JetBrains Mono', monospace; color: var(--accent); }
.score-max { font-size: 11px; color: var(--text3); }

.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}
.image-upload-area:hover { border-color: var(--accent); background: rgba(29,78,216,0.04); }
.image-upload-area .upload-icon { font-size: 32px; margin-bottom: 8px; }
.image-upload-area .upload-text { font-size: 13px; color: var(--text3); }
.image-upload-area .upload-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

.image-grid {
  display: grid;
  /* 槽位 + 多张图 + ＋按钮全部放在同一网格里 */
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

/* 每个槽位是一个 flex 容器，包含该槽位所有已上传图片 + ＋按钮 */
.media-slot-group {
  display: contents;  /* 让子元素直接参与外层 grid，视觉上连续排列 */
}

.media-phase-title {
  margin-top: 18px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent2);
}

.media-group-title {
  margin-top: 10px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

.image-thumb {
  aspect-ratio: 1;
  background: #f0e8d8;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}
.image-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-thumb .img-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0.82));
  font-size: 11px;
  line-height: 1.35;
  padding: 18px 7px 6px;
  color: #ffffff;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
  font-weight: 600;
  word-break: break-word;
}
.image-thumb .img-count {
  color: var(--text3);
  margin-left: 3px;
}
.upload-add-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  height: 100%;
}
.upload-add-icon {
  font-size: 28px;
  color: var(--text3);
  line-height: 1;
}
.upload-add-label {
  font-size: 11px;
  color: var(--text3);
}
.visually-hidden-file { display: none; }
.media-phase-hint {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 14px;
}
.image-thumb .img-remove {
  position: absolute;
  top: 4px; right: 4px;
  z-index: 3;
  background: rgba(239,68,68,0.8);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ＋添加更多图片按钮卡片 */
.image-thumb-add {
  background: var(--bg2);
  border: 2px dashed var(--border);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.image-thumb-add:hover {
  border-color: var(--accent);
  background: var(--bg3, #f5f0e8);
}
.image-thumb-add:hover span {
  color: var(--accent) !important;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.rating-label { font-size: 13px; color: var(--text2); min-width: 120px; }
.rating-stars {
  display: flex;
  gap: 4px;
}
.star {
  font-size: 18px;
  cursor: pointer;
  color: var(--text3);
  transition: color 0.1s;
}
.star.filled { color: var(--gold); }

.measurement-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 8px;
  align-items: center;
}
.measurement-unit {
  font-size: 12px;
  color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
}

.highlight-box {
  background: rgba(29,78,216,0.04);
  border: 1px solid rgba(29,78,216,0.15);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.highlight-box .hb-title { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }

.tag-input-area {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 42px;
  cursor: text;
}
.input-tag {
  padding: 3px 10px;
  background: rgba(29,78,216,0.1);
  color: var(--accent);
  border-radius: 20px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.input-tag button { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0; line-height: 1; }
.tag-input-field { background: none; border: none; outline: none; font-size: 13px; color: var(--text); min-width: 80px; font-family: 'Noto Sans SC', sans-serif; }

/* Progress bar */
.overall-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.progress-bar-container { flex: 1; }
.progress-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text3); margin-bottom: 6px; }
.progress-bar-track { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #1d4ed8, #2563eb); transition: width 0.5s ease; }
.progress-pct { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; color: var(--accent); min-width: 48px; text-align: right; }

/* AI Generate Panel */
.ai-panel {
  background: linear-gradient(135deg, rgba(124,58,237,0.05), rgba(29,78,216,0.05));
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 24px;
}
.ai-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.ai-panel-icon { font-size: 22px; }
.ai-panel-main { flex: 1; }
.ai-panel-title { font-size: 15px; font-weight: 600; color: var(--text); }
.ai-panel-subtitle { font-size: 12px; color: var(--text3); margin-top: 1px; }
.ai-panel-subtitle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
}
.ai-key-status {
  font-size: 11px;
}
.ai-key-status.ok { color: var(--green); }
.ai-key-status.warn {
  color: var(--red);
  cursor: pointer;
}
.ai-settings-btn {
  font-size: 11px;
  padding: 5px 10px;
}

.ai-generate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.ai-model-selector {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(180px, 1.2fr);
  gap: 10px;
  margin-bottom: 10px;
}
.ai-model-selector label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.ai-model-selector span {
  font-size: 11px;
  color: var(--text3);
  font-weight: 600;
}
.ai-route-note {
  margin: -2px 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(20, 184, 166, 0.08);
  color: var(--text3);
  font-size: 11px;
  line-height: 1.6;
}

.ai-gen-btn {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(139,92,246,0.3);
  background: rgba(139,92,246,0.08);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-family: 'Noto Sans SC', sans-serif;
  transition: all 0.2s;
  text-align: left;
  font-weight: 500;
}
.ai-gen-btn:hover { background: rgba(139,92,246,0.18); border-color: rgba(139,92,246,0.5); transform: translateY(-1px); }
.ai-gen-btn .gen-icon { font-size: 20px; display: block; margin-bottom: 6px; }
.ai-gen-btn .gen-label { font-size: 12px; color: var(--text3); display: block; margin-top: 2px; font-weight: 400; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 700; font-family: 'Noto Serif SC', serif; }
.modal-close { background: none; border: none; color: var(--text3); font-size: 22px; cursor: pointer; padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--text); }

.modal-body { font-size: 14px; line-height: 1.8; color: var(--text2); }
.modal-body h3 { font-family: 'Noto Serif SC', serif; font-size: 16px; color: var(--text); margin: 16px 0 8px; }
.modal-body p { margin-bottom: 10px; }
.modal-body .ai-loading { text-align: center; padding: 32px; }
.modal-body .ai-loading .load-icon { font-size: 40px; animation: spin 1.5s linear infinite; display: block; margin-bottom: 12px; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.output-text {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 420px;
  overflow-y: auto;
  font-family: 'Noto Sans SC', sans-serif;
}

.scan-modal { max-width: 980px; }
.scan-modal-subtitle {
  color: var(--text3);
  font-size: 12px;
  margin-top: 4px;
}

.scan-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
}

.scan-left,
.scan-right {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fffdf2;
  padding: 14px;
}

.scan-upload-btn {
  display: block;
  text-align: center;
  border: 1px dashed var(--accent);
  background: #fef3e2;
  color: var(--accent2);
  border-radius: var(--radius);
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 12px;
}

.scan-upload-btn input { display: none; }

.scan-preview {
  min-height: 260px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 12px;
}

.scan-preview img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  display: block;
}

.scan-placeholder,
.scan-empty,
.scan-loading,
.scan-error,
.scan-note {
  color: var(--text3);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  padding: 16px;
}

.scan-note {
  text-align: left;
  padding: 10px 0 0;
}

.scan-error { color: var(--red); }

.scan-result-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.scan-result-body {
  max-height: 460px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scan-result-row {
  display: grid;
  grid-template-columns: 18px 1fr 44px;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
  cursor: pointer;
}

.scan-result-row input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.scan-result-row strong {
  display: block;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 5px;
}

.scan-result-row em {
  display: block;
  font-style: normal;
  color: var(--accent2);
  font-size: 13px;
  line-height: 1.45;
}

.scan-result-row small {
  display: block;
  color: var(--text3);
  font-size: 11px;
  line-height: 1.45;
  margin-top: 4px;
}

.scan-result-row b {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--green);
  text-align: right;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Toast */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  animation: toastIn 0.3s ease;
  box-shadow: var(--shadow-lg);
  width: fit-content;
  max-width: 100%;
}
.toast-icon { font-size: 18px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Tabs */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 10px 18px;
  font-size: 13px;
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 500;
  color: var(--text3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent2); border-bottom-color: var(--accent2); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Stats bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.stat-value { font-size: 28px; font-weight: 700; font-family: 'JetBrains Mono', monospace; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text3); margin-top: 4px; }
.stat-trend { font-size: 11px; color: var(--green); margin-top: 2px; }

.folder-board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.folder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  font-family: 'Noto Sans SC', sans-serif;
  color: var(--text2);
  transition: all 0.15s;
  min-height: 78px;
}

.folder-card:hover,
.folder-card.active {
  border-color: var(--accent);
  background: #fef3e2;
  box-shadow: inset 0 0 0 1px rgba(180,83,9,0.1);
}

.folder-card strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 5px;
}

.folder-card em {
  font-style: normal;
  color: var(--accent2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.folder-card span {
  display: block;
  color: var(--text3);
  font-size: 11px;
  line-height: 1.45;
}

.task-board {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 16px;
}

.task-board-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.task-board-header strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.task-board-header span,
.task-board-header small {
  display: block;
  color: var(--text3);
  font-size: 12px;
  margin-top: 3px;
}

.task-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.task-item {
  border: 1px solid rgba(146,64,14,0.16);
  background: #fffdf2;
  border-radius: var(--radius);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  font-family: 'Noto Sans SC', sans-serif;
}

.task-item:hover { border-color: var(--accent); background: #fef3e2; }
.task-item span {
  display: inline-block;
  margin-bottom: 5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(180,83,9,0.08);
  color: var(--accent2);
  font-size: 11px;
  font-weight: 700;
}
.task-item strong {
  display: block;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.55;
  font-weight: 500;
}

.task-empty {
  color: var(--text3);
  font-size: 13px;
  padding: 8px 0 2px;
}

.admission-task-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(146,64,14,0.16);
  background: #fffdf2;
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 8px;
}

.admission-task-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
}

.admission-task-title span {
  display: inline-block;
  margin-left: 6px;
  color: var(--accent2);
  background: rgba(180,83,9,0.08);
  border: 1px solid rgba(180,83,9,0.14);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
}

.admission-task-meta {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.55;
}

.admission-task-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admission-draft-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.admission-draft-item {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px;
}

.admission-draft-item span {
  display: block;
  color: var(--text3);
  font-size: 11px;
  margin-bottom: 5px;
}

.admission-draft-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.feature-overview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-xs);
}

.deployment-status-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  background: rgba(217,119,6,0.08);
  border: 1px solid rgba(217,119,6,0.22);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.deployment-status-card.cloud-ready {
  background: rgba(22,101,52,0.07);
  border-color: rgba(22,101,52,0.22);
}

.deployment-status-card strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 4px;
}

.deployment-status-card span {
  display: block;
  color: var(--text3);
  font-size: 12px;
  line-height: 1.55;
}

.feature-overview-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.feature-overview-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.feature-overview-subtitle {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.feature-card {
  border: 1px solid rgba(146,64,14,0.12);
  background: #fffdf8;
  border-radius: var(--radius);
  padding: 10px;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feature-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.feature-card-desc {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.5;
  flex: 1;
}

.feature-card-action {
  align-self: flex-start;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent2);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11px;
  font-family: 'Noto Sans SC', sans-serif;
  cursor: pointer;
}

.feature-card-action:hover { border-color: var(--accent); background: #fef3e2; }

.workflow-guide {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.workflow-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
  background: #fff8ee;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 9px;
}

.workflow-step span {
  grid-row: 1 / span 2;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
}

.workflow-step strong { font-size: 12px; color: var(--text); }
.workflow-step small { font-size: 11px; color: var(--text3); }

.phase-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.phase-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 11px;
  text-align: left;
  cursor: pointer;
  font-family: 'Noto Sans SC', sans-serif;
  color: var(--text2);
  transition: all 0.15s;
  min-height: 78px;
}

.phase-tab:hover { border-color: var(--accent); background: #fef3e2; }
.phase-tab.active { border-color: var(--accent); background: rgba(180,83,9,0.08); box-shadow: inset 0 0 0 1px rgba(180,83,9,0.12); }
.phase-tab strong { display: block; font-size: 14px; color: var(--text); margin-bottom: 5px; }
.phase-tab span { display: block; font-size: 11px; color: var(--text3); line-height: 1.45; }
.phase-tab em {
  display: inline-flex;
  margin-top: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg2);
  color: var(--accent2);
  font-size: 11px;
  font-style: normal;
  font-family: 'JetBrains Mono', monospace;
}

.entry-nav-panel .phase-tabs {
  grid-template-columns: 1fr;
  gap: 7px;
  margin: 0;
}

.entry-nav-panel .phase-tab {
  min-height: 0;
  padding: 9px 10px;
}

.entry-nav-panel .phase-tab strong { font-size: 13px; }
.entry-nav-panel .phase-tab span { font-size: 11px; }

.case-folder-tools {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.entry-nav-panel .case-folder-tools {
  flex-direction: column;
  margin-bottom: 0;
  padding: 10px;
  border-radius: var(--radius);
}

.entry-nav-panel .case-folder-title { font-size: 14px; }
.entry-nav-panel .tag-list { justify-content: flex-start; }

.case-folder-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.case-folder-subtitle {
  color: var(--text3);
  font-size: 12px;
  margin-top: 3px;
  line-height: 1.5;
}

.tag-list {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tag-action,
.tag-chip,
.tag-add-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text2);
  padding: 6px 10px;
  font-size: 12px;
  font-family: 'Noto Sans SC', sans-serif;
  cursor: pointer;
}

.tag-action.active {
  color: var(--accent2);
  border-color: var(--accent);
  background: #fef3e2;
}

.tag-chip {
  background: rgba(14,116,144,0.08);
  border-color: rgba(14,116,144,0.16);
  color: #0e7490;
}

.tag-add-btn:hover,
.tag-action:hover,
.tag-chip:hover { border-color: var(--accent); background: #fef3e2; }

.tag-placeholder {
  color: var(--text3);
  font-size: 12px;
  padding: 7px 0;
}

.case-timeline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 14px;
}

.entry-assistant-panel .case-timeline {
  margin-bottom: 0;
  padding: 10px;
  border-radius: var(--radius);
}

.entry-assistant-panel .timeline-items {
  grid-template-columns: 1fr;
}

.entry-assistant-panel .timeline-item {
  min-height: 0;
  padding: 8px;
}

.entry-assistant-panel .evidence-chain {
  margin-bottom: 0;
  padding: 10px;
  border-radius: var(--radius);
}

.entry-assistant-panel .evidence-steps {
  grid-template-columns: 1fr;
}

.timeline-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.timeline-items {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.timeline-item {
  position: relative;
  background: #fff8ee;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 82px;
}

.timeline-item.done {
  border-style: solid;
  border-color: rgba(22,101,52,0.22);
  background: rgba(22,101,52,0.05);
}

.timeline-item > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  display: block;
  margin-bottom: 7px;
}

.timeline-item.done > span { background: var(--green); }
.timeline-item strong { display: block; font-size: 12px; color: var(--text); margin-bottom: 5px; }
.timeline-item small { display: block; font-size: 11px; color: var(--text3); line-height: 1.45; }

.case-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(250px, 0.75fr) minmax(280px, 0.85fr);
  gap: 14px;
  margin: 16px 0;
}

.workbench-main,
.workbench-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.workbench-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.workbench-subtitle {
  font-size: 12px;
  color: var(--text3);
  margin: 4px 0 14px;
}

.workbench-status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.workbench-status-item {
  background: #fff8ee;
  border: 1px solid rgba(146,64,14,0.14);
  border-radius: var(--radius);
  padding: 10px;
}

.workbench-status-item span {
  display: block;
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 4px;
}

.workbench-status-item strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}

.todo-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.todo-list {
  padding-left: 18px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.7;
}

.quality-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}

.quality-item {
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.55;
  border: 1px solid var(--border);
}

.quality-ok { color: var(--green); background: rgba(22,101,52,0.08); border-color: rgba(22,101,52,0.18); }
.quality-info { color: var(--accent2); background: rgba(180,83,9,0.07); border-color: rgba(180,83,9,0.16); }
.quality-warning { color: var(--amber); background: rgba(217,119,6,0.08); border-color: rgba(217,119,6,0.18); }
.quality-danger { color: var(--red); background: rgba(185,28,28,0.08); border-color: rgba(185,28,28,0.18); }

.ai-advisor-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 12px 0 6px;
}

.evidence-chain {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 14px;
}

.evidence-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.evidence-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.evidence-step {
  background: #fff8ee;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.evidence-step.has-data {
  border-style: solid;
  border-color: rgba(22,101,52,0.25);
  background: rgba(22,101,52,0.05);
}

.evidence-step strong { display: block; font-size: 13px; color: var(--text); margin-bottom: 4px; }
.evidence-step span { display: block; font-size: 11px; color: var(--text3); }

.followup-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.followup-card {
  background: #fff8ee;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.followup-card strong { display: block; font-size: 13px; color: var(--text); margin-bottom: 5px; }
.followup-card span { display: block; font-size: 11px; color: var(--text3); line-height: 1.5; }
.followup-quality-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 12px;
  background: var(--bg2);
}
.followup-quality-strip strong {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
}
.followup-quality-strip span {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.5;
}
.followup-quality-strip.ok {
  border-color: rgba(22,101,52,0.2);
  background: rgba(22,101,52,0.07);
}
.followup-quality-strip.warning {
  border-color: rgba(217,119,6,0.22);
  background: rgba(217,119,6,0.07);
}
.followup-note { font-size: 12px; color: var(--text3); margin-top: 12px; line-height: 1.6; }

.case-action-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.case-action-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent2);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  font-family: 'Noto Sans SC', sans-serif;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.case-action-btn:hover { border-color: var(--accent); background: #fef3e2; }
.case-action-btn:active { transform: scale(0.97); }

/* Dashboard case cards */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s;
}
.dash-card:hover { border-color: var(--accent); transform: translateY(-2px); }
/* 长按/右键打开操作菜单时，高亮触发卡片，明确菜单归属哪个病例 */
.dash-card--menu-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(217,119,6,0.25), var(--shadow-md);
}
/* 删除小特效：卡片向右滑出并淡出 */
.dash-card--removing {
  animation: dashCardSwipeOut 0.32s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
  will-change: transform, opacity;
}
@keyframes dashCardSwipeOut {
  to { transform: translateX(115%) rotate(2deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .dash-card--removing { animation: none; opacity: 0; }
}
.dash-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.dash-card-name { font-size: 15px; font-weight: 600; font-family: 'Noto Serif SC', serif; }
.dash-card-date { font-size: 11px; color: var(--text3); font-family: 'JetBrains Mono', monospace; }
.dash-card-module { font-size: 12px; color: var(--text3); margin-bottom: 10px; }
.dash-card-progress-bar { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; margin-bottom: 10px; }
.dash-card-progress-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.dash-card-next {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 7px 9px;
  margin-bottom: 8px;
}
.dash-card-next span {
  font-size: 10px;
  color: var(--text3);
  white-space: nowrap;
}
.dash-card-next strong {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text2);
}
.dash-card-next.tone-warning { border-color: rgba(217,119,6,0.25); background: rgba(217,119,6,0.07); }
.dash-card-next.tone-primary { border-color: rgba(180,83,9,0.22); background: rgba(180,83,9,0.07); }
.dash-card-next.tone-danger { border-color: rgba(185,28,28,0.22); background: rgba(185,28,28,0.07); }
.dash-card-next.tone-success { border-color: rgba(22,101,52,0.22); background: rgba(22,101,52,0.07); }
.dash-card-footer { display: flex; gap: 6px; flex-wrap: wrap; }
.dash-card-progress-text {
  font-size: 11px;
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace;
}
.dash-card-progress-text.complete { color: var(--green); }
.dash-card-progress-text.pending { color: var(--amber); }

/* New case form */
.new-case-modal .form-grid {
  grid-template-columns: 1fr 1fr;
}

/* Responsive */
@media (min-width: 1101px) and (max-width: 1360px) {
  .header { padding: 0 18px; }
  .header-actions { gap: 6px; }
  .header-actions .btn { padding: 7px 10px; font-size: 12px; }
  .sidebar { width: 220px; min-width: 220px; }
  .main { max-width: calc(100vw - 220px); padding: 22px; }
  .entry-workspace { grid-template-columns: 200px minmax(0, 1fr) 250px; gap: 10px; }
  .case-workbench { grid-template-columns: minmax(0, 1fr) minmax(230px, 0.72fr); }
  .case-workbench .workbench-side:last-child { grid-column: 1 / -1; }
  .feature-grid { grid-template-columns: repeat(3, 1fr); }
  .folder-board { grid-template-columns: repeat(3, 1fr); }
  .timeline-items { grid-template-columns: repeat(3, 1fr); }
  .image-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
  .login-welcome {
    padding: 28px 18px;
    align-items: flex-start;
  }
  .welcome-shell {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .welcome-copy h1 {
    font-size: 40px;
  }
  .welcome-auth-card {
    max-width: 620px;
  }
  .header {
    height: auto;
    min-height: 60px;
    padding: 10px 16px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .header-brand { min-width: 220px; flex: 1; }
  .header-actions {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }
  .header-actions .btn,
  .auth-badge {
    flex: 0 0 auto;
  }
  .layout {
    display: block;
    min-height: auto;
  }
  .sidebar {
    position: static;
    width: 100%;
    min-width: 0;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 12px 12px 10px;
    gap: 10px;
  }
  .sidebar-section {
    padding: 0;
    margin-bottom: 12px;
  }
  .sidebar-section:first-child {
    max-height: 230px;
    overflow-y: auto;
  }
  .case-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .feature-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .feature-nav-item {
    min-height: 64px;
  }
  .folder-quick-filter {
    grid-template-columns: repeat(5, minmax(64px, 1fr));
    overflow-x: auto;
  }
  .main {
    max-width: 100%;
    padding: 18px;
  }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .ai-generate-grid { grid-template-columns: 1fr 1fr; }
  .ai-model-selector { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .workbench-queue-grid { grid-template-columns: repeat(2, 1fr); }
  .todo-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .todo-card { grid-template-columns: 1fr; }
  .todo-card-actions { justify-content: flex-start; }
  .todo-admission-grid { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .workflow-guide { grid-template-columns: repeat(2, 1fr); }
  .folder-board { grid-template-columns: repeat(3, 1fr); }
  .task-list { grid-template-columns: 1fr; }
  .admission-task-card { grid-template-columns: 1fr; }
  .admission-task-actions { justify-content: flex-start; }
  .admission-draft-grid { grid-template-columns: 1fr; }
  .phase-tabs { grid-template-columns: repeat(2, 1fr); }
  .phase-progress-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-folder-tools { flex-direction: column; }
  .tag-list { justify-content: flex-start; }
  .timeline-items { grid-template-columns: repeat(2, 1fr); }
  .case-workbench { grid-template-columns: 1fr; }
  .entry-header { flex-direction: column; }
  .entry-header-actions { justify-content: flex-start; }
  .entry-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .entry-workspace { grid-template-columns: 1fr; }
  .entry-nav-panel,
  .entry-assistant-panel { position: static; }
  .entry-nav-panel .phase-tabs { grid-template-columns: repeat(2, 1fr); }
  .scan-layout { grid-template-columns: 1fr; }
  .workbench-status-grid { grid-template-columns: repeat(2, 1fr); }
  .evidence-steps { grid-template-columns: 1fr; }
  .followup-grid { grid-template-columns: repeat(2, 1fr); }
  .modal {
    width: min(94vw, 760px);
    max-height: calc(100dvh - 28px);
    padding: 20px;
  }
  .scan-modal { max-width: 94vw; }
  .scan-preview { min-height: 220px; }
  .scan-result-body { max-height: 340px; }
  .modal-overlay {
    align-items: flex-start;
    padding: 14px 0;
    overflow-y: auto;
  }
}

@media (min-width: 700px) and (max-width: 1100px) {
  .entry-workspace {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.74fr);
  }
  .todo-head { flex-direction: column; }
  .entry-nav-panel {
    grid-column: 1 / -1;
  }
  .entry-nav-panel .phase-tabs,
  .entry-section-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .entry-section-nav {
    display: grid;
  }
  .entry-form-panel { grid-column: 1; }
  .entry-assistant-panel { grid-column: 2; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-bar { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 699px) {
  :root {
    --radius-lg: 12px;
  }
  body::before { background-size: 28px 28px; }
  .login-welcome {
    padding: 18px 12px 28px;
  }
  .welcome-brand {
    margin-bottom: 22px;
  }
  .welcome-copy h1 {
    font-size: 30px;
    line-height: 1.18;
  }
  .welcome-lead {
    font-size: 14px;
    line-height: 1.75;
  }
  .welcome-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .welcome-flow {
    grid-template-columns: 1fr;
    margin-top: 26px;
  }
  .welcome-auth-card {
    padding: 18px;
  }
  .header {
    padding: 9px 10px;
  }
  .header-logo {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }
  .header-title {
    font-size: 15px;
    line-height: 1.2;
  }
  .header-subtitle {
    font-size: 10px;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100vw - 86px);
  }
  .header-actions {
    gap: 6px;
  }
  .header-actions .btn,
  .auth-badge {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 12px;
  }
  .sidebar {
    padding: 10px;
  }
  .sidebar-label {
    font-size: 10px;
    margin-bottom: 6px;
  }
  .case-list,
  .feature-nav,
  .module-grid,
  .stats-bar,
  .workbench-queue-grid,
  .todo-tabs,
  .phase-progress-strip,
  .feature-grid,
  .workflow-guide,
  .folder-board,
  .dash-grid,
  .entry-summary-grid,
  .form-grid,
  .form-grid-3,
  .checkbox-grid,
  .score-grid,
  .image-grid,
  .ai-generate-grid,
  .workbench-status-grid,
  .timeline-items,
  .followup-grid,
  .admission-draft-grid {
    grid-template-columns: 1fr;
  }
  .todo-head,
  .todo-section-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .main {
    padding: 12px 10px 18px;
  }
  .feature-overview,
  .task-board,
  .case-timeline,
  .evidence-chain,
  .case-folder-tools,
  .workbench-main,
  .workbench-side,
  .entry-header,
  .entry-summary-card,
  .entry-panel-heading,
  .entry-panel-card,
  .section-block,
  .ai-panel,
  .dash-card,
  .stat-card {
    border-radius: 8px;
  }
  .feature-overview-header,
  .deployment-status-card,
  .task-board-header,
  .dash-card-header,
  .entry-header,
  .form-header,
  .auth-mode-panel,
  .demo-account-panel {
    flex-direction: column;
    align-items: stretch;
  }
  .entry-title {
    font-size: 19px;
    word-break: break-word;
  }
  .entry-subtitle {
    word-break: break-all;
  }
  .entry-header-actions,
  .case-action-strip,
  .modal-footer,
  .admission-task-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .entry-header-actions .autosave-indicator {
    grid-column: 1 / -1;
    justify-self: stretch;
    text-align: center;
  }
  .entry-header-actions .btn,
  .case-action-btn,
  .modal-footer .btn,
  .admission-task-actions .btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
  .phase-tabs,
  .entry-nav-panel .phase-tabs {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    margin: 10px 0;
    scroll-snap-type: x mandatory;
  }
  .phase-tab {
    flex: 0 0 150px;
    min-height: 72px;
    scroll-snap-align: start;
  }
  .entry-section-nav {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 7px;
    padding: 7px;
    scroll-snap-type: x mandatory;
  }
  .entry-section-nav button {
    flex: 0 0 150px;
    min-height: 44px;
    scroll-snap-align: start;
  }
  .section-header {
    padding: 12px;
    align-items: flex-start;
  }
  .section-title {
    line-height: 1.4;
  }
  .section-progress {
    display: none;
  }
  .section-body {
    padding: 12px;
  }
  .field-input {
    min-height: 44px;
    font-size: 16px;
  }
  textarea.field-input {
    min-height: 96px;
  }
  .checkbox-item,
  .tag-action,
  .tag-chip,
  .tag-add-btn,
  .review-action-btn,
  .ai-gen-btn,
  .feature-card-action,
  .task-item,
  .folder-card,
  .case-item {
    min-height: 44px;
  }
  .measurement-row {
    grid-template-columns: 1fr;
  }
  .rating-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .rating-label { min-width: 0; }
  .image-upload-area {
    padding: 18px 12px;
  }
  .image-thumb {
    aspect-ratio: 4 / 3;
  }
  .ai-panel {
    padding: 14px;
  }
  .ai-panel-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .model-badge {
    max-width: 100%;
    white-space: normal;
    line-height: 1.4;
    font-family: 'Noto Sans SC', sans-serif;
  }
  .scan-layout {
    gap: 10px;
  }
  .scan-left,
  .scan-right {
    padding: 10px;
    border-radius: 8px;
  }
  .scan-preview {
    min-height: min(56vh, 330px);
  }
  .scan-preview img {
    max-height: min(56vh, 330px);
  }
  .scan-result-body {
    max-height: min(46vh, 360px);
  }
  .scan-result-row {
    grid-template-columns: 22px 1fr;
  }
  .scan-result-row b {
    grid-column: 2;
    text-align: left;
  }
  .modal {
    width: 100vw;
    max-width: none;
    min-height: 100dvh;
    max-height: none;
    border-radius: 0;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
  }
  .modal-overlay {
    padding: 0;
    align-items: stretch;
  }
  .modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    padding-top: env(safe-area-inset-top);
  }
  .modal-title {
    font-size: 16px;
  }
  .modal-close {
    min-width: 44px;
    min-height: 44px;
  }
  .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .toast-stack {
    left: 10px;
    right: 10px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    align-items: stretch;
  }
  .new-case-modal .form-grid {
    grid-template-columns: 1fr;
  }
  .new-case-modal .field-group > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 390px) {
  .header-title { font-size: 14px; }
  .header-actions .btn,
  .auth-badge { font-size: 11px; padding: 7px 9px; }
  .entry-header-actions,
  .case-action-strip,
  .modal-footer,
  .admission-task-actions {
    grid-template-columns: 1fr;
  }
  .phase-tab,
  .entry-section-nav button {
    flex-basis: 132px;
  }
}

/* Toast shadow fix for light theme */
.toast { box-shadow: var(--shadow-lg); }

/* Settings panel */
.settings-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.settings-hint { font-size: 11px; color: var(--text3); margin-top: 4px; line-height: 1.5; }
.settings-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.danger-zone {
  background: rgba(220,38,38,0.04);
  border: 1px solid rgba(220,38,38,0.15);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 4px;
}
.danger-zone-title { font-size: 12px; font-weight: 600; color: var(--red); margin-bottom: 8px; }

/* Import drag area */
.import-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
  margin-bottom: 14px;
}
.import-drop-zone:hover, .import-drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(29,78,216,0.04);
}
.import-drop-zone .drop-icon { font-size: 36px; margin-bottom: 10px; }
.import-drop-zone .drop-text { font-size: 14px; color: var(--text2); margin-bottom: 4px; }
.import-drop-zone .drop-sub { font-size: 12px; color: var(--text3); }

/* Print styles */
@media print {
  .header, .sidebar, .header-actions, .ai-panel, .modal-overlay,
  .overall-progress, .form-header .btn, .image-upload-area { display: none !important; }
  body { background: white !important; color: black !important; }
  .layout { display: block !important; }
  .main { max-width: 100% !important; padding: 0 !important; }
  .section-block { border: 1px solid #ccc !important; page-break-inside: avoid; }
  .section-body { display: block !important; }
  .field-input { border: 1px solid #ddd !important; background: white !important; }
}

/* Backend connection banner */
.backend-banner {
  background: linear-gradient(90deg, rgba(21,128,61,0.08), rgba(21,128,61,0.04));
  border: 1px solid rgba(21,128,61,0.2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  color: #15803d;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(124,58,237,0.08);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 20px;
  font-size: 11px;
  color: #7c3aed;
  font-family: 'JetBrains Mono', monospace;
}

/* dash-card shadow for light theme */
.dash-card { box-shadow: var(--shadow-sm); }
.dash-card:hover { box-shadow: var(--shadow-md); }

.auth-badge {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text2);
  background: var(--surface);
}

.auth-mode-panel {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid rgba(217,119,6,0.22);
  background: rgba(217,119,6,0.08);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
}

.auth-mode-panel.backend-ready {
  border-color: rgba(22,101,52,0.22);
  background: rgba(22,101,52,0.07);
}

.auth-mode-panel strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 4px;
}

.auth-mode-panel span {
  display: block;
  color: var(--text3);
  font-size: 12px;
  line-height: 1.55;
}

.demo-account-panel {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(180,83,9,0.18);
  background: #fffdf2;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
}

.demo-account-panel strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 4px;
}

.demo-account-panel span {
  display: block;
  color: var(--text3);
  font-size: 12px;
  line-height: 1.5;
}

.user-admin-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.user-admin-center-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
}

.user-admin-center-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--accent2);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.user-admin-center-head span {
  color: var(--text3);
  font-size: 12px;
  font-weight: 500;
}

.user-admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 220px) auto auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fffdf2;
  padding: 12px;
}

.user-admin-row strong,
.user-admin-row span,
.user-admin-row small {
  display: block;
}

.user-admin-row strong {
  color: var(--text);
  font-size: 14px;
}

.user-admin-row span,
.user-admin-row small {
  color: var(--text3);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 3px;
}

@media (max-width: 699px) {
  .user-admin-row {
    grid-template-columns: 1fr;
  }
}

.media-progress-row {
  display: grid;
  grid-template-columns: 1fr 70px;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

/* ── 大图预览 Lightbox ─────────────────────────────────────── */
#lightboxOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  touch-action: manipulation;
}
#lightboxOverlay.active { display: flex; }
#lightboxImg {
  max-width: 100%;
  max-height: calc(100vh - 90px);
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  user-select: none;
}
#lightboxVideo {
  max-width: 100%;
  max-height: calc(100vh - 90px);
  border-radius: 6px;
  display: none;
}
#lightboxLabel {
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}
#lightboxClose {
  position: fixed;
  top: 14px; right: 18px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
#lightboxClose:hover { background: rgba(255,255,255,0.3); }

/* ── 图片缩略图可点击提示 ───────────────────────────────────── */
.image-thumb img {
  cursor: zoom-in;
  transition: transform 0.15s;
}
.image-thumb img:hover { transform: scale(1.04); }

/* ── 上传中 loading 卡片 ────────────────────────────────────── */
.image-thumb-uploading {
  background: #1a1a2e;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 1;
}
.image-thumb-uploading .thumb-preview {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.45;
  filter: blur(1px);
}
.image-thumb-uploading .upload-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0,0,0,0.35);
}
.upload-progress-ring {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.upload-pct-text {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
/* 进度弧线（CSS conic-gradient 驱动） */
.upload-progress-ring-wrap {
  position: relative;
  width: 44px; height: 44px;
}
.upload-progress-ring-wrap svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}
.upload-progress-ring-wrap circle.track {
  fill: none;
  stroke: rgba(255,255,255,0.2);
  stroke-width: 3;
}
.upload-progress-ring-wrap circle.fill {
  fill: none;
  stroke: #ffffff;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.2s linear;
}

/* ── 上传失败状态 ────────────────────────────────────────────── */
.image-thumb-error {
  background: #fee2e2;
  border: 2px solid #ef4444;
  border-radius: var(--radius);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  position: relative;
}
.image-thumb-error .err-icon { font-size: 22px; }
.image-thumb-error .err-text {
  font-size: 10px;
  color: #b91c1c;
  text-align: center;
  word-break: break-word;
  line-height: 1.3;
}
.image-thumb-error .err-retry {
  font-size: 10px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  margin-top: 2px;
}
.image-thumb-error .img-remove {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(239,68,68,0.8);
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   v2 simplified UI — header more-menu, dashboard filter chips,
   task panel, module picker, settings tabs, mobile drawer
   ============================================================ */

/* Welcome — single centered card */
.login-welcome .welcome-shell { display: none; }
.login-welcome { justify-content: center; }
.welcome-auth-card {
  width: min(440px, 100%);
  margin: 0 auto;
}
.welcome-brand-inline {
  display: flex;
  align-items: center;
  gap: 12px;
}
.welcome-brand-inline strong,
.welcome-brand-inline span {
  display: block;
}
.welcome-brand-inline strong {
  font-family: 'Noto Serif SC', serif;
  font-size: 17px;
}
.welcome-brand-inline span {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.4px;
}
.welcome-card-head { border-bottom: 1px solid var(--border); padding-bottom: 16px; }

/* Header */
.header-title { letter-spacing: 0.3px; }

/* Header — more menu */
.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--radius);
  width: 38px;
  height: 38px;
  font-size: 18px;
  cursor: pointer;
}
.mobile-menu-toggle:hover { background: #fef3e2; }

.more-menu { position: relative; }
.more-menu-trigger { padding: 7px 12px; }
.more-menu-popup {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.more-menu-popup[hidden] { display: none; }
.more-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  text-decoration: none;
}
.more-menu-item:hover { background: #fef3e2; color: var(--text); }
.more-menu-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 2px;
}

/* Sidebar — mobile drawer */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28,22,17,0.32);
  z-index: 90;
}
.sidebar-backdrop.open { display: block; }

/* Dashboard — toolbar + filter chips + task panel + empty state */
.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.dash-toolbar-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.dash-toolbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.deployment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text3);
}
.deployment-pill #deploymentStatusTitle { color: var(--text2); font-weight: 600; }
.deployment-pill #deploymentStatusDesc { color: var(--text3); }
.deployment-pill #deploymentStatusDesc:empty { display: none; }
.deployment-pill-action {
  border: 0;
  background: transparent;
  color: var(--accent2);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 2px;
}
.deployment-pill-action:hover { background: rgba(180,83,9,0.1); }

/* Compact stats — about half the previous height */
.stats-bar { grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-card { padding: 10px 14px; }
.stat-value { font-size: 22px; }
.stat-label { font-size: 11px; margin-top: 2px; }
.stat-trend { display: none; }

.workbench-queue-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.workbench-queue-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.workbench-queue-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: #fffdf8;
}
.workbench-queue-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(217,119,6,0.16), var(--shadow-xs);
  background: #fffdf8;
}
.workbench-queue-card span {
  font-size: 12px;
  color: var(--text2);
  font-weight: 700;
}
.workbench-queue-card strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  line-height: 1;
  color: var(--text);
}
.workbench-queue-card small {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--text3);
  line-height: 1.35;
}
.workbench-queue-card.tone-warning strong { color: var(--amber); }
.workbench-queue-card.tone-primary strong { color: var(--accent2); }
.workbench-queue-card.tone-danger strong { color: var(--red); }
.workbench-queue-card.tone-success strong { color: var(--green); }

.dash-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.filter-chip-group-modules {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.filter-cat-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.facet-filter-row {
  padding-bottom: 2px;
  border-bottom: 1px dashed var(--border);
}
.filter-cat-label {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
  min-height: 26px;
  letter-spacing: 0.5px;
  user-select: none;
}
.filter-chip {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text3);
  border-radius: 999px;
  padding: 4px 10px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.filter-chip strong {
  font-weight: 600;
  color: inherit;
}
.filter-chip em {
  font-style: normal;
  color: var(--text3);
  font-size: 11px;
}
.filter-chip:hover { color: var(--accent2); background: rgba(180,83,9,0.06); }
.filter-chip.active {
  background: var(--accent);
  color: #fffdf2;
  font-weight: 600;
}
.filter-chip.active strong,
.filter-chip.active em { color: inherit; }

.dash-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px;
  color: var(--text3);
}

.dash-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.dash-empty-title {
  font-size: 15px;
  margin-bottom: 8px;
}

.dash-empty-action { margin-top: 8px; }

.task-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.task-panel[hidden] { display: none; }
.task-panel summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
}
.task-panel summary::-webkit-details-marker { display: none; }
.task-panel summary::after {
  content: '▾';
  color: var(--text3);
  font-size: 12px;
  margin-left: auto;
  transition: transform 0.15s;
}
.task-panel[open] summary::after { transform: rotate(180deg); }
.task-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.task-panel-count {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent2);
  background: rgba(180,83,9,0.1);
  border-radius: 999px;
  padding: 1px 8px;
}
.task-panel-count:empty { display: none; }
.task-board-inline {
  margin: 0;
  border-radius: 0;
  border: 0;
  border-top: 1px solid var(--border);
  padding: 12px 14px;
}
.task-board-inline:empty { display: none; }

.todo-workbench {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.todo-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}
.todo-head h1 {
  margin: 0 0 5px;
  font-size: 22px;
  font-family: 'Noto Serif SC', serif;
  color: var(--text);
}
.todo-head p {
  margin: 0;
  color: var(--text3);
  font-size: 13px;
}
.todo-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.todo-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.todo-tab.active {
  border-color: var(--accent);
  background: rgba(180,83,9,0.07);
}
.todo-tab span {
  display: block;
  color: var(--text3);
  font-size: 12px;
}
.todo-tab strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font: 700 18px 'JetBrains Mono', monospace;
}
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.todo-card,
.todo-admission,
.todo-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-xs);
}
.todo-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}
.todo-card-kicker {
  color: var(--accent2);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}
.todo-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  color: var(--text);
  font-family: 'Noto Serif SC', serif;
}
.todo-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.todo-card-meta span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text3);
  background: var(--bg2);
}
.todo-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.todo-reject-note {
  margin-top: 10px;
  border-left: 3px solid var(--red);
  background: rgba(185,28,28,0.06);
  color: var(--text2);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
}
.todo-empty {
  text-align: center;
  color: var(--text3);
  padding: 32px 18px;
}
.todo-empty-title {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 5px;
}
.todo-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.todo-section-head strong,
.todo-section-head span {
  display: block;
}
.todo-section-head strong { color: var(--text); font-size: 14px; }
.todo-section-head span { color: var(--text3); font-size: 12px; margin-top: 3px; }
.todo-admission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.dash-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--text3);
}
.dash-grid-empty-icon { font-size: 40px; margin-bottom: 12px; }
.dash-grid-empty-title { font-size: 15px; margin-bottom: 8px; color: var(--text2); }
.dash-grid-empty-sub { font-size: 13px; margin-bottom: 20px; }

/* New case — module picker (replaces inline-styled radios) */
.module-pick-categories {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}
.module-cat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  background: var(--surface);
}
.module-cat-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.module-pick {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}
.module-pick-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}
.module-pick-opt:hover { border-color: var(--accent); color: var(--text); }
.module-pick-opt input[type="radio"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.module-pick-opt:has(input:checked) {
  border-color: var(--accent);
  background: #fef3e2;
  color: var(--text);
}
.module-pick-categories.is-invalid .module-cat {
  border-color: rgba(185,28,28,0.65);
}
.module-pick-opt span { line-height: 1.3; }

.new-case-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Settings — tabs */
.settings-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.settings-tab-btn {
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  min-height: 36px;
}
.settings-tab-btn.active {
  background: var(--surface);
  color: var(--accent2);
  box-shadow: var(--shadow-sm);
}
.settings-tab-panel { display: none; }
.settings-tab-panel.active { display: block; }
.settings-row-action { width: 100%; font-size: 12px; }

/* Import — preview */
.import-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 13px;
  color: var(--text2);
}

/* ============================================================
   Responsive — mobile drawer + simplified header
   ============================================================ */

/* Tablet / narrow desktop: hide secondary header nav buttons */
@media (max-width: 1100px) {
  .login-welcome { padding: 28px 18px; align-items: center; }
  .welcome-auth-card { max-width: 440px; }
  .header-actions { width: auto; overflow: visible; flex-wrap: wrap; }
  .header-nav-btn { display: none; }
}

@media (max-width: 900px) {
  .mobile-menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .layout { display: block; min-height: auto; }
  .sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 84vw;
    max-width: 320px;
    min-width: 0;
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    padding-top: 12px;
  }
  .sidebar-backdrop { top: 60px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar .sidebar-section { padding: 12px 14px; }
  .case-list { display: flex; flex-direction: column; gap: 4px; }
  .main { max-width: 100%; padding: 18px 16px 24px; }
  .header { padding: 10px 14px; flex-wrap: nowrap; gap: 8px; }
  .header-brand { min-width: 0; flex: 1; overflow: hidden; }
  .header-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header-subtitle { display: none; }
  .header-actions { gap: 6px; }
  .auth-badge { display: none; }
}

@media (max-width: 699px) {
  .login-welcome { padding: 18px 12px 28px; align-items: flex-start; }
  .welcome-auth-card { width: 100%; max-width: none; padding: 18px; }
  .header { padding: 9px 10px; gap: 6px; }
  .header-logo { width: 30px; height: 30px; font-size: 16px; }
  /* Hide brand text on small screens - logo + actions only */
  .header-brand > div:not(.header-logo) { display: none; }
  .header-brand { flex: 0 0 auto; }
  .header-actions { flex: 1; justify-content: flex-end; }
  .header-actions .btn { font-size: 12px; padding: 7px 10px; min-height: 38px; }
  .more-menu-trigger { padding: 7px 10px; }
  /* Hide secondary buttons; new-case + more + login stay visible */
  .header-nav-btn { display: none; }
  /* Sidebar drawer fullscreen-ish */
  .sidebar { width: 90vw; }
  .main { padding: 12px 10px 18px; }
  .dash-toolbar { flex-direction: column; align-items: stretch; }
  .dash-toolbar .btn-gold { width: 100%; }
  .dash-toolbar-title h1 { font-size: 22px; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px; }
  .dash-filter { padding: 8px; }
  .filter-chip { font-size: 12px; padding: 8px 12px; min-height: 36px; }
  .filter-chip-group { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; scroll-snap-type: x mandatory; }
  .filter-chip-group::-webkit-scrollbar { height: 4px; }
  .filter-chip { scroll-snap-align: start; }
  .filter-chip-group-modules { border-top: 1px dashed var(--border); padding-top: 8px; flex-direction: column; }
  .filter-cat-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
  .filter-cat-row::-webkit-scrollbar { height: 3px; }
  .filter-cat-row .filter-chip { scroll-snap-align: start; }
  .task-panel summary { padding: 12px; gap: 8px; }
  .module-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-pick-opt { padding: 12px; font-size: 13px; min-height: 48px; }
  .settings-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-tab-btn { font-size: 11px; padding: 8px 6px; }
  .agent-panel-header,
  .agent-workflow-item,
  .agent-run-head { grid-template-columns: 1fr; }
  .agent-panel-header .settings-row-action { width: 100%; }
  .agent-metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-workflow-badges { justify-content: flex-start; }
  /* More-menu popup becomes fullwidth dropdown anchored to right */
  .more-menu-popup {
    right: 0;
    left: auto;
    min-width: 220px;
    max-width: 88vw;
  }
  .more-menu-item { padding: 12px; min-height: 44px; font-size: 13px; }
}

@media (max-width: 390px) {
  .header-title { font-size: 13px; }
  .header-actions .btn,
  .more-menu-trigger { font-size: 11px; padding: 7px 8px; }
  .filter-chip { font-size: 11px; padding: 7px 10px; }
  .dash-toolbar-title h1 { font-size: 20px; }
}

/* ================================================================
   AI CHAT DIALOG
   ================================================================ */

/* Modal size override */
.ai-chat-modal {
  display: flex;
  flex-direction: column;
  max-width: 700px;
  width: 95vw;
  height: 84vh;
  max-height: 720px;
  padding: 0;
  overflow: hidden;
}
.ai-chat-modal .modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Context bar */
.ai-chat-context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  background: rgba(139,92,246,0.06);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text3);
  flex-shrink: 0;
}

/* Scrollable messages area */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
}
.ai-chat-messages::-webkit-scrollbar { width: 4px; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Bubbles */
.ai-chat-bubble {
  display: flex;
  gap: 10px;
  max-width: 100%;
  animation: chatBubbleIn 0.18s ease-out;
}
@keyframes chatBubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-chat-bubble-assistant { align-items: flex-start; }
.ai-chat-bubble-user      { flex-direction: row-reverse; }

.ai-chat-bubble-icon {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(139,92,246,0.14);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-chat-bubble-content {
  max-width: calc(100% - 42px);
  min-width: 0;
}

.ai-chat-bubble-assistant .ai-chat-bubble-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 12px 12px 12px;
  padding: 11px 15px;
}

.ai-chat-bubble-user-content {
  background: rgba(139,92,246,0.14);
  border: 1px solid rgba(139,92,246,0.28);
  border-radius: 12px 0 12px 12px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.ai-chat-bubble-error {
  background: rgba(239,68,68,0.06) !important;
  border-color: rgba(239,68,68,0.3) !important;
  color: var(--red);
  font-size: 13px;
}
.ai-bubble-retry-btn {
  background: none;
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--red);
  cursor: pointer;
  font-family: 'Noto Sans SC', sans-serif;
  transition: all 0.15s;
}
.ai-bubble-retry-btn:hover { background: rgba(239,68,68,0.08); }

/* Clear history button in AI chat modal header */
.ai-chat-clear-history-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text3);
  cursor: pointer;
  font-family: 'Noto Sans SC', sans-serif;
  transition: all 0.15s;
  margin-right: 6px;
}
.ai-chat-clear-history-btn:hover {
  color: var(--red);
  border-color: rgba(239,68,68,0.6);
  background: rgba(239,68,68,0.05);
}

.ai-bubble-text {
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ai-md-heading {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin: 8px 0 4px;
}
.ai-md-li { padding-left: 6px; margin: 2px 0; }

/* Copy / Download action row */
.ai-bubble-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.ai-bubble-actions button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s;
}
.ai-bubble-actions button:hover {
  background: var(--bg);
  color: var(--text);
  border-color: rgba(139,92,246,0.4);
}

/* Typing animation */
.ai-typing-indicator {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 6px 2px;
}
.ai-typing-indicator span {
  width: 7px; height: 7px;
  background: var(--text3);
  border-radius: 50%;
  animation: aiTypingDot 1.3s infinite ease-in-out;
}
.ai-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.ai-typing-indicator span:nth-child(2) { animation-delay: 0.22s; }
.ai-typing-indicator span:nth-child(3) { animation-delay: 0.44s; }
@keyframes aiTypingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* Preset quick-action pill row */
.ai-chat-presets {
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}
.ai-chat-preset-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: 'Noto Sans SC', sans-serif;
}
.ai-chat-preset-btn:hover {
  background: rgba(139,92,246,0.1);
  border-color: rgba(139,92,246,0.4);
  color: var(--purple);
}

/* Input row */
.ai-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  align-items: flex-end;
}
.ai-chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  resize: none;
  font-family: 'Noto Sans SC', sans-serif;
  line-height: 1.55;
  transition: border-color 0.2s;
  max-height: 120px;
  overflow-y: auto;
}
.ai-chat-input:focus {
  outline: none;
  border-color: rgba(139,92,246,0.5);
  box-shadow: 0 0 0 2px rgba(139,92,246,0.1);
}
.ai-chat-input::placeholder { color: var(--text3); }

.ai-chat-send-btn {
  background: var(--purple, #7c3aed);
  border: none;
  border-radius: 10px;
  width: 42px; min-width: 42px; height: 42px;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
.ai-chat-send-btn:hover  { opacity: 0.88; transform: scale(1.06); }
.ai-chat-send-btn:active { transform: scale(0.96); }
.ai-chat-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.ai-chat-stop-btn {
  background: #dc2626;
  border: none;
  border-radius: 10px;
  width: 42px; min-width: 42px; height: 42px;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
  animation: stopBtnPulse 1.6s ease-in-out infinite;
}
.ai-chat-stop-btn:hover  { opacity: 0.88; transform: scale(1.06); animation: none; }
.ai-chat-stop-btn:active { transform: scale(0.94); }
@keyframes stopBtnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}

/* Streaming cursor — blinking bar at end of in-progress AI response */
.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 0.9em;
  background: var(--purple, #7c3aed);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: streamBlink 0.75s step-end infinite;
}
@keyframes streamBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Entry button in AI panel */
.ai-chat-entry {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.ai-chat-entry-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(139,92,246,0.07) 0%, rgba(99,102,241,0.04) 100%);
  border: 1px solid rgba(139,92,246,0.22);
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
}
.ai-chat-entry-btn:hover {
  background: linear-gradient(135deg, rgba(139,92,246,0.14) 0%, rgba(99,102,241,0.08) 100%);
  border-color: rgba(139,92,246,0.42);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139,92,246,0.12);
}
.ai-chat-entry-icon {
  font-size: 22px;
  line-height: 1;
}
.ai-chat-entry-copy {
  flex: 1;
  text-align: left;
}
.ai-chat-entry-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.ai-chat-entry-subtitle {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}
.ai-chat-entry-arrow {
  color: var(--text3);
  font-size: 18px;
  font-weight: 300;
}

/* ── AI code block (dark theme, scrollable) ── */
.ai-code-block {
  background: #1a1a2e;
  border-radius: 8px;
  margin: 8px 0;
  overflow: hidden;
  font-family: 'JetBrains Mono', 'Fira Mono', 'Cascadia Code', monospace;
}
.ai-code-lang {
  background: #16213e;
  color: #8892a4;
  font-size: 11px;
  padding: 4px 12px;
  letter-spacing: 0.5px;
  user-select: none;
}
.ai-code-pre {
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.6;
  padding: 12px 14px;
  overflow-x: auto;
  white-space: pre;
  max-height: 360px;
  overflow-y: auto;
  margin: 0;
}

/* ── HTML report preview / download buttons ── */
.ai-bubble-html-btn {
  background: linear-gradient(135deg, rgba(13,148,136,0.10), rgba(5,150,105,0.07)) !important;
  border: 1px solid rgba(13,148,136,0.40) !important;
  color: #0f766e !important;
}
.ai-bubble-html-btn:hover {
  background: linear-gradient(135deg, rgba(13,148,136,0.20), rgba(5,150,105,0.15)) !important;
  border-color: rgba(13,148,136,0.70) !important;
  color: #0d9488 !important;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .ai-chat-modal {
    height: 92vh;
    max-height: none;
    border-radius: var(--radius) var(--radius) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
  }
  .ai-chat-preset-btn { font-size: 11px; padding: 5px 10px; }
}

/* ════════════════════════════════════════════════════════════
   #13 — Skeleton loaders & composed empty states
   ════════════════════════════════════════════════════════════ */

/* Skeleton placeholders shown during async loads */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface2);
  border-radius: var(--radius);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    rgba(255,255,248,0) 0%,
    rgba(255,255,248,0.6) 50%,
    rgba(255,255,248,0) 100%
  );
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-line {
  height: 14px;
  width: 100%;
  margin-bottom: var(--space-2);
}
.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line.short { width: 60%; }
.skeleton-card {
  height: 72px;
  width: 100%;
  margin-bottom: var(--space-3);
}
@keyframes skeleton-shimmer {
  100% { transform: translateX(100%); }
}

/* Composed empty states (formalizes the ad-hoc .scan-empty / .task-empty) */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--text3);
}
.empty-state-icon {
  font-size: 34px;
  line-height: 1;
  opacity: 0.5;
  margin-bottom: var(--space-3);
}
.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text2);
  margin-bottom: var(--space-2);
}
.empty-state-hint {
  font-size: var(--text-sm);
  color: var(--text3);
  max-width: 46ch;
  line-height: 1.5;
}
.empty-state-action {
  margin-top: var(--space-4);
}

.center-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.center-list-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.center-list-item strong {
  font-size: 13px;
  color: var(--text);
}
.center-list-item span {
  font-size: 11px;
  color: var(--text3);
}
.agent-panel-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}
.agent-panel-header .settings-row-action {
  width: auto;
  min-width: 132px;
}
.agent-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.agent-metric-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface);
}
.agent-metric-card span {
  display: block;
  color: var(--text3);
  font-size: 11px;
}
.agent-metric-card strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.1;
}
.agent-mode-hint,
.agent-workflow-item,
.agent-run-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.agent-mode-hint {
  padding: 10px 12px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 8px;
}
.agent-workflow-list,
.agent-run-list,
.agent-finding-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-workflow-item,
.agent-run-item {
  padding: 12px;
}
.agent-workflow-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}
.agent-workflow-item strong,
.agent-run-head strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}
.agent-workflow-item span,
.agent-run-head span,
.agent-run-summary {
  color: var(--text3);
  font-size: 11px;
  line-height: 1.5;
}
.agent-workflow-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.agent-workflow-badges span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 7px;
  background: var(--bg);
  color: var(--text2);
  font-size: 10px;
  white-space: nowrap;
}
.agent-run-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 8px;
}
.agent-run-summary {
  margin-bottom: 8px;
}
.agent-finding-item {
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 8px 10px;
}
.agent-finding-item.critical { border-left-color: var(--red); }
.agent-finding-item.warning { border-left-color: var(--amber); }
.agent-finding-item.info { border-left-color: var(--accent); }
.agent-finding-item strong,
.agent-finding-item span,
.agent-finding-item em {
  display: block;
  font-size: 11px;
  line-height: 1.45;
}
.agent-finding-item strong {
  color: var(--text);
  margin-bottom: 3px;
}
.agent-finding-item span {
  color: var(--text2);
}
.agent-finding-item em {
  color: var(--text3);
  font-style: normal;
  margin-top: 3px;
}
.center-filter-row {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.sort-filter-row {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.compact-select {
  width: auto;
  min-width: 132px;
  height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}
.case-card-inline-action {
  width: 100%;
  border: 1px solid rgba(185,28,28,0.18);
  background: rgba(185,28,28,0.07);
  color: var(--red);
  border-radius: var(--radius);
  padding: 7px 8px;
  font-size: 11px;
  cursor: pointer;
  margin-bottom: 8px;
}
.case-card-inline-action:hover {
  background: rgba(185,28,28,0.11);
}

/* ── Accessibility: honor reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
  .btn:active,
  .btn-primary:active,
  .btn-gold:active,
  .btn-green:active,
  .btn-danger:active,
  .btn-ghost:active,
  .case-action-btn:active { transform: none; }
  .case-context-menu { animation: none; }
  .case-context-menu-item:active { transform: none; }
}

/* ════════════════════════════════════════════════════════════
   Case quick-action context menu (floating popover)
   Position (top/left/fixed|absolute) is set inline by JS.
   ════════════════════════════════════════════════════════════ */
.case-context-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: var(--space-1);
  min-width: 180px;
  z-index: 200; /* above cards/header (100), below modal overlay (500) */
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: contextMenuIn var(--dur-fast) var(--ease-out);
}
@keyframes contextMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.case-context-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: var(--text-sm);
  color: var(--text2);
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.case-context-menu-item:hover { background: #fef3e2; color: var(--text); }
.case-context-menu-item:active { transform: translateY(1px); }
.case-context-menu-item .menu-item-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-size: var(--text-base);
  line-height: 1;
}
.case-context-menu-item.danger { background: var(--red); color: #fff; }
.case-context-menu-item.danger:hover { background: #991b1b; color: #fff; }
.case-context-menu-item.danger:active { background: #7f1616; color: #fff; }

/* Discreet "⋯" trigger on case cards — hover/focus reveal, no layout shift */
.case-card-menu-btn {
  border: none;
  background: transparent;
  color: var(--text3);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.dash-card:hover .case-card-menu-btn,
.case-item:hover .case-card-menu-btn,
.case-card-menu-btn:focus-visible,
.case-card-menu-btn.is-open { opacity: 1; }
.case-card-menu-btn:hover { background: #fef3e2; color: var(--text2); }
.case-card-menu-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(146,64,14,0.22); }

/* ════════════════════════════════════════════════════════════
   Forgot / reset password view + form
   Consistent with .login-welcome aesthetic; reuses .field-input/.btn/.field-error
   ════════════════════════════════════════════════════════════ */
#resetPasswordView {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(120deg, rgba(255,251,235,0.95), rgba(255,248,238,0.98)),
    repeating-linear-gradient(90deg, rgba(146,64,14,0.05) 0 1px, transparent 1px 96px);
}
#resetPasswordView.active { display: flex; }

.reset-password-card {
  width: min(420px, 100%);
  background: rgba(255,255,248,0.94);
  border: 1px solid rgba(146,64,14,0.18);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
}
.reset-password-card h2 {
  font-family: 'Noto Serif SC', serif;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-2);
}
.reset-password-card .reset-password-sub {
  color: var(--text3);
  font-size: var(--text-sm);
  line-height: 1.6;
  margin-bottom: var(--space-5);
}
.reset-password-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.reset-password-field label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text2);
}
.reset-password-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-5);
}
.reset-password-actions .btn { width: 100%; }
.reset-password-back {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text3);
}
.reset-password-back a { color: var(--accent2); cursor: pointer; text-decoration: none; }
.reset-password-back a:hover { text-decoration: underline; }

/* ════════════════════════════════════════════════════════════
   Case-brief — print-friendly document layout (A4-ish)
   ════════════════════════════════════════════════════════════ */
.case-brief {
  max-width: 760px;
  margin: 0 auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-8);
  font-size: var(--text-base);
  line-height: 1.8;
}
.case-brief-header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--border);
}
.case-brief-title {
  font-family: 'Noto Serif SC', serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-2);
}
.case-brief-meta {
  font-size: var(--text-sm);
  color: var(--text3);
  line-height: 1.6;
}
.case-brief-section { margin-bottom: var(--space-6); }
.case-brief-section h3 {
  font-family: 'Noto Serif SC', serif;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--border);
}
.case-brief-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: var(--space-3);
  padding: var(--space-1) 0;
}
.case-brief-row dt {
  color: var(--text3);
  font-size: var(--text-sm);
}
.case-brief-row dd {
  color: var(--text);
  font-size: var(--text-base);
}
.case-brief p { margin-bottom: var(--space-2); }
.case-brief-footer {
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text3);
  text-align: center;
}

/* Print: hide app chrome, render brief full-width & clean.
   Complements the existing @media print block above. */
@media print {
  .case-brief {
    max-width: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: white !important;
    color: black !important;
  }
  .case-brief-section { page-break-inside: avoid; }
  .case-brief-title,
  .case-brief-section h3 { color: black !important; }
  .case-card-menu-btn,
  .case-context-menu { display: none !important; }
}

/* ════════════════════════════════════════════════════════════
   Progress consistency — token-driven status colors (colors only)
   complete → --green/--accent · incomplete → --text3 · error → --red
   ════════════════════════════════════════════════════════════ */
.progress-bar-fill.is-complete { background: linear-gradient(90deg, var(--green), #15803d); }
.progress-bar-fill.is-incomplete { background: var(--text3); }
.progress-bar-fill.is-error { background: var(--red); }
.progress-dot.complete { background: var(--green); }
.progress-ring.is-complete { color: var(--green); }
.progress-ring.is-error { color: var(--red); }

/* ════════════════════════════════════════════════════════════
   Round 1 UX/safety hardening: onboarding banner · PII reveal ·
   sandboxed AI report preview
   ════════════════════════════════════════════════════════════ */

/* 顶部引导横幅 */
.onboarding-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 18px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.onboarding-banner[hidden] { display: none; }
.onboarding-banner--login {
  background: linear-gradient(0deg, rgba(217,119,6,0.06), rgba(217,119,6,0.06)), var(--surface);
  color: var(--text);
}
.onboarding-banner--local {
  background: var(--surface);
  color: var(--text2);
}
.onboarding-icon { font-size: 16px; flex-shrink: 0; }
.onboarding-text { flex: 1; line-height: 1.5; }
.onboarding-text strong { color: var(--accent); }
.onboarding-cta { flex-shrink: 0; }
.onboarding-dismiss {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text3);
  font-size: 15px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}
.onboarding-dismiss:hover { background: var(--bg); color: var(--text); }

/* 患者信息脱敏：详情标题旁的小眼睛 */
.pii-eye { font-size: 0.8em; opacity: 0.55; }
#piiToggleBtn[aria-pressed="true"] { color: var(--accent); }

/* AI 报告安全沙箱预览 */
.report-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(6px);
  z-index: 600; /* above modal-overlay (500) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalIn var(--dur-fast) var(--ease-out);
}
.report-preview-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg, 0 24px 60px rgba(0,0,0,0.35));
  width: min(960px, 96vw);
  height: min(88vh, 1100px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.report-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.report-preview-title { font-size: 13px; font-weight: 600; color: var(--text); }
.report-preview-close {
  border: none;
  background: transparent;
  color: var(--text3);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 10px;
  border-radius: 6px;
}
.report-preview-close:hover { background: var(--surface); color: var(--text); }
.report-preview-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}
@media (max-width: 768px) {
  .report-preview-overlay { padding: 0; }
  .report-preview-dialog { width: 100vw; height: 100vh; border-radius: 0; }
  .onboarding-banner { flex-wrap: wrap; }
}

/* Round 2: 上传体验 — 失败重试按钮 · HEIC 无法预览占位 */
.image-thumb-error .img-retry {
  font-size: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
  margin-top: 2px;
}
.image-thumb-error .img-retry:hover { filter: brightness(0.94); }
.image-thumb--media-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(110deg, rgba(255,255,255,0.08) 8%, rgba(255,255,255,0.34) 18%, rgba(255,255,255,0.08) 33%),
    rgba(15,23,42,0.08);
  background-size: 220% 100%;
  animation: thumbPreviewLoading 1.1s linear infinite;
}
@keyframes thumbPreviewLoading {
  to { background-position-x: -220%; }
}
.thumb-preview-status {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  text-align: center;
  background: rgba(15,23,42,0.78);
  color: #fff;
}
.thumb-preview-status span {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}
.thumb-preview-status button {
  border: 0;
  border-radius: 5px;
  background: #ffffff;
  color: #0f172a;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 9px;
  cursor: pointer;
}
.thumb-preview-status button:hover { filter: brightness(0.94); }
.thumb-heic-ph {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 8px, #e8edf3 8px, #e8edf3 16px);
  color: var(--text3);
  cursor: pointer;
}
.thumb-heic-ph span { font-size: 14px; font-weight: 700; letter-spacing: 0.5px; color: var(--text2); }
.thumb-heic-ph small { font-size: 9px; color: var(--text3); }
.image-thumb-uploading .thumb-heic-ph { position: absolute; inset: 0; }

/* Round 3 Phase 1: 个人工作台范围 chip 行 */
.work-scope-row {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.work-scope-row[hidden] { display: none; }
.work-scope-row .scope-count {
  font-style: normal;
  margin-left: 5px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(217,119,6,0.14);
  color: var(--accent);
  border-radius: 8px;
  padding: 0 5px;
}
.work-scope-row .filter-chip.active .scope-count {
  background: rgba(255,255,255,0.25);
  color: inherit;
}

/* #6 AI 入口收敛：导览 + 文书分组标签 */
.ai-entry-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
  line-height: 1.6;
}
.ai-entry-guide > span { font-size: 11px; color: var(--text3); white-space: nowrap; }
.ai-entry-guide b { color: var(--text2); font-weight: 600; }
.ai-gen-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.ai-gen-group-label:first-of-type { margin-top: 4px; }

/* 影像换槽位：移动手柄 + 拖放高亮 + 选择器 */
.image-thumb { position: relative; }
.image-thumb .img-move {
  position: absolute;
  top: 4px; left: 4px;
  width: 20px; height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(15,23,42,0.55);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
.image-thumb .img-move:hover { background: var(--accent); }
.image-thumb .img-move:active { cursor: grabbing; }
.media-slot-group { transition: box-shadow .15s, background .15s; border-radius: 8px; }
.media-slot-group.drag-over {
  box-shadow: inset 0 0 0 2px var(--accent);
  background: rgba(217,119,6,0.06);
}
.move-picker-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 620;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.move-picker-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg, 0 24px 60px rgba(0,0,0,0.35));
  width: min(420px, 94vw);
  max-height: 80vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.move-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
}
.move-picker-head button { border: none; background: transparent; font-size: 16px; cursor: pointer; color: var(--text3); }
.move-picker-body { overflow-y: auto; padding: 8px; }
.move-picker-phase { font-size: 11px; color: var(--text3); margin: 8px 8px 4px; }
.move-picker-item {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; margin: 2px 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font-size: 13px; cursor: pointer;
}
.move-picker-item:hover { border-color: var(--accent); background: rgba(217,119,6,0.06); }

/* ── AI 生成状态栏（生成 modal：模型/计时/字数 + 完成/停止态） ── */
.ai-gen-statusbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 10px; margin-bottom: 10px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  font-size: 12px; color: var(--text3);
  position: sticky; top: 0; z-index: 2;
}
.ai-gen-status { font-weight: 600; color: var(--text2); }
.ai-gen-status.done { color: var(--green); }
.ai-gen-status.stopped { color: var(--gold2); }
.ai-gen-meta { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ── AI 输出 Markdown 表格 / 分隔线 ── */
.ai-md-table {
  border-collapse: collapse; width: 100%; margin: 8px 0;
  font-size: 13px; line-height: 1.5;
}
.ai-md-table th, .ai-md-table td {
  border: 1px solid var(--border); padding: 6px 10px; text-align: left;
  vertical-align: top;
}
.ai-md-table th { background: var(--bg2); font-weight: 600; color: var(--text2); white-space: nowrap; }
.ai-md-table tr:nth-child(even) td { background: var(--bg2); }
.ai-md-hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

/* ── AI 对话档位切换器（上下文条右侧） ── */
.ai-chat-tier-sel {
  margin-left: auto; font-size: 12px; padding: 3px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm, 6px);
  background: var(--bg); color: var(--text2); cursor: pointer; max-width: 200px;
}

/* ── AI 对话气泡里的 HTML 报告卡片（替代整段源码） ── */
.ai-html-card {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 6px 0; padding: 10px 12px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
}
.ai-html-card-icon { font-size: 22px; line-height: 1; }
.ai-html-card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.ai-html-card-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.ai-html-src { margin: 4px 0 2px; }
.ai-html-src > summary { cursor: pointer; font-size: 12px; color: var(--text3); }
.ai-html-src .ai-code-pre { margin-top: 6px; max-height: 240px; overflow: auto; font-size: 12px; }

/* ── 移动端手势翻页：方向滑入动画（仅手势导航时附加） ── */
@keyframes page-slide-in-right {  /* 后退：新页面从左侧滑入 */
  from { transform: translateX(-6%); opacity: 0.5; }
  to   { transform: translateX(0);   opacity: 1; }
}
@keyframes page-slide-in-left {   /* 前进：新页面从右侧滑入 */
  from { transform: translateX(6%);  opacity: 0.5; }
  to   { transform: translateX(0);   opacity: 1; }
}
.page.page-slide-in-right { animation: page-slide-in-right 0.22s ease-out; }
.page.page-slide-in-left  { animation: page-slide-in-left 0.22s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .page.page-slide-in-right, .page.page-slide-in-left { animation: none; }
}

/* ── 病例表单：折叠区完成度徽标 + 全部展开/收起 + 辅助卡片折叠 ── */
.section-progress {
  margin-left: auto; margin-right: 8px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px;
  background: var(--bg2); color: var(--text3);
  border: 1px solid var(--border);
}
.section-progress.warn { color: var(--gold); border-color: #f59e0b66; background: #f59e0b14; }
.section-progress.done { color: var(--green); border-color: #16a34a44; background: #16a34a12; }
.section-header { display: flex; align-items: center; }
.section-header .section-chevron { margin-left: 0; }

.entry-heading-tools { display: flex; gap: 6px; flex-shrink: 0; }
.entry-heading-tools .btn { font-size: 12px; padding: 4px 10px; }
.entry-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* AI 面板/患者通知面板的可折叠头部 */
.ai-panel-header-toggle { cursor: pointer; }
.ai-panel-header-toggle .section-chevron { margin-left: 8px; }
.ai-panel .section-body { display: none; }
.ai-panel .section-body.open { display: block; }

/* 辅助区可折叠卡片（details）：summary 即卡片标题行 */
.entry-card-collapsible > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.entry-card-collapsible > summary::-webkit-details-marker { display: none; }
.entry-card-collapsible > summary::after {
  content: '▾'; margin-left: auto; font-size: 11px; color: var(--text3);
  transition: transform 0.15s ease;
}
.entry-card-collapsible:not([open]) > summary::after { transform: rotate(-90deg); }
/* 内嵌组件自带的标题与 summary 重复，折叠卡内隐藏 */
.entry-card-collapsible .evidence-title,
.entry-card-collapsible .timeline-title { display: none; }

/* ── 应用内确认/输入弹层（替代原生 confirm/prompt） ── */
.app-dialog-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.12s ease-out;
}
.app-dialog {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 18px 50px rgba(0,0,0,0.25));
  width: min(92vw, 420px); padding: 20px;
  animation: dialogPop 0.16s ease-out;
}
@keyframes dialogPop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.app-dialog-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.app-dialog-message { font-size: 13.5px; line-height: 1.6; color: var(--text2); margin-bottom: 14px; }
.app-dialog-input { width: 100%; margin-bottom: 14px; }
.app-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (prefers-reduced-motion: reduce) { .app-dialog, .app-dialog-overlay { animation: none; } }

/* ── FAM 互联面板（同步条 + 测量结果）：统一用设计令牌，融入暖色主题 ── */
.fam-panel {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--surface2);
}
.fam-sync-bar { margin: 4px 0 10px; }
.fam-measure-panel { margin-top: 12px; flex-direction: column; align-items: stretch; }
.fam-panel-label { font-size: var(--text-sm); font-weight: 600; color: var(--text2); }
.fam-panel-hint { font-size: var(--text-xs); color: var(--text3); }
.fam-btn-sm { font-size: var(--text-xs); padding: 4px 12px; }
.fam-measure-status { font-size: var(--text-xs); color: var(--text3); padding: 6px 0; }
.fam-measure-status.error { color: var(--red); }
.fam-measure-item {
  margin-top: 8px; padding: 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
.fam-measure-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--text-xs);
}
.fam-measure-head .fam-measure-meta { color: var(--text3); }
.fam-metric-row { margin-top: 4px; }
.fam-metric { display: inline-block; margin: 2px 8px 2px 0; font-size: var(--text-xs); }
.fam-measure-adopted { font-size: 11px; color: var(--green); }
.fam-adopt-btn { font-size: 11px; padding: 2px 10px; }
