:root {
  --bg0: #0b1020;
  --bg1: #131a33;
  --card: rgba(16, 22, 42, 0.78);
  --card-border: rgba(120, 160, 255, 0.22);
  --txt: #e8eefc;
  --txt-dim: #9fb0d4;
  --accent: #ffb347;
  --blue: #5ea8ff;
  --green: #57dfa4;
  --orange: #ff9f43;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(1200px 700px at 50% 18%, var(--bg1), var(--bg0));
  color: var(--txt);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#labels {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}
.lbl {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -50%);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(8, 12, 26, 0.72);
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(3px);
  will-change: transform;
}
.lbl.small { font-size: 11px; font-weight: 500; padding: 1px 6px; opacity: .92; }

.card {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 12px 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.42);
  z-index: 5;
}

.card-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--txt-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* ---------- 标题 ---------- */
#titleCard {
  top: 14px; left: 14px;
  max-width: 430px;
  border-left: 4px solid var(--accent);
}
#titleCard h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .5px;
}
#titleCard .sub {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--txt-dim);
  line-height: 1.5;
}
#titleCard .sub b { color: var(--accent); }


/* ---------- 步骤 ---------- */
#stepCard {
  top: 14px; right: 14px;
  width: 300px;
  border-left: 4px solid var(--blue);
}
#stepTag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--blue);
  background: rgba(94,168,255,.14);
  border: 1px solid rgba(94,168,255,.4);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}
#stepTitle { margin: 0 0 5px; font-size: 16px; font-weight: 700; }
#stepDesc { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--txt-dim); }
#stepDesc b { color: var(--accent); }
#stepDots { display: flex; gap: 5px; margin-top: 9px; flex-wrap: wrap; }
#stepDots button {
  width: 22px; height: 6px;
  border-radius: 3px;
  border: none;
  background: rgba(255,255,255,.16);
  cursor: pointer;
  padding: 0;
  transition: background .15s;
}
#stepDots button.active { background: var(--accent); }
#stepDots button:hover { background: rgba(255,255,255,.4); }

/* ---------- 公式 ---------- */
#formulaCard {
  left: 14px; bottom: 84px;
  min-width: 240px;
  max-width: 360px;
  border-left: 4px solid var(--accent);
}
#formula {
  font-family: "Cambria Math", "STIX Two Math", Georgia, serif;
  font-size: 26px;
  text-align: center;
  color: #fff;
  padding: 6px 0 2px;
  line-height: 1.35;
}
#formula .op { color: var(--txt-dim); margin: 0 4px; }
#formula .sym-cyl { color: var(--blue); }
#formula .sym-cone { color: var(--orange); }
#formula .sym-ball { color: var(--green); }
#formulaSub { font-size: 12px; color: var(--txt-dim); text-align: center; line-height: 1.55; }
#formulaSub b { color: var(--accent); }

.frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  margin: 0 2px;
  line-height: 1.05;
  text-align: center;
}
.frac > .num { border-bottom: 2px solid currentColor; padding: 0 6px 1px; }
.frac > .den { padding: 1px 6px 0; }

/* ---------- 参数 ---------- */
#paramCard {
  right: 14px; bottom: 84px;
  width: 290px;
  border-left: 4px solid var(--green);
}
.slider-row { margin-bottom: 8px; }
.slider-row label {
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: var(--txt-dim);
  margin-bottom: 3px;
}
.slider-row output { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 20px;
}
#readout {
  margin-top: 6px;
  border-top: 1px dashed rgba(255,255,255,.14);
  padding-top: 7px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--txt-dim);
  font-variant-numeric: tabular-nums;
}
#readout .row { display: flex; justify-content: space-between; gap: 8px; }
#readout .row b { color: var(--txt); }
#readout .bar {
  position: relative;
  height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,.1);
  margin: 2px 0 6px;
  overflow: hidden;
}
#readout .bar > i {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 3px;
  background: var(--accent);
  transition: width .12s linear;
}

/* ---------- 控制栏 ---------- */
#controlBar {
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  max-width: calc(100vw - 28px);
  flex-wrap: wrap;
  justify-content: center;
}
#controlBar button, #controlBar select {
  appearance: none;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  color: var(--txt);
  border-radius: 9px;
  padding: 6px 11px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
}
#controlBar button:hover, #controlBar select:hover { background: rgba(255,255,255,.16); }
#controlBar button:active { transform: translateY(1px); }
#btnPlay { min-width: 62px; color: var(--accent); border-color: rgba(255,179,71,.5); font-weight: 700; }
#controlBar select { padding: 6px 6px; }
#scrub { flex: 1 1 160px; min-width: 120px; max-width: 320px; }

#hint {
  position: absolute;
  bottom: 16px; right: 16px;
  font-size: 11px;
  color: rgba(255,255,255,.4);
  z-index: 4;
  pointer-events: none;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  #titleCard { max-width: calc(100vw - 28px); }
  #titleCard h1 { font-size: 17px; }
  #titleCard .sub { font-size: 11.5px; margin-bottom: 8px; }
  #stepCard {
    top: auto; bottom: 150px; right: 10px; left: 10px;
    width: auto;
    padding: 9px 12px;
  }
  #stepTitle { font-size: 14px; }
  #stepDesc { font-size: 11.5px; }
  #stepDots { margin-top: 6px; }
  #formulaCard { left: 10px; bottom: 150px; min-width: 0; max-width: 46vw; padding: 8px 10px; }
  #formula { font-size: 19px; }
  #formulaSub { font-size: 10.5px; }
  #paramCard { right: 10px; bottom: 150px; width: 46vw; padding: 8px 10px; }
  #paramCard .slider-row label { font-size: 11px; }
  #readout { font-size: 10.5px; }
  #controlBar { bottom: 8px; gap: 5px; padding: 7px 9px; }
  #controlBar button, #controlBar select { font-size: 12px; padding: 5px 8px; }
  #scrub { flex-basis: 100%; order: 10; max-width: none; }
  #hint { display: none; }
}

@media (max-width: 620px) {
  #formulaCard, #paramCard {
    position: absolute;
    bottom: 150px;
    max-height: 38vh;
    overflow: auto;
  }
  #formulaCard { left: 8px; width: 48vw; }
  #paramCard { right: 8px; width: 48vw; }
  #stepCard { bottom: 108px; }
  #formulaCard, #paramCard { bottom: 196px; }
}

/* ---------- 模式切换 ---------- */
#modeTabs { display: flex; gap: 6px; margin-top: 8px; }
#modeTabs button {
  border: 1px solid var(--card-border); background: rgba(255,255,255,0.05); color: var(--txt-dim);
  padding: 5px 12px; border-radius: 8px; font-size: 12px; cursor: pointer; font-family: inherit;
}
#modeTabs button.on { background: var(--blue); color: #04182e; border-color: var(--blue); font-weight: 700; }
#tabs { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
#tabs .tab-sep { width: 1px; background: var(--card-border); margin: 2px 2px; }
#tabs button {
  border: 1px solid var(--card-border); background: rgba(255,255,255,0.05); color: var(--txt);
  padding: 5px 12px; border-radius: 8px; font-size: 12px; cursor: pointer; font-family: inherit;
}
#tabs button small { font-size: 10px; opacity: .8; }
#tabs button.on { background: rgba(255,179,71,0.18); color: #ffd9a0; border-color: var(--accent); }
#tabs button[data-mode="exp"].on { background: rgba(94,168,255,0.16); color: #bcdcff; border-color: var(--blue); }
#tabs button.hide { display: none; }

/* ---------- 为什么 ---------- */
#whyBtn {
  margin-top: 8px; border: 1px solid var(--accent); background: rgba(255,179,71,0.12); color: #ffd9a0;
  padding: 5px 12px; border-radius: 8px; font-size: 12px; cursor: pointer; font-family: inherit;
}
#whyBtn:hover { background: rgba(255,179,71,0.25); }
#whyBtn.hide { display: none; }
#whyPanel { position: fixed; inset: 0; background: rgba(2,6,23,0.66); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
#whyPanel.show { display: flex; }
#whyBox {
  max-width: 620px; width: 100%; background: rgba(15,23,42,0.97); border: 1px solid var(--accent);
  border-radius: 16px; padding: 20px 22px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  max-height: 80vh; overflow-y: auto;
}
#whyBox #whyClose { position: absolute; top: 10px; right: 12px; background: none; border: none; color: var(--txt-dim); font-size: 22px; cursor: pointer; }
#whyQ { font-size: 15px; font-weight: 700; color: #ffd9a0; margin-bottom: 10px; padding-right: 26px; }
#whyA { font-size: 13px; line-height: 1.9; color: var(--txt); }
#whyA b { color: #fff; }

/* ---------- 证明面板 ---------- */
.pf-group { margin-bottom: 12px; }
.pf-group > .pf-label {
  font-size: 10px; letter-spacing: 1.5px; color: var(--txt-dim); text-transform: uppercase;
  margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.pf-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 3px 0; gap: 8px; }
.pf-row .k { color: var(--txt-dim); flex-shrink: 0; }
.pf-row .v { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.pf-row .v.em { color: #86efac; }
.pf-row .v.warn { color: #fca5a5; }
.pf-row .v.amber { color: #fde68a; }
.pf-slider { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 6px 0; }
.pf-slider label { color: var(--txt-dim); flex-shrink: 0; min-width: 56px; }
.pf-slider output { color: #fff; font-weight: 700; min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.pf-slider input[type=range] { flex: 1; min-width: 0; }
.pf-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--txt-dim); margin: 4px 0; cursor: pointer; }
.pf-toggle input { accent-color: var(--accent); }
.pf-note { font-size: 10px; color: var(--txt-dim); line-height: 1.5; margin-top: 6px; }
.pf-note.strong { color: #fca5a5; }
.pf-formula { font-size: 13px; color: var(--txt); background: rgba(2,6,23,0.4); border: 1px solid rgba(255,255,255,0.06); border-radius: 8px; padding: 7px 9px; margin: 6px 0; text-align: center; line-height: 1.8; }
.pf-bar-wrap { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; margin: 4px 0 2px; }
.pf-bar { height: 100%; background: var(--green); border-radius: 3px; transition: width 0.15s; }
.pf-bar.amber { background: var(--accent); }
.pf-bar.red { background: #ef4444; }
.pf-layer { font-size: 11px; color: var(--txt-dim); line-height: 1.6; }
.pf-layer b { color: var(--txt); }

/* ---------- 参数卡容器 ---------- */
#paramCard { max-height: calc(100vh - 120px); overflow-y: auto; }
#proofControls:empty { display: none; }
#expControls.hide, #proofControls.hide { display: none; }


/* pythagoras */
#modeTabs{display:none}
#readout .v-eq{color:#86efac}


/* pythagoras · readout */
#readout{margin-top:10px;font-size:12px;color:#c7d4ee}
.ro-row{display:flex;justify-content:space-between;line-height:1.55;font-variant-numeric:tabular-nums}
.ro-row span{opacity:.8}
.ro-row.hl{color:#e9f2ff;font-weight:700}
.ro-sep{height:1px;background:rgba(255,255,255,.08);margin:6px 0}
.ro-bar{display:grid;grid-template-columns:48px 1fr 52px;gap:8px;align-items:center;margin-top:6px}
.ro-bar .t{font-size:11px;opacity:.8}
.ro-bar .track{height:8px;border-radius:99px;background:rgba(255,255,255,.08);overflow:hidden}
.ro-bar .track i{display:block;height:100%;background:linear-gradient(90deg,#ffb347,#5ea8ff);border-radius:99px}
.ro-bar .track.c i{background:linear-gradient(90deg,#57dfa4,#2fd39a)}
.ro-bar b{text-align:right;font-size:11px;font-weight:600}
.ro-eq{margin-top:8px;font-size:11px;color:#86efac}
