:root {
  color-scheme:dark;
  --bg:#101817;
  --panel:#17201e;
  --line:#334039;
  --text:#e4eadc;
  --muted:#9ba99b;
  --accent:#d6ee9b;
  font-family:Arial,Helvetica,sans-serif
}
* {
  box-sizing:border-box
}
body {
  margin:0;
  background:var(--bg);
  color:var(--text)
}
button,a,input,summary {
  -webkit-tap-highlight-color:transparent
}
button {
  font:inherit;
  color:inherit;
  cursor:pointer;
  border:1px solid var(--line);
  background:transparent;
  transition:background .15s,border-color .15s
}
button:hover {
  background:#2b3730;
  border-color:#829474
}
button:disabled {
  opacity:.45;
  cursor:wait
}
button:focus-visible,a:focus-visible,summary:focus-visible,canvas:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:4px
}
a {
  color:inherit
}
header {
  height:74px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 32px;
  border-bottom:1px solid var(--line)
}
.back {
  font:12px monospace;
  color:var(--muted);
  text-decoration:none
}
.wordmark {
  font-size:24px;
  letter-spacing:.08em;
  font-weight:800
}
.wordmark span {
  font-size:13px;
  font-weight:400;
  vertical-align:top;
  margin-left:5px;
  color:var(--accent)
}
.quiet {
  border:0;
  background:transparent;
  color:var(--muted)
}
header button {
  font-size:12px;
  padding:10px
}
main {
  display:grid;
  grid-template-columns:minmax(0,1fr) 320px;
  min-height:calc(100svh - 74px)
}
#viewport {
  position:sticky;
  top:0;
  height:calc(100svh - 74px);
  min-height:530px;
  overflow:hidden
}
canvas {
  display:block;
  width:100%;
  height:100%;
  touch-action:none;
  cursor:grab
}
canvas:active {
  cursor:grabbing
}
.caption {
  position:absolute;
  top:32px;
  left:32px;
  pointer-events:none
}
.eyebrow {
  font:10px monospace;
  letter-spacing:.18em;
  color:var(--accent)
}
h1 {
  font-size:clamp(26px,3vw,46px);
  line-height:1.02;
  font-weight:400;
  letter-spacing:-.05em;
  margin:17px 0 12px
}
.caption p {
  font-size:12px;
  color:var(--muted);
  margin:0
}
.flow-label {
  position:absolute;
  top:40px;
  right:30px;
  font:9px monospace;
  letter-spacing:.16em;
  color:var(--muted)
}
.flow-label span {
  display:block;
  font:32px Arial;
  line-height:20px;
  margin-bottom:10px
}
.viewport-bottom {
  position:absolute;
  bottom:25px;
  left:32px;
  right:32px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px
}
#gesture {
  font-size:11px;
  color:var(--muted)
}
.views {
  display:flex
}
.views button {
  font:10px monospace;
  padding:9px 12px
}
.active {
  background:var(--accent)!important;
  color:#162015!important;
  border-color:var(--accent)!important
}
.legend {
  position:absolute;
  bottom:84px;
  left:32px;
  width:145px;
  font:9px monospace;
  letter-spacing:.1em;
  color:var(--muted);
  pointer-events:none
}
.legend i {
  display:block;
  height:4px;
  margin:10px 0 7px;
  background:linear-gradient(90deg,#376caa,#74c1b0,#d6ee9b,#f3ad62)
}
.legend div {
  display:flex;
  justify-content:space-between;
  font-size:9px;
  letter-spacing:0
}
aside {
  padding:28px 24px 18px;
  background:var(--panel);
  border-left:1px solid var(--line)
}
.panel-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:28px
}
.live {
  font:9px monospace;
  color:var(--muted);
  display:flex;
  gap:6px;
  align-items:center
}
.live i {
  width:5px;
  height:5px;
  border-radius:50%;
  background:var(--accent)
}
.control-group {
  border-bottom:1px solid var(--line);
  padding-bottom:20px;
  margin-bottom:23px
}
h2 {
  font:10px monospace;
  color:#73816f;
  display:flex;
  gap:12px;
  margin:0 0 16px
}
h2 span {
  font:13px Arial;
  color:var(--text)
}
.shapes {
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:6px
}
.shapes button {
  height:82px;
  font-size:11px
}
.shapes svg {
  display:block;
  width:52px;
  height:42px;
  margin:0 auto 5px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.2
}
.note {
  font-size:11px;
  line-height:1.6;
  color:var(--muted);
  margin:12px 0 0;
  min-height:32px
}
label {
  display:flex;
  justify-content:space-between;
  gap:12px;
  font-size:12px;
  margin:18px 0 12px
}
output {
  font:11px monospace;
  color:var(--accent)
}
input[type=range] {
  display:block;
  width:100%;
  height:16px;
  accent-color:var(--accent);
  cursor:pointer;
  margin:0
}
.range-ends {
  display:flex;
  justify-content:space-between;
  font:9px monospace;
  color:var(--muted);
  margin-top:6px
}
.modes {
  display:flex;
  flex-wrap:wrap;
  gap:6px
}
.modes button {
  font-size:10px;
  padding:9px 10px
}
.actions {
  display:flex;
  gap:8px
}
.actions button {
  padding:11px;
  font-size:12px;
  flex:1
}
.actions #pause {
  background:var(--accent);
  color:#162015;
  border-color:var(--accent)
}
details {
  margin-top:25px;
  color:var(--muted);
  font-size:11px;
  line-height:1.65
}
summary {
  cursor:pointer;
  color:var(--text);
  font-size:12px
}
details p {
  margin:12px 0
}
footer {
  display:flex;
  flex-direction:column;
  gap:7px;
  border-top:1px solid var(--line);
  padding-top:16px;
  margin-top:23px;
  font:9px monospace;
  letter-spacing:.04em;
  color:#83907e
}
footer span:last-child {
  color:#657360
}
#loading {
  position:absolute;
  top:55%;
  left:50%;
  transform:translate(-50%,-50%);
  font:12px monospace;
  width:max-content;
  color:var(--accent)
}
.pulse {
  display:inline-block;
  width:7px;
  height:7px;
  border-radius:50%;
  background:var(--accent);
  margin-right:8px;
  animation:pulse 1s infinite alternate
}
@keyframes pulse {
  to {
    opacity:.25
  }

}
#unavailable {
  position:absolute;
  inset:35% 12% auto;
  padding:28px;
  background:var(--panel);
  border:1px solid var(--line)
}
#unavailable h2 {
  font:20px Arial;
  color:var(--text)
}
#unavailable p {
  font-size:13px;
  line-height:1.6;
  color:var(--muted)
}
#unavailable a {
  font-size:13px;
  display:block;
  margin-bottom:20px
}
#retry {
  padding:8px 14px
}
#toast {
  position:fixed;
  bottom:20px;
  left:50%;
  transform:translateX(-50%);
  background:var(--accent);
  color:var(--bg);
  padding:12px 20px;
  font-size:12px;
  pointer-events:none;
  opacity:0
}
#toast.visible {
  opacity:1
}
.noscript {
  position:fixed;
  top:40%;
  left:20%;
  padding:24px;
  background:var(--panel)
}
[hidden] {
  display:none!important
}
@media(min-width:1500px) {
  aside {
    padding:32px
  }
  main {
    grid-template-columns:minmax(0,1fr) 360px
  }

}
@media(max-width:760px) {
  header {
    height:58px;
    padding:0 18px
  }
  .wordmark {
    font-size:20px
  }
  header button {
    font-size:10px
  }
  main {
    display:block;
    min-height:0
  }
  #viewport {
    position:relative;
    height:64svh;
    min-height:440px;
    max-height:680px
  }
  .caption {
    top:22px;
    left:20px
  }
  h1 {
    font-size:29px
  }
  .caption p {
    font-size:10px
  }
  .flow-label {
    top:28px;
    right:18px;
    font-size:8px
  }
  .viewport-bottom {
    bottom:17px;
    left:20px;
    right:20px
  }
  #gesture {
    font-size:9px
  }
  .legend {
    left:20px;
    bottom:65px;
    width:110px
  }
  aside {
    border-left:0;
    border-top:1px solid var(--line);
    padding:24px 20px
  }
  .panel-head {
    margin-bottom:23px
  }
  .control-group {
    padding-bottom:17px;
    margin-bottom:20px
  }
  .shapes button {
    height:74px
  }
  .note {
    min-height:0
  }
  #unavailable {
    inset:38% 6% auto;
    padding:18px
  }
  #unavailable h2 {
    font-size:17px
  }

}
@media(prefers-reduced-motion:reduce) {
  .pulse {
    animation:none
  }
  button {
    transition:none
  }

}

/* The sandbox keeps controls scrollable while the experiment stays in view. */
@media (min-width: 761px) {
  main { height: calc(100svh - 74px); min-height: 0; }
  aside { overflow-y: auto; }
}
#force-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#force-overlay path { fill: none; stroke-width: 2; stroke-linejoin: round; opacity: .9; }
#object-count { margin-left: auto; font: 10px monospace; color: var(--muted); }
#object-list { margin-top: 15px; font-size: 11px; color: var(--muted); }
.object-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 4px; border: 1px solid var(--line); padding: 8px; margin-bottom: 6px; }
.object-row.selected { border-color: var(--accent); }
.object-row button { border: 0; font-size: 11px; padding: 3px; }
.object-select { text-align: left; color: var(--object-color); }
.object-hold { color: var(--accent); }
.object-remove { color: var(--muted); font-size: 16px!important; }
.object-force { grid-column: 1 / -1; font: 9px monospace; padding-top: 4px; color: var(--muted); }
.compact { margin-top: 10px; }
.compact button { font-size: 11px; padding: 9px; }
.wide { width: 100%; padding: 10px; font-size: 12px; color: var(--accent); }
.forces { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; margin-top: 16px; }
.forces div { display: flex; flex-direction: column; gap: 7px; }
.forces span { color: var(--muted); font-size: 10px; }
.forces output { font: 14px monospace; }
.force-note { font: 9px monospace; color: var(--muted); margin: 12px 0 0; }
.editor-details { margin-top: 18px; }
.editor-details summary { font-size: 11px; }
.editor-details label { font-size: 11px; margin-top: 13px; }
.modes button[aria-pressed="true"]:not(.active) { border-color: var(--accent); color: var(--accent); }

.transport { margin-bottom: 22px; position: sticky; top: -28px; padding: 12px 0; background: var(--panel); z-index: 2; }
@media (max-width: 760px) { .transport { position: static; } }

.cow-choice { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 10px; }
.cow-choice svg { width: 45px; height: 32px; margin: 0; }
