:root { --panel-w: 300px; }
[hidden] { display: none !important; }
#stage {
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 48% 44%, #101d31, #080d17 54%, #05070d 84%);
}
#stage::before {
  content: "";
  position: absolute;
  inset: 90px 0 120px;
  opacity: .56;
  background-image: radial-gradient(circle at 9% 60%, #a0b7d9 0 1px, transparent 1.5px),
    radial-gradient(circle at 82% 17%, #9bd6f0 0 1px, transparent 1.5px),
    radial-gradient(circle at 64% 83%, #77839f 0 1px, transparent 1.5px);
  background-size: 177px 193px, 287px 249px, 331px 217px;
  pointer-events: none;
}
.stage-head { position: relative; z-index: 1; padding: 15px 20px 0; }
.stage-head .seg button { min-height: 36px; color: var(--accent); padding: 5px 12px; }
.stage-head .seg button.on { color: #131416; }
.stage-head h2 { color: #f1f5ff; font-size: 18px; margin: 10px 0 3px; }
#stage .learn-fab { inset: 59px 18px auto auto; transform: none; min-height: 28px; }
.stage-head p { color: #a5b4cb; font-size: 12px; margin: 0; }
#space { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#space canvas, #chart { touch-action: none; }
#space canvas { cursor: grab; }
#space canvas.can-drag, #chart { cursor: ew-resize; }
#space canvas.dragging, #chart.dragging { cursor: grabbing; }
.object-label {
  position: absolute;
  transform: translate(-50%, 12px);
  color: #e0edff;
  background: #0b1423c9;
  text-shadow: 0 1px 3px #000;
  border-radius: 6px;
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.solar-label { color: #ffd189; transform: translate(-50%, 24px); }
.station-label { color: var(--accent); }
#webglFallback { text-align: center; color: var(--muted); font-size: 12px; }
#webglFallback img { width: min(75%, 440px); max-height: 85%; object-fit: contain; }
.view-tools {
  position: relative;
  padding: 0 18px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
}
.view-key { display: flex; gap: 11px; color: #b7c3d7; font-size: 12px; }
.view-key i, .chart-foot i { display: inline-block; width: 13px; vertical-align: middle; margin-right: 4px; }
#surfaceKey i { border-top: 2px solid #65e3ff; }
#meanKey i, .chart-foot i { border-top: 1px dashed #a8b7d0; }
.force-key i { border-top: 2px solid #ffad75; }
#app:not([data-scene="force"]) .force-key,
#app[data-scene="force"] .range-detail,
#app[data-scene="force"] .transport { display: none; }
.chart-box {
  position: relative;
  margin: 0 16px 15px;
  padding: 8px 10px 5px;
  border: 1px solid #263650;
  border-radius: 12px;
  background: #0c1421f2;
}
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.chart-head h3, .force-box h3 { margin: 0; font-size: 14px; color: var(--accent); }
.chart-head output { color: #ffe19b; white-space: nowrap; }
#chart { width: 100%; height: clamp(76px, 15vh, 143px); }
.chart-foot { display: flex; justify-content: space-between; color: #acb9d0; font-size: 11px; }
.force-box { padding: 12px; }
.force-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 10px; }
.force-cells div { padding: 7px; border: 1px solid #2a3853; border-radius: 6px; }
.force-cells strong, .force-cells span { display: block; font-size: 12px; }
.force-cells strong { color: #ffad75; margin-bottom: 4px; }
.force-cells span { color: #c0cce0; }
#panel h1 { margin-bottom: 3px; }
#panel h2 { font-size: 15px; }
.phase-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
button.small { color: var(--accent); border-color: #634f2d; min-height: 34px; }
button.small.on, #play[aria-pressed="true"] { background: var(--accent); color: #131416; }
.tide-slider { font-size: 12px; grid-template-columns: 54px minmax(0, 1fr) 42px; }
.tide-slider input { margin: 0; min-height: 36px; }
#solarRow { font-size: 12px; min-height: 34px; }
#solarRow input { margin-left: 0; }
.scope { margin-top: 12px; line-height: 1.6; }
#mechanism { line-height: 1.55; }
.learn-table { overflow-x: auto; }
@media (max-width: 760px) {
  .stage-head { padding: 9px 10px 0; }
  .stage-head .seg button { min-height: 38px; padding-inline: 8px; font-size: 11px; }
  .stage-head h2 { font-size: 16px; margin-top: 6px; }
  .stage-head p { font-size: 11px; }
  #panelToggle { top: 9px; right: 9px; min-height: 38px; color: var(--accent); border-color: #634f2d; font-size: 11px; }
  #stage .learn-fab { inset: 49px 9px auto auto; font-size: 11px; min-height: 34px; display: flex; align-items: center; padding-inline: 8px; }
  .view-tools { padding: 0 8px 5px; }
  .view-tools button { min-height: 40px; padding-inline: 7px; font-size: 11px; }
  .view-key { gap: 7px; font-size: 11px; }
  .chart-box { margin: 0 7px 8px; padding-inline: 7px; }
  .chart-head h3, .force-box h3 { font-size: 12px; }
  .chart-head output { font-size: 11px; }
  .object-label { font-size: 11px; }
  #panel button.small { min-height: 44px; }
  #solarRow { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { #panel { transition: none; } }
