:root {
  --bg: #090b11;
  --bg-subtle: #0e1320;
  --panel: #141c2e;
  --panel-hover: #1b263e;
  --card: #121827;
  --card-inner: #162035;
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-focus: #3b82f6;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-soft: #64748b;
  --brand: #3b82f6;
  --brand-hover: #2563eb;
  --brand-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  --brand-glow: rgba(59, 130, 246, 0.28);
  --teal: #14b8a6;
  --danger: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.12);
  --danger-border: rgba(244, 63, 94, 0.35);
  --ok: #10b981;
  --ok-bg: rgba(16, 185, 129, 0.12);
  --ok-border: rgba(16, 185, 129, 0.35);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --warn-border: rgba(245, 158, 11, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* 现代化滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ================= 移动端顶部导航栏 ================= */
.mobile-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: calc(50px + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 12px;
  padding-right: 12px;
  background: rgba(9, 11, 17, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.icon-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.icon-btn:hover { background: var(--panel-hover); border-color: rgba(255, 255, 255, 0.15); }
.icon-btn:active { transform: scale(0.95); }

.mobile-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 8px;
}
.m-topic-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.m-counter-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.28);
  color: #60a5fa;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.mobile-nav-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.m-mode-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.m-mode-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}
.m-mode-btn:active { transform: scale(0.95); }

.m-ai-btn {
  background: var(--brand-gradient);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 10px var(--brand-glow);
  transition: all 0.15s ease;
}
.m-ai-btn:active { transform: scale(0.95); }

/* ================= 遮罩背景 ================= */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ================= 主框架布局 ================= */
#app {
  width: 100%;
  display: block;
}

/* ================= 侧边栏 (Sidebar) ================= */
.sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-sizing: border-box;
}

.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.brand {
  display: flex;
  flex-direction: column;
}
.brand-sub {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #60a5fa;
  margin-bottom: 2px;
}
.brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
#ai-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 5px 0 0;
  font-weight: 500;
}
#ai-status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.close-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.15s ease;
}
.close-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: var(--border);
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* 现代化分段开关 (shadcn tabs 风格) */
.mode-segmented {
  display: flex;
  background: rgba(11, 15, 26, 0.85);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
.mode-segmented button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.mode-segmented button:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.mode-segmented button.active {
  background: var(--brand-gradient);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--brand-glow);
}

.field-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* 现代化表单控件 */
select, textarea {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  outline: none;
  transition: all 0.15s ease;
  font-family: inherit;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}
select:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background-color: var(--panel-hover);
}
select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 4px;
  user-select: none;
}
.check-item input {
  accent-color: var(--brand);
  width: 16px;
  height: 16px;
  cursor: pointer;
  border-radius: 4px;
}

.stats-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.7;
}
.stats-box b {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.danger-outline-btn {
  background: transparent;
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: #fb7185;
  font-size: 12px;
  font-weight: 600;
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: auto;
  transition: all 0.15s ease;
}
.danger-outline-btn:hover {
  background: var(--danger-bg);
  border-color: rgba(244, 63, 94, 0.5);
}
.danger-outline-btn:active { transform: scale(0.98); }

/* ================= 主刷题展示区 (Main Area) ================= */
.main {
  width: 100%;
  min-width: 0;
  padding: 12px 14px calc(72px + var(--safe-bottom)) 14px;
  display: flex;
  flex-direction: column;
}

.top-progress-track {
  height: 4px;
  background: var(--border-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}
.top-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #14b8a6, #3b82f6);
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 核心题目卡片 (shadcn Card 风格) */
.question-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s ease;
}

.card-header-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.tag-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tag-topic, .tag-module {
  font-size: 11.5px;
  font-weight: 500;
  padding: 2.5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.tag-core {
  font-size: 11px;
  font-weight: 700;
  padding: 2.5px 9px;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fb7185;
}
.question-seq {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.question-title {
  margin: 0 0 16px 0;
  font-size: 20px;
  line-height: 1.45;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  word-break: break-word;
}

/* 答题区域包装 */
.answer-container {
  width: 100%;
}

/* 现代化口头作答卡片 */
.oral-answer-box {
  margin: 12px 0 16px;
  padding: 16px;
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(20, 28, 46, 0.6) 0%, rgba(13, 19, 32, 0.7) 100%);
  backdrop-filter: blur(8px);
}
.oral-answer-head, .oral-answer-actions, .transcript-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.oral-answer-head {
  justify-content: space-between;
}
.oral-answer-head .k {
  color: #38bdf8;
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 2px;
}
.oral-answer-tip, .record-status {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}
.record-time {
  color: #f87171;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 13px;
  background: rgba(239, 68, 68, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.oral-answer-actions {
  margin: 12px 0 8px;
}
.record-btn {
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.1);
  color: #fecdd3;
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.record-btn:hover {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.5);
}
.record-btn.recording {
  background: rgba(248, 113, 113, 0.28);
  border-color: rgba(248, 113, 113, 0.7);
  color: #ffffff;
  animation: record-pulse 1.2s infinite;
}
.record-status.err {
  color: var(--danger);
  font-weight: 600;
}

.answer-transcript {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 96px;
  margin-top: 6px;
  background: rgba(9, 13, 22, 0.75);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.6;
}
.transcript-actions {
  justify-content: flex-end;
  margin-top: 10px;
  gap: 10px;
}
.transcript-actions .ghost-btn {
  padding: 7px 15px;
  font-size: 12.5px;
  border-radius: 8px;
}
.transcript-actions .btn-primary {
  flex: none;
  width: auto;
  padding: 8px 22px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  box-shadow: 0 2px 12px var(--brand-glow);
}

.answer-feedback {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}
.feedback-summary {
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
}
.feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.feedback-grid > div {
  padding: 10px 12px;
  background: rgba(11, 16, 28, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}
.feedback-grid b {
  color: #93c5fd;
  font-size: 12.5px;
  display: block;
  margin-bottom: 4px;
}
.feedback-grid ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
.feedback-grid li {
  margin: 3px 0;
  color: #cbd5e1;
}
.feedback-next {
  margin-top: 12px;
  color: #93c5fd;
  font-size: 13px;
}
.feedback-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.feedback-result-actions button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.feedback-result-actions button:hover:not(:disabled) {
  background: var(--panel-hover);
  border-color: rgba(255, 255, 255, 0.15);
}
.feedback-result-actions button:disabled {
  opacity: 0.55;
  cursor: default;
}
.feedback-error { color: var(--danger); font-weight: 600; }
@keyframes record-pulse {
  50% { box-shadow: 0 0 0 5px rgba(248, 113, 113, 0.15); }
}

/* 刷题模式未揭晓提示卡片 */
.practice-think-box {
  background: radial-gradient(circle at 50% 20%, rgba(59, 130, 246, 0.08), transparent 75%), rgba(16, 22, 36, 0.5);
  border: 1px dashed rgba(59, 130, 246, 0.28);
  border-radius: 16px;
  padding: 30px 20px;
  text-align: center;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}
.practice:not(.revealed) .practice-think-box {
  display: flex;
}
.practice.revealed .practice-think-box {
  display: none;
}

.think-badge {
  font-size: 12px;
  font-weight: 700;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.28);
  padding: 3px 12px;
  border-radius: 999px;
}
.think-lead {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 4px 0;
  line-height: 1.55;
}
.action-reveal-btn {
  background: var(--brand-gradient);
  border: none;
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 700;
  padding: 10px 28px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--brand-glow);
  margin-top: 6px;
  transition: all 0.15s ease;
}
.action-reveal-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--brand-glow);
}
.action-reveal-btn:active { transform: scale(0.97); }
.think-subtip {
  font-size: 11.5px;
  color: var(--text-soft);
}

/* 详细答案解析与卡片排版 */
.answer-content {
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}
.practice:not(.revealed) .answer-content {
  display: none;
}
.practice.revealed .answer-content,
:not(.practice) .answer-content {
  display: block;
}

.answer-content p { margin: 8px 0; }
.answer-content ul, .answer-content ol { padding-left: 1.35em; margin: 8px 0; }
.answer-content li { margin: 4px 0; }
.answer-content h3, .answer-content h4 {
  color: #f8fafc;
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 700;
}
.answer-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}
.answer-content pre {
  background: #090c14;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
}
.answer-content pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: #e2e8f0;
}
.answer-content img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 10px 0;
  border: 1px solid var(--border);
  background: #ffffff;
}

/* 口语 / 原理 / 易错 精美卡片排版 */
.oral, .reason, .pit {
  border-radius: 12px;
  padding: 14px 16px;
  margin: 12px 0;
  transition: border-color 0.15s ease;
}
.oral {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.02) 100%);
  border: 1px solid rgba(16, 185, 129, 0.24);
  border-left: 3.5px solid #10b981;
}
.reason {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(59, 130, 246, 0.02) 100%);
  border: 1px solid rgba(59, 130, 246, 0.24);
  border-left: 3.5px solid #3b82f6;
}
.pit {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(245, 158, 11, 0.02) 100%);
  border: 1px solid rgba(245, 158, 11, 0.24);
  border-left: 3.5px solid #f59e0b;
  color: #fef08a;
}
.k {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.oral .k { color: #34d399; }
.reason .k { color: #60a5fa; }
.pit .k { color: #fbbf24; }

/* ================= 移动端吸底操作栏 ================= */
.mobile-dock {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  padding-left: 10px;
  padding-right: 10px;
  background: rgba(9, 11, 17, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  align-items: center;
  gap: 8px;
  z-index: 50;
}

.dock-btn {
  flex: 1;
  min-width: 0;
  height: 42px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  gap: 3px;
  transition: all 0.15s ease;
}
.dock-btn:active { transform: scale(0.95); }
.dock-icon { font-size: 13.5px; }
.dock-txt { font-size: 11px; font-weight: 600; white-space: nowrap; }

.dock-wrong.active { background: var(--danger-bg); border-color: var(--danger-border); color: #fda4af; }
.dock-star.active { background: var(--warn-bg); border-color: var(--warn-border); color: #fde68a; }
.dock-master.active { background: var(--ok-bg); border-color: var(--ok-border); color: #6ee7b7; }

/* 上一题按钮：紧凑箭头，不占 flex 份额 */
.dock-prev {
  flex: 0 0 auto;
  width: 46px;
  font-size: 16px;
}

.dock-primary-btn {
  flex: 1.8;
  min-width: 0;
  height: 42px;
  background: var(--brand-gradient);
  border: none;
  color: #ffffff;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--brand-glow);
  white-space: nowrap;
}
.dock-primary-btn:active { transform: scale(0.97); }
.dock-arrow { font-size: 14px; }

/* ================= AI 面试助教居中弹窗 (shadcn Dialog 风格) ================= */
.ai-pane {
  position: fixed;
  z-index: 120;
  left: 50%;
  top: 50%;
  width: min(780px, calc(100vw - 28px));
  height: min(84vh, 780px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 20px calc(16px + var(--safe-bottom));
  background: rgba(14, 19, 32, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -46%) scale(0.98);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.ai-pane.active {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
#ai-backdrop {
  z-index: 110;
  background: rgba(5, 7, 12, 0.72);
}
.ai-sheet-grabber { display: none; }

.ai-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.ai-header-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.ai-header-left h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.ai-sub {
  font-size: 11.5px;
  color: var(--text-soft);
}

.ai-model-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.ai-model-switch span {
  white-space: nowrap;
}
.ai-model-switch select {
  font-size: 12.5px;
  padding: 6px 10px;
}

.quick-prompts-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}
.quick-prompts-row::-webkit-scrollbar { display: none; }
.quick-prompts-row button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.quick-prompts-row button:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
  color: #93c5fd;
}
.quick-prompts-row button:active {
  transform: scale(0.97);
}

.answer-reference-image, .image-generation-card {
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.answer-reference-title, .image-generation-title { color: #93c5fd; font-weight: 800; font-size: 13px; }
.answer-reference-title { display: flex; align-items: center; justify-content: space-between; }
.reference-image-remove { padding: 4px 12px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: transparent; color: var(--text-muted); border-radius: 8px; cursor: pointer; }
.reference-image-remove:hover { color: #fca5a5; border-color: rgba(248, 113, 113, 0.5); }
.answer-reference-image img, .generated-answer-image { display: block; width: 100%; max-height: 560px; object-fit: contain; margin-top: 10px; border-radius: 8px; background: #080d18; cursor: zoom-in; }
.image-lightbox { position: fixed; inset: 0; z-index: 999; display: none; align-items: center; justify-content: center; background: rgba(2, 6, 16, 0.92); cursor: zoom-out; padding: 24px; }
.image-lightbox.open { display: flex; }
.image-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; }
.image-generation-tip { margin: 10px 0; color: var(--text-muted); line-height: 1.5; }
.image-generation-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.image-generation-actions button.saved { color: #86efac; border-color: #22c55e; }

/* 聊天流容器 */
.chat-stream-box {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}
.msg {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}
.msg.user {
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.35);
  align-self: flex-end;
  max-width: 88%;
  color: #bfdbfe;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.msg.assistant {
  background: var(--panel);
  border: 1px solid var(--border);
  align-self: flex-start;
  max-width: 96%;
  border-bottom-left-radius: 4px;
}
.msg.err {
  color: #fda4af;
  border-color: var(--danger-border);
  background: var(--danger-bg);
  white-space: pre-wrap;
}
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant h3, .msg.assistant h4 {
  color: #f8fafc;
  margin: 14px 0 6px;
  font-size: 14px;
  font-weight: 700;
}
.msg.assistant h3:first-child, .msg.assistant h4:first-child { margin-top: 0; }
.msg.assistant ul, .msg.assistant ol {
  margin: 6px 0 10px;
  padding-left: 1.35em;
}
.msg.assistant li { margin: 3px 0; }
.msg.assistant strong { color: #f8fafc; font-weight: 700; }
.msg.assistant em { color: #e2e8f0; }
.msg.assistant a { color: #93c5fd; }
.msg.assistant code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  background: rgba(11, 15, 25, 0.8);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #7dd3fc;
}
.msg.assistant pre {
  background: #090c14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg.assistant pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.5;
}
.msg.assistant blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--brand);
  background: rgba(59, 130, 246, 0.08);
  color: #cbd5e1;
  border-radius: 0 6px 6px 0;
}
.msg.assistant table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
  display: block;
  overflow-x: auto;
}
.msg.assistant th, .msg.assistant td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.msg.assistant th {
  background: rgba(11, 16, 28, 0.85);
  color: #e2e8f0;
  font-weight: 700;
}
.msg.assistant img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 8px 0;
}

/* 聊天输入栏 */
.chat-input-bar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}
.chat-input-bar textarea {
  flex: 1;
  resize: none;
  font-size: 13.5px;
  height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
}
#chat-send-btn {
  background: var(--brand-gradient);
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
  padding: 0 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 10px var(--brand-glow);
}
#chat-send-btn:hover {
  filter: brightness(1.08);
}
#chat-send-btn:active { transform: scale(0.96); }

/* ================= 移动端弹窗抽屉行为 (< 1025px) ================= */
.mobile-only { display: block; }
.desktop-only { display: none !important; }

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 84%;
    max-width: 320px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.7);
  }
  .sidebar.active {
    transform: translateX(0);
  }
  .feedback-grid { grid-template-columns: 1fr; }
}

/* ================= 手机端细节优化 (<= 768px) ================= */
@media (max-width: 768px) {
  /* 触控目标加大：顶栏模式/AI 按钮 */
  .m-mode-btn, .m-ai-btn {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 13px;
  }
  .m-ai-btn { padding: 8px 15px; }

  /* 顶栏计数徽章、品牌副标题、分组标题字号提升 */
  .m-counter-badge { font-size: 12px; padding: 3px 9px; }
  .brand-sub { font-size: 11px; }
  .group-title { font-size: 12px; }

  /* 移除参考图按钮触控区加大 */
  .reference-image-remove { min-height: 36px; padding: 6px 14px; font-size: 13px; }

  /* 侧栏复选框触控区加大 */
  .check-item input {
    width: 22px;
    height: 22px;
  }
  .check-item { min-height: 36px; font-size: 13px; }

  /* AI 面板快捷提问按钮 */
  .quick-prompts-row button {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 12.5px;
  }
  .ai-model-switch select { min-height: 36px; }

  /* 卡片与排版：榨取小屏横向空间 */
  .question-card { padding: 18px 16px; border-radius: 16px; }
  .question-title { font-size: 19px; }
  .main { padding: 10px 12px calc(76px + var(--safe-bottom)) 12px; }
  .answer-content code { font-size: 13px; }
  .answer-content pre { padding: 12px; font-size: 13px; }
  .answer-content pre code { font-size: 13px; }

  /* 参考图预览 */
  .answer-reference-image, .image-generation-card { padding: 10px 12px; }

  /* 关闭按钮触控区加大 */
  .close-icon-btn { width: 36px; height: 36px; font-size: 17px; }

  /* 灯箱留边收紧 */
  .image-lightbox { padding: 16px; }
}

/* ================= 桌面端适配 (>= 1025px) ================= */
@media (min-width: 1025px) {
  #sidebar-backdrop { display: none !important; }
  .mobile-only { display: none !important; }
  .desktop-only { display: block !important; }
  .mobile-navbar { display: none; }
  .mobile-dock { display: none; }

  #app {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    height: 100vh;
    overflow-y: auto;
    position: static;
    transform: none;
    box-shadow: none;
  }

  .main {
    height: 100vh;
    overflow-y: auto;
    padding: 24px 32px;
  }

  .desktop-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }
  .crumb-text {
    font-size: 13.5px;
    color: var(--text-muted);
    font-weight: 500;
    background: rgba(255, 255, 255, 0.03);
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
  }
  .desktop-top-tools {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .model-picker {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-soft);
  }
  .model-picker select { width: auto; font-size: 12.5px; padding: 5px 10px; }

  .ghost-btn {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
  }
  .ghost-btn:hover {
    background: var(--panel-hover);
    border-color: rgba(255, 255, 255, 0.15);
  }
  .ghost-btn:active { transform: scale(0.97); }

  #btn-open-ai-desktop {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.3);
    color: #93c5fd;
  }
  #btn-open-ai-desktop:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
  }

  .desktop-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1.35fr;
    gap: 10px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border-subtle);
  }
  .btn-state {
    height: 42px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    padding: 0 10px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
  }
  .btn-state:hover {
    background: var(--panel-hover);
    border-color: rgba(255, 255, 255, 0.15);
  }
  .btn-state.active-wrong {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: #fda4af;
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.15);
  }
  .btn-state.active-master {
    background: var(--ok-bg);
    border-color: var(--ok-border);
    color: #6ee7b7;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
  }
  .btn-state.active-star {
    background: var(--warn-bg);
    border-color: var(--warn-border);
    color: #fde68a;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.15);
  }

  .desktop-card-actions .btn-primary {
    height: 42px;
    background: var(--brand-gradient);
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    padding: 0 16px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px var(--brand-glow);
    transition: all 0.15s ease;
  }
  .desktop-card-actions .btn-primary:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--brand-glow);
  }
  .desktop-card-actions .btn-primary:active { transform: scale(0.98); }

  .keyboard-tip {
    font-size: 12px;
    color: var(--text-soft);
    margin: 14px 0 0;
    text-align: center;
  }
}

/* ---------- AI Key 设置 ---------- */
.ai-key-setting {
  padding: 6px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar .ai-key-setting { padding: 0; gap: 6px; }
.sidebar .ai-key-row { flex-wrap: wrap; }
.sidebar .ai-key-row input { flex: 1 1 100%; }
.sidebar .ai-key-row button { flex: 1; }
.sidebar .field-item input {
  width: 100%;
  background: rgba(11, 15, 25, 0.7);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
}
.sidebar .field-item input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}
.ai-key-row {
  display: flex;
  gap: 8px;
}
.ai-key-row input {
  flex: 1;
  min-width: 0;
  background: rgba(11, 15, 25, 0.7);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: all 0.15s ease;
}
.ai-key-row input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}
.ai-key-row button {
  background: var(--brand-gradient);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.ai-key-row button:hover {
  filter: brightness(1.08);
}
.ai-key-row button:last-child {
  background: transparent;
  border: 1px solid var(--danger-border);
  color: #fda4af;
}
.ai-key-row button:last-child:hover {
  background: var(--danger-bg);
}
.ai-key-status {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 0 0;
  word-break: break-all;
}
.ai-key-status.ok { color: var(--ok); font-weight: 600; }
.ai-key-status.err { color: var(--danger); font-weight: 600; }

/* ---------- 登录遮罩 ---------- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 12, 0.88);
  backdrop-filter: blur(8px);
}
.login-overlay[hidden] { display: none; }
.login-card {
  width: min(340px, 88vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.login-card h2 { margin: 0 0 6px; font-size: 19px; color: var(--text); }
.login-card p { margin: 0 0 16px; font-size: 13px; color: var(--text-muted); }
.login-card input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(11, 15, 25, 0.7);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  padding: 11px 12px;
  outline: none;
  text-align: center;
  letter-spacing: 2px;
}
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16); }
.login-err { color: var(--danger); font-size: 12.5px; margin-top: 8px; }
.login-card button {
  width: 100%;
  margin-top: 16px;
  background: var(--brand-gradient);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 11px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--brand-glow);
}

/* 口头作答关闭时隐藏作答区 */
body.oral-off .oral-answer-box { display: none; }

/* ================= 设置入口按钮 ================= */
.settings-open-btn {
  width: 100%;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: #bae6fd;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}
.settings-open-btn:hover {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
}
.settings-open-btn:active { transform: scale(0.98); }

/* ================= 设置弹窗 ================= */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 16, 0.72);
  backdrop-filter: blur(6px);
}
.settings-overlay[hidden] { display: none; }

.settings-modal {
  width: min(600px, 100%);
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  background: #0e1524;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
.settings-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: #f1f5f9;
}
.settings-body {
  padding: 4px 18px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-body .sidebar-group { margin: 10px 0 2px; }
.settings-body .field-label { display: block; }
.settings-body .ai-key-setting { padding: 10px 0 2px; gap: 8px; }
.settings-body .ai-key-row input { flex: 1 1 100%; }
.settings-body .ai-key-row button { flex: 1 1 calc(50% - 4px); }
.settings-body .danger-outline-btn { width: 100%; margin-top: 4px; }

@media (max-width: 768px) {
  .settings-overlay { padding: 12px; align-items: flex-end; }
  .settings-modal {
    width: 100%;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
  }
  .settings-body { padding: 4px 16px calc(16px + env(safe-area-inset-bottom)); }
}
