/* Shared dark theme for the WebGPU RMHD pages (landing + 2D + 3D).
   Plain <link rel="stylesheet">, so it works from file:// like the scripts do.
   Mobile-first: every control row wraps, and nothing has a fixed width that
   cannot fit inside a 360 px viewport. */
:root { color-scheme: dark;
        /* the hero Run button's two states -- deliberately desaturated, dark-palette
           tones (NOT stoplight green/red); retune these two lines after on-device */
        --run-go: #2f6b4f; --run-stop: #7a3d3d; }
body { margin: 0; padding: 12px 14px 40px; background: #14161a; color: #d8dee6;
       font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
h1 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.sub { color: #8a94a3; font-size: 12px; margin-bottom: 10px; }

/* ---- 2D / 3D tabs: chrome built once (chromeBuild), sitting on the sticky bar ----
   The active tab is a <span>, the other one an <a>; the active one is filled like the
   bar under it and gives up its own bottom edge, so the bar's top border becomes the
   tab strip's baseline. No negative margins anywhere near the sticky bar. */
#tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { padding: 4px 15px; font-size: 13px; font-weight: 600; line-height: 1.5;
       background: #14161a; color: #8a94a3; text-decoration: none;
       border: 1px solid #252a33; border-radius: 6px 6px 0 0; }
a.tab:hover { background: #1d2129; color: #a9c7e8; }
.tab.on { background: #181b21; color: #d8dee6;
          border-color: #333a45; border-bottom-color: transparent; }

/* ---- sticky bar: Run / Reset / preset / steps readout, always visible ---- */
#topbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap;
          align-items: center; gap: 8px; padding: 7px 10px; margin-bottom: 10px;
          background: #181b21; border: 1px solid #252a33; border-radius: 6px; }
#topbar label { color: #9aa5b4; }
#steps { margin-left: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
         font-size: 11.5px; color: #b8c2d0; font-variant-numeric: tabular-nums; }
/* the preset's explanatory text, moved into the sticky bar as its own last row
   (flex-wrap + width:100% puts it on a line of its own, under the buttons) */
#topbar #demohint { width: 100%; margin-top: 2px; }
/* the hero button (ONEPAGE_PLAN A.2): the one control a first-time visitor needs, so
   the one control allowed to be bigger than the rest of the bar. Colour carries the
   state -- setRunning() toggles .stop; disabled (IC editor open) drops back to the
   neutral button colour so it reads as inert, not as "will run". */
#btnRun { background: var(--run-go); font-size: 14px; font-weight: 600; padding: 6px 18px;
          border-color: color-mix(in srgb, var(--run-go), #d8dee6 14%); }
#btnRun:hover { background: color-mix(in srgb, var(--run-go), #d8dee6 9%); }
#btnRun.stop { background: var(--run-stop);
               border-color: color-mix(in srgb, var(--run-stop), #d8dee6 14%); }
#btnRun.stop:hover { background: color-mix(in srgb, var(--run-stop), #d8dee6 9%); }
#btnRun:disabled { background: #1d2129; border-color: #333a45; }

/* ---- collapsible control groups ---- */
#controls { background: #181b21; border: 1px solid #252a33; border-radius: 6px;
            padding: 4px 12px 8px; margin-bottom: 12px; }
#controls details { border-top: 1px solid #232833; padding: 2px 0; }
#controls details:first-of-type { border-top: none; }
#controls summary { cursor: pointer; color: #9fb3c8; font-size: 12px; padding: 5px 0;
                    list-style-position: outside; }
#controls summary:hover { color: #cfd8e3; }
/* the ?demo= / preset callout: one line, set off from the controls */
#demohint { border-left: 2px solid #3d5a7a; padding: 2px 0 2px 9px; margin: 6px 0;
            color: #9fb3c8; font-size: 12px; }

/* ---- display + chart columns ---- */
#display { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
#displaycol { flex: 3 1 340px; min-width: 0; }
#displays { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
#charts { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
/* the "what is all this?" rail is the LAST child of #display, so a 100% basis is what
   drops it under both columns; only past 1400px is there room for a third column beside
   them, and the canvas must never be pushed down to make space for prose */
#rail { flex: 1 1 100%; min-width: 0; max-width: 780px; margin: 0; }
@media (min-width: 1400px) { #rail { flex: 0 1 300px; max-width: 340px; } }
/* the intro pane under the subtitle: one line closed (the price everyone pays), the two
   lead paragraphs open (the first visit, until dismissed once). Width-capped for
   readability, like the rail. */
#intro { max-width: 780px; margin: 0 0 10px; }
#intro summary { cursor: pointer; color: #a9c7e8; font-size: 13px; font-weight: 600;
                 padding: 2px 0; }
#intro summary:hover { color: #cfe0f2; }
#intro .lead { margin: 6px 0 10px; }

/* ---- cards ---- */
.card.disp, .card.chart { background: #181b21; border: 1px solid #252a33; border-radius: 6px;
                          padding: 6px 8px 8px; box-sizing: border-box; }
/* container-type so .cvwrap's max-height can be written against the CARD's width (100cqw)
   rather than the viewport -- see the note there. inline-size only: the card's own height
   must stay content-driven, or the wrap's height would depend on the card's and vice versa. */
.card.disp { flex: 1 1 300px; min-width: 0; max-width: 540px; container-type: inline-size; }
.card.chart { width: 100%; }
.cardhead { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 6px; }
.cardhead select { padding: 2px 5px; font-size: 12px; max-width: 100%; }
/* a chart card's numeric option (the spectrum fit line's index / amplitude) sits beside
   its selects, so it matches them rather than the control panel's wider number boxes */
.cardhead .optnum { padding: 2px 4px; font-size: 12px; max-width: 100%; }
/* a chart card's ACTION option (the spectrum card's pin / unpin), sized like the
   selects beside it -- not like the close button, which owns the row's right edge */
.cardhead .optbtn { padding: 2px 7px; font-size: 12px; line-height: 1.2; color: #9aa5b4; }
/* a chart card's `save`: the display card's capture button, but on the header row this
   card carries instead of a caption line, so it is sized like the options beside it */
.cardhead .capbtn { padding: 2px 7px; font-size: 12px; line-height: 1.2; color: #9aa5b4; }
.cardhead .cbl { display: inline-flex; align-items: center; gap: 3px; color: #9aa5b4; font-size: 12px; }
/* a short label in front of a header slider (the volume level / opacity knobs and the
   filter handle): sized like the selects beside it, and never squeezed -- the slider is
   the flexible item on that row, not its name */
.cardhead label { flex: none; color: #9aa5b4; font-size: 12px; }
.cardhead .zslider { flex: 1 1 70px; min-width: 60px; width: auto; }
/* label + slider as ONE wrapping unit (.rngl, from _rngLab): they can never land on
   different lines, and the slider grows only within the group's cap instead of eating
   the whole row on a wide card */
.cardhead label.rngl { display: inline-flex; align-items: center; gap: 4px;
                       flex: 0 1 150px; min-width: 100px; }
.cardhead label.rngl span { flex: none; }
.cardhead label.rngl .zslider { flex: 1 1 50px; min-width: 40px; }
.cardhead button.x { margin-left: auto; padding: 1px 7px; line-height: 1.2; color: #9aa5b4; }
.viewcap { color: #7a8494; font-size: 11.5px; margin-top: 5px; }
/* a display card's FOOTER: the caption, then the colorbar and the two capture buttons
   pushed to the right edge. It wraps, so on a narrow card they drop onto their own line
   rather than squeezing the caption; nothing here is ever drawn over the field canvas. */
.viewfoot { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 10px; }
.viewfoot .viewcap { flex: 1 1 160px; min-width: 0; }
.cbar { flex: 0 0 auto; margin-left: auto; }
.cbarcv { display: block; width: 132px; height: 9px; border: 1px solid #2b303a;
          box-sizing: content-box; }
.cbartk { display: flex; justify-content: space-between; width: 134px;
          color: #7a8494; font-size: 10px; font-variant-numeric: tabular-nums;
          font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.3; }
.viewfoot .capbtn { flex: 0 0 auto; padding: 1px 6px; font-size: 11px; line-height: 1.4;
                    color: #9aa5b4; margin-bottom: 1px; }
.viewfoot .capbtn.reclive { color: #ff8b8b; border-color: #6b2a2a; }
/* save + rec are ONE flex item of the footer: the row wraps, and a wrap that dropped `rec`
   onto the next line without `save` would read as two unrelated controls on a phone. So
   the pair never wraps inside itself and never shrinks -- the caption and the colorbar do
   the wrapping around it. A hidden `rec` (no recording leg here) is out of the flex flow
   entirely, gap and all, so the group is then just the save button. */
.capgrp { display: flex; flex-wrap: nowrap; flex: 0 0 auto; gap: 6px; align-items: flex-end; }
/* a finished picture or recording waits here (recResult): size (and a video's length),
   then download / share. There can be two of these -- one per kind, a save and a take
   being two different files -- and each is a row of its own, so they stack:
   `flex: 1 0 100%` takes a whole new line of the footer, under the buttons that made it,
   so it never squeezes the caption or the colorbar and there is nothing to squeeze it
   either; it wraps on its own at a narrow card, whence the flex-wrap. */
.recres { flex: 1 0 100%; display: flex; flex-wrap: wrap; align-items: center;
          justify-content: flex-end; gap: 4px 8px; margin-top: 3px; }
.recinfo { color: #9aa5b4; font-size: 11.5px; font-variant-numeric: tabular-nums;
           margin-right: auto; }
.viewfoot .capbtn.recx { padding: 1px 5px; color: #7a8494; }

/* the border lives on the wrapper, so the absolutely-positioned overlays
   (inset 0 of the padding box) line up with the WebGPU canvas exactly at every scale */
.cvwrap { position: relative; display: block; width: auto;
          border: 1px solid #2b303a; box-sizing: border-box; aspect-ratio: 1 / 1;
          /* A card sizes from its WIDTH, so an aspect-correct card taller than it is wide
             (the tall 2pi x 8pi box: 1/4, hence 4x the card width in height) would run off
             the screen -- 2160 px at the 540 px max card width. Cap the height at the
             card's own width, i.e. at the height a SQUARE box would have had, and let the
             ratio take it out of the width instead: a tall card becomes narrow, not long.
             `100cqw` is the card's content width (container-type below); with `width: auto`
             and a definite max-height, aspect-ratio resolves the width from the height, so
             this is inert for every box with h <= w and nothing about the square and wide
             cards changes. Container queries predate every browser version that has
             WebGPU, so this needs no fallback. */
          max-height: 100cqw; margin-inline: auto; }
.cvmain { width: 100%; height: 100%; background: #000; image-rendering: auto; display: block; }
.cvvec { position: absolute; left: 0; top: 0; width: 100%; height: 100%;
         display: block; pointer-events: none; }
/* IC blob editor: its own VIEW (#editview replaces #display while editing), so the
   canvas is an ordinary card canvas and nothing is ever painted over a live display.
   touch-action: none keeps a drag from scrolling the page. */
.cvedit { width: 100%; height: 100%; display: block; background: #000;
          cursor: crosshair; touch-action: none; }
#editview { margin-bottom: 12px; }
#editview .card.disp { max-width: 540px; }
#editview .cardhead b { color: #a9c7e8; font-weight: 600; }

canvas.chart { display: block; width: 100%; height: auto; background: #0f1115;
               border: 1px solid #2b303a; }
.panel { min-width: 260px; max-width: 980px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 5px 0; }
.row label { width: auto; color: #9aa5b4; flex: none; }
.row input[type=range] { flex: 1 1 110px; min-width: 90px; max-width: 160px; }
.row .val { width: 64px; text-align: right; font-variant-numeric: tabular-nums; color: #cfd8e3; }
/* a label and the control it names, as ONE flex item of the row (_ctrlRow): the row can
   still wrap anywhere it likes, but never BETWEEN a slider and its name. Same bargain as
   .cardhead label.rngl above, applied to the control panel; the group is what wraps, the
   slider is the flexible thing inside it. The internal gap is tighter than the row's, so
   a group reads as one control rather than three neighbours. */
.row .ctlg, #topbar .ctlg { display: inline-flex; align-items: center; gap: 6px;
                            flex: 0 1 auto; min-width: 0; }
.row .ctlg > label { flex: none; }
/* the slider is the only part allowed to give ground, and only down to a thumb-sized
   minimum -- past that the whole group wraps instead of the label shearing off. The
   BASIS is the old max-width, not the old basis: a slider used to be a flex item of the
   row and grew into it, and it is now inside a shrink-to-fit box, so 110 here would have
   quietly narrowed every slider on the page to its minimum. At 160 the desktop widths
   are what they were, and the shrink to 80 is what buys the phone its single line. */
.row .ctlg > input[type=range] { flex: 1 1 160px; min-width: 80px; max-width: 160px; }
.row .ctlg > .val { flex: none; }
select, input[type=number], input[type=text], button { background: #1d2129; color: #d8dee6;
    border: 1px solid #333a45; border-radius: 4px; padding: 4px 8px; font: inherit;
    max-width: 100%; }
button { cursor: pointer; }
button:hover { background: #262c36; }
button:disabled { opacity: 0.5; cursor: default; }
#readout { margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
           font-size: 11.5px; color: #b8c2d0; white-space: pre-wrap; }
#status { margin-top: 10px; padding: 8px 10px; border-radius: 4px; font-size: 12px; display: none; }
#status.err { display: block; background: #3a1d1d; color: #ffb4b4; border: 1px solid #6b2a2a; }
#status.info { display: block; background: #1b2430; color: #a9c7e8; border: 1px solid #2c3d52; }
table { border-collapse: collapse; margin-top: 10px; font-size: 12px;
        font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
th, td { border: 1px solid #2b303a; padding: 3px 9px; text-align: left; }
th { background: #1d2129; color: #9aa5b4; font-weight: 600; }
.pass { color: #7fd18b; } .fail { color: #ff8b8b; } .note { color: #9aa5b4; }
hr { border: none; border-top: 1px solid #262b34; margin: 16px 0 10px; }
/* overflow-wrap because the expression error line is the first .hint whose text the
   USER writes: a long unbroken identifier has no break opportunity and would run out of
   a 360px panel. */
.hint { color: #7a8494; font-size: 11.5px; margin-top: 6px; overflow-wrap: anywhere; }
a { color: #7aa7d8; } a:hover { color: #a9c7e8; }

/* narrow window (phone / half-screen): one column, cards full width */
@media (max-width: 700px) {
  body { padding: 10px 10px 32px; }
  #display { flex-direction: column; }
  /* flex: none here as well as width: a 100% BASIS in a column container would be 100%
     of the height, not the width */
  #displaycol, #charts, #rail { width: 100%; flex: none; }
  .card.disp { flex: 1 1 100%; max-width: none; }
  .row .val { width: 58px; }
}

/* ---- the base card box. Written for the landing page's two link cards (gone with
   index.html, ONEPAGE_PLAN B.4), but the app cards inherit from it -- most notably the
   flex line, which is what gives a chart card its height inside the column #charts --
   so it stays here rather than being folded into .card.disp / .card.chart. ---- */
.card { display: block; flex: 1 1 300px; max-width: 460px; text-decoration: none;
        background: #181b21; border: 1px solid #252a33; border-radius: 8px;
        padding: 14px 16px; color: #d8dee6; }
.lead { max-width: 780px; }

/* ---- collapsible prose panes: docs.html, and the what-is rail on both apps ---- */
.panes { margin: 16px 0 6px; max-width: 780px; }
.panes details { background: #181b21; border: 1px solid #252a33; border-radius: 6px;
                 padding: 0 14px; margin-bottom: 8px; }
.panes details[open] { padding-bottom: 10px; }
.panes summary { cursor: pointer; color: #a9c7e8; font-size: 14px; font-weight: 600;
                 padding: 9px 0; }
.panes summary:hover { color: #cfd8e3; }
.panes p, .panes ol { margin: 6px 0 10px; color: #c6cdd7; }
.panes ol { padding-left: 22px; }
.panes li { margin-bottom: 8px; }
.panes blockquote { margin: 6px 0 10px; padding: 2px 0 2px 12px;
                    border-left: 2px solid #3d5a7a; color: #9fb3c8; font-style: italic; }
.panes .attrib { color: #7a8494; font-size: 11.5px; font-style: normal; }
