*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    height: 100vh;
    /* The visible viewport, where the browser's own chrome takes a bite out of
       100vh and the dock went under it. */
    height: 100dvh;
    overflow: hidden;
    /* Near-black grey with a purple cast, not a purple. The canvas is painted
       a shade darker in app.js, so the field still reads as inset against it. */
    background-color: #0a090e;
    color: #eee;
    font-family: Arial, "PC Glyphs", sans-serif;
    position: relative;
}

.controlPanel {
    background: rgba(34, 34, 34, 0.8);
    padding: 10px;
    z-index: 10;
    border-radius: 4px;
}

.controlPanel label,
.controlPanel button,
.controlPanel select,
.controlPanel input,
.controlPanel div:not(.controlRow) {
    margin-top: 4px;
    display: block;
}

/*
 * Ensure collapsible sections inside the controls menu can be hidden.
 * Without this override, the display:block rule above prevents the
 * generic `.sectionContent.collapsed` style from taking effect.
 */
.controlPanel .sectionContent.collapsed {
    display: none;
}

#controlButtons,
#pulseRow,
#genesisRow {
    display: flex;
    gap: 6px;
}

#pulseRow {
    align-items: center;
}

#infoLinks {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    margin-bottom: 0;
}
#infoLinks a {
    color: #fff;
    text-decoration: none;
}

#grid {
    /* What shows before the first frame is painted; app.js fills the same
       colour from then on. */
    background: #08070a;
    display: block;
}

#tools {
    background: rgba(34, 34, 34, 0.8);
    padding: 10px;
    z-index: 10;
    border-radius: 4px;
}

#tools select,
#tools input,
#tools button {
    margin-top: 4px;
    display: block;
}

#patternSaver {
    background: rgba(34, 34, 34, 0.8);
    padding: 10px;
    z-index: 10;
    border-radius: 4px;
}

#patternSaver input,
#patternSaver button {
    margin-top: 4px;
    display: block;
}

.infoSection {
    background: rgba(34, 34, 34, 0.8);
    padding: 10px;
    z-index: 10;
    border-radius: 4px;
    color: #eee;
}

/* The toggle, the drawer, its columns and its phone rules were all here.
   They are rebuilt further down, after the section-header styles they need
   to override. */

.popupOverlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(34, 34, 34, 0.95);
    padding: 20px;
    border-radius: 4px;
    /* Above the drawer and the dock: these are read on top of everything,
       and the drawer it used to out-rank is now a far higher layer. */
    z-index: 960;
    max-width: 80%;
    max-height: 80%;
    overflow-y: auto;
    display: none;
}

.popupOverlay.show {
    display: block;
}

.popupOverlay .closePopup {
    position: absolute;
    top: 5px;
    right: 8px;
    background: transparent;
    color: #eee;
    border: none;
    font-size: 18px;
    cursor: pointer;
}


#novaOverlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: 48px;
    color: #fff;
    pointer-events: none;
    opacity: 0;
}

#novaOverlay.show {
    animation: nova-fade 1.5s ease-out forwards;
}

#novaOverlay.prompt {
    opacity: 1;
    animation: none;
}

@keyframes nova-fade {
    from { opacity: 1; }
    to { opacity: 0; }
}

#novaInfoContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#novaInfoContainer .novaInfoBox,
.novaInfoBox {
    position: absolute;
    background: rgba(34, 34, 34, 0.95);
    padding: 10px;
    border-radius: 4px;
    color: #eee;
    z-index: 40;
    display: none;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.novaInfoBox.show {
    display: block;
}

#resolutionWarning {
    color: #f88;
    font-weight: bold;
    margin-left: 4px;
    display: none;
}

#stateLabel {
    margin-left: 8px;
}

#stateLabel.pulse-start {
    animation: pulse-glow 0.3s ease-out;
}

.sectionHeader {
    cursor: pointer;
    margin-top: 10px;
    position: relative;
}

button.sectionHeader {
    background: #444;
    color: #fff;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
}

.sectionHeader::after {
    content: '▲';
    margin-left: 4px;
    font-size: 0.8em;
}

.sectionHeader.collapsed::after {
    content: '▼';
}

.sectionContent.collapsed {
    display: none;
}

@keyframes pulse-glow {
    from { box-shadow: 0 0 6px #fff; }
    to { box-shadow: none; }
}

/* ======================================================================
   The settings drawer, the dock and the readouts
   ----------------------------------------------------------------------
   This was one 520px slab that opened by default and sat over the
   simulation, with Start and Stop buried in its first section and the
   counters hidden behind it in the very same corner. Now the drawer is a
   drawer, the transport floats clear of it, and the readouts take the
   opposite corner.
   ====================================================================== */

body {
    --pc-drawer-w: min(460px, 100vw);
    /* The glass the site bar uses (--sb-bg in sitebar.css). Hardcoded because
       that token is scoped under .pc-sitebar and cannot be reached from here.
       The dock and the readouts keep it: they are small and sit over a moving
       field, so they need the backing. */
    --pc-surface: rgba(10, 11, 13, .82);
    /* The panel is large enough to take far less, and the field showing through
       it is the point. The blur goes up as the alpha comes down, so what shows
       through stays a suggestion rather than competing with the controls. */
    --pc-panel:   rgba(10, 11, 13, .58);
    --pc-line: #2a2e37;
    --pc-text: #e6e9ef;
    --pc-dim: #98a0ae;
    --pc-teal: #35e8e0;
    --pc-pink: #ff3366;
    --pc-field: rgba(255, 255, 255, .06);
}

/* ---- The drawer ------------------------------------------------------ */

/* It hangs below the site bar rather than over it, so the nav stays
   reachable while it is open. The page measures the bar and says how tall. */
#slideMenu {
    position: fixed;
    /* The fallback is the bar's usual height, not zero: at zero this panel's
       header, and on a phone the only button that closes it, hides behind a
       site bar that out-ranks it. The page refines the figure; it must never
       be the difference between closable and stuck. */
    top: var(--pc-bar-h, 56px);
    right: 0;
    /* Stops short of the consent bar, so its last section is not sitting
       underneath it. The page measures the bar; see --pc-consent-h. */
    bottom: var(--pc-consent-h, 0px);
    z-index: 880;
    display: flex;
    flex-direction: column;
    width: var(--pc-drawer-w);
    padding: 0;
    color: var(--pc-text);
    background: var(--pc-panel);
    backdrop-filter: blur(17px);
    border-left: 1px solid var(--pc-line);
    box-shadow: -18px 0 50px rgba(0, 0, 0, .5);
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    overflow: hidden;
}
#slideMenu.open { transform: translateX(0); }

.pc-drawer-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    background: rgba(0, 0, 0, .25);
    border-bottom: 1px solid var(--pc-line);
}
.pc-drawer-title {
    margin: 0;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--pc-dim);
}
/* It says what it does now, so it is sized to words rather than to a glyph.
   The accessible name keeps "settings" on the end, which the visible label is
   allowed to be shorter than. */
#menuClose {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 11px;
    font: inherit;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    line-height: 1;
    color: var(--pc-dim);
    background: transparent;
    border: 1px solid var(--pc-line);
    border-radius: 9px;
    cursor: pointer;
}
/* The cross carries the weight the word does not. */
#menuClose span { font-size: 1.5em; line-height: 0; }
#menuClose:hover { color: var(--pc-text); background: rgba(255, 255, 255, .07); }

/* Start and Stop again, at the top of the panel and outside the scroll, so
   they are there whether or not the drawer is covering the dock. */
.pc-drawer-transport {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--pc-line);
}
/* Outlined, not filled. A solid slab of colour sat on top of a panel you can
   now see through; a thin line in the same neon sits in front of it. Each keeps
   its own colour in both states, so which button is which never depends on
   reading the word. */
.panelBtn {
    flex: 1 1 0;
    min-height: 40px;
    padding: 0 12px;
    font: inherit;
    font-size: .92rem;
    font-weight: 600;
    background: transparent;
    border: 1px solid var(--pc-line);
    border-radius: 9px;
    cursor: pointer;
    transition: border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.panelBtn-go   { color: var(--pc-teal); border-color: rgba(53, 232, 224, .4); }
.panelBtn-stop { color: var(--pc-pink); border-color: rgba(255, 51, 102, .4); }
.panelBtn-go:hover:not(:disabled) {
    border-color: var(--pc-teal);
    background: rgba(53, 232, 224, .08);
}
.panelBtn-stop:hover:not(:disabled) {
    border-color: var(--pc-pink);
    background: rgba(255, 51, 102, .08);
}

/* Selected — the state the simulation is already in, which is why it cannot be
   pressed. The same outline at full strength with the neon lit behind it,
   rather than dimmed out of the way. */
.panelBtn:disabled { cursor: default; }
.panelBtn-go:disabled {
    border-color: var(--pc-teal);
    background: rgba(53, 232, 224, .07);
    box-shadow: inset 0 0 12px rgba(53, 232, 224, .12),
                0 0 10px rgba(53, 232, 224, .14);
}
.panelBtn-stop:disabled {
    border-color: var(--pc-pink);
    background: rgba(255, 51, 102, .07);
    box-shadow: inset 0 0 12px rgba(255, 51, 102, .12),
                0 0 10px rgba(255, 51, 102, .14);
}

/* The panel stays put; only this scrolls. */
.pc-drawer-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 14px 26px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Two half-width columns inside a 460px drawer left every label fighting its
   own field for room. One column, in reading order. */
.leftColumn,
.rightColumn {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}
.spanTwo { width: 100%; }

/* ---- Sections inside it --------------------------------------------- */

#slideMenu .section {
    border: 1px solid var(--pc-line);
    border-radius: 10px;
    background: rgba(255, 255, 255, .02);
    overflow: hidden;
}
/* The panels carried their own slab backgrounds, which inside a panel read as
   boxes within boxes. */
#slideMenu .controlPanel,
#slideMenu .infoSection,
#slideMenu #tools,
#slideMenu #patternSaver {
    padding: 0;
    background: none;
    border-radius: 0;
}
#slideMenu #tools,
#slideMenu #patternSaver {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#slideMenu .sectionHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0;
    padding: 11px 13px;
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-align: left;
    color: var(--pc-text);
    background: rgba(255, 255, 255, .04);
    border: 0;
    border-radius: 0;
    cursor: pointer;
}
#slideMenu .sectionHeader:hover { background: rgba(255, 255, 255, .07); }
/* One mark that turns, rather than two that swap. */
#slideMenu .sectionHeader::after {
    content: '\25be';
    margin: 0;
    font-size: .9em;
    color: var(--pc-dim);
    transition: transform .18s ease;
}
#slideMenu .sectionHeader.collapsed::after { content: '\25be'; transform: rotate(-90deg); }

#slideMenu .sectionContent {
    display: flex;
    flex-direction: column;
    gap: 11px;
    padding: 12px 13px 14px;
}

/* ---- Fields ---------------------------------------------------------- */

/* Block, not a flex column: these labels wrap their own field and their text
   is several nodes -- words, an info glyph, a colon, sometimes a value readout.
   As flex items each of those took a line of its own. */
#slideMenu label {
    display: block;
    margin: 0;
    font-size: .79rem;
    line-height: 1.5;
    color: var(--pc-dim);
}
#slideMenu label > input:not([type="checkbox"]),
#slideMenu label > select {
    display: block;
    margin-top: 5px;
}
#slideMenu label > input[type="checkbox"] {
    margin-right: 8px;
    vertical-align: -2px;
}
/* The readout beside a slider's name, not under it. */
#slideMenu label > span { color: var(--pc-text); }
/* A select's popup list is drawn by the browser, which had no idea this panel
   was dark and rendered white-on-white. This is what tells it. */
#slideMenu,
#slideMenu select,
#slideMenu input {
    color-scheme: dark;
}
#slideMenu select option,
#slideMenu select optgroup {
    color: var(--pc-text);
    background: #1b1e24;
}

#slideMenu input[type="number"],
#slideMenu input[type="text"],
#slideMenu select {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    font: inherit;
    font-size: .92rem;
    color: var(--pc-text);
    background: var(--pc-field);
    border: 1px solid var(--pc-line);
    border-radius: 8px;
}
#slideMenu input[type="number"]:focus,
#slideMenu input[type="text"]:focus,
#slideMenu select:focus {
    outline: none;
    border-color: var(--pc-teal);
}
#slideMenu input[type="range"] {
    width: 100%;
    min-height: 26px;
    accent-color: var(--pc-teal);
}
#slideMenu input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--pc-teal);
}
/* A checkbox reads as a thing you switch, so its words get the brighter ink. */
#slideMenu label:has(> input[type="checkbox"]) {
    font-size: .88rem;
    color: var(--pc-text);
}
#slideMenu input[type="color"] {
    width: 54px;
    height: 34px;
    padding: 2px;
    background: var(--pc-field);
    border: 1px solid var(--pc-line);
    border-radius: 8px;
}
#slideMenu input[type="file"] { font-size: .82rem; color: var(--pc-dim); }

#slideMenu .controlRow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
#slideMenu #stateLabel {
    margin: 0;
    padding: 7px 10px;
    font-size: .82rem;
    color: var(--pc-teal);
    background: rgba(53, 232, 224, .08);
    border-radius: 8px;
}
#slideMenu #pulseCounterDisplay { font-size: .82rem; color: var(--pc-dim); }

#slideMenu button:not(.sectionHeader):not(#menuClose) {
    min-height: 36px;
    padding: 8px 12px;
    font: inherit;
    font-size: .88rem;
    color: var(--pc-text);
    background: rgba(255, 255, 255, .07);
    border: 1px solid var(--pc-line);
    border-radius: 8px;
    cursor: pointer;
}
#slideMenu button:not(.sectionHeader):not(#menuClose):hover {
    background: rgba(255, 255, 255, .12);
}
/* It clears every stored thing, so it does not look like Clear. */
#slideMenu #hardResetBtn {
    color: #ffb3c1;
    border-color: rgba(255, 51, 102, .4);
    background: rgba(255, 51, 102, .1);
}

#slideMenu #infoLinks {
    gap: 12px;
    margin: 0;
    padding-top: 12px;
    font-size: .84rem;
    border-top: 1px solid var(--pc-line);
}
#slideMenu #infoLinks a { color: var(--pc-dim); }
#slideMenu #infoLinks a:hover { color: var(--pc-teal); }
#slideMenu #infoLinks span { color: var(--pc-line); }

/* ---- The dock -------------------------------------------------------- */

#simDock {
    position: fixed;
    right: 14px;
    /* Above the consent bar, which owns the bottom of the page. */
    bottom: calc(14px + var(--pc-consent-h, 0px));
    z-index: 890;
    display: flex;
    align-items: center;
    gap: 8px;
    /* Tighter top and bottom than the sides: the buttons already carry their
       own height, so the chrome only has to frame them. */
    padding: 5px 8px;
    background: var(--pc-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--pc-line);
    border-radius: 13px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    transition: right .28s cubic-bezier(.4, 0, .2, 1), opacity .2s ease,
                bottom .3s cubic-bezier(.4, 0, .2, 1);
}
.dockBtn {
    min-width: 66px;
    min-height: 40px;
    padding: 0 12px;
    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    color: var(--pc-text);
    background: rgba(255, 255, 255, .08);
    border: 1px solid var(--pc-line);
    border-radius: 10px;
    cursor: pointer;
}
.dockBtn-go {
    color: #06251f;
    background: linear-gradient(135deg, var(--pc-teal), #17b8b2);
    border-color: transparent;
}
.dockBtn-stop {
    color: #2b0512;
    background: var(--pc-pink);
    border-color: transparent;
}
.dockBtn:disabled { opacity: .35; cursor: default; }
.dockBtn-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 0;
}
.dockBurger { position: relative; display: block; width: 16px; height: 2px; }
.dockBurger,
.dockBurger::before,
.dockBurger::after {
    background: currentColor;
    border-radius: 2px;
}
.dockBurger::before,
.dockBurger::after {
    content: "";
    position: absolute;
    left: 0;
    width: 16px;
    height: 2px;
}
.dockBurger::before { top: -5px; }
.dockBurger::after { top: 5px; }

/* Steps aside for the drawer instead of hiding under it. */
body.menu-open #simDock { right: calc(var(--pc-drawer-w) + 14px); }

/* ---- The readouts ---------------------------------------------------- */

/* The opposite corner from the dock. They used to share one. */
#liveCounters {
    position: fixed;
    left: 14px;
    right: auto;
    bottom: calc(14px + var(--pc-consent-h, 0px));
    top: auto;
    z-index: 870;
    display: grid;
    gap: 3px;
    padding: 9px 12px;
    font-size: .8rem;
    color: var(--pc-text);
    background: var(--pc-surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--pc-line);
    border-radius: 12px;
}
#liveCounters span { color: var(--pc-teal); font-variant-numeric: tabular-nums; }
/* Rises with the dock, on the same easing as the bar that displaces both. */
#liveCounters { transition: bottom .3s cubic-bezier(.4, 0, .2, 1); }
body.menu-open #liveCounters { left: 14px; right: auto; }

@media (max-width: 700px) {
    /* Full width, so there is nothing for the dock to step aside to: it goes
       instead, and the drawer's own close button brings it back. */
    body.menu-open #simDock {
        right: 14px;
        opacity: 0;
        pointer-events: none;
    }
    .dockBtn { min-width: 60px; padding: 0 10px; font-size: .9rem; }
    #liveCounters { font-size: .74rem; padding: 7px 10px; }
}

@media (prefers-reduced-motion: reduce) {
    #slideMenu, #simDock, #liveCounters, .panelBtn { transition: none; }
}

/* Styles for admin pages */
body.adminPage {
    background: #fff;
    color: #000;
    font-family: sans-serif;
    height: auto;
    overflow: auto;
}

body.nova-detail {
    font-family: monospace;
    white-space: pre-wrap;
}

body.nova-data table {
    border-collapse: collapse;
    width: 100%;
}

body.nova-data th,
body.nova-data td {
    border: 1px solid #ccc;
    padding: 4px;
    text-align: left;
}

body.nova-data thead tr.group th {
    background: #f0f0f0;
}

body.nova-data .climax-row th {
    background: #eef;
    cursor: pointer;
}

body.nova-data .climax-group-row th {
    background: #ddd;
    cursor: pointer;
}

body.nova-data .nova-detail-row {
    display: none;
}

body.nova-data .climax-row {
    display: none;
}

body.nova-data .tension-high {
    background-color: #ffdddd;
}

body.nova-data .energy-high {
    background-color: #e0ffe0;
}

#feed-error {
    display: none;
    color: red;
    margin: 8px 0;
}

#phaseModeControls {
    margin-top: 5px;
}

#patternUploadBtn {
    display: none;
}

body.nova-data a.nova-hash {
    color: #ff3366;
}

body.nova-data .climax-row .toggle {
    padding: 0 4px;
    border-radius: 3px;
    transition: background 0.2s;
}

body.nova-data .climax-row:hover .toggle {
    background: #ccc;
    cursor: pointer;
}

body.nova-data .climax-group-row .toggle {
    padding: 0 4px;
    border-radius: 3px;
    transition: background 0.2s;
}

body.nova-data .climax-group-row:hover .toggle {
    background: #ccc;
    cursor: pointer;
}

/* ---- Phones (2026-10-18): no zoom on focus, thumb-sized drawer controls ---- */
@media (max-width: 700px) {
    /* iOS zooms into any field under 16px when it gets focus, and stays zoomed. */
    #slideMenu input, #slideMenu select, #slideMenu textarea { font-size: 16px; }
    #slideMenu input[type="range"] { min-height: 36px; }
    #slideMenu #infoLinks { flex-wrap: wrap; gap: 4px 6px; }
    #slideMenu #infoLinks a { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 6px; }
}
