/* =====================================================================
 *  styles.css — 虚拟实验室界面
 * ===================================================================== */
:root {
  --bg: #070b12;
  --bg2: #0b1220;
  --panel: rgba(14, 22, 36, 0.72);
  --panel-solid: #0e1624;
  --border: rgba(120, 170, 220, 0.18);
  --border-strong: rgba(120, 190, 255, 0.4);
  --txt: #e8f1fb;
  --txt-dim: #9fb2c8;
  --accent: #4fc3f7;
  --accent2: #38e0b0;
  --gold: #ffcc44;
  --animal: #ff8a80;
  --plant: #7ee787;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--txt);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex-direction: column; height: 100%; }

/* ---------------- 顶栏 ---------------- */
#topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(9, 14, 24, 0.96), rgba(9, 14, 24, 0.72));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.brand .logo { font-size: 22px; filter: drop-shadow(0 0 8px rgba(79, 195, 247, 0.6)); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt strong { font-size: 15px; letter-spacing: 0.5px; }
.brand-txt small { color: var(--txt-dim); font-size: 11px; }

.seg { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: rgba(8, 14, 24, 0.7); }
.seg-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border: 0; border-radius: 9px;
  background: transparent; color: var(--txt-dim);
  font-size: 13px; font-family: inherit; cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.18s;
}
.seg-btn:hover { color: var(--txt); background: rgba(90, 150, 220, 0.12); }
.seg-btn.active { background: linear-gradient(180deg, rgba(79, 195, 247, 0.24), rgba(79, 195, 247, 0.1)); color: #fff; box-shadow: inset 0 0 0 1px rgba(79, 195, 247, 0.45); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-animal { background: var(--animal); box-shadow: 0 0 8px var(--animal); }
.dot-plant { background: var(--plant); box-shadow: 0 0 8px var(--plant); }
.dot-both { background: linear-gradient(90deg, var(--animal), var(--plant)); box-shadow: 0 0 8px rgba(160, 220, 255, 0.7); }

.top-actions { margin-left: auto; display: flex; gap: 8px; }
.btn {
  font-family: inherit; font-size: 13px; cursor: pointer;
  padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: rgba(20, 32, 50, 0.8); color: var(--txt);
  transition: all 0.16s;
}
.btn:hover { border-color: var(--border-strong); background: rgba(30, 48, 74, 0.9); transform: translateY(-1px); }
.btn.ghost.active { background: rgba(79, 195, 247, 0.2); border-color: var(--border-strong); color: #fff; }
.btn.primary { background: linear-gradient(180deg, #1f7fb8, #17607f); border-color: rgba(120, 200, 255, 0.4); color: #fff; font-weight: 600; }
.btn.primary:hover { background: linear-gradient(180deg, #2a93d0, #1a6f92); }
.btn.primary.active { background: linear-gradient(180deg, #b8562f, #8c3d1f); }
.btn.tiny { padding: 4px 8px; font-size: 12px; }
.btn.wide { width: 100%; margin-top: 14px; }

/* ---------------- 舞台 ---------------- */
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#gl:active { cursor: grabbing; }
#gl.panning { cursor: move; }

#labelLayer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.lab {
  position: absolute; top: 0; left: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 6px; margin: 0;
  transform-origin: 0 0;
  background: rgba(8, 16, 28, 0.78);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11.5px; white-space: nowrap; color: #dbe9f8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  transition: opacity 0.2s, border-color 0.2s;
  will-change: transform;
}
.lab i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.lab.sel { border-color: var(--gold); color: #fff; background: rgba(40, 30, 6, 0.9); }
.lab.sel i { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.lab[data-tag="mitochondria"] i, .lab[data-tag="chloroplast"] i { background: var(--accent2); box-shadow: 0 0 6px var(--accent2); }

/* ---------------- 面板 ---------------- */
.panel {
  position: absolute; z-index: 10;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.panel-left { left: 14px; top: 14px; bottom: 76px; width: 250px; }
.panel-right { right: 14px; top: 14px; width: 330px; max-height: calc(100% - 90px); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 14px 8px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 14px; letter-spacing: 0.5px; }
.panel-head .hint { font-size: 10.5px; color: var(--txt-dim); }

.legend { flex: 1; overflow-y: auto; padding: 8px; }
.legend-group { font-size: 10.5px; color: var(--txt-dim); letter-spacing: 1.5px; margin: 8px 6px 4px; }
.legend-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; margin-bottom: 2px;
  border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--txt);
  font-family: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.legend-row:hover, .legend-row.hover { background: rgba(79, 195, 247, 0.12); border-color: rgba(79, 195, 247, 0.28); }
.legend-row.active { background: rgba(255, 204, 68, 0.16); border-color: rgba(255, 204, 68, 0.5); }
.legend-row .sw { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; box-shadow: 0 0 6px rgba(255, 255, 255, 0.15); }
.legend-row .nm { flex: 1; }
.legend-row .b { font-style: normal; font-size: 9.5px; padding: 1px 5px; border-radius: 5px; }
.legend-row .b.a { background: rgba(255, 138, 128, 0.2); color: #ffb4ac; }
.legend-row .b.p { background: rgba(126, 231, 135, 0.18); color: #a7f0ad; }
.legend-row .b.both { background: rgba(120, 190, 255, 0.16); color: #a8d8ff; }

.panel-foot { padding: 10px 12px 12px; border-top: 1px solid var(--border); }
.mini-title { font-size: 10.5px; color: var(--txt-dim); letter-spacing: 1.2px; margin: 4px 0 8px; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 4px 0; cursor: pointer; color: var(--txt); }
.switch input { appearance: none; width: 32px; height: 17px; border-radius: 10px; background: rgba(120, 150, 190, 0.25); position: relative; cursor: pointer; transition: background 0.18s; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #cfe3f7; transition: transform 0.18s; }
.switch input:checked { background: rgba(79, 195, 247, 0.6); }
.switch input:checked::after { transform: translateX(15px); }
input[type="range"] { width: 100%; height: 4px; margin: 6px 0 10px; appearance: none; border-radius: 3px; background: rgba(120, 150, 190, 0.28); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(79, 195, 247, 0.8); cursor: pointer; }
input[type="range"]:disabled { opacity: 0.35; }

/* ---------------- 信息卡 ---------------- */
.info-empty { padding: 26px 18px 20px; text-align: center; color: var(--txt-dim); }
.info-empty .big-ico { font-size: 40px; margin-bottom: 10px; filter: drop-shadow(0 0 12px rgba(79, 195, 247, 0.4)); }
.info-empty p { font-size: 12.5px; line-height: 1.75; margin: 0 0 16px; }
.info-body { padding: 14px 16px 16px; overflow-y: auto; }
.info-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.info-head .swatch { width: 14px; height: 34px; border-radius: 6px; flex: 0 0 auto; box-shadow: 0 0 12px rgba(255, 255, 255, 0.2); }
.info-head h2 { margin: 0; font-size: 17px; }
.info-head small { color: var(--txt-dim); font-size: 11.5px; }
.info-head .btn { margin-left: auto; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.info-desc { font-size: 13px; line-height: 1.82; color: #d7e6f5; margin: 0 0 12px; }
.info-block { border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 8px; }
.info-block ul { margin: 0; padding-left: 18px; }
.info-block li { font-size: 12.5px; line-height: 1.8; color: #cfe0f0; margin-bottom: 4px; }
.presence { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pres-txt { font-size: 12.5px; color: var(--txt-dim); }
.pres-chips { display: flex; gap: 6px; }
.chip { font-style: normal; font-size: 10.5px; padding: 2px 8px; border-radius: 6px; }
.chip.a { background: rgba(255, 138, 128, 0.18); color: #ffb4ac; border: 1px solid rgba(255, 138, 128, 0.3); }
.chip.p { background: rgba(126, 231, 135, 0.16); color: #a7f0ad; border: 1px solid rgba(126, 231, 135, 0.3); }

/* ---------------- 底部 ---------------- */
.dock {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 12; display: flex; align-items: center; gap: 14px;
  padding: 8px 12px 8px 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 40px;
  backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.dock-hint { font-size: 11.5px; color: var(--txt-dim); white-space: nowrap; }

/* ---------------- 测验 ---------------- */
.quiz {
  position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%);
  z-index: 20; width: min(620px, calc(100% - 40px));
  padding: 14px 16px 16px;
  background: rgba(16, 14, 34, 0.86); border: 1px solid rgba(160, 140, 255, 0.35);
  border-radius: 16px; backdrop-filter: blur(16px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: rise 0.28s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.quiz-head { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--txt-dim); }
.quiz-head strong { font-size: 13.5px; color: #d9c9ff; }
.quiz-head #quizProgress { margin-left: auto; }
.quiz-head #quizScore { color: var(--accent2); }
.quiz-q { font-size: 14px; margin: 10px 0 12px; color: #ece4ff; }
.quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quiz-opt {
  font-family: inherit; font-size: 13px; cursor: pointer;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(150, 140, 220, 0.3); background: rgba(30, 26, 58, 0.7); color: var(--txt);
  transition: all 0.15s; text-align: left;
}
.quiz-opt:hover { border-color: rgba(190, 170, 255, 0.6); background: rgba(44, 38, 80, 0.85); transform: translateY(-1px); }
.quiz-opt.ok { background: rgba(46, 160, 90, 0.32); border-color: #46d07e; color: #ddffe9; }
.quiz-opt.no { background: rgba(170, 50, 60, 0.28); border-color: #e06470; color: #ffe1e1; }

/* ---------------- 帮助 / 加载 ---------------- */
.overlay {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 8, 14, 0.72); backdrop-filter: blur(4px);
}
.modal {
  width: min(520px, calc(100% - 40px));
  padding: 22px 24px 20px;
  background: var(--panel-solid); border: 1px solid var(--border-strong);
  border-radius: 18px; box-shadow: var(--shadow);
}
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.help-list { margin: 0; padding-left: 20px; }
.help-list li { font-size: 13px; line-height: 1.95; color: #cfe0f0; }

.loading {
  position: absolute; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(circle at 50% 45%, #101c30, #070b12 70%);
  font-size: 13px; color: var(--txt-dim);
  transition: opacity 0.5s;
}
.loading.done { opacity: 0; pointer-events: none; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(79, 195, 247, 0.18); border-top-color: var(--accent); animation: sp 0.9s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120, 160, 210, 0.25); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120, 180, 240, 0.45); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .panel-left { width: 208px; }
  .panel-right { width: 290px; }
  .brand { min-width: 0; }
  .brand-txt small { display: none; }
}
@media (max-width: 820px) {
  #topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .panel-left { top: auto; bottom: 128px; left: 8px; right: 8px; width: auto; max-height: 30%; bottom: 130px; }
  .panel-right { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 46%; }
  .dock { bottom: 8px; left: 8px; right: 8px; transform: none; justify-content: space-between; flex-wrap: wrap; }
  .dock-hint { display: none; }
  .quiz { bottom: 8px; }
  .quiz-opts { grid-template-columns: 1fr; }
}
