:root {
  --paper: #f7faf8;
  --mist: #e9f3f4;
  --panel: rgba(255, 255, 255, 0.84);
  --ink: #183747;
  --muted: #6f858d;
  --line: #cfe0e3;
  --blue: #267c9b;
  --blue-deep: #14536e;
  --cyan: #67bbcb;
  --coral: #e96c58;
  --mustard: #efbd4f;
  --shadow: 0 24px 70px rgba(31, 80, 95, 0.13);
  --radius: 22px;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 13% 8%, rgba(103, 187, 203, 0.22), transparent 25rem),
    radial-gradient(circle at 89% 92%, rgba(239, 189, 79, 0.15), transparent 28rem),
    linear-gradient(135deg, #f8fbf9 0%, #edf6f6 100%);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(38, 124, 155, 0.35);
  outline-offset: 3px;
}

.app-shell {
  width: min(1540px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px clamp(18px, 3vw, 48px) 30px;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  transform: rotate(-7deg);
}

.brand-mark span {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--blue-deep);
  background: rgba(255, 255, 255, 0.66);
}

.brand-mark span:nth-child(1) {
  left: 1px;
  top: 8px;
}

.brand-mark span:nth-child(2) {
  left: 14px;
  top: 1px;
  border-color: var(--coral);
}

.brand-mark span:nth-child(3) {
  left: 14px;
  top: 18px;
  width: 13px;
  height: 13px;
  border-color: var(--mustard);
}

.brand-text {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(19px, 1.6vw, 25px);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.scene-counter {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.scene-counter span:first-child {
  color: var(--blue-deep);
  font-size: 17px;
  font-weight: 700;
}

.scene-counter i {
  width: 42px;
  height: 1px;
  background: var(--line);
}

.workspace {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: clamp(18px, 2.5vw, 36px);
  min-height: calc(100vh - 110px);
  align-items: stretch;
}

.scene-nav {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 18px 0;
}

.scene-tab {
  min-height: 56px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 0;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.scene-tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
}

.scene-tab.is-active {
  color: #fff;
  background: var(--blue-deep);
  box-shadow: 0 12px 28px rgba(20, 83, 110, 0.22);
  transform: translateX(5px);
}

.tab-number {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  opacity: 0.68;
}

.scene-tab.is-active .tab-number {
  color: #a8e1eb;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 620px;
  display: grid;
  grid-template-rows: auto minmax(450px, 1fr) auto;
  border: 1px solid rgba(207, 224, 227, 0.78);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.stage-head {
  position: relative;
  z-index: 3;
  min-height: 98px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px clamp(20px, 3vw, 38px) 14px;
  border-bottom: 1px solid rgba(207, 224, 227, 0.7);
}

.stage-body {
  min-width: 0;
  min-height: 450px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.stage.has-panel .stage-body {
  grid-template-columns: minmax(0, 1fr) 318px;
}

.stage[data-scene="cube"].has-panel .stage-body {
  grid-template-columns: minmax(0, 1fr) 238px;
}

.stage[data-scene="cube"] .lesson-panel {
  padding-inline: 16px;
}

.stage-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--blue);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(27px, 3vw, 42px);
  line-height: 1.12;
  letter-spacing: 0.06em;
}

.scene-actions,
.view-controls,
.dock-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.action-button,
.view-button,
.icon-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 160ms ease;
}

.action-button,
.view-button {
  min-height: 35px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.action-button:hover,
.view-button:hover,
.icon-button:hover {
  border-color: #91bdc7;
  color: var(--blue-deep);
  transform: translateY(-1px);
}

.action-button.is-active,
.view-button.is-active {
  border-color: var(--blue-deep);
  color: #fff;
  background: var(--blue-deep);
}

.action-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(54, 115, 132, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(54, 115, 132, 0.055) 1px, transparent 1px),
    radial-gradient(circle at 50% 43%, #ffffff 0%, #eff7f7 68%, #e5f0f1 100%);
  background-size: 28px 28px, 28px 28px, auto;
}

.lesson-panel {
  display: none;
  min-width: 0;
  padding: 25px 22px;
  border-left: 1px solid rgba(207, 224, 227, 0.86);
  background:
    linear-gradient(rgba(54, 115, 132, 0.035) 1px, transparent 1px),
    rgba(250, 253, 252, 0.94);
  background-size: 100% 34px;
  overflow-y: auto;
}

.stage.has-panel .lesson-panel {
  display: block;
}

.panel-eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.panel-title {
  margin: 0 0 22px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 24px;
  letter-spacing: 0.08em;
}

.thought-steps {
  display: grid;
  gap: 11px;
}

.thought-step {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 42px 1fr 20px;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.84);
  cursor: pointer;
  text-align: left;
  transition: opacity 220ms ease, transform 220ms ease, border-color 220ms ease, background 220ms ease;
}

.thought-step:hover {
  border-color: #8fbcc6;
  transform: translateX(3px);
}

.thought-step.is-current {
  border-color: var(--blue-deep);
  background: #e2f1f3;
}

.thought-step.is-locked {
  opacity: 0.24;
  cursor: default;
  pointer-events: none;
}

.step-number {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--blue-deep);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
}

.step-keyword {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.step-arrow {
  color: var(--blue);
  font-size: 20px;
}

.question-list {
  display: grid;
  gap: 13px;
}

.question-card {
  padding: 15px 14px 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.86);
}

.question-text {
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: 8px;
  margin: 0 0 13px;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.6;
}

.question-number {
  color: var(--blue);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  padding-top: 4px;
}

.answer-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-left: 33px;
}

.answer-button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-size: 19px;
  font-weight: 800;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.answer-button[data-answer="yes"].is-selected {
  border-color: var(--blue-deep);
  color: #fff;
  background: var(--blue-deep);
}

.answer-button[data-answer="no"].is-selected {
  border-color: var(--coral);
  color: #fff;
  background: var(--coral);
}

.unfold-progress {
  display: flex;
  align-items: center;
  gap: 6px;
}

.unfold-progress i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition: width 180ms ease, background 180ms ease;
}

.unfold-progress i.is-filled {
  width: 22px;
  border-radius: 999px;
  background: var(--coral);
}

.canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 -30px 60px rgba(36, 90, 103, 0.06);
}

.canvas-host,
.canvas-host canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-host {
  position: absolute;
  inset: 0;
  cursor: grab;
}

.canvas-host:active {
  cursor: grabbing;
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--blue-deep);
  background: #eff7f7;
  font-size: 13px;
  letter-spacing: 0.08em;
  transition: opacity 300ms ease, visibility 300ms ease;
}

.loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-cube {
  width: 42px;
  height: 42px;
  border: 3px solid var(--blue);
  animation: loading-turn 1.25s ease-in-out infinite;
}

@keyframes loading-turn {
  0% { transform: rotate(0deg) scale(0.8); border-radius: 4px; }
  50% { transform: rotate(90deg) scale(1); border-radius: 13px; border-color: var(--coral); }
  100% { transform: rotate(180deg) scale(0.8); border-radius: 4px; }
}

.axis-badge {
  position: absolute;
  right: 24px;
  bottom: 20px;
  width: 62px;
  height: 62px;
  color: var(--muted);
  font-size: 10px;
  opacity: 0.72;
  pointer-events: none;
}

.axis-badge i,
.axis-badge::before,
.axis-badge::after {
  content: "";
  position: absolute;
  left: 29px;
  bottom: 12px;
  width: 1px;
  height: 38px;
  background: var(--blue);
  transform-origin: bottom;
}

.axis-badge::before {
  transform: rotate(118deg);
  background: var(--coral);
}

.axis-badge::after {
  transform: rotate(-118deg);
  background: var(--mustard);
}

.axis-up {
  position: absolute;
  top: 0;
  left: 23px;
}

.axis-front {
  position: absolute;
  right: 0;
  bottom: 3px;
}

.control-dock {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px clamp(18px, 2.5vw, 34px);
  border-top: 1px solid rgba(207, 224, 227, 0.75);
  background: rgba(250, 253, 252, 0.94);
}

.icon-button {
  min-width: 62px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 11px;
  font-size: 12px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button[aria-pressed="true"] {
  border-color: var(--coral);
  color: #fff;
  background: var(--coral);
}

@media (max-width: 900px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    height: 52px;
    padding: 0 5px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 10px;
    min-height: calc(100vh - 68px);
  }

  .scene-nav {
    display: grid;
    grid-template-columns: repeat(6, minmax(126px, 1fr));
    overflow-x: auto;
    justify-content: initial;
    padding: 3px 2px 8px;
    scrollbar-width: none;
  }

  .scene-nav::-webkit-scrollbar {
    display: none;
  }

  .scene-tab {
    min-height: 44px;
    grid-template-columns: 25px 1fr;
    padding: 6px 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.65);
  }

  .scene-tab.is-active {
    transform: none;
  }

  .stage {
    min-height: calc(100vh - 132px);
    grid-template-rows: auto minmax(410px, 1fr) auto;
    border-radius: 18px;
  }

  .stage-head {
    min-height: 86px;
    padding: 14px 18px;
  }

  .control-dock {
    align-items: flex-start;
  }

  .view-controls {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px;
    scrollbar-width: none;
  }

  .view-controls::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 590px) {
  .brand-text {
    font-size: 18px;
  }

  .scene-counter {
    display: none;
  }

  .stage-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  h1 {
    font-size: 28px;
  }

  .scene-actions {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .stage {
    grid-template-rows: auto minmax(390px, 1fr) auto;
  }

  .axis-badge {
    right: 10px;
    bottom: 9px;
    transform: scale(0.78);
  }

  .control-dock {
    min-height: 66px;
    padding: 10px 12px;
  }

  .dock-tools {
    gap: 4px;
  }

  .icon-button {
    min-width: 42px;
    width: 42px;
    padding: 0;
  }

  .icon-button span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
