/* macOS Apple Design System - Hearing Anatomy Virtual Lab */
:root {
  --sf-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --bg-gradient: radial-gradient(circle at 20% 20%, #1e2638 0%, #0f1420 60%, #080a10 100%);
  --ink: #f5f5f7;
  --muted: #98989d;
  --system-blue: #007aff;
  --system-blue-dark: #0056b3;
  --system-cyan: #32ade6;
  --system-green: #34c759;
  --glass-bg: rgba(30, 34, 42, 0.72);
  --glass-border: rgba(255, 255, 255, 0.12);
  --mac-shadow: 0 20px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1);
  --panel-radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body, #app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: var(--sf-font);
  color: var(--ink);
  background: var(--bg-gradient);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

/* 屏幕分层容器 */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  background: var(--bg-gradient);
}

.screen.active { display: block; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* macOS 红黄绿 Traffic Lights 控制组件 */
.traffic-lights {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  display: inline-block;
  cursor: pointer;
}

.dot.close { background-color: #ff5f56; }
.dot.minimize { background-color: #ffbd2e; }
.dot.maximize { background-color: #27c93f; }

/* macOS Screen Top Header */
.mac-screen-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  z-index: 10;
  background: rgba(20, 24, 32, 0.75);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}

.mac-header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: -0.01em;
}

/* 按钮通用风格 (macOS Control Pill Buttons) */
.round-action {
  min-width: 64px;
  height: 38px;
  padding: 0 16px;
  border-radius: 980px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.round-action:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.round-action:active { transform: scale(0.96); }

.exit-action {
  position: absolute;
  z-index: 15;
  right: 24px;
  top: 52px;
}

/* 封面标题与画布 stage */
.cover-heading {
  position: absolute;
  z-index: 3;
  left: 7vw;
  top: 14vh;
  width: 38vw;
}

.cover-heading span, .panel-label, .nav-caption {
  font-size: 11px;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--system-cyan);
  text-transform: uppercase;
}

.cover-heading h1 {
  font-size: clamp(48px, 5.5vw, 92px);
  line-height: 1.02;
  margin: 14px 0 18px;
  letter-spacing: -0.04em;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 40%, #a5c7eb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cover-heading p {
  font-size: 18px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.cover-stage {
  position: absolute;
  left: 36vw;
  right: 6vw;
  top: 14vh;
  bottom: 8vh;
  background: rgba(20, 24, 32, 0.65);
  backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--mac-shadow);
  overflow: hidden;
}

.cover-stage:before {
  content: "";
  position: absolute;
  z-index: 2;
  left: 0;
  top: 0;
  width: 4px;
  height: 100%;
  background: var(--system-blue);
}

#cover-canvas { position: absolute; inset: 0; }

.cover-index {
  position: absolute;
  z-index: 2;
  right: 28px;
  top: 24px;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-align: right;
  font-weight: 600;
}

.primary-action {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  min-width: 200px;
  padding: 14px 32px;
  border: 0;
  border-radius: 980px;
  background: var(--system-blue);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 122, 255, 0.4);
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.primary-action:hover {
  transform: translateX(-50%) translateY(-2px);
  background: var(--system-blue-dark);
  box-shadow: 0 12px 30px rgba(0, 122, 255, 0.55);
}

/* 章节屏 Headers & Cards */
.angled-header {
  position: absolute;
  z-index: 6;
  left: 0;
  top: 0;
  width: 100%;
  height: 60px;
  background: rgba(20, 24, 32, 0.82);
  backdrop-filter: blur(25px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding-left: 24px;
  gap: 20px;
}

.angled-header h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.angled-header span {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--system-cyan);
  font-weight: 700;
}

.chapter-back {
  position: absolute;
  z-index: 8;
  right: 28px;
  top: 76px;
}

.chapter-grid {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 290px);
  gap: 40px;
  align-content: center;
  justify-content: center;
}

.chapter-card {
  position: relative;
  height: 420px;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(25px);
  padding: 24px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  box-shadow: var(--mac-shadow);
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s, background 0.25s;
}

.chapter-card.available:hover {
  transform: translateY(-8px);
  box-shadow: 0 24px 48px rgba(0, 122, 255, 0.25);
  border-color: rgba(50, 173, 230, 0.4);
  background: rgba(35, 42, 54, 0.85);
}

.chapter-card.locked { opacity: 0.45; cursor: not-allowed; }

.chapter-number {
  position: absolute;
  left: 22px;
  top: 20px;
  color: var(--system-cyan);
  font-size: 16px;
  font-weight: 800;
}

.chapter-visual {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 60px;
  height: 220px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.25);
}

.chapter-ear:after {
  content: "EAR / 3D";
  position: absolute;
  left: 20px;
  bottom: 20px;
  font-size: 26px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.08em;
}

.chapter-card strong {
  background: rgba(0, 122, 255, 0.18);
  border: 1px solid rgba(0, 122, 255, 0.3);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  font-size: 18px;
  color: #fff;
}

.chapter-card small {
  text-align: center;
  color: var(--muted);
  margin-top: 10px;
  font-size: 13px;
}

/* 3D 实验室界面 (Lab Screen) */
#lab-screen { background: var(--bg-gradient); }

.lab-title {
  width: auto;
  height: 52px;
  padding-left: 20px;
  gap: 14px;
}

.lab-title h1 { font-size: 18px; white-space: nowrap; }

.top-actions {
  position: absolute;
  z-index: 10;
  right: 24px;
  top: 8px;
  display: flex;
  gap: 12px;
}

/* 左侧 macOS 风格 Sidebar 导航 */
.module-nav {
  position: absolute;
  z-index: 9;
  left: 24px;
  top: 72px;
  width: 220px;
  padding: 14px;
  background: var(--glass-bg);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--mac-shadow);
}

.nav-caption { padding: 4px 6px 10px; font-size: 11px; }

.module-btn {
  width: 100%;
  min-height: 38px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  padding-left: 12px;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.module-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(2px);
}

.module-btn.active {
  background: var(--system-blue);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.35);
}

/* 左下 macOS Inspector 视窗 (Hierarchy Panel) */
.hierarchy-panel {
  position: absolute;
  z-index: 9;
  left: 24px;
  bottom: 24px;
  width: 440px;
  max-height: 220px;
  overflow: auto;
  padding: 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--mac-shadow);
  color: #fff;
}

#hierarchy-content { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.hierarchy-level { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.level-title { width: 100%; font-size: 13px; font-weight: 700; color: var(--system-cyan); }

.hierarchy-btn {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}

.hierarchy-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.hierarchy-btn.selected {
  background: var(--system-blue);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
}

.hierarchy-btn.hidden-item { opacity: 0.4; text-decoration: line-through; }

/* 右侧 macOS Inspector 详情视窗 (Info Panel) */
.info-panel {
  position: absolute;
  z-index: 9;
  right: 24px;
  top: 72px;
  width: 360px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  background: var(--glass-bg);
  backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border);
  border-radius: var(--panel-radius);
  padding: 20px;
  box-shadow: var(--mac-shadow);
}

.info-panel h2 { font-size: 24px; font-weight: 700; margin: 8px 0 4px; }
.breadcrumb { font-size: 12px; color: var(--system-cyan); padding-bottom: 10px; border-bottom: 1px solid var(--glass-border); }
.info-panel dl { margin: 12px 0 0; }
.info-panel dt { font-weight: 700; margin-top: 12px; color: var(--system-cyan); font-size: 13px; }
.info-panel dd { margin: 4px 0 0; color: var(--muted); line-height: 1.6; font-size: 13px; }

/* 底部 macOS Dock / Floating Pill Tools */
.viewport-tools {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 6px;
  background: rgba(20, 24, 32, 0.75);
  backdrop-filter: blur(25px);
  border: 1px solid var(--glass-border);
  border-radius: 980px;
  box-shadow: var(--mac-shadow);
}

.viewport-tools button {
  border: 0;
  border-radius: 980px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  padding: 8px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, transform 0.15s;
}

.viewport-tools button:hover {
  background: var(--system-blue);
  transform: translateY(-1px);
}

/* 声音传入 macOS Floating Dock HUD */
.journey-hud {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  width: min(600px, 50vw);
  padding: 18px 24px;
  background: rgba(20, 24, 32, 0.85);
  backdrop-filter: blur(30px);
  color: white;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--mac-shadow);
}

.journey-stage { display: flex; gap: 12px; align-items: baseline; }
.journey-stage span { font-size: 13px; color: var(--system-cyan); font-weight: 700; }
.journey-stage strong { font-size: 22px; font-weight: 700; }
.track { height: 6px; margin: 12px 0; background: rgba(255, 255, 255, 0.15); border-radius: 3px; overflow: hidden; }
.track span { display: block; height: 100%; width: 0; background: var(--system-blue); transition: width 0.15s; }
.journey-hud p { margin: 0; font-size: 12px; color: var(--muted); }

/* macOS Alert / Dialog Modal */
dialog {
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 24px;
  max-width: 460px;
  background: rgba(24, 28, 36, 0.92);
  backdrop-filter: blur(40px);
  color: #fff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px); }

dialog h2 { font-size: 18px; margin-top: 0; }
dialog p { font-size: 13px; color: var(--muted); line-height: 1.6; }

dialog button {
  border: 0;
  border-radius: 980px;
  background: var(--system-blue);
  color: #fff;
  padding: 8px 24px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  margin-top: 12px;
  float: right;
}

@media(max-width:1100px){
  .module-nav { left: 14px; width: 190px; }
  .hierarchy-panel { left: 14px; width: 360px; }
  .info-panel { right: 14px; width: 310px; }
  .chapter-grid { grid-template-columns: repeat(3, 230px); gap: 24px; }
}
