/* The Bench: the prototype's dark "lab bench" look. Single dark theme by choice. */
body.bench {
  color-scheme: dark;
  --ink: #0d1322; --panel: #151d31; --line: #29344f; --text: #e1e6f2; --muted: #8a95b0; --void: #04060b;
  /* Orb colors 0–2: Gulf livery orange and sky blue (Pantone 1585 C / 291 C), plus mint. They also color the wordmark. */
  --orange: #ff6a13; --sky: #9bcbeb; --mint: #4fd6a0;
  --gold: #f4c24d; /* UI highlight only (selection, stars, warnings); no longer an orb color */
  --display: "Syne", "Avenir Next", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 20px max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left));

  .wrap { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
  header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; }
  h1 { font-family: var(--display); font-weight: 800; font-size: clamp(28px, 5vw, 44px); letter-spacing: -0.02em; margin: 0; line-height: 1; }
  h1 .kin { color: var(--orange); } h1 .odd { color: var(--sky); }
  h1 em { font-style: normal; font-weight: 600; font-size: .5em; color: var(--muted); margin-left: 10px; vertical-align: middle; }
  h2 { font-family: var(--display); font-weight: 600; font-size: 18px; margin: 0; }
  .rule { color: var(--muted); max-width: 60ch; margin: 0; }
  .rule b { color: var(--text); font-weight: 500; }

  .stage { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--void); max-width: 860px; width: 100%; margin: 0 auto; }
  .stage canvas { display: block; cursor: grab; }

  .bar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; }
  .info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 260px; }
  .lvl { font-family: var(--display); font-weight: 600; font-size: 18px; }
  .hint, .legend, .status { color: var(--muted); }
  .legend { font-size: 12px; margin: 0; }
  .status { min-height: 1.2em; margin: 0; }
  .btns, .presets { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

  button, select, input, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
  button { padding: 8px 14px; cursor: pointer; }
  button:hover { border-color: var(--muted); }
  button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
  button.primary { background: var(--text); color: var(--ink); border-color: var(--text); }
  button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
  select, input[type="text"], input[type="number"] { padding: 7px 8px; }
  textarea { width: 100%; box-sizing: border-box; padding: 8px; resize: vertical; }
  .speed { display: flex; gap: 6px; align-items: center; color: var(--muted); }

  .levels { display: flex; gap: 6px; flex-wrap: wrap; }
  .levels button { padding: 6px 10px; min-width: 36px; }
  .levels button[aria-current="true"] { border-color: var(--gold); color: var(--gold); }

  .columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; align-items: start; }
  @media (max-width: 760px) { .columns { grid-template-columns: minmax(0, 1fr); } }
  .card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }

  fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 10px; padding: 8px 10px 4px; min-width: 0; }
  legend { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; padding: 0 4px; }
  .param { display: grid; grid-template-columns: minmax(0, 9em) minmax(0, 1fr) 7.5em auto; gap: 8px; align-items: center; padding: 4px 4px; border-radius: 6px; border: 1px solid transparent; }
  .param .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .param input[type="range"] { width: 100%; accent-color: var(--sky); min-width: 0; }
  .param input[type="number"] { width: 100%; box-sizing: border-box; font-variant-numeric: tabular-nums; }
  .param .reset { padding: 4px 8px; visibility: hidden; }
  .param.changed { border-color: var(--gold); }
  .param.changed .reset { visibility: visible; }
  .param.off-default .name::after { content: " •"; color: var(--orange); }
  @media (max-width: 480px) {
    .param { grid-template-columns: minmax(0, 1fr) 6.5em auto; }
    .param input[type="range"] { grid-column: 1 / -1; grid-row: 2; }
  }

  .results ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
  .results li { display: flex; gap: 8px; align-items: baseline; font-variant-numeric: tabular-nums; }
  .results li span { min-width: 3.5em; }
  .results li small { color: var(--muted); }
  .results li.ok span { color: var(--mint); }
  .results li.bad span, .results li.bad small { color: var(--orange); }
  .results p { margin: 0 0 8px; color: var(--muted); }

  [hidden] { display: none !important; }
  a { color: var(--sky); }
  a.button { display: inline-block; text-decoration: none; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); color: var(--text); background: var(--panel); }
  a.button.primary { background: var(--text); color: var(--ink); border-color: var(--text); }
  button:disabled { opacity: .4; cursor: default; }
  button.danger { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 40%, var(--line)); }

  .benchnav { max-width: 1100px; margin: 0 auto 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
  .benchnav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border: 1px solid transparent; border-radius: 6px; }
  .benchnav a[aria-current="page"] { color: var(--text); border-color: var(--line); background: var(--panel); }
  .benchnav .notice { color: var(--gold); margin-left: auto; }

  .levelgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
  .levelcard a { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); text-decoration: none; }
  .levelcard a:hover { border-color: var(--muted); }
  .levelcard .title { font-family: var(--display); font-weight: 600; font-size: 15px; display: flex; gap: 8px; }
  .levelcard .meta { color: var(--muted); font-size: 12px; }
  .levelcard[draggable="true"] { cursor: grab; }
  .levelcard.dragging { opacity: .4; }
  .levelcard .num { color: var(--gold); font-family: var(--mono); font-weight: 500; font-size: 13px; }
  .thumb { display: block; width: 100%; height: auto; background: var(--void); border-radius: 6px;
           background-image: linear-gradient(rgb(138 149 176 / .07) 1px, transparent 1px), linear-gradient(90deg, rgb(138 149 176 / .07) 1px, transparent 1px);
           background-size: 5% 8%; } /* one cell = 40 field units; the helper sets it per world size */

  .field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
  .field input, .field textarea { color: var(--text); }
  .check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); align-self: flex-end; padding-bottom: 8px; }
  .tray, .world { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
  .tray .name, .world .name { color: var(--muted); margin-right: 4px; }
  .world input { width: 5.5em; }
  .world button { padding: 6px 10px; }
  .addc { display: inline-flex; align-items: center; padding: 8px 11px; }
  .addc[aria-pressed="false"] .sw { opacity: .25; }
  .sw { display: inline-block; width: 12px; height: 12px; transform: rotate(45deg); border-radius: 2px; }
  .sw.c0 { background: var(--orange); } .sw.c1 { background: var(--sky); } .sw.c2 { background: var(--mint); }
  .sw.c3 { background: var(--text); } .sw.c4 { background: var(--ink); box-shadow: inset 0 0 0 2px var(--text); }

  .ok { color: var(--mint); } .warn { color: var(--gold); } .bad { color: var(--orange); }
  .results p.ok, .results p.warn, .results p.bad { margin: 6px 0 0; }
  .evgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
  .evgrid span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
  .evgrid b { font-weight: 500; font-size: 18px; font-variant-numeric: tabular-nums; }
  .progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
  .progress i { display: block; height: 100%; width: 0; background: var(--sky); }

  /* Sandbox: My levels */
  .mylevels { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .mylevel { display: flex; flex-direction: column; gap: 6px; }
  .mylevel .title { font-weight: 600; }
  .mylevel .meta { color: var(--muted); }
}
