:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #73808f;
  --line: #e5e9ee;
  --accent: #f06c3b;
  --accent-soft: #fff1eb;
  --navy: #162a3a;
  --x: #ec5b54;
  --y: #43ad78;
  --z: #4c87e8;
  --shadow: 0 10px 35px rgba(27, 39, 51, .07);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}
button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 272px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 28px 20px 22px;
  background: #fbfcfd; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 3;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  color: #fff; background: var(--accent); font: 800 22px/1 Georgia, serif;
  box-shadow: 0 8px 18px rgba(240,108,59,.25); transform: rotate(-3deg);
}
.brand strong { display: block; font-size: 19px; letter-spacing: -.3px; }
.brand span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; letter-spacing: .6px; }

.course-progress { padding: 0 8px 20px; }
.progress-copy { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.progress-copy b { color: var(--accent); }
.progress-track { height: 3px; background: #e7ebee; border-radius: 10px; overflow: hidden; }
.progress-track i { display: block; width: 20%; height: 100%; background: var(--accent); transition: width .25s ease; }

.lesson-nav { display: grid; gap: 7px; }
.lesson-item {
  width: 100%; border: 0; background: transparent; border-radius: 12px; min-height: 64px;
  display: grid; grid-template-columns: 34px 1fr 8px; align-items: center; gap: 9px;
  padding: 9px 12px; text-align: left; cursor: pointer; transition: .18s ease;
}
.lesson-item:hover { background: #f4f6f8; transform: translateX(2px); }
.lesson-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.lesson-index { font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: #a4adb7; }
.lesson-item.active .lesson-index { color: var(--accent); }
.lesson-item b { display: block; font-size: 13px; margin-bottom: 5px; }
.lesson-item small { display: block; color: #909aa5; font-size: 10px; white-space: nowrap; }
.lesson-item > i { width: 6px; height: 6px; border-radius: 50%; background: #dce1e6; }
.lesson-item.active > i { background: var(--accent); box-shadow: 0 0 0 4px rgba(240,108,59,.12); }

.sidebar-tip { margin-top: auto; background: var(--navy); color: #fff; padding: 16px; border-radius: 14px; }
.sidebar-tip span { color: #f2a485; font-size: 10px; letter-spacing: 1.2px; font-weight: 800; }
.sidebar-tip p { font-size: 11px; line-height: 1.7; color: #c2cdd5; margin: 7px 0 0; }
.source-link { color: #8b96a1; text-decoration: none; font-size: 10px; text-align: center; padding-top: 15px; }
.source-link:hover { color: var(--accent); }

.main-stage { min-width: 0; padding: 0 30px 24px; }
.topbar { height: 104px; display: flex; align-items: center; justify-content: space-between; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 1.5px; margin-bottom: 7px; }
h1 { margin: 0; font: 650 25px/1.1 Georgia, "Noto Serif SC", serif; letter-spacing: -.4px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.ghost-button, .footer-nav button {
  border: 1px solid var(--line); background: #fff; padding: 9px 13px; border-radius: 9px;
  cursor: pointer; font-size: 11px; transition: .18s ease;
}
.ghost-button:hover, .footer-nav button:hover { border-color: #cdd3d9; transform: translateY(-1px); }
.live-pill { background: #fff; border: 1px solid var(--line); padding: 9px 12px; border-radius: 9px; color: #697582; font-size: 10px; }
.live-pill i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #48ad78; margin-right: 5px; box-shadow: 0 0 0 3px rgba(72,173,120,.12); }

.workspace { display: grid; grid-template-columns: minmax(500px, 1.55fr) minmax(320px, .75fr); gap: 18px; }
.visual-column { min-width: 0; }
.canvas-card { height: 560px; position: relative; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.canvas-toolbar { position: absolute; inset: 18px 20px auto; z-index: 2; display: flex; justify-content: space-between; pointer-events: none; }
.view-labels, .axis-legend { display: flex; align-items: center; gap: 9px; }
.view-chip { background: var(--navy); color: #fff; border-radius: 7px; padding: 6px 10px; font-size: 9px; letter-spacing: .5px; }
.view-help { font-size: 9px; color: #98a1ab; }
.axis-legend span { display: flex; align-items: center; gap: 4px; color: #84909b; font: 700 9px ui-monospace, monospace; }
.axis-legend i { width: 12px; height: 2px; display: inline-block; }
.axis-x { background: var(--x); } .axis-y { background: var(--y); } .axis-z { background: var(--z); }
#kinematicsCanvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#kinematicsCanvas:active { cursor: grabbing; }
.canvas-caption {
  position: absolute; left: 20px; bottom: 18px; max-width: 330px; display: flex; gap: 11px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border: 1px solid var(--line);
  border-radius: 11px; padding: 11px 13px; box-shadow: 0 7px 20px rgba(31,43,53,.07);
}
.caption-number { color: var(--accent); font: 800 11px ui-monospace, monospace; padding-top: 2px; }
.canvas-caption b { display: block; font-size: 11px; margin-bottom: 3px; }
.canvas-caption small { display: block; font-size: 9px; color: var(--muted); line-height: 1.45; }

.lesson-strip { margin-top: 15px; min-height: 92px; display: grid; grid-template-columns: 1fr 1.5fr; gap: 15px; }
.lesson-goal, .step-flow { background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 15px 17px; }
.lesson-goal span { color: var(--accent); font-size: 9px; letter-spacing: 1px; font-weight: 800; }
.lesson-goal p { margin: 7px 0 0; font-size: 11px; line-height: 1.55; }
.step-flow { display: flex; align-items: center; justify-content: space-around; }
.flow-step { position: relative; flex: 1; text-align: center; color: #9aa3ac; font-size: 9px; }
.flow-step:not(:last-child)::after { content: ""; position: absolute; top: 8px; left: calc(50% + 14px); right: calc(-50% + 14px); height: 1px; background: #e4e7ea; }
.flow-step i { position: relative; z-index: 1; display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: #eef1f3; margin: 0 auto 6px; font: 700 8px ui-monospace, monospace; }
.flow-step.active { color: var(--ink); font-weight: 700; }
.flow-step.active i { background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }

.inspector { height: 667px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.inspector-tabs { height: 54px; display: grid; grid-template-columns: 1fr 1fr; padding: 8px; gap: 5px; border-bottom: 1px solid var(--line); }
.inspector-tabs button { border: 0; background: transparent; border-radius: 8px; color: #929ca6; cursor: pointer; font-size: 10px; }
.inspector-tabs button.active { background: #f2f4f6; color: var(--ink); font-weight: 700; }
.panel-scroll { height: calc(100% - 54px); overflow-y: auto; padding: 18px; scrollbar-width: thin; scrollbar-color: #d9dee3 transparent; }
.hidden { display: none !important; }

.control-section + .control-section { margin-top: 20px; padding-top: 19px; border-top: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 14px; }
.section-heading span { display: block; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: 1px; margin-bottom: 4px; }
.section-heading b { display: block; font-size: 12px; }
.section-heading small { color: #9ba4ad; font: 9px ui-monospace, monospace; }
.slider-row { display: grid; grid-template-columns: 28px 1fr 50px; align-items: center; gap: 8px; margin: 9px 0; }
.slider-row label { font: 700 10px ui-monospace, monospace; color: #596673; }
.slider-row output { text-align: right; font: 600 9px ui-monospace, monospace; color: #606d79; }
input[type="range"] { width: 100%; height: 3px; accent-color: var(--accent); cursor: pointer; }

.button-row { display: flex; gap: 8px; margin-top: 12px; }
.action-button { flex: 1; border: 1px solid var(--line); background: #fff; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 10px; }
.action-button:hover { border-color: var(--accent); color: var(--accent); }
.action-button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); background: #f1f3f5; border-radius: 8px; padding: 3px; margin-top: 9px; }
.segmented button { border: 0; background: transparent; border-radius: 6px; padding: 7px; font-size: 9px; color: #8b96a1; cursor: pointer; }
.segmented button.active { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(20,30,40,.08); }

.matrix-card { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; margin: 11px 0; }
.matrix-card header { padding: 10px 12px; background: #f7f8f9; display: flex; justify-content: space-between; align-items: center; }
.matrix-card header b { font: 700 10px ui-monospace, monospace; }
.matrix-card header span { font-size: 8px; color: #929ca5; }
.matrix-wrap { padding: 11px 12px; overflow-x: auto; }
.matrix {
  position: relative; display: grid; gap: 5px 11px; width: max-content; min-width: 100%;
  padding: 2px 9px; font: 500 9px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; color: #34414d;
}
.matrix::before, .matrix::after { content: ""; position: absolute; top: 0; bottom: 0; width: 5px; border-top: 1px solid #8c97a1; border-bottom: 1px solid #8c97a1; }
.matrix::before { left: 0; border-left: 1px solid #8c97a1; }
.matrix::after { right: 0; border-right: 1px solid #8c97a1; }
.matrix span { text-align: right; min-width: 34px; }
.matrix .rotation-value { color: #315f9f; }
.matrix .translation-value { color: var(--accent); font-weight: 700; }
.matrix-note { margin: 0; padding: 0 12px 11px; color: #8c97a1; font-size: 9px; line-height: 1.55; }
.formula-box { padding: 12px; background: var(--navy); border-radius: 10px; color: #fff; margin: 10px 0; }
.formula-box span { display: block; color: #8fa6b7; font-size: 8px; letter-spacing: .8px; margin-bottom: 6px; }
.formula-box code { font: 500 10px/1.7 ui-monospace, monospace; color: #f7c0aa; white-space: normal; }
.value-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.value-tile { background: #f6f8f9; border-radius: 9px; padding: 9px 10px; }
.value-tile span { display: block; color: #929ca6; font-size: 8px; margin-bottom: 4px; }
.value-tile b { font: 700 11px ui-monospace, monospace; }
.value-tile.wide { grid-column: 1 / -1; }
.status-note { padding: 10px 12px; border-radius: 9px; background: #edf7f1; color: #347b57; font-size: 9px; line-height: 1.6; margin-top: 10px; }
.status-note.warn { background: #fff4e9; color: #9b5f28; }
.tf-tree { display: grid; gap: 7px; margin: 8px 0 14px; }
.tf-node { position: relative; padding: 9px 11px; margin-left: 18px; background: #f5f7f8; border-radius: 8px; font: 700 9px ui-monospace, monospace; }
.tf-node::before { content: ""; position: absolute; left: -12px; top: -9px; bottom: 50%; width: 8px; border-left: 1px solid #cbd2d8; border-bottom: 1px solid #cbd2d8; }
.tf-node:first-child { margin-left: 0; background: var(--navy); color: #fff; }
.tf-node:first-child::before { display: none; }
.tf-edge { color: var(--accent); float: right; font-weight: 500; }

.learning-footer { min-height: 88px; margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.concept-card { display: flex; align-items: center; gap: 12px; max-width: 660px; }
.concept-icon { flex: 0 0 auto; width: 33px; height: 33px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: 800 14px Georgia, serif; }
.concept-card b { font-size: 11px; }
.concept-card p { color: var(--muted); font-size: 10px; line-height: 1.55; margin: 4px 0 0; }
.footer-nav { display: flex; gap: 8px; flex-shrink: 0; }
.footer-nav .primary-button { color: #fff; background: var(--navy); border-color: var(--navy); }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 226px minmax(0, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .workspace { grid-template-columns: 1fr; }
  .canvas-card { height: 500px; }
  .inspector { height: auto; min-height: 570px; }
  .panel-scroll { height: auto; max-height: 610px; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; }
  .brand { padding-bottom: 12px; }
  .course-progress, .sidebar-tip, .source-link { display: none; }
  .lesson-nav { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .lesson-item { min-width: 175px; min-height: 54px; }
  .main-stage { padding: 0 12px 20px; }
  .topbar { height: 82px; }
  .live-pill, .ghost-button { display: none; }
  .workspace { display: block; }
  .canvas-card { height: 430px; }
  .lesson-strip { grid-template-columns: 1fr; }
  .inspector { margin-top: 12px; }
  .learning-footer { align-items: flex-start; flex-direction: column; }
  .footer-nav { width: 100%; }
  .footer-nav button { flex: 1; }
}
