/* Void family: canvas fills the viewport, one floating card, UI fades on
   idle. Density: tight. Surface strategy (catalog record): a flat dusk canvas
   under one opaque rounded inspector card lifted by a single soft shadow;
   controls are borderless filled wells; no glass, no blur. */

#stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--radius-control);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
}

.wordmark {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px 0 10px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--ink);
  pointer-events: none;
}

.wordmark svg {
  display: block;
  width: 27px;
  height: 22px;
}

.wordmark .mark-lead {
  fill: var(--accent);
}

.wordmark .mark-rest {
  fill: var(--ink);
}

.hud {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
  display: flex;
  gap: 8px;
  transition: opacity 0.4s ease;
}

.hud[data-idle="true"] {
  opacity: 0.18;
}

.hud:focus-within,
.hud:hover {
  opacity: 1;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
}

.icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.icon-line .icon-dot,
.icon-line .icon-fill {
  fill: currentColor;
  stroke: none;
}

.icon-line .icon-knob {
  fill: var(--surface);
}

.icon-btn[aria-pressed="true"] .icon-knob {
  fill: var(--accent);
}

/* play toggle: pressed means playing, so it offers pause */
#playToggle .icon-play,
#playToggle[aria-pressed="false"] .icon-pause {
  display: none;
}

#playToggle[aria-pressed="false"] .icon-play {
  display: block;
}

.icon-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.icon-btn:hover {
  border-color: var(--accent);
}

.icon-btn[aria-pressed="true"]:hover {
  border-color: var(--ink);
}

.panel {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 6;
  width: min(340px, calc(100vw - 36px));
  max-height: min(78vh, 720px);
  overflow-y: auto;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.panel[data-idle="true"] {
  opacity: 0.22;
  transform: translateY(4px);
}

.panel:focus-within,
.panel:hover {
  opacity: 1;
  transform: none;
}

.panel[hidden] {
  display: none;
}

.panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.field-group {
  margin-bottom: 14px;
}

.field {
  display: block;
  margin-bottom: 10px;
}

.field .label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  margin-bottom: 3px;
}

.field .label-row > span:first-child {
  color: var(--muted);
}

.field .label-row > span:last-child:not(:first-child) {
  min-width: 40px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--well);
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* The rule key (signature): each steering rule owns one colour, shown as a
   tinted chip on its weight slider and as the matching vector in the debug
   overlay. The colour sits on the dot and the tint; the name stays in ink. */
.rule-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 7px;
  border-radius: var(--radius-chip);
  background: color-mix(in srgb, var(--rule) 16%, var(--surface));
  color: var(--ink);
  font-weight: 550;
}

.field .label-row > span.rule-chip {
  color: var(--ink);
}

.rule-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rule);
}

[data-rule="sep"] {
  --rule: var(--rule-sep);
}

[data-rule="ali"] {
  --rule: var(--rule-ali);
}

[data-rule="coh"] {
  --rule: var(--rule-coh);
}

.field[data-rule] input[type="range"] {
  accent-color: var(--rule);
}

.field .hint {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
}

input[type="range"] {
  width: 100%;
  height: 44px;
  padding: 0;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  min-height: 44px;
}

select,
.text-input {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  background: var(--well);
  color: var(--ink);
  padding: 8px 10px;
  font-size: 13px;
}

.seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.seg button {
  flex: 1 1 auto;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  background: var(--well);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  padding: 8px 10px;
}

.seg button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}

.preset-grid button {
  min-height: 44px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  background: var(--well);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.preset-grid button:hover,
.seg button:hover,
.small-btn:hover,
select:hover {
  background: var(--well-hover);
}

.seg button[aria-pressed="true"]:hover,
.small-btn[aria-pressed="true"]:hover {
  background: var(--accent);
}

.small-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.small-btn {
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  background: var(--well);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

hr.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.link-row .text-input {
  flex: 1;
}

.copied-toast {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 7;
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: var(--radius-control);
  font-size: 12px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.copied-toast[data-show="true"] {
  opacity: 1;
  transform: none;
}

.notice {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
  text-align: center;
}

.notice[hidden] {
  display: none;
}

.notice-card {
  max-width: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 28px;
}

.notice-card h1 {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.notice-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 16px;
}

footer.site-footer {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  font-size: 11px;
}

footer.site-footer a {
  display: block;
  padding: 3px 10px;
  border-radius: var(--radius-chip);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .panel {
    left: 12px;
    right: 12px;
    bottom: 32px;
    width: auto;
    max-height: 56vh;
  }

  .hud {
    top: 12px;
    right: 12px;
  }

  .wordmark {
    top: 12px;
    left: 12px;
    font-size: 17px;
  }
}
