:root {
  color-scheme: dark;
  --bg: #202d3a;
  --panel: #202a34;
  --panel-soft: #2a3541;
  --line: rgba(255, 255, 255, 0.13);
  --text: #f7f5ed;
  --muted: #b9c2ca;
  --subtle: #8e9aa5;
  --sun: #f8c663;
  --earth: #4aa3df;
  --accent: #68c6a8;
  --warm: #e8955b;
  --danger: #e47474;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(160deg, rgba(232, 149, 91, 0.18), transparent 34%),
    linear-gradient(25deg, rgba(104, 198, 168, 0.15), transparent 46%),
    var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--left-width, 260px) minmax(0, 1fr) var(--right-width, 330px);
  gap: 0;
}

body.sidebar-left-collapsed .app-shell {
  --left-width: 76px;
}

body.sidebar-right-collapsed .app-shell {
  --right-width: 76px;
}

.lesson-rail,
.teaching-panel {
  min-width: 0;
  background: rgba(24, 29, 36, 0.92);
  border-color: var(--line);
  border-style: solid;
  backdrop-filter: blur(18px);
}

.lesson-rail {
  border-width: 0 1px 0 0;
  padding: 22px 18px;
}

.teaching-panel {
  border-width: 0 0 0 1px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin-bottom: 22px;
}

.panel-toggle {
  width: 100%;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  cursor: pointer;
}

.panel-toggle:hover,
.panel-toggle:focus-visible {
  color: var(--text);
  border-color: rgba(248, 198, 99, 0.58);
  outline: none;
}

.panel-toggle-right {
  margin-bottom: 0;
}

.collapse-icon {
  width: 15px;
  height: 15px;
  display: inline-block;
  position: relative;
  flex: 0 0 auto;
}

.collapse-icon::before,
.collapse-icon::after {
  content: "";
  position: absolute;
  top: 3px;
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.collapse-icon::before {
  left: 1px;
  transform: rotate(45deg);
}

.collapse-icon::after {
  right: 1px;
  transform: rotate(-135deg);
}

body.sidebar-left-collapsed .lesson-rail,
body.sidebar-right-collapsed .teaching-panel {
  padding-inline: 12px;
}

body.sidebar-left-collapsed .brand-block {
  justify-content: center;
}

body.sidebar-left-collapsed .brand-block div,
body.sidebar-left-collapsed .step-button span:last-child,
body.sidebar-left-collapsed .lesson-rail .toggle-label,
body.sidebar-right-collapsed .teaching-panel section,
body.sidebar-right-collapsed .teaching-panel .toggle-label {
  display: none;
}

body.sidebar-left-collapsed .step-button {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 10px 0;
}

body.sidebar-left-collapsed .step-index {
  width: 38px;
  height: 38px;
}

body.sidebar-right-collapsed .teaching-panel {
  align-items: center;
}

body.sidebar-left-collapsed .lesson-rail .collapse-icon::before,
body.sidebar-right-collapsed .teaching-panel .collapse-icon::before {
  transform: rotate(-135deg);
}

body.sidebar-left-collapsed .lesson-rail .collapse-icon::after,
body.sidebar-right-collapsed .teaching-panel .collapse-icon::after {
  transform: rotate(45deg);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #fff6bd 0 13%, transparent 14%),
    conic-gradient(from 20deg, #f9c85d, #e98148, #f9c85d);
  box-shadow: 0 0 28px rgba(248, 198, 99, 0.44);
}

.brand-block strong {
  display: block;
  font-size: 1rem;
  letter-spacing: 0;
}

.brand-block small,
.eyebrow,
.panel-kicker {
  color: var(--subtle);
  font-size: 0.82rem;
  letter-spacing: 0;
}

.step-list {
  display: grid;
  gap: 10px;
}

.step-button {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  border-radius: 8px;
  padding: 12px 10px;
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.step-button:hover,
.step-button:focus-visible {
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(248, 198, 99, 0.42);
  color: var(--text);
  outline: none;
}

.step-button.active {
  background: rgba(248, 198, 99, 0.13);
  border-color: rgba(248, 198, 99, 0.72);
  color: var(--text);
}

.step-index {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--sun);
  font-weight: 700;
}

.step-button span:last-child {
  min-width: 0;
}

.step-button strong,
.step-button small {
  display: block;
}

.step-button strong {
  margin-bottom: 3px;
  font-size: 0.96rem;
}

.step-button small {
  color: var(--subtle);
  line-height: 1.35;
}

.stage-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), transparent 28%),
    #1d2936;
}

.stage-toolbar {
  min-width: 0;
  min-height: 92px;
  padding: 20px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.top-panel-toggle {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.top-panel-toggle:hover,
.top-panel-toggle:focus-visible {
  color: var(--text);
  border-color: rgba(248, 198, 99, 0.58);
  outline: none;
}

.stage-heading {
  min-width: 220px;
  flex: 1 1 auto;
}

body.toolbar-collapsed .stage-toolbar {
  min-height: 52px;
  padding: 8px 14px;
  justify-content: flex-start;
}

body.toolbar-collapsed .stage-heading,
body.toolbar-collapsed .tool-buttons,
body.toolbar-collapsed .stage-toolbar .toggle-label {
  display: none;
}

body.toolbar-collapsed .stage-toolbar .collapse-icon::before {
  transform: rotate(-135deg);
}

body.toolbar-collapsed .stage-toolbar .collapse-icon::after {
  transform: rotate(45deg);
}

.stage-toolbar h1 {
  margin: 4px 0 0;
  font-size: clamp(1.6rem, 2.6vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow,
.panel-kicker {
  margin: 0;
}

.tool-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
}

.tool-button:hover,
.tool-button:focus-visible,
.tool-button[aria-pressed="true"] {
  color: var(--text);
  border-color: rgba(104, 198, 168, 0.66);
  background: rgba(104, 198, 168, 0.13);
  outline: none;
}

.button-icon {
  width: 17px;
  height: 17px;
  display: inline-block;
  position: relative;
  flex: 0 0 auto;
}

.scale-icon::before,
.scale-icon::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: currentColor;
}

.scale-icon::before {
  width: 14px;
  height: 14px;
  left: 0;
  top: 2px;
  opacity: 0.65;
}

.scale-icon::after {
  width: 7px;
  height: 7px;
  right: 0;
  bottom: 0;
}

.motion-icon {
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
}

.data-icon {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 2px;
}

.data-icon::before,
.data-icon::after,
.audio-icon::before,
.audio-icon::after,
.reset-icon::before,
.reset-icon::after,
.fullscreen-icon::before,
.fullscreen-icon::after {
  content: "";
}

.data-icon::before,
.data-icon::after,
.data-icon {
  background:
    linear-gradient(currentColor, currentColor) left bottom / 4px 8px no-repeat,
    linear-gradient(currentColor, currentColor) center bottom / 4px 13px no-repeat,
    linear-gradient(currentColor, currentColor) right bottom / 4px 5px no-repeat;
}

.audio-icon::before {
  position: absolute;
  left: 1px;
  top: 4px;
  width: 7px;
  height: 9px;
  background: currentColor;
  clip-path: polygon(0 28%, 42% 28%, 100% 0, 100% 100%, 42% 72%, 0 72%);
}

.audio-icon::after {
  position: absolute;
  right: 1px;
  top: 3px;
  width: 8px;
  height: 10px;
  border: 2px solid currentColor;
  border-left: 0;
  border-top-color: transparent;
  border-bottom-color: transparent;
  border-radius: 0 999px 999px 0;
}

.reset-icon {
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

.reset-icon::after {
  position: absolute;
  width: 6px;
  height: 6px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  right: -1px;
  top: 1px;
  transform: rotate(35deg);
}

.fullscreen-icon::before,
.fullscreen-icon::after {
  position: absolute;
  width: 7px;
  height: 7px;
}

.fullscreen-icon::before {
  left: 0;
  top: 0;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  box-shadow: 8px 8px 0 -5px transparent;
}

.fullscreen-icon::after {
  right: 0;
  bottom: 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.app-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  background: var(--bg);
}

.canvas-wrap {
  min-width: 0;
  min-height: 480px;
  position: relative;
  overflow: hidden;
}

.scene-host {
  position: absolute;
  inset: 0;
}

.scene-host canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.scene-caption,
.scale-note {
  position: absolute;
  left: 22px;
  max-width: min(520px, calc(100% - 44px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(14, 17, 24, 0.74);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  backdrop-filter: blur(14px);
}

.scene-caption {
  bottom: 20px;
}

.scale-note {
  top: 18px;
}

.talk-track h2,
.fact-section h3,
.planet-section h3,
.phase-section h3 {
  margin: 0 0 10px;
  letter-spacing: 0;
}

.talk-track h2 {
  font-size: 1.55rem;
  line-height: 1.15;
}

.narration {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.75;
}

.fact-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fact-list li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--muted);
  line-height: 1.55;
}

.fact-list li::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.focus-bodies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.body-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
}

.body-chip::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--chip-color, var(--sun));
  box-shadow: 0 0 14px color-mix(in srgb, var(--chip-color, var(--sun)), transparent 30%);
}

.phase-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.phase-section p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.phase-strip {
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 12px;
  align-items: center;
}

.phase {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #d5d9df;
  box-shadow: inset -14px 0 0 #222831;
}

.new-moon {
  background: #222831;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.first-quarter {
  background: linear-gradient(90deg, #222831 0 50%, #d5d9df 51%);
}

.full-moon {
  background: #d5d9df;
  box-shadow: inset -3px 2px 0 rgba(0, 0, 0, 0.12);
}

.last-quarter {
  background: linear-gradient(90deg, #d5d9df 0 50%, #222831 51%);
}

body.show-values .metric {
  display: inline;
}

.metric {
  display: none;
  color: #d9e8ef;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: var(--left-width, 220px) minmax(0, 1fr);
  }

  .teaching-panel {
    grid-column: 1 / -1;
    border-width: 1px 0 0;
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr;
    gap: 18px;
  }

  .phase-section {
    border-top: 0;
    padding-top: 0;
  }

  body.sidebar-right-collapsed .teaching-panel {
    min-height: 64px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  body.sidebar-left-collapsed .app-shell,
  body.sidebar-right-collapsed .app-shell {
    --left-width: auto;
    --right-width: auto;
  }

  .lesson-rail {
    border-width: 0 0 1px;
    padding: 16px;
  }

  .brand-block {
    margin-bottom: 12px;
  }

  .step-list {
    grid-template-columns: repeat(6, minmax(150px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .stage-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .tool-buttons {
    justify-content: flex-start;
  }

  .tool-button {
    flex: 1 1 150px;
    justify-content: center;
  }

  .canvas-wrap {
    min-height: 62vh;
  }

  .teaching-panel {
    grid-template-columns: 1fr;
    padding: 18px 16px 24px;
  }
}
