:root {
  --bg-top: #fffdf7;
  --bg-bottom: #eef6ff;
  --surface: rgba(255, 255, 255, 0.88);
  --border: rgba(217, 228, 243, 0.95);
  --text: #223148;
  --muted: #607188;
  --accent: #ff7148;
  --accent-soft: rgba(255, 113, 72, 0.1);
  --left: #4c87ff;
  --right: #35b38a;
  --shadow: 0 22px 48px rgba(25, 44, 72, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(126, 170, 255, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 190, 120, 0.16), transparent 30%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

.page-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.hero {
  padding: 18px 0 28px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  margin-bottom: 18px;
  color: #4d6485;
  text-decoration: none;
  font-weight: 600;
}

.hero-tag,
.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(255, 177, 92, 0.34);
  color: #d26b2b;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 18px 0 12px;
  font-size: clamp(2.4rem, 4vw, 4rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.hero p {
  max-width: 860px;
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--muted);
}

.experiment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 22px;
  align-items: start;
}

.experiment-card,
.learn-card {
  border-radius: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.experiment-card {
  padding: 22px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.card-header.compact {
  margin-bottom: 20px;
}

.card-header h2,
.learn-card h2 {
  margin: 10px 0 0;
  font-size: 1.7rem;
  line-height: 1.15;
}

.toolbar,
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff6e4c 0%, #ff915f 100%);
  color: white;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 14px 26px rgba(255, 113, 72, 0.2);
}

.action-btn:hover {
  transform: translateY(-1px);
}

.action-btn.secondary {
  background: white;
  color: #48607f;
  border: 1px solid rgba(215, 225, 240, 0.96);
  box-shadow: none;
}

.action-btn.wide {
  width: 100%;
}

.canvas-wrap {
  position: relative;
}

#leverCanvas {
  width: 100%;
  height: auto;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(245, 249, 255, 0.98) 100%);
  border: 1px solid rgba(230, 237, 247, 0.96);
}

.board-bg {
  fill: rgba(255, 255, 255, 0.38);
}

.grid-layer path {
  stroke: rgba(119, 145, 185, 0.13);
  stroke-width: 1;
}

.beam {
  stroke: #5e78aa;
  stroke-width: 14;
  stroke-linecap: round;
}

.pivot-cap {
  fill: #f9c16b;
  stroke: white;
  stroke-width: 5;
}

.pivot-base {
  fill: #ff9f66;
}

.slot {
  fill: rgba(91, 117, 154, 0.08);
  stroke: rgba(91, 117, 154, 0.18);
  stroke-width: 1.5;
}

.slot-label {
  fill: #7b8ca1;
  font-size: 14px;
  font-weight: 700;
  text-anchor: middle;
}

.weight-rope {
  stroke: rgba(60, 80, 110, 0.36);
  stroke-width: 4;
  stroke-linecap: round;
}

.weight-block {
  stroke: white;
  stroke-width: 5;
  cursor: default;
}

.weight-block.left {
  fill: var(--left);
}

.weight-block.right {
  fill: var(--right);
}

.weight-text,
.marker-text {
  fill: white;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.weight-text {
  font-size: 24px;
}

.marker-text {
  font-size: 13px;
}

.slot-click {
  cursor: pointer;
}

.slot.side-left {
  fill: rgba(76, 135, 255, 0.08);
  stroke: rgba(76, 135, 255, 0.18);
}

.slot.side-right {
  fill: rgba(53, 179, 138, 0.08);
  stroke: rgba(53, 179, 138, 0.18);
}

.slot.active {
  stroke-width: 2.5;
}

.slot.side-left.active {
  fill: rgba(76, 135, 255, 0.18);
  stroke: rgba(76, 135, 255, 0.5);
}

.slot.side-right.active {
  fill: rgba(53, 179, 138, 0.18);
  stroke: rgba(53, 179, 138, 0.5);
}

.helper-strip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(247, 250, 255, 0.95);
  border: 1px solid rgba(225, 233, 244, 0.96);
}

.helper-strip strong {
  flex: 0 0 auto;
  color: var(--accent);
}

.helper-strip span {
  color: #566982;
  line-height: 1.7;
}

.weight-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.weight-control {
  padding: 16px;
  border-radius: 20px;
  background: rgba(247, 250, 255, 0.95);
  border: 1px solid rgba(225, 233, 244, 0.96);
}

.control-label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #55677f;
}

.secondary-label {
  margin-top: 16px;
}

.segment-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segment-btn {
  border: none;
  border-radius: 12px;
  padding: 11px 8px;
  font-weight: 700;
  background: white;
  color: #5f6f86;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(216, 226, 239, 0.92);
}

.segment-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 113, 72, 0.24);
}

.distance-group {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.distance-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 6px;
  font-weight: 700;
  background: white;
  color: #5f6f86;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(216, 226, 239, 0.92);
}

.distance-btn.active {
  background: #eef4ff;
  color: #365b99;
  box-shadow: inset 0 0 0 1px rgba(76, 135, 255, 0.24);
}

.balance-status {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff8f3 0%, #fff 100%);
  border: 1px solid rgba(255, 184, 124, 0.26);
}

.status-label {
  display: block;
  margin-bottom: 8px;
  color: #8b6245;
  font-size: 0.9rem;
  font-weight: 700;
}

.balance-status strong {
  display: block;
  font-size: 2rem;
  line-height: 1.05;
  color: var(--accent);
}

.balance-status p {
  margin: 12px 0 0;
  line-height: 1.75;
  color: #6b778d;
}

.effect-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.effect-card {
  padding: 16px;
  border-radius: 20px;
  text-align: center;
  background: rgba(247, 250, 255, 0.96);
}

.effect-card span {
  display: block;
  margin-bottom: 8px;
  color: #687a92;
  font-size: 0.84rem;
}

.effect-card strong {
  font-size: 1.8rem;
}

.effect-card.left {
  box-shadow: inset 0 0 0 1px rgba(76, 135, 255, 0.16);
}

.effect-card.right {
  box-shadow: inset 0 0 0 1px rgba(53, 179, 138, 0.16);
}

.effect-card p {
  margin: 8px 0 0;
  color: #6e7f95;
}

.detail-card {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(247, 250, 255, 0.96);
  border: 1px solid rgba(224, 232, 244, 0.98);
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.detail-row + .detail-row {
  border-top: 1px solid rgba(224, 232, 244, 0.98);
}

.detail-row span {
  color: #6c7c92;
}

.detail-row strong {
  color: #31425d;
}

.controls {
  margin-top: 18px;
}

.hint-board {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(247, 250, 255, 0.94);
  border: 1px solid rgba(224, 232, 244, 0.98);
  opacity: 0.55;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.hint-board.active {
  opacity: 1;
  transform: translateY(-2px);
}

.hint-title {
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 113, 72, 0.08);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.hint-board p {
  margin: 14px 0 0;
  line-height: 1.8;
  color: #596b84;
}

.hint-formula {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: white;
  color: #344560;
  font-weight: 800;
}

.learn-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 22px;
}

.learn-card {
  padding: 24px;
}

.learn-card p,
.learn-card li {
  color: #5e6f87;
  line-height: 1.85;
}

.learn-card ul {
  margin: 16px 0 0;
  padding-left: 18px;
}

@media (max-width: 1100px) {
  .experiment-layout,
  .learn-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 20px 14px 40px;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .card-header {
    flex-direction: column;
  }

  .toolbar,
  .weight-controls,
  .effect-grid {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .toolbar .action-btn {
    width: 100%;
  }

  .helper-strip {
    flex-direction: column;
  }
}
