:root {
  color-scheme: light;
  --ink: #1d2433;
  --muted: #637083;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --line: #d9dee7;
  --accent: #276ef1;
  --accent-dark: #164db8;
  --mint: #28a879;
  --sun: #f5b93f;
  --soft-blue: #e9f1ff;
  --soft-green: #e8f7f0;
  --shadow: 0 18px 50px rgba(45, 55, 72, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(39, 110, 241, 0.08), transparent 30%),
    linear-gradient(315deg, rgba(40, 168, 121, 0.12), transparent 34%),
    var(--paper);
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(430px, 500px) minmax(0, 1fr);
  gap: 18px;
  width: min(1180px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  min-height: calc(100svh - 32px);
  margin: 16px auto;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

.lesson-panel,
.cube-stage {
  border: 1px solid rgba(217, 222, 231, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.lesson-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 14px;
  overflow: hidden;
}

.brand-row {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 9px;
  align-items: center;
}

.logo-mark {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  width: 38px;
  height: 38px;
  padding: 4px;
  border-radius: 8px;
  background: #202636;
}

.logo-mark span {
  border-radius: 3px;
}

.logo-mark span:nth-child(1), .logo-mark span:nth-child(6) { background: #ffffff; }
.logo-mark span:nth-child(2), .logo-mark span:nth-child(8) { background: #f5d547; }
.logo-mark span:nth-child(3) { background: #f25f5c; }
.logo-mark span:nth-child(4), .logo-mark span:nth-child(9) { background: #2fbf71; }
.logo-mark span:nth-child(5) { background: #276ef1; }
.logo-mark span:nth-child(7) { background: #ff9f1c; }

.eyebrow,
.step-kicker {
  display: block;
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(19px, 2.2vw, 24px);
  line-height: 1.18;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
}

.progress-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-blue);
}

.progress-card strong {
  min-width: 58px;
  color: var(--accent-dark);
  font-size: 15px;
  text-align: right;
}

.lesson-intro {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.32;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.formula-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #202636;
  color: #ffffff;
}

.formula-row span {
  color: #c9d3e7;
  font-size: 13px;
}

.formula-row code {
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  margin-top: auto;
}

.icon-button,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 8px;
  user-select: none;
}

.icon-button {
  background: var(--soft-green);
  color: #116143;
  font-size: 27px;
  line-height: 1;
}

.primary-button {
  background: var(--mint);
  color: #ffffff;
  font-weight: 800;
}

.secondary-button {
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.next-action {
  font-size: 18px;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
}

.lesson-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lesson-steps li {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.lesson-steps b {
  display: none;
}

.move-guide {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, auto);
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.guide-header strong {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 8px;
  background: #202636;
  color: #ffffff;
  font-size: 18px;
}

.move-guide p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.32;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.diagram-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.diagram-card {
  display: grid;
  gap: 4px;
  min-height: 96px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.diagram-card svg {
  width: 100%;
  height: 60px;
}

.diagram-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.coach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.coach-list li {
  padding: 5px 7px;
  border-radius: 8px;
  background: var(--soft-green);
  color: #174d3a;
  font-size: 12px;
  line-height: 1.25;
  flex: 1 1 130px;
}

.sequence-box {
  margin-top: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.sequence-box p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.cube-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(460px, 1fr) auto;
  min-height: 620px;
  overflow: hidden;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.stage-toolbar p {
  color: var(--muted);
  font-size: 16px;
}

.legend {
  display: grid;
  grid-template-columns: repeat(6, 18px);
  gap: 7px;
}

.c {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(29, 36, 51, 0.25);
  border-radius: 4px;
}

.white { background: #ffffff; }
.yellow { background: #ffd93d; }
.red { background: #e53935; }
.orange { background: #ff8f00; }
.blue { background: #1e88e5; }
.green { background: #43a047; }

.cube-canvas {
  position: relative;
  min-height: 460px;
  touch-action: none;
  background:
    linear-gradient(rgba(29, 36, 51, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 36, 51, 0.06) 1px, transparent 1px),
    #f5f8fc;
  background-size: 36px 36px;
}

@media (pointer: coarse) {
  .icon-button,
  .primary-button,
  .secondary-button,
  .ghost-button {
    min-height: 46px;
  }

  .icon-button {
    font-size: 38px;
  }
}

@media (min-width: 861px) and (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(460px, 48vw) minmax(0, 1fr);
    gap: 12px;
    width: calc(100vw - 24px);
    min-height: calc(100svh - 24px);
    margin: 12px auto;
  }

  .lesson-panel {
    gap: 7px;
    max-height: calc(100svh - 24px);
    padding: 10px;
  }

  h1 {
    font-size: 20px;
  }

  h2 {
    font-size: 16px;
  }

  .lesson-intro {
    font-size: 12px;
    line-height: 1.25;
  }

  .controls {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr);
  }

  .diagram-card {
    min-height: 92px;
    padding: 5px;
  }

  .diagram-card svg {
    height: 56px;
  }

  .coach-list li,
  .lesson-steps li {
    line-height: 1.32;
  }

  .cube-stage {
    min-height: calc(100svh - 24px);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .cube-canvas {
    min-height: 0;
  }
}

@media (min-width: 861px) and (max-width: 1180px) and (orientation: portrait) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 48svh);
    width: min(820px, calc(100vw - 28px));
  }

  .lesson-panel {
    max-height: none;
    overflow: visible;
  }

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

  .diagram-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

.hint-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.hint-strip span {
  padding: 7px 10px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
  font-size: 14px;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100vw - 20px, 760px);
    min-height: calc(100svh - 20px);
    margin: 10px auto;
  }

  .lesson-panel {
    padding: 18px;
  }

  .cube-stage {
    min-height: 560px;
    grid-template-rows: auto 420px auto;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .diagram-row {
    grid-template-columns: 1fr;
  }

  .lesson-panel {
    overflow: visible;
  }
}

@media (min-width: 700px) and (max-width: 860px) {
  .lesson-panel {
    gap: 16px;
    padding: 22px;
  }

  .diagram-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .controls {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 460px) {
  .brand-row {
    grid-template-columns: 48px 1fr;
  }

  .logo-mark {
    width: 48px;
    height: 48px;
  }

  .formula-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .stage-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
