/* Prop Foundry web. An editor's look: flat grey panels, hairline borders, one small radius, blue only where you act. */

@font-face { font-family: "Plex Sans"; font-weight: 400; font-display: swap; src: url("vendor/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 500; font-display: swap; src: url("vendor/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 600; font-display: swap; src: url("vendor/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 400; font-display: swap; src: url("vendor/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }

:root {
    --bg: #1b1b1d;
    --panel: #232325;
    --panel-head: #2a2a2d;
    --field: #18181a;
    --hover: #303034;
    --line: #313134;
    --line-strong: #46464b;
    --text: #d6d6d9;
    --text-strong: #f2f2f4;
    --muted: #8e8e94;
    --faint: #66666c;
    --accent: #2f8cff;
    --accent-hover: #4b9cff;
    --accent-press: #1f74de;
    --accent-rgb: 47 140 255;
    --danger: #e5534b;
    --radius: 3px;
    --topbar: 40px;
    --strip: 36px;          /* The search bar, the viewport's toolbar and the inspector's header line up. */
    --tabs: 48px;
    --row: 24px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "Plex Mono", ui-monospace, Consolas, monospace;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 12px/1.45 var(--font);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
body { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* Buttons: flat, a hairline border; primary is the one blue thing in a group. */
button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 26px; padding: 0 10px;
    background: var(--panel-head);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--hover); }
button:active:not(:disabled) { background: var(--line); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:active:not(:disabled) { background: var(--accent-press); border-color: var(--accent-press); }
button.quiet { background: none; border-color: transparent; color: var(--muted); }
button.quiet:hover:not(:disabled) { background: var(--hover); color: var(--text); }
button.inline-link { display: inline; height: auto; padding: 0; border: 0; background: none; color: var(--accent); }
button.inline-link:hover:not(:disabled) { background: none; text-decoration: underline; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.muted { color: var(--muted); }

/* Top bar */
.topbar {
    height: var(--topbar);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0 8px 0 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
/* The name, version and tagline sit on one baseline; the mark is centred on the bar. */
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.mark { width: 16px; height: 16px; align-self: center; }
.mark-fill { fill: var(--accent); stroke: none; }
.mark-edge { stroke: #fff; stroke-opacity: 0.55; stroke-width: 1; }
.brand-name { font-weight: 600; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-strong); white-space: nowrap; }
/* About: a tab on phones, a dialog elsewhere. */
#tab-about { display: none; }
.about-body { line-height: 1.55; color: var(--text); }
.about-body p { margin: 0 0 10px; }
.about-body a { color: var(--accent); text-decoration: none; }
.about-body a:hover { text-decoration: underline; }
.about-note { color: var(--muted); font-size: 12px; }
.about-version { color: var(--faint); font-size: 11px; }
.about-version .version { font-family: var(--mono); }
#tab-about .about-body { padding: 16px; }
.tagline { line-height: 14px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 8px; border-left: 1px solid var(--line); }
.actions { display: flex; gap: 6px; align-items: center; flex: none; }

/* Layout */
.layout { height: calc(100% - var(--topbar)); display: grid; grid-template-columns: 220px minmax(0, 1fr) 320px; }
.tabs { display: none; }
.panel { background: var(--panel); overflow-y: auto; overflow-x: hidden; min-height: 0; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.gallery { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }
/* The prop list and the inspector scroll their bodies only: the search strip, the About strip and the inspector's
   tabs stay put, the scrollbar beside the list alone. */
.gallery, .inspector { display: flex; flex-direction: column; overflow: hidden; }
#gallery, .panel-body {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}

/* Gallery: a plain list under category headers, like a project browser. */
.panel-head { position: sticky; top: 0; z-index: 1; flex: none; height: var(--strip); display: flex; align-items: center; padding: 0 6px; background: var(--panel); border-bottom: 1px solid var(--line); }
#search {
    width: 100%; height: 24px; padding: 0 8px;
    background: var(--field); border: 1px solid var(--line); border-radius: var(--radius);
}
#search:focus { border-color: var(--accent); outline: none; }
#gallery { flex: 1; padding-bottom: 8px; }
.category > summary {
    list-style: none; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
    color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
.category > summary::-webkit-details-marker { display: none; }
.category > summary::before, details.group > summary::before, .section > summary::before, .subsection > summary::before {
    content: ""; width: 0; height: 0; flex: none;
    border-left: 4px solid currentColor; border-top: 3.5px solid transparent; border-bottom: 3.5px solid transparent;
    transition: transform 0.12s;
}
.category[open] > summary::before, details.group[open] > summary::before, .section[open] > summary::before, .subsection[open] > summary::before { transform: rotate(90deg); }
.category > summary:hover { color: var(--text); }
.category > summary .count { margin-left: auto; font-family: var(--mono); font-weight: 400; letter-spacing: 0; color: var(--faint); }
.chips { display: flex; flex-direction: column; padding-bottom: 4px; }
.chip {
    justify-content: flex-start; height: 24px; padding: 0 10px 0 24px;
    background: none; border: 0; border-radius: 0; color: var(--text);
    box-shadow: inset 2px 0 0 transparent;
}
.chip:hover:not(:disabled) { background: var(--hover); }
.chip.selected, .chip.selected:hover:not(:disabled) { background: rgb(var(--accent-rgb) / 0.16); color: var(--text-strong); }
.chip[hidden], .results[hidden] { display: none; }
.results { padding-top: 4px; }
.chip.result { padding-left: 12px; gap: 8px; }
.chip.result .why { margin-left: auto; color: var(--faint); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.empty { color: var(--muted); padding: 8px 12px; }
/* The foot of the prop list: a strip the height of the search strip above, About in it, muted until hovered. */
.panel-foot {
    position: sticky; bottom: 0; flex: none; height: var(--strip); display: flex; align-items: center; padding: 0 6px;
    background: var(--panel); border-top: 1px solid var(--line);
}
.foot-link {
    height: 24px; justify-content: flex-start; gap: 6px; padding: 0 6px;
    background: none; border: 0; color: var(--muted);
}
.foot-link svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.foot-link:hover:not(:disabled) { background: var(--hover); color: var(--text-strong); }

/* Viewport: a toolbar strip over the stage, as a scene view has. */
.viewport { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.viewbar {
    height: var(--strip); flex: none;
    display: flex; align-items: center; gap: 0; padding: 0 4px;
    background: var(--panel); border-bottom: 1px solid var(--line);
}
.viewbar .group { display: flex; align-items: center; gap: 1px; padding: 0 4px; flex: none; }
.viewbar .group + .group { border-left: 1px solid var(--line); }
.viewbar button { height: 24px; padding: 0 8px; background: none; border: 1px solid transparent; color: var(--muted); font-size: 11.5px; }
.viewbar button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.viewbar button[aria-pressed="true"] { color: var(--text-strong); background: rgb(var(--accent-rgb) / 0.2); border-color: rgb(var(--accent-rgb) / 0.45); }
.viewbar .group.push { margin-left: auto; border-left: 0; }
.viewbar button.icon { width: 28px; height: 26px; padding: 0; }
.viewbar button.icon svg { width: 18px; height: 18px; stroke-width: 1.75; }
.viewbar .group { gap: 2px; padding: 0 6px; }

/* The axes gizmo, top right of the stage, as a scene view has it. */
.gizmo { position: absolute; top: 6px; right: 6px; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 0; }
#gizmo { width: 84px; height: 84px; display: block; touch-action: none; cursor: default; }
#projection {
    height: 18px; padding: 0 6px; margin-top: 4px;
    background: rgb(20 20 22 / 0.6); border: 0; color: #d0d0d4; font-size: 11px;
}
#projection:hover:not(:disabled) { background: rgb(20 20 22 / 0.85); color: #fff; }

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #2c2d30; }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stats {
    position: absolute; bottom: 8px; padding: 2px 6px;
    background: rgb(20 20 22 / 0.72); border-radius: var(--radius);
    font-size: 11px; color: #c4c4c8; pointer-events: none;
}
.stats { left: 8px; font-family: var(--mono); }
.message {
    position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
    max-width: min(560px, calc(100% - 32px)); padding: 6px 10px;
    background: #3a1d1c; border: 1px solid var(--danger); border-radius: var(--radius); color: #ffd7d4;
}
.message.info { background: #172a44; border-color: var(--accent); color: #d8e8ff; }
.loading {
    position: absolute; inset: 0; z-index: 5;
    display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center;
    background: var(--bg); color: var(--muted); padding: 16px; text-align: center;
}
.loading[hidden] { display: none; }
.loading .bar { width: 160px; height: 2px; background: var(--line); position: relative; overflow: hidden; }
.loading .bar::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* Inspector: rows of label and control, groups that fold, section header bars. */
.inspector-head {
    position: sticky; top: 0; z-index: 1; flex: none;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    height: var(--strip); padding: 0 8px 0 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.inspector-head { padding-left: 4px; }
.itabs { display: flex; align-items: stretch; align-self: stretch; min-width: 0; }
.itabs button {
    height: auto; padding: 0 10px; background: none; border: 0; border-radius: 0;
    color: var(--muted); box-shadow: inset 0 -2px 0 transparent; min-width: 0;
}
.itabs button:hover:not(:disabled) { background: none; color: var(--text); }
.itabs button[aria-selected="true"] { color: var(--text-strong); box-shadow: inset 0 -2px 0 var(--accent); }
.itabs .tab-title { display: block; margin: 0; font: inherit; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.itabs button[aria-selected="true"] .tab-title { color: var(--text-strong); }
.ipanel[hidden] { display: none; }
.panel-actions { padding: 2px 8px 12px 12px; }
.panel-actions.flush { padding: 8px 0 0; }
#properties { padding: 6px 8px 8px 12px; }

.prop { display: grid; grid-template-columns: 108px minmax(0, 1fr); align-items: center; gap: 8px; min-height: var(--row); }
.prop[hidden], .group[hidden] { display: none; }
.prop > label {
    color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    cursor: default; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.prop > label.changed { color: var(--text-strong); }
.control { display: flex; align-items: center; gap: 6px; min-width: 0; }
.control input[type="number"], .control input[type="text"], .control select {
    height: 20px; min-width: 0; padding: 0 5px;
    background: var(--field); border: 1px solid var(--line); border-radius: var(--radius);
    font-family: var(--mono); font-size: 11px;
}
.control select { flex: 1; font-family: var(--font); font-size: 12px; padding: 0 3px; }
.control input[type="number"] { width: 58px; flex: none; -moz-appearance: textfield; }
.control input[type="number"]::-webkit-inner-spin-button { display: none; }
.control input:focus, .control select:focus { border-color: var(--accent); outline: none; }
.control input.wide { flex: 1; width: auto; }
.control input[type="color"] { width: 32px; height: 20px; padding: 1px; flex: none; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); }
.control input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.control input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 2px; }
.control input[type="checkbox"] { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.control output { width: 36px; text-align: right; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.control .dice { width: 22px; height: 20px; padding: 0; }

/* Sliders: a hairline track and a small round thumb. */
input[type="range"] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 20px; margin: 0; background: none; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line-strong); border-radius: 1px; }
input[type="range"]::-moz-range-track { height: 2px; background: var(--line-strong); border-radius: 1px; }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; margin-top: -4px; border-radius: 50%; background: var(--accent); border: 0; }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 0; }
input[type="range"]:hover::-webkit-slider-thumb { background: var(--accent-hover); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px rgb(var(--accent-rgb) / 0.4); }

details.group { margin: 2px 0; }
details.group > summary {
    list-style: none; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 6px; height: var(--row); font-weight: 500; color: var(--text);
}
details.group > summary::-webkit-details-marker, .section > summary::-webkit-details-marker, .subsection > summary::-webkit-details-marker { display: none; }
details.group > summary::before { color: var(--muted); }
details.group > .group-body { padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--line); }

.section { border-top: 1px solid var(--line); }
.section > summary {
    list-style: none; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px;
    background: var(--panel-head); font-weight: 600; color: var(--text-strong);
}
.section > summary::before { color: var(--muted); }
.section-body { padding: 8px 8px 10px 12px; }
.subsection > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; height: var(--row); color: var(--muted); }
.note { color: var(--muted); margin: 0 0 6px; }
.buttons { display: flex; gap: 4px; margin: 8px 0 4px; }
.buttons #export-set { margin-left: auto; }
.varied-item { display: flex; align-items: center; gap: 6px; min-height: 20px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.varied-item input { accent-color: var(--accent); margin: 0; }

.palette-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 6px; color: var(--muted); }
.inline-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.inline-check input { margin: 0; accent-color: var(--accent); }
.palette-preview { display: block; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 2px; }
.ball-wrap { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
#light-ball { width: 140px; height: 140px; flex: none; touch-action: none; cursor: crosshair; }
.ball-wrap .note { margin: 0; }
.control input[type="color"] + input[type="color"] { margin-left: 0; }
.palette { display: grid; gap: 1px; margin-top: 8px; width: max-content; max-width: 100%; }
.palette div { width: 18px; height: 18px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1); }


.tooltip {
    position: fixed; z-index: 60; max-width: min(300px, calc(100vw - 16px)); pointer-events: none;
    padding: 6px 8px; background: var(--panel-head); border: 1px solid var(--line-strong); border-radius: var(--radius);
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.4);
}
.tooltip.tip { padding: 4px 7px; white-space: nowrap; max-width: none; }
.tooltip.tip strong { font-weight: 600; color: var(--text-strong); }
.tooltip.tip kbd { margin-left: 6px; padding: 0 4px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 2px; }
.tooltip.tip span { display: block; color: var(--muted); }
.tooltip code { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 2px; }

/* Dialogs */
dialog.sheet {
    width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto;
    margin: auto; padding: 0;
    background: var(--panel); color: var(--text);
    border: 1px solid var(--line-strong); border-radius: 4px;
    box-shadow: 0 16px 48px rgb(0 0 0 / 0.5);
}
dialog.wide-sheet { width: min(520px, calc(100vw - 32px)); }
dialog.sheet::backdrop { background: rgb(0 0 0 / 0.55); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; height: 38px; padding: 0 6px 0 14px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-strong); }
.close { width: 26px; padding: 0; background: none; border-color: transparent; color: var(--muted); }
.sheet-body { padding: 14px; }
.sheet-foot { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line); }
.sheet-foot .status { margin-right: auto; color: var(--muted); font-family: var(--mono); font-size: 11px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-foot .status.done { color: var(--text); }
.sheet-note { margin: 0; padding: 9px 14px; background: var(--bg); border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }

.export-head { display: flex; gap: 12px; align-items: flex-start; }
.export-head img { width: 88px; height: 88px; flex: none; object-fit: cover; border: 1px solid var(--line); border-radius: var(--radius); background: #2c2d30; }
.export-name { font-size: 14px; font-weight: 600; color: var(--text-strong); margin-bottom: 6px; }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; font-family: var(--mono); font-size: 11px; line-height: 18px; }
.specs dd:last-child { font-family: var(--font); font-size: 12px; }

.formats { border: 0; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.formats legend { padding: 0; margin-bottom: 6px; color: var(--muted); }
.format {
    display: grid; grid-template-columns: 18px 64px 1fr; align-items: center;
    height: 30px; padding: 0 10px; cursor: pointer;
    background: var(--field); border: 1px solid var(--line); border-radius: var(--radius);
    text-align: left; font-weight: 400; justify-content: stretch;
}
.format:hover { border-color: var(--line-strong); }
.format:has(input:checked) { border-color: var(--accent); background: rgb(var(--accent-rgb) / 0.08); }
.format input { margin: 0; accent-color: var(--accent); }
.format-name { font-weight: 600; color: var(--text-strong); }
.format-note { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.format { width: 100%; background: none; border-style: dashed; }
button.format:hover:not(:disabled) { background: var(--hover); }
.format-locked .format-name { color: var(--muted); }
.lock { display: flex; color: var(--faint); }
.lock svg { width: 12px; height: 12px; }

.after { margin-top: 14px; }
.after[hidden] { display: none; }
.after label { display: block; color: var(--muted); margin-bottom: 4px; }
.credit-row { display: flex; gap: 4px; }
.credit-row input { flex: 1; min-width: 0; height: 26px; padding: 0 8px; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--mono); font-size: 11px; }

.lead { color: var(--muted); margin: 0 0 12px; }
.soon {
    display: inline-block; vertical-align: middle; margin-left: 6px; padding: 1px 6px;
    border: 1px solid var(--line); border-radius: 3px;
    color: var(--faint); font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
}
.fineprint { color: var(--faint); font-size: 11px; margin: 10px 0 0; }
.compare { width: 100%; border-collapse: collapse; }
.compare th, .compare td { height: 28px; padding: 0 8px; border-bottom: 1px solid var(--line); text-align: center; }
.compare th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.compare th:last-child { color: var(--accent); }
.compare td:first-child, .compare th:first-child { text-align: left; padding-left: 10px; }
.compare td.yes { width: 64px; color: var(--text); }
.compare td.no { width: 64px; color: var(--faint); }
.compare tr.highlight td { background: rgb(var(--accent-rgb) / 0.1); }

/* A popover, so it shows in the top layer, above an open dialog too. */
.toast {
    position: fixed; inset: auto auto calc(16px + var(--safe-bottom)) 50%; margin: 0; z-index: 70;
    transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px);
    padding: 7px 12px; color: var(--text);
    background: var(--panel-head); border: 1px solid var(--line-strong); border-radius: var(--radius);
    box-shadow: 0 6px 18px rgb(0 0 0 / 0.45);
}
.toast:not(:popover-open) { display: none; }

/* Maximized: the viewport fills the window, the bars and panels hidden until the button is pressed again. */
#maximize .when-on, #maximize[aria-pressed="true"] .when-off { display: none; }
#maximize[aria-pressed="true"] .when-on { display: block; }
body.maximized .topbar, body.maximized .panel, body.maximized .tabs { display: none !important; }
body.maximized .layout { height: 100dvh; display: flex; }
body.maximized .viewport { flex: 1 1 auto; height: auto; min-height: 0; }

/* Phones and narrow windows: the viewport on top, one panel under it, tabs at the bottom. */
@media (max-width: 900px) {
    .tagline, .hide-narrow, #share .label { display: none; }
    #share { width: 30px; padding: 0; }
    .layout { display: flex; flex-direction: column; height: calc(100dvh - var(--topbar)); }
    .viewport { order: 0; flex: 0 0 auto; height: 46dvh; min-height: 240px; }
    .panel { order: 1; flex: 1 1 0; border: 0; border-top: 1px solid var(--line); }
    .layout:not([data-tab="props"]) #tab-props { display: none; }
    .layout:not([data-tab="edit"]) #tab-edit { display: none; }
    .layout[data-tab="about"] #tab-about { display: block; }
    /* Tapping the open tab again hides its panel; the viewport takes the room. */
    .layout[data-tab="none"] .viewport { flex: 1 1 auto; height: auto; }
    /* Searching: the viewport steps aside so the keyboard leaves the results in view. */
    .layout.searching:not([data-tab="none"]) .viewport { display: none; }
    .tabs {
        order: 2; display: flex; flex: none;
        height: calc(var(--tabs) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
        background: var(--panel); border-top: 1px solid var(--line);
    }
    .tabs button { flex: 1; height: 100%; background: none; border: 0; border-radius: 0; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; box-shadow: inset 0 2px 0 transparent; }
    .tabs button:hover:not(:disabled) { background: none; color: var(--text); }
    .tabs button.active { color: var(--text-strong); box-shadow: inset 0 2px 0 var(--accent); }
    .viewbar { overflow-x: auto; scrollbar-width: none; }
    .viewbar::-webkit-scrollbar { display: none; }
    .panel-foot { display: none; }

    dialog.sheet, dialog.wide-sheet {
        width: 100%; max-width: none; max-height: 92dvh;
        margin: auto 0 0; border-radius: 6px 6px 0 0; border-width: 1px 0 0;
        padding-bottom: var(--safe-bottom);
    }
    .toast { inset: calc(var(--topbar) + 10px) auto auto 50%; }
}

/* Short landscape phones: the panel beside the viewport. */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .layout { display: grid; grid-template-columns: minmax(0, 1fr) min(340px, 45vw); grid-template-rows: minmax(0, 1fr) auto; }
    .viewport { height: auto; min-height: 0; grid-row: 1 / 3; grid-column: 1; }
    .panel { grid-column: 2; grid-row: 1; border-top: 0; border-left: 1px solid var(--line); }
    .tabs { grid-column: 2; grid-row: 2; height: calc(40px + var(--safe-bottom)); }
    .layout[data-tab="none"] { grid-template-columns: minmax(0, 1fr) 200px; }
    .layout.searching:not([data-tab="none"]) .viewport { display: flex; }
}

/* Fingers: taller rows and targets, 16 px text in fields so phones do not zoom on focus. */
/* Thumbs: 44 px targets with room between them, 16 px text in fields so phones do not zoom on focus. */
@media (pointer: coarse) {
    :root { --row: 44px; --strip: 56px; --tabs: 56px; --topbar: 52px; }
    body, html { font-size: 14px; }
    button { height: 40px; padding: 0 14px; }
    #share { width: 40px; }
    .viewbar { padding: 0 6px; }
    .viewbar .group { gap: 2px; padding: 0 4px; }
    .viewbar button.icon { width: 42px; height: 44px; }
    .viewbar button.icon svg { width: 22px; height: 22px; }
    .gizmo { top: 8px; right: 8px; }
    #gizmo { width: 64px; height: 64px; }
    #projection { height: 28px; padding: 0 10px; margin-top: 4px; font-size: 12px; }
    .stats { font-size: 12px; }
    .panel-head { padding: 0 12px; }
    #search { height: 40px; font-size: 16px; padding: 0 12px; }
    .category > summary { height: 44px; padding: 0 16px; font-size: 12px; }
    .chip { height: 48px; padding: 0 16px 0 32px; font-size: 15px; }
    .chip.result { padding-left: 16px; }
    .chip.result .why { font-size: 12px; }
    .inspector-head { padding: 0 12px 0 16px; }
    .itabs button { font-size: 14px; padding: 0 12px; }
    #properties { padding: 8px 16px 12px; }
    .prop { grid-template-columns: 112px minmax(0, 1fr); gap: 12px; }
    .prop > label { font-size: 14px; }
    details.group > summary { font-size: 14px; }
    details.group > .group-body { padding-left: 14px; }
    .control { gap: 10px; }
    .control input[type="number"], .control input[type="text"], .control select { height: 38px; font-size: 16px; padding: 0 8px; }
    .control input[type="number"] { width: 76px; }
    .control input[type="checkbox"] { width: 24px; height: 24px; }
    .control input[type="color"] { width: 48px; height: 38px; }
    .control .dice { width: 40px; height: 38px; }
    input[type="range"] { height: 44px; }
    input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; }
    input[type="range"]::-moz-range-track { height: 4px; }
    input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -10px; border-radius: 50%; }
    input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; }
    .section > summary { height: 48px; padding: 0 16px; font-size: 14px; }
    .section-body { padding: 10px 16px 14px; }
    .buttons { gap: 8px; }
    .panel-actions { padding: 4px 16px 16px; }
    .panel-actions.flush { padding: 10px 0 0; }
    .tabs button { font-size: 13px; }
    .sheet-head { height: 52px; padding: 0 8px 0 16px; }
    .sheet-head h2 { font-size: 16px; }
    .close { width: 44px; height: 44px; }
    .sheet-body { padding: 16px; }
    .sheet-foot { padding: 12px 16px; }
    .sheet-foot button { height: 44px; padding: 0 18px; }
    .format { height: 52px; grid-template-columns: 28px 72px 1fr; }
    .format input { width: 20px; height: 20px; }
    .credit-row input { height: 40px; font-size: 16px; }
    .compare th, .compare td { height: 40px; }
    .tooltip.tip { font-size: 13px; }
    .topbar svg { width: 18px; height: 18px; }
    .specs dd { font-size: 13px; line-height: 22px; }
    .stats { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Shown only without JavaScript (crawlers, readers with scripts off): the page's text and the prop list. */
.noscript {
    position: fixed;
    inset: 0;
    z-index: 100;
    overflow: auto;
    padding: 24px;
    background: #232325;
    color: #d4d4d6;
    font: 14px/1.5 system-ui, sans-serif;
}
.noscript .noscript-title { font-size: 20px; font-weight: 600; margin: 0 0 12px; }
/* Read by search engines and screen readers, not drawn. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.noscript h2 { font-size: 15px; margin: 20px 0 6px; }
.noscript a { color: #2f8cff; }
.noscript ul { margin: 0; padding-left: 20px; }
