#app {
  --panel-w: 308px;
  --gravity: #ffcc6e;
  --normal: #80dcff;
  --friction: #ff9989;
  --accent: var(--gravity);
  --line: #263447;
}
#stage {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  background: #05070d;
  padding: clamp(16px, 2.6vw, 36px);
  gap: 12px;
}
.experiment-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px 16px;
}
.experiment-head h1 { margin: 0; font-size: 18px; font-weight: 650; }
.force-key { display: flex; gap: 13px; list-style: none; padding: 0; margin: 0; font-size: 12px; }
.force-key li::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 2px;
  margin: 0 4px 3px 0;
  background: currentColor;
}
.gravity { color: var(--gravity); }
.normal { color: var(--normal); }
.friction { color: var(--friction); }
.apparatus {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #223044;
  border-radius: 12px;
  background: #05070d;
}
#canvas { position: absolute; width: 100%; height: 100%; touch-action: none; }
.experiment-foot {
  display: grid;
  grid-template-columns: minmax(144px, 1fr) 2fr;
  align-items: center;
  gap: 12px;
}
.motion-state { display: grid; gap: 2px; }
.motion-state strong { font-size: 17px; color: var(--normal); }
.motion-state[data-moving=true] strong { color: var(--gravity); }
.motion-state span, .motion-data dt, dd small { color: #a4b2c6; font-size: 12px; }
.motion-data { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0; }
.motion-data div { background: #111925; padding: 7px 10px; border-radius: 7px; }
.motion-data i { font-size: 11px; color: #859cb5; }
.motion-data dd { margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
dd, output, .threshold b { font-variant-numeric: tabular-nums; }
.motion-data b { font-size: 16px; font-weight: 600; }
.transport { display: flex; align-items: center; gap: 8px; }
#app button {
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid #314156;
  border-radius: 8px;
  background: #131d2a;
  color: #e8eff8;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#app button:hover { border-color: #8298b3; }
#app button:active { filter: brightness(1.2); }
#app #play {
  background: var(--gravity);
  border-color: var(--gravity);
  color: #211708;
  font-weight: 700;
  min-width: 100px;
}
#play span:first-child { display: inline-block; width: 1em; margin-right: 5px; }
#app :focus-visible { outline: 2px solid var(--normal); outline-offset: 2px; }
.experiment-learn { color: #a4b2c6; margin-left: auto; font-size: 12px; padding: 12px 0; white-space: nowrap; }
#panel { padding: 22px 16px; background: #0e1520; }
#panel h2 { color: #c5d3e6; }
#panel .settings-title { font-size: 15px; margin: 0 0 14px; color: var(--text); }
.presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; max-width: 420px; }
#app .presets button { padding-inline: 4px; white-space: nowrap; }
#app .presets button[aria-pressed=true] { border-color: #a3834b; background: #2d2519; color: var(--gravity); }
.parameters label { display: flex; justify-content: space-between; font-size: 13px; }
.parameters output { color: var(--gravity); }
#panel .parameters input { display: block; width: 100%; height: 36px; margin: 0 0 4px; accent-color: var(--gravity); }
.threshold { padding: 9px 11px; background: #192331; border-radius: 8px; color: #c5d3e6; font-size: 12px; }
.threshold > div:first-child { display: flex; justify-content: space-between; align-items: center; }
.threshold b { color: var(--normal); font-size: 15px; }
.threshold-track {
  position: relative;
  height: 5px;
  margin: 8px 0 6px;
  border-radius: 4px;
  background: linear-gradient(to right, #4d8196 var(--critical, 0%), #523c32 var(--critical, 0%));
}
.threshold-track span {
  position: absolute;
  left: var(--current, 0%);
  top: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 11px;
  border-radius: 2px;
  background: var(--gravity);
}
.threshold p { margin: 0; }
.decomp { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-size: 13px; }
.decomp input { accent-color: var(--gravity); }
.force-data { border-top: 1px solid var(--line); font-size: 13px; }
.force-data summary { padding: 12px 0; cursor: pointer; }
.force-data dl { display: block; margin: 0; }
.force-data dl div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.force-data .note { color: #a4b2c6; font-size: 12px; }
@media (max-width: 760px) {
  #app { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 440px; }
  #stage { position: relative; padding: 10px 12px; gap: 7px; }
  .experiment-head h1, .motion-state strong { font-size: 16px; }
  .force-key { font-size: 11px; }
  .presets { max-width: none; }
  .experiment-foot { grid-template-columns: 1fr; gap: 4px; }
  .motion-state { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
  .motion-data div { padding: 4px 6px; }
  .motion-data b { font-size: 15px; }
  .motion-data dt, .motion-data small { font-size: 11px; }
  .motion-data dd { margin-top: 0; }
  .transport { gap: 5px; }
  #app .transport button { padding-inline: 7px; white-space: nowrap; }
  #app #play { min-width: 81px; }
  .experiment-learn { font-size: 11px; }
  #panel { position: static; max-height: min(36dvh, 260px); padding: 12px; transform: none; }
  #panel.collapsed { display: none; }
  #app #panelToggle { position: static; }
  #app #panelToggle[aria-expanded=true] { border-color: var(--gravity); color: var(--gravity); }
}
