/* ═══════════════════════════════════════════════════════════
   眼科自习室 — 样式系统
   设计语言：医学/科学 + 活人感
   ═══════════════════════════════════════════════════════════ */

/* ── 变量 ─────────────────────────────────────────────── */
:root {
  /* 眼科学调色盘 */
  --cornea:    #7C6FE3;
  --angle:     #F59E0B;
  --lens:      #10B981;
  --uvea:      #EF4444;
  --retina:    #3B82F6;
  --nerve:     #8B5CF6;
  --orbit:     #EC4899;
  --kids:      #06B6D4;
  --infection: #84CC16;

  /* 主色调 */
  --bg:        #F8F7F4;
  --surface:   #FFFFFF;
  --surface2:  #F3F2EE;
  --border:    #E5E3DC;
  --border2:   #D4D1C8;
  --text:      #1A1A18;
  --text2:     #6B6860;
  --text3:     #A09E97;

  /* 导航高亮 */
  --accent:    #3B82F6;
  --accent-h:  #2563EB;
  --accent-bg: #EFF6FF;

  /* 功能色 */
  --success:   #10B981;
  --warn:      #F59E0B;
  --danger:    #EF4444;
  --info:      #6366F1;

  /* 闪卡色 */
  --fc-again:  #EF4444;
  --fc-good:   #F59E0B;
  --fc-easy:   #10B981;

  /* 字体 */
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-serif:'Crimson Pro', Georgia, serif;
  --font-mono: 'DM Mono', 'Courier New', monospace;

  /* 圆角 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* 阴影 */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.05);
}

/* ── 深色模式 ─────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:       #111110;
  --surface:  #1C1C1A;
  --surface2: #252522;
  --border:   #2E2E2B;
  --border2:  #3E3E3A;
  --text:     #F0EEE8;
  --text2:    #A09E97;
  --text3:    #6B6860;
  --accent-bg:#1E2A4A;
  --shadow-sm:0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:0 12px 32px rgba(0,0,0,0.5);
}

/* ── 基础重置 ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

/* 选区 */
::selection { background: var(--accent); color: #fff; }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* 焦点 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ── 头部 ─────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-eye {
  font-size: 22px;
  color: var(--retina);
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.logo-text {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.nav-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--r-md);
  transition: all 0.15s;
}

.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--accent-bg); color: var(--accent); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }

/* ── 扫描进度条 ─────────────────────────────────────────── */
.scan-bar-wrap {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.scan-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.scan-label-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.scan-label-done {
  font-size: 12px;
  color: var(--text3);
  font-family: var(--font-mono);
}

.scan-track {
  position: relative;
  height: 28px;
}

.scan-segments {
  display: flex;
  height: 100%;
  gap: 3px;
}

.scan-seg {
  flex: 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.1s;
}

.scan-seg:hover { transform: scaleY(1.1); }

.scan-seg-inner {
  width: 100%;
  height: 14px;
  border-radius: var(--r-sm);
  opacity: 0.3;
  transition: opacity 0.2s;
}

.scan-seg.covered .scan-seg-inner { opacity: 1; }

.scan-seg-label {
  font-size: 9px;
  color: var(--text3);
  text-align: center;
  margin-top: 2px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.scan-cursor {
  position: absolute;
  top: 0;
  width: 2px;
  height: 14px;
  background: var(--text);
  border-radius: 1px;
  transition: left 0.5s ease, opacity 0.3s;
  opacity: 0;
}

.scan-cursor.visible { opacity: 1; }

.scan-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 6px;
  font-style: italic;
}

/* ── 主内容区 ─────────────────────────────────────────── */
.content-area {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 28px 24px;
}

.view { display: none; }
.view.active { display: block; }

/* ── 今日学习 ─────────────────────────────────────────── */
#view-learn {
  display: none;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: start;
}

#view-learn.active {
  display: grid;
}

.seg-panel {
  position: sticky;
  top: 90px;
}

.seg-panel-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 10px;
}

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

.seg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.12s;
  border: 1.5px solid transparent;
}

.seg-item:hover { background: var(--surface2); }

.seg-item.active {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.seg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.seg-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.seg-badge {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text3);
  background: var(--surface2);
  padding: 1px 6px;
  border-radius: 99px;
}

/* 知识卡片 */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.knowledge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
  animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.knowledge-card:hover { box-shadow: var(--shadow-md); }

.kc-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.kc-accent {
  width: 4px;
  min-height: 40px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-top: 2px;
}

.kc-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.kc-meta {
  font-size: 12px;
  color: var(--text3);
  margin-top: 3px;
}

.kc-body { }

.kc-section { margin-bottom: 12px; }

.kc-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 5px;
}

.kc-points {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kc-points li {
  font-size: 13px;
  color: var(--text);
  padding-left: 14px;
  position: relative;
  line-height: 1.5;
}

.kc-points li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--text3);
  font-size: 11px;
  top: 2px;
}

.kc-numbers { display: flex; flex-direction: column; gap: 5px; }

.kc-num-item {
  display: flex;
  gap: 8px;
  font-size: 12px;
}

.kc-num-label {
  color: var(--text3);
  min-width: 120px;
  flex-shrink: 0;
}

.kc-num-value { color: var(--text); font-family: var(--font-mono); }

.kc-pitfalls .kc-section-label { color: var(--danger); }
.kc-pearls   .kc-section-label { color: var(--success); }

.kc-pitfalls li::before { content: '⚠'; color: var(--danger); font-size: 10px; }
.kc-pearls   li::before { content: '★'; color: var(--success); font-size: 10px; }

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 300px;
  color: var(--text3);
  text-align: center;
}

.empty-icon {
  font-size: 40px;
  opacity: 0.3;
}

/* ── 科研速递 ─────────────────────────────────────────── */
.research-header { margin-bottom: 20px; }

.section-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-year {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--accent-bg);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 500;
}

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

.seg-pills { display: flex; gap: 6px; flex-wrap: wrap; }

.seg-pill {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  color: var(--text2);
}

.seg-pill:hover { border-color: var(--border2); color: var(--text); }
.seg-pill.active {
  border-color: currentColor;
  background: var(--accent-bg);
  color: var(--accent);
}

.feed-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}

.feed-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
  animation: fadeUp 0.25s ease;
}

.feed-card:hover { box-shadow: var(--shadow-md); }

.feed-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.level-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.feed-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.feed-key {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 10px;
}

.feed-source {
  font-size: 11px;
  color: var(--text3);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  word-break: break-all;
}

.feed-source:hover { color: var(--accent); text-decoration: underline; }

/* ── 闪卡 ──────────────────────────────────────────────── */
.flashcard-stage {
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 0;
}

.fc-empty {
  text-align: center;
  color: var(--text3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-height: 300px;
  justify-content: center;
}

.fc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  min-height: 320px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fc-card:hover { transform: translateY(-2px); box-shadow: 0 20px 48px rgba(0,0,0,0.12); }

.fc-card-front {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}

.fc-seg-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.fc-question {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.fc-hint {
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
}

.fc-answer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  display: none;
  animation: fadeUp 0.3s;
}

.fc-card.flipped .fc-answer { display: block; }
.fc-card.flipped .fc-hint  { display: none; }

.fc-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 0;
  flex-wrap: wrap;
}

.fc-counter {
  font-size: 13px;
  color: var(--text3);
  font-family: var(--font-mono);
}

.btn-rate {
  padding: 9px 20px;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: #fff;
}

.btn-again { background: var(--fc-again); }
.btn-again:hover { background: #dc2626; }
.btn-good  { background: var(--fc-good); }
.btn-good:hover  { background: #d97706; }
.btn-easy  { background: var(--fc-easy); }
.btn-easy:hover  { background: #059669; }

/* ── 自测 ─────────────────────────────────────────────── */
.quiz-start {
  max-width: 500px;
  margin: 0 auto;
  padding: 40px 0;
  text-align: center;
}

.quiz-desc {
  color: var(--text2);
  margin: 10px 0 24px;
  font-size: 14px;
}

.quiz-seg-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.quiz-seg-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  transition: all 0.12s;
}

.quiz-seg-check:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}

.quiz-area {
  max-width: 620px;
  margin: 0 auto;
}

.quiz-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 28px;
}

.quiz-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.quiz-q {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.4;
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; }

.quiz-opt {
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
  text-align: left;
  font-family: var(--font-body);
}

.quiz-opt:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.quiz-opt.correct   { border-color: var(--success); background: #D1FAE5; color: #065F46; }
.quiz-opt.wrong    { border-color: var(--danger);  background: #FEE2E2; color: #991B1B; }
.quiz-opt:disabled { cursor: default; }

.quiz-feedback {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.5;
}

.quiz-feedback.correct { background: #D1FAE5; color: #065F46; }
.quiz-feedback.wrong   { background: #FEF3C7; color: #92400E; }

.quiz-result {
  max-width: 500px;
  margin: 40px auto;
  text-align: center;
}

.result-score {
  font-family: var(--font-serif);
  font-size: 64px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.result-score span { font-size: 28px; color: var(--text2); }

.result-detail {
  margin: 20px 0;
  font-size: 14px;
  color: var(--text2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── 进度 ─────────────────────────────────────────────── */
.progress-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.prog-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  text-align: center;
}

.prog-stat-value {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
}

.prog-stat-label {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ETDRS 9 区格子 */
.etdrs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 300px;
  margin-bottom: 28px;
}

.etdrs-cell {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  opacity: 0.25;
}

.etdrs-cell:hover { transform: scale(1.08); }
.etdrs-cell.covered { opacity: 1; }

.etdrs-cell span { color: rgba(255,255,255,0.7); font-size: 9px; font-weight: 400; }

.log-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
}

.log-date {
  font-family: var(--font-mono);
  color: var(--text3);
  font-size: 11px;
  min-width: 70px;
}

.log-text { color: var(--text2); }

/* ── 按钮 ─────────────────────────────────────────────── */
.btn-primary {
  padding: 11px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover { background: var(--accent-h); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  padding: 9px 18px;
  background: transparent;
  color: var(--text2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
}

.btn-ghost:hover { border-color: var(--border2); color: var(--text); }

/* ── 底部 ─────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  text-align: center;
  margin-top: auto;
}

.disclaimer {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 4px;
}

.copyright {
  font-size: 11px;
  color: var(--text3);
}

/* ── 响应式 ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner { padding: 0 16px; gap: 12px; }
  .logo-text { display: none; }
  .nav-btn { padding: 6px 10px; font-size: 13px; }

  #view-learn { grid-template-columns: 1fr; }
  .seg-panel { position: static; }
  .seg-list { flex-direction: row; flex-wrap: wrap; }
  .seg-item { padding: 6px 10px; }

  .scan-bar-wrap { padding: 10px 16px; }
  .content-area { padding: 20px 16px; }

  .feed-list { grid-template-columns: 1fr; }
  .etdrs-grid { max-width: 240px; }

  .quiz-seg-select { justify-content: flex-start; }
}
