/* ===== 全局变量 (Glassmorphism Pastel Theme) ===== */
:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --gradient-primary: linear-gradient(135deg, #4c1d95, #3b82f6);
  --accent: #14b8a6;
  --accent-light: #2dd4bf;
  /* Backgrounds */
  --bg-body: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 50%, #dbeafe 100%);
  --bg-window: rgba(255, 255, 255, 0.45);
  --bg-sidebar: transparent;
  --bg-main: rgba(255, 255, 255, 0.96);
  --bg-card: #ffffff;
  --bg-input: #f8fafc;

  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: rgba(226, 232, 240, 0.8);
  --border-light: rgba(255, 255, 255, 0.6);
  --border-focus: #818cf8;

  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.03);
  --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 重置与隐藏滚动条 ===== */
::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  /* 启用现代 View Transitions API，提供极其顺滑的跨页面切换体验 */
  view-transition-name: root;
}

@view-transition {
  navigation: auto;
  /* 允许在同源导航时自动执行过渡动画 */
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-body);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* ===== 页面外层容器（用于按钮条绝对定位参考） ===== */
.page-frame {
  position: relative;
  width: 100%;
  max-width: 1440px;    /* 与 layout-wrapper 相同 */
  height: calc(100vh - 3rem); /* 与 layout-wrapper 相同 */
}

/* ===== 外层容器 (App Window) ===== */
.layout-wrapper {
  background: var(--bg-window);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1440px;
  height: calc(100vh - 3rem);
  overflow: hidden;
}

/* ===== 顶部导航 ===== */
.navbar {
  height: 68px;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.navbar-logo {
  width: 70px;
  height: 70px;
  object-fit: contain;
}

.navbar-brand .title {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.navbar-badge {
  background: rgba(255, 255, 255, 0.7);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid white;
}

.navbar-center-status {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.5);
  padding: 5px 8px;
  border-radius: 20px;
  border: 1px solid white;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 2px 8px;
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
  animation: status-pulse 2s infinite;
}

#topStatusText {
  animation: status-fade 3s ease-in-out infinite;
}

@keyframes status-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@keyframes status-fade {

  0%,
  100% {
    opacity: 0.8;
  }

  50% {
    opacity: 1;
  }
}

.status-time {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0 10px;
  border-left: 1px solid var(--border);
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: white;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg-input);
}

/* ===== 核心两栏容器 ===== */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== 侧边栏 ===== */
.sidebar-steps {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
}

.sidebar-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 2rem;
  padding: 0 10px;
  color: var(--text);
}

.sidebar-title .step-ratio {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.step-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 14px;
  cursor: pointer;
  position: relative;
  background: transparent;
  border: 1px solid transparent;
  margin-left: 4px;
}

.step-card:hover:not(.viewing) {
  background: rgba(255, 255, 255, 0.4);
  border-color: var(--border-light);
}

.step-card.viewing {
  background: white;
  box-shadow: 0 12px 30px -10px rgba(99, 102, 241, 0.15), 0 4px 12px -4px rgba(0, 0, 0, 0.05);
  border-color: var(--border-light);
  /* 给当前浏览的节点设置唯一的视图转场名称，实现跨页面“滑动”错觉 */
  view-transition-name: active-step-pill;
}

.step-card.viewing .step-title {
  color: var(--primary);
}

.step-card.viewing::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 32px;
  background: var(--primary);
  border-radius: 50px;
}

.step-circle {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  /* 圆角改为圆润矩形，更具现代感 */
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 800;
  flex-shrink: 0;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.step-card.done .step-circle {
  background: var(--success);
  color: white;
  border-color: var(--success);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.step-card.active .step-circle,
.step-card.viewing .step-circle {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
}

.step-info {
  display: flex;
  flex-direction: column;
}

.step-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.step-card.active .step-title {
  color: var(--text);
}

.step-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

/* 底部进度条 */
.sidebar-bottom {
  margin-top: 2rem;
  padding: 0 10px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(148, 163, 184, 0.15);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.step-fill-1 {
  width: 16.66%;
}

.step-fill-2 {
  width: 33.33%;
}

.step-fill-3 {
  width: 50%;
}

.step-fill-4 {
  width: 66.66%;
}

.step-fill-5 {
  width: 83.33%;
}

.step-fill-6 {
  width: 100%;
}

/* ===== 主内容区 ===== */
.main-content {
  flex: 1;
  background: var(--bg-main);
  padding: 1.5rem 3.5rem;
  overflow-y: auto;
  min-width: 0;
  position: relative;
}

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.card-header .icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.card-body {
  padding: 1.75rem;
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.form-label .required {
  color: var(--error);
  margin-left: 4px;
}

.form-control {
  width: 100%;
  padding: 0.85rem 1.15rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-input);
  transition: var(--transition);
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  background: var(--bg-card);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

textarea.form-control {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 6px 16px rgba(76, 29, 149, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(76, 29, 149, 0.35);
  filter: brightness(1.05);
}

.btn-outline {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 2px solid transparent;
}

.btn-outline:hover {
  background: #e2e8f0;
  color: var(--text);
}

.btn-lg {
  padding: 1rem 3rem;
  font-size: 1.05rem;
  border-radius: var(--radius);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ===== 辅助检查列表 ===== */
.aux-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-input);
  border-radius: var(--radius);
}

.aux-num {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 2px;
}

.aux-item-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.aux-item-reason {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.5;
}

/* ===== 诊断卡片 ===== */
.diagnosis-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.diagnosis-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;           /* 折叠时裁剪 diag-body */
  padding: 0;                 /* 内边距交由子元素处理 */
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease, border-color 0.2s, box-shadow 0.2s;
}

.diagnosis-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.diagnosis-card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow);
}

/* 折叠标题行 hover */
.diag-header {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transition: background 0.2s ease;
}
.diag-header:hover {
  background: rgba(99, 102, 241, 0.04);
}
.diagnosis-accordion.diag-open .diag-header {
  background: rgba(99, 102, 241, 0.03);
}


.diagnosis-card.rank-1 {
  border-left: 6px solid var(--primary);
}

.diagnosis-card.rank-2 {
  border-left: 6px solid var(--accent);
}

.diagnosis-card.rank-3 {
  border-left: 6px solid var(--warning);
}

.confidence-ring {
  width: 80px;
  height: 80px;
  position: relative;
  flex-shrink: 0;
}

.confidence-ring svg {
  transform: rotate(-90deg);
}

.confidence-ring .track {
  fill: none;
  stroke: var(--bg-input);
  stroke-width: 6;
}

.confidence-ring .fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 188;
  stroke-dashoffset: 188;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.confidence-ring .fill.primary {
  stroke: var(--primary);
}

.confidence-ring .fill.accent {
  stroke: var(--accent);
}

.confidence-ring .fill.warning {
  stroke: var(--warning);
}

.confidence-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
}

.diagnosis-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.diagnosis-rank {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.rank-badge-1 {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}

.rank-badge-2 {
  background: rgba(20, 184, 166, 0.1);
  color: var(--accent);
}

.rank-badge-3 {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.diagnosis-reason {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.changes-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 10px;
}

/* ===== 工具相关卡片 ===== */
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.4s ease;
}

.tool-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.tool-card-header {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.tool-card-header:hover {
  background: var(--bg-input);
}

.tool-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 700;
}

.tool-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.tool-bing {
  background: rgba(0, 120, 212, 0.15);
  color: #0078d4;
}

.tool-pubmed {
  background: rgba(0, 150, 80, 0.15);
  color: #009650;
}

.tool-rag {
  background: rgba(120, 80, 200, 0.15);
  color: #7850c8;
}

.tool-card-body {
  padding: 0 1.5rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
}

.tool-card-body.open {
  max-height: 500px;
  padding: 0 1.5rem 1.5rem;
}

.tool-result-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== 提示框与组件 ===== */
.agent-stream-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.8;
  min-height: 120px;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.skeleton-card {
  height: 90px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ===== 页面标题 ===== */
.page-title {
  margin-bottom: 2.5rem;
}

.page-title h1 {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.page-title p {
  font-size: 1.05rem;
  color: var(--text-secondary);
}

/* ===== 参考文献卡片与抽屉 ===== */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.ref-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.ref-card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow);
  transform: translateY(-4px);
}

.ref-card.highlight {
  border-color: var(--border-focus);
  background: rgba(99, 102, 241, 0.04);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.ref-card-badge {
  min-width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  flex-shrink: 0;
}

.ref-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ref-card-snippet {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== 参考文献详情弹窗 ===== */
.ref-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ref-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-light);
}

.ref-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ref-modal-badge {
  min-width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
}

.ref-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ref-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--bg-input);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  flex-shrink: 0;
}

.ref-modal-close:hover {
  background: #e2e8f0;
}

.ref-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.ref-modal-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 1rem;
}

.ref-source-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.ref-modal-url {
  font-size: 0.85rem;
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
}

.ref-modal-url:hover {
  text-decoration: underline;
}

.ref-modal-content {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
}

.ref-drawer {
  position: fixed;
  top: 0;
  right: -450px;
  width: 450px;
  height: 100vh;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: -15px 0 40px rgba(0, 0, 0, 0.08);
  z-index: 200;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-light);
}

.ref-drawer.open {
  right: 0;
}

.ref-drawer-header {
  padding: 1.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ref-drawer-header h3 {
  font-size: 1.2rem;
  font-weight: 800;
}

.ref-drawer-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--bg-input);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
}

.ref-drawer-close:hover {
  background: #e2e8f0;
}

.ref-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem;
}

.ref-item {
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  transition: var(--transition);
}

.ref-item.highlighted {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(4px);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

.drawer-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.cite-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: none;
  border: 1.5px solid;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  top: -3px;
}

.cite-chip:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Badge Spinner */
.badge-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: badge-spin 0.8s linear infinite;
}

@keyframes badge-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== 诊断修改变化高亮美化 ===== */
.diagnosis-changes {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.08) 0%, rgba(99, 102, 241, 0.05) 100%);
  border: 1px solid rgba(20, 184, 166, 0.2);
  border-left: 5px solid var(--accent);
  display: block;
  box-shadow: 0 4px 15px rgba(20, 184, 166, 0.06);
  position: relative;
  overflow: hidden;
}

.diagnosis-changes .changes-content {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.6;
  z-index: 1;
}

.diagnosis-changes .changes-content strong {
  color: var(--accent);
  background: rgba(20, 184, 166, 0.1);
  padding: 0 4px;
  border-radius: 3px;
}

/* ===== 打印专属优化 (@media print) ===== */
/* ============================================================
   响应式布局
   断点：
     ≥ 1280px  大屏桌面（默认）
     1024-1279 普通桌面 / 小笔记本
     768-1023  平板横屏（侧边栏收窄至图标模式）
     < 768     平板竖屏（侧边栏隐藏，按钮条改回 navbar）
   ============================================================ */

/* ----- 1024px ~ 1279px：缩减侧边栏和内边距 ----- */
@media (max-width: 1279px) {
  body { padding: 1rem; }
  .page-frame, .layout-wrapper { height: calc(100vh - 2rem); }
  .navbar { padding: 0 1.25rem; height: 60px; }
  .navbar-logo { width: 54px; height: 54px; }
  .sidebar-steps { width: 240px; padding: 1.75rem 1rem; }
  .sidebar-title { font-size: 1rem; margin-bottom: 1.25rem; }
  .step-card { padding: 10px 12px; }
  .step-circle { width: 32px; height: 32px; font-size: 0.85rem; }
  .step-title { font-size: 0.88rem; }
  .step-subtitle { font-size: 0.7rem; }
  .main-content { padding: 1.25rem 2rem; }

  /* 平板：隐藏右侧竖排条，改用 navbar 内迷你按钮（与用户名同行） */
  #sideActionBar { display: none !important; }
  .navbar-tablet-actions { display: flex !important; }
}

/* ----- 768px ~ 1023px：平板横屏，侧边栏缩为纯图标 ----- */
@media (max-width: 1023px) {
  body { padding: 0.75rem; }
  .page-frame, .layout-wrapper { height: calc(100vh - 1.5rem); border-radius: 14px; }
  .navbar { padding: 0 1rem; height: 56px; }
  .navbar-logo { width: 44px; height: 44px; }
  .navbar-brand .title { font-size: 1.05rem; }
  .navbar-badge { display: none; }

  /* 侧边栏：收窄为 64px 图标列 */
  .sidebar-steps {
    width: 64px;
    padding: 1.25rem 0;
    align-items: center;
  }
  .sidebar-title { display: none; }
  .steps-list { gap: 0.5rem; align-items: center; }
  .step-card {
    padding: 10px 0;
    width: 48px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 12px;
    margin-left: 0;
  }
  .step-info { display: none; }
  .step-circle { width: 36px; height: 36px; font-size: 0.9rem; border-radius: 10px; }
  .sidebar-bottom { display: none; }
  .main-content { padding: 1rem 1.5rem; }

  /* 竖排按钮条隐藏，改用 navbar 内迷你按钮 */
  #sideActionBar { display: none !important; }
  .navbar-tablet-actions { display: flex !important; }
}

/* ----- < 768px：平板竖屏，侧边栏完全隐藏 ----- */
@media (max-width: 767px) {
  body { padding: 0.5rem; align-items: flex-start; }
  .page-frame, .layout-wrapper { height: calc(100vh - 1rem); border-radius: 10px; }
  .navbar { padding: 0 0.85rem; height: 52px; }
  .navbar-logo { width: 36px; height: 36px; }
  .navbar-brand .title { font-size: 0.95rem; }
  .sidebar-steps { display: none; }
  .main-content { padding: 0.85rem 1rem; }
  .navbar-center-status { display: none !important; }
  #sideActionBar { display: none !important; }
  .navbar-tablet-actions { display: flex !important; }
  .card-body { padding: 1rem; }
  .card-header { padding: 0.85rem 1rem; }
  .form-row { grid-template-columns: 1fr; gap: 0.75rem; }
  .ref-grid { grid-template-columns: 1fr !important; }
}

/* 平板 / 手机下的 navbar 内迷你操作按钮（大屏默认隐藏） */
.navbar-tablet-actions {
  display: none;
  align-items: center;
  gap: 0.4rem;
}
.navbar-tablet-actions button {
  padding: 0.3rem 0.65rem;
  font-size: 0.72rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
  backdrop-filter: blur(8px);
  line-height: 1.4;
}
.navbar-tablet-actions button:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.navbar-tablet-actions .btn-logout:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

@media print {

  /* 1. 基础页面包裹重制 */
  body,
  html {
    background: #fff !important;
    min-height: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* 消除固定高度和溢出隐藏导致的挤压截断 */
  .layout-wrapper {
    height: auto !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    overflow: visible !important;
    max-width: none !important;
  }

  .app-body {
    overflow: visible !important;
    display: block !important;
    /* 去除 Flex 防止异常横向或纵向拉伸 */
  }

  .main-content {
    padding: 0 !important;
    overflow: visible !important;
    background: transparent !important;
  }

  /* 2. 彻底隐藏界面交互控件及边栏 */
  .navbar,
  .sidebar-steps,
  .btn,
  .icon-btn,
  #topStatusText,
  .navbar-center-status,
  button {
    display: none !important;
  }

  /* 3. 剥离特效以增强对比度，并设置不可截断规则以防分页导致排版割裂 */
  .card,
  .diagnosis-card,
  .tool-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    background: transparent !important;
    break-inside: avoid;
    /* 现代属性 */
    page-break-inside: avoid;
    /* 旧版支持 */
    margin-bottom: 24px !important;
    transform: none !important;
    animation: none !important;
  }

  .aux-item {
    background: transparent !important;
    border: 1px solid #eee !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .diagnosis-changes {
    background: transparent !important;
    border: 1px dashed #bbb !important;
    border-left: 5px solid #666 !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* 将主要文字强制深色渲染以方便激光/喷墨打印设备 */
  h1,
  h2,
  h3,
  h4,
  h5,
  p,
  span,
  div,
  .reason-text {
    color: #111 !important;
    text-shadow: none !important;
  }

  .cite-chip {
    background: transparent !important;
    border: 1px solid #999 !important;
    color: #333 !important;
  }

  /* 纸张排版调整 */
  @page {
    size: A4 portrait;
    margin: 20mm 15mm;
  }
}
