/* =====================================================================
   VoxEx tool theme — the ONE stylesheet every page in tools/ and the
   launcher (index.html) link. It carries the game's design tokens and
   the shared tool shell (nav bar, page header, panels, buttons, status
   stripes) so the tools read as the same product as voxEx.html.

   TOKENS: the :root block below is a COPY of the "DESIGN TOKENS" block
   at the top of voxEx.html's <style> (CCR-UI-TOKENS-001), minus the
   touch/HUD runtime vars. Every name here must carry the same value as
   in voxEx.html — tools/parity-check.mjs P14 fails on drift. Change a
   token in voxEx.html first, then copy it here.

   RULES (the VoxEx design system):
   - Dark only. Neutral ladder bg → panel → panel-2 → elem → border.
   - Green is the brand, the selected option, or where focus is. Blue
     means "info". Status is a stripe/border plus a word, never a fill.
   - Squares, not circles: no border-radius: 50% anywhere.
   - Radii: --r-sm (4) small buttons, --r (6) controls, --r-lg (12) panels.
   ===================================================================== */
:root {
    /* Tier 1 — ui-mockups.html :root (approved) */
    --bg: #1a1a1a; --bg-0: #141414; --panel: #222; --panel-2: #2a2a2a; --elem: #333;
    --elem-2: #3a3a3a; --border: #444; --border-2: #333; --line: #2a2a2a;
    --green: #4caf50; --green-d: #45a049; --green-dd: #2d4a2d; --lime: #8bc34a;
    --blue: #2196f3; --orange: #ff9800; --amber: #ffc107; --red: #f44336;
    --gold: #ccaa00; --gold-bg: #aa8800;
    --text: #fff; --text-2: #ccc; --text-3: #aaa; --muted: #999; --muted-2: #8a8a8a;
    --font: 'Segoe UI', system-ui, sans-serif; --mono: 'Consolas', 'Courier New', monospace;
    /* Tier 2 — game surfaces */
    --black: #000; --bg-sunken: #111; --bg-1: #161616; --field: #1c1c1c; --field-hover: #252525;
    --elem-3: #444; --elem-4: #555; --elem-5: #666; --border-3: #555; --border-4: #666;
    --text-soft: #eee; --knob-off: #aaa;
    /* Tier 3 — semantic roles */
    --btn-primary-bg: #2e7d32; --btn-primary-bg-hover: #27692a;
    --btn-info-bg: #1976d2;
    --btn-gold-bg: #806600;
    --btn-disabled-bg: #666;
    --green-dd-hover: #3a5a3a; --green-l: #81c784;
    --select-bg: #2d3a4d; --select-border: #4488cc;
    --info-dd: #2a3a4a; --info-border: #3a5a7a;
    --danger-bg: #5a3030; --danger-bg-hover: #7a4040; --danger-text: #faa; --error-text: #ff6b6b; --red-2: #ff5722;
    --warn-border: #d69a2d; --warn-text: #ffcf7a; --notice: #ffcc00;
    /* Tier 4 — channel triples (alpha at the use site: rgba(var(--rgb-black), 0.5)) */
    --rgb-black: 0, 0, 0; --rgb-white: 255, 255, 255; --rgb-green: 76, 175, 80; --rgb-green-btn: 46, 125, 50;
    --rgb-panel: 20, 20, 20; --rgb-blue: 33, 150, 243; --rgb-orange: 255, 152, 0;
    /* Tier 5 — radius + spacing scales */
    --r-xs: 3px; --r-sm: 4px; --r: 6px; --r-md: 8px; --r-lg: 12px;
    --sp-xs: 4px; --sp-sm: 8px; --sp-md: 12px; --sp-lg: 16px; --sp-xl: 20px; --sp-2xl: 24px;
}

/* Form controls inherit the one font stack instead of the UA font. */
button, input, select, textarea { font-family: inherit; }

/* ===== Shared tool navigation (was a hand-copied block in every tool) ===== */
.voxex-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-xs);
    padding: var(--sp-sm) var(--sp-lg);
    background: var(--bg-0);
    border-bottom: 1px solid var(--border-2);
    flex-shrink: 0;
    font-family: var(--font);
}
.voxex-nav-back,
.voxex-nav-link {
    padding: 6px 12px;
    background: var(--panel-2);
    border: 1px solid var(--elem-2);
    border-radius: var(--r-sm);
    color: var(--text-3);
    text-decoration: none;
    font-size: 12px;
    font-family: var(--font);
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.voxex-nav-back { border-color: var(--border); color: var(--text-2); }
.voxex-nav-back:hover,
.voxex-nav-link:hover {
    background: var(--elem);
    border-color: var(--green);
    color: var(--text);
}
.voxex-nav-link.active {
    background: var(--green-dd);
    border-color: var(--green);
    color: var(--text);
    font-weight: 600;
}
.voxex-nav-back:focus-visible,
.voxex-nav-link:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.voxex-nav-sep {
    width: 1px;
    height: 20px;
    background: var(--border-2);
    margin: 0 var(--sp-sm);
}

/* ===== Shell for the simple single-column tools (tests, debugger, textures) ===== */
.vx-tool-body {
    margin: 0;
    background: var(--bg);
    color: var(--text-soft);
    font-family: var(--font);
}
.vx-page { padding: var(--sp-2xl) 48px; }
.vx-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-lg);
    margin-bottom: var(--sp-xl);
}
.vx-page-head h1 { margin: 0 0 var(--sp-xs); font-size: 24px; font-weight: 600; color: var(--text); }
.vx-page-head p { margin: 0; font-size: 14px; color: var(--text-3); }

.vx-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}

/* ===== Game controls (the same rules as voxEx.html's button grammar, fields and switches) =====
   Every <button> is painted by ONE zero-specificity rule from --btn-* slots, exactly like the game's
   ":where(.menu-btn, …)" grammar (CCR-UI-TOKENS-001). A page never sets a button's background, border
   or colour directly: it sets slots, by role. Defaults = the game's grey secondary button (.seed-btn /
   .world-modal-btn.secondary). Slots: --btn-bg --btn-fg --btn-border --btn-bw --btn-r --btn-pad --btn-fs
   --btn-fw and the -hover forms. Role classes use the game's names. */
:where(button, input[type="button"], input[type="submit"]) {
    padding: var(--btn-pad, 8px 12px);
    font-size: var(--btn-fs, 13px);
    font-weight: var(--btn-fw, 400);
    color: var(--btn-fg, var(--text-2));
    background: var(--btn-bg, var(--elem-3));
    border: var(--btn-bw, 1px) solid var(--btn-border, var(--elem-4));
    border-radius: var(--btn-r, var(--r));
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}
:where(button, input[type="button"], input[type="submit"]):hover:not(:disabled) {
    background: var(--btn-bg-hover, var(--elem-4));
    color: var(--btn-fg-hover, var(--text));
    border-color: var(--btn-border-hover, var(--btn-border, var(--elem-4)));
}
:where(button, input[type="button"], input[type="submit"]):focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
:where(button, input[type="button"], input[type="submit"]):disabled {
    background: var(--btn-disabled-bg);
    border-color: var(--btn-disabled-bg);
    color: var(--text-2);
    cursor: not-allowed;
    opacity: 0.6;
}
/* Roles (slot presets, the game's variant names) */
.btn--primary { --btn-bg: var(--btn-primary-bg); --btn-border: var(--btn-primary-bg); --btn-bg-hover: var(--btn-primary-bg-hover); --btn-border-hover: var(--btn-primary-bg-hover); --btn-fg: var(--text); --btn-fg-hover: var(--text); }
.btn--info { --btn-bg: var(--btn-info-bg); --btn-border: var(--btn-info-bg); --btn-bg-hover: var(--btn-info-bg); --btn-fg: var(--text); }
.btn--secondary { --btn-bg: var(--elem-4); --btn-border: var(--elem-4); --btn-bg-hover: var(--elem-5); --btn-fg: var(--text); }
.btn--danger { --btn-bg: var(--danger-bg); --btn-border: var(--danger-bg); --btn-fg: var(--danger-text); --btn-bg-hover: var(--danger-bg-hover); --btn-border-hover: var(--danger-bg-hover); --btn-fg-hover: var(--text); }
.btn--chip { --btn-bg: var(--elem); --btn-border: var(--border); --btn-fg: var(--text-3); --btn-bg-hover: var(--elem-2); --btn-border-hover: var(--elem-4); }
.btn--chip.active, .btn--chip.selected { --btn-bg: var(--green-dd); --btn-border: var(--green); --btn-fg: var(--text); --btn-bg-hover: var(--green-dd); --btn-border-hover: var(--green); }

/* Fields: the game's dark well with a green focus (#create-world-panel / #world-manage-modal inputs) */
:where(input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="password"], input:not([type]), select, textarea) {
    background: var(--field);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text-soft);
}
:where(input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="password"], input:not([type]), select, textarea):focus {
    outline: none;
    border-color: var(--green);
}
:where(input[type="color"]) { background: var(--field); border: 1px solid var(--border); border-radius: var(--r-xs); padding: 2px; cursor: pointer; }
:where(input[type="radio"]) { accent-color: var(--green); }

/* Switches: the game's square on/off switch (#create-world-panel .toggle-row, settings rows). No circles. */
:where(input[type="checkbox"]) {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 22px;
    vertical-align: middle;
    background: var(--elem-3);
    border-radius: var(--r-xs);
    cursor: pointer;
    transition: background 0.3s;
}
:where(input[type="checkbox"])::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--knob-off);
    transition: transform 0.3s, background 0.3s;
}
:where(input[type="checkbox"]):checked { background: var(--green); }
:where(input[type="checkbox"]):checked::before { transform: translateX(18px); background: var(--text); }
:where(input[type="checkbox"]):focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
:where(input[type="checkbox"]):disabled { opacity: 0.5; cursor: not-allowed; }

/* Scrollbars: the game's menu scrollbars */
html, body, * { scrollbar-width: thin; scrollbar-color: var(--elem-4) var(--bg-1); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--elem-4); border-radius: var(--r); }
::-webkit-scrollbar-thumb:hover { background: var(--elem-5); }

/* Range sliders: square track + square thumb (the browser default thumb is round).
   A tool's own range rules load after this file and win. */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 14px;
    background: transparent;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--elem); }
input[type="range"]::-moz-range-track { height: 4px; background: var(--elem); }
input[type="range"]::-moz-range-progress { height: 4px; background: var(--green); }
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    margin-top: -4px;
    background: var(--text);
    border: 1px solid var(--green);
    border-radius: 0;
}
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; background: var(--text); border: 1px solid var(--green); border-radius: 0; }
input[type="range"]:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
