/* ============ 高中实验宝典 样式 ============ */
:root {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --text: #1c2333;
  --text-2: #5b6478;
  --border: rgba(28, 35, 51, 0.08);
  --card: rgba(255, 255, 255, 0.82);
  --shadow: 0 10px 34px rgba(35, 48, 86, 0.10);
  --shadow-hover: 0 18px 48px rgba(35, 48, 86, 0.18);
  --chem: #10b981;
  --chem-soft: rgba(16, 185, 129, 0.12);
  --phys: #3b82f6;
  --phys-soft: rgba(59, 130, 246, 0.12);
  --accent: #6366f1;
  --radius: 18px;
}
html[data-theme="dark"] {
  --bg: #0d1220;
  --bg-soft: #151c2e;
  --text: #e7ecf7;
  --text-2: #93a0b8;
  --border: rgba(255, 255, 255, 0.09);
  --card: rgba(24, 32, 52, 0.82);
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 18px 48px rgba(0, 0, 0, 0.5);
  --chem-soft: rgba(16, 185, 129, 0.16);
  --phys-soft: rgba(59, 130, 246, 0.16);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.4s, color 0.4s;
  overflow-x: hidden;
}

.container { width: min(1180px, 92%); margin: 0 auto; }

/* 背景光斑 */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; animation: float 14s ease-in-out infinite; }
.orb-1 { width: 420px; height: 420px; background: radial-gradient(circle, #22d3ee, transparent 65%); top: -120px; left: -80px; }
.orb-2 { width: 480px; height: 480px; background: radial-gradient(circle, #a78bfa, transparent 65%); top: 30%; right: -140px; animation-delay: -5s; }
.orb-3 { width: 380px; height: 380px; background: radial-gradient(circle, #34d399, transparent 65%); bottom: -140px; left: 30%; animation-delay: -9s; }
@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-40px) scale(1.08); }
}

/* 头部 */
.site-header { position: sticky; top: 0; z-index: 40; backdrop-filter: blur(18px); background: rgba(244, 246, 251, 0.72); border-bottom: 1px solid var(--border); }
html[data-theme="dark"] .site-header { background: rgba(13, 18, 32, 0.72); }
.header-inner { display: flex; align-items: center; gap: 26px; padding: 14px 0; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-badge { font-size: 30px; filter: drop-shadow(0 4px 8px rgba(99, 102, 241, 0.35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 18px; letter-spacing: 0.5px; }
.brand-text small { font-size: 12px; color: var(--text-2); }
.header-nav { display: flex; gap: 6px; margin-left: auto; }
.nav-link {
  border: none; background: transparent; color: var(--text-2);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 14px;
  transition: all 0.25s; font-weight: 600;
}
.nav-link:hover { color: var(--text); background: var(--border); }
.nav-link.active { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35); }
.icon-btn { border: 1px solid var(--border); background: var(--card); color: var(--text); width: 40px; height: 40px; border-radius: 12px; cursor: pointer; font-size: 17px; transition: transform 0.2s, background 0.2s; }
.icon-btn:hover { transform: translateY(-2px); background: var(--bg-soft); }

/* Hero */
.hero { padding: 64px 0 34px; text-align: center; }
.hero-title { font-size: clamp(30px, 5vw, 46px); font-weight: 800; letter-spacing: 0.5px; line-height: 1.3; }
.grad-chem { background: linear-gradient(90deg, #10b981, #22d3ee); -webkit-background-clip: text; background-clip: text; color: transparent; }
.grad-phys { background: linear-gradient(90deg, #3b82f6, #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { margin: 18px auto 0; max-width: 680px; color: var(--text-2); font-size: 15px; line-height: 1.8; }
.hero-sub b { color: var(--text); }
.hero-actions { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-top: 30px; }

.search-box { position: relative; width: min(560px, 100%); }
.search-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); font-size: 16px; }
.search-box input {
  width: 100%; padding: 15px 92px 15px 48px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--card); color: var(--text);
  font-size: 15px; outline: none; box-shadow: var(--shadow);
  transition: border 0.25s, box-shadow 0.25s;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), var(--shadow); }
.search-box kbd {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-2); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 6px; background: var(--bg-soft); font-family: inherit;
}
.quick-stats { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.stat-chip { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--border); padding: 9px 18px; border-radius: 999px; box-shadow: var(--shadow); }
.chip-num { font-size: 17px; font-weight: 800; }
.stat-chip:nth-child(1) .chip-num { color: var(--chem); }
.stat-chip:nth-child(2) .chip-num { color: var(--phys); }
.stat-chip:nth-child(3) .chip-num { color: var(--accent); }
.chip-label { font-size: 13px; color: var(--text-2); }

/* 筛选栏 */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 18px 0 8px; }
.filter-btn {
  border: 1.5px solid var(--border); background: var(--card); color: var(--text-2);
  padding: 9px 18px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600;
  transition: all 0.25s;
}
.filter-btn:hover { transform: translateY(-2px); color: var(--text); border-color: var(--accent); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35); }
.filter-arrow { color: var(--text-2); font-size: 14px; opacity: 0.6; margin: 0 4px; }
.sort-group { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* 卡片网格 */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 24px 0 40px; }
.card {
  position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 20px; cursor: pointer; overflow: hidden; box-shadow: var(--shadow);
  transition: transform 0.3s, box-shadow 0.3s; animation: rise 0.5s ease both;
}
.card:nth-child(n) { animation-delay: calc(var(--i, 0) * 30ms); }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--chem), #22d3ee);
}
.card.phys::before { background: linear-gradient(90deg, var(--phys), #a78bfa); }
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-hover); }
.card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-emoji { font-size: 34px; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.18)); }
.card-badge { font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px; }
.badge-chem { color: #047857; background: var(--chem-soft); }
.badge-phys { color: #1d4ed8; background: var(--phys-soft); }
html[data-theme="dark"] .badge-chem { color: #6ee7b7; }
html[data-theme="dark"] .badge-phys { color: #93c5fd; }
.card h3 { font-size: 16.5px; line-height: 1.45; margin-bottom: 8px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.card-tags span { font-size: 11.5px; color: var(--text-2); background: var(--bg-soft); border: 1px solid var(--border); padding: 3px 9px; border-radius: 999px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-2); }
.card-illus {
  width: 100%; aspect-ratio: 560 / 380; object-fit: cover; display: block;
  border-radius: 12px; margin: -4px 0 14px; border: 1px solid var(--border);
  background: #fafafa;
}
html[data-theme="dark"] .card-illus { filter: brightness(0.92) saturate(0.9); }
.drawer-illus {
  width: 100%; aspect-ratio: 560 / 380; object-fit: cover; display: block;
  border-radius: 16px; margin-bottom: 22px; border: 1px solid var(--border);
  background: #fafafa; box-shadow: var(--shadow);
}
html[data-theme="dark"] .drawer-illus { filter: brightness(0.92) saturate(0.9); }
.card-photos { display: flex; align-items: center; gap: 5px; }
.card-photo-count { background: var(--accent); color: #fff; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }

.empty-state { text-align: center; padding: 80px 0; color: var(--text-2); }
.empty-emoji { font-size: 54px; display: block; margin-bottom: 14px; opacity: 0.7; }
.hidden { display: none !important; }

/* 详情抽屉 */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 14, 26, 0.55);
  backdrop-filter: blur(6px); display: flex; justify-content: flex-end;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  width: min(680px, 96vw); height: 100%; background: var(--bg-soft);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.25); overflow-y: auto; padding: 30px 34px 60px;
  animation: slideIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}
@keyframes slideIn { from { transform: translateX(30%); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-close { position: absolute; top: 20px; right: 22px; z-index: 5; }
.drawer-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.drawer-emoji { font-size: 52px; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.2)); }
.drawer h2 { font-size: 24px; line-height: 1.35; }
.sec { margin-top: 26px; }
.sec-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; margin-bottom: 10px; }
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.sec-body { font-size: 14.5px; line-height: 1.9; color: var(--text); }
.sec-body p { margin-bottom: 6px; }
ul.step-list { list-style: none; counter-reset: step; }
ul.step-list li {
  counter-increment: step; position: relative; padding: 9px 0 9px 44px; font-size: 14.5px; line-height: 1.7;
}
ul.step-list li::before {
  content: counter(step); position: absolute; left: 0; top: 10px; width: 28px; height: 28px;
  border-radius: 9px; background: linear-gradient(135deg, var(--accent), #818cf8); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
ul.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
ul.tag-list li { list-style: none; background: var(--bg); border: 1px solid var(--border); padding: 6px 14px; border-radius: 999px; font-size: 13px; }
ul.note-list { list-style: none; }
ul.note-list li { position: relative; padding: 6px 0 6px 24px; font-size: 14px; line-height: 1.7; color: var(--text-2); }
ul.note-list li::before { content: '⚠'; position: absolute; left: 0; }
.alert-box { margin-top: 10px; padding: 12px 16px; border-radius: 12px; background: var(--chem-soft); border: 1px dashed var(--chem); font-size: 13.5px; color: var(--text); line-height: 1.7; }

/* 照片区 */
.photo-zone { margin-top: 30px; }
.photo-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.btn {
  border: none; padding: 11px 20px; border-radius: 12px; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s; font-family: inherit;
}
.btn:hover { transform: translateY(-2px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #818cf8); color: #fff; box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35); }
.btn-ghost { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.photo-item { position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 1; box-shadow: var(--shadow); animation: rise 0.35s ease both; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; transition: transform 0.35s; }
.photo-item:hover img { transform: scale(1.08); }
.photo-del {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 9px;
  border: none; background: rgba(15, 23, 42, 0.65); color: #fff; cursor: pointer;
  font-size: 13px; opacity: 0; transition: opacity 0.2s, transform 0.2s;
}
.photo-item:hover .photo-del { opacity: 1; }
.photo-del:hover { transform: scale(1.12); background: rgba(220, 38, 38, 0.85); }
.photo-empty { border: 2px dashed var(--border); border-radius: 14px; padding: 40px 20px; text-align: center; color: var(--text-2); font-size: 14px; line-height: 2; }

/* 灯箱 */
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(6, 9, 18, 0.92); display: flex; align-items: center; justify-content: center; animation: fadeIn 0.25s; padding: 40px; }
.lightbox img { max-width: 90vw; max-height: 86vh; border-radius: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.lightbox-close { position: absolute; top: 24px; right: 26px; background: rgba(255, 255, 255, 0.12); border: none; color: #fff; }

/* 上传对话框 */
.upload-overlay { position: fixed; inset: 0; z-index: 70; background: rgba(10, 14, 26, 0.6); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; animation: fadeIn 0.25s; padding: 20px; }
.upload-card { background: var(--bg-soft); border-radius: 22px; padding: 30px; width: min(560px, 100%); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4); animation: pop 0.3s cubic-bezier(0.22, 1, 0.36, 1); max-height: 88vh; overflow-y: auto; }
@keyframes pop { from { transform: scale(0.92) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.upload-card h3 { font-size: 19px; margin-bottom: 6px; }
.upload-sub { color: var(--text-2); font-size: 13px; margin-bottom: 18px; }
.drop-zone {
  border: 2px dashed var(--accent); border-radius: 16px; padding: 34px 20px; text-align: center;
  cursor: pointer; transition: background 0.25s, transform 0.25s; background: var(--bg);
}
.drop-zone:hover, .drop-zone.dragover { background: var(--accent); transform: scale(1.01); }
.drop-zone p { font-weight: 700; margin: 10px 0 4px; color: var(--text); }
.drop-zone small { color: var(--text-2); }
.dz-icon { font-size: 34px; }
.upload-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 16px; }
.upload-preview figure { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1; }
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 13px 26px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 100; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  animation: toastIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
@keyframes toastIn { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* 页脚 */
.site-footer { border-top: 1px solid var(--border); padding: 30px 0 40px; text-align: center; color: var(--text-2); font-size: 13.5px; }
.footer-sub { margin-top: 6px; font-size: 12px; opacity: 0.75; }

/* 搜索高亮 */
mark { background: linear-gradient(120deg, rgba(99,102,241,0.25) 0%, rgba(99,102,241,0.25) 100%); color: inherit; border-radius: 3px; padding: 0 2px; }

/* 加载遮罩 */
.lab-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg-soft); z-index: 20; border-radius: var(--radius); }
.lab-loading-spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* PWA 安装提示 */
.pwa-banner { position: fixed; bottom: 0; left: 0; right: 0; z-index: 90; background: var(--card); border-top: 1px solid var(--border); padding: 14px 20px; display: flex; align-items: center; gap: 14px; justify-content: center; box-shadow: 0 -4px 20px rgba(0,0,0,0.08); animation: slideUp 0.35s ease; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.pwa-banner button { padding: 8px 18px; border-radius: 10px; border: none; font-weight: 700; cursor: pointer; font-family: inherit; }
.pwa-banner .btn-install { background: var(--accent); color: #fff; }
.pwa-banner .btn-dismiss { background: transparent; color: var(--text-2); border: 1px solid var(--border); }

/* 骨架屏 */
.skeleton { background: linear-gradient(90deg, var(--bg) 25%, var(--bg-soft) 50%, var(--bg) 75%); background-size: 200% 100%; animation: skeleton 1.2s ease-in-out infinite; border-radius: 8px; }
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 导出工具栏 */
.export-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.export-bar button { font-size: 13px; padding: 8px 14px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--card); color: var(--text-2); cursor: pointer; font-weight: 600; font-family: inherit; transition: all 0.2s; }
.export-bar button:hover { border-color: var(--accent); color: var(--text); }

/* 键盘导航焦点 */
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.nav-link:focus-visible, .filter-btn:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* 3D实验室加载 */
#lab3d .lab-loading { background: var(--bg); }

/* 打印样式 */
@media print {
  .site-header, .filter-bar, .hero-actions, .bg-orbs, .icon-btn, .card-foot, .photo-toolbar, .photo-del, .upload-overlay, .overlay { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; color: #000; }
  .drawer { width: 100%; position: static; box-shadow: none; overflow: visible; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-2); }

@media (max-width: 760px) {
  .header-inner { flex-wrap: wrap; gap: 12px; }
  .header-nav { order: 3; width: 100%; justify-content: center; }
  .sort-group { margin-left: 0; width: 100%; justify-content: flex-start; }
  .hero { padding-top: 40px; }
  .drawer { padding: 26px 22px 60px; }
}