:root {
  --bg: #0d0e10;
  --panel: #131416;
  --raise: #181a1d;
  --hover: #1f2125;
  --line: #24262a;
  --line2: #30333a;
  --text: #dadde0;
  --muted: #8b9198;
  --dim: #5e646b;
  --accent: #f2a33a;
  --accent-ink: #1b1306;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 13px/1.4 var(--sans); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
kbd { font: 10px/1 var(--mono); padding: 2px 4px; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 3px; color: var(--muted); background: var(--bg); }

#app { display: grid; grid-template-columns: 1fr 320px; height: 100vh; height: 100dvh; }

/* ---------- viewport ---------- */
#stage { position: relative; overflow: hidden; min-height: 0; background: var(--bg); }
#view { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

.brand { position: absolute; top: 18px; left: 20px; display: flex; gap: 10px; align-items: center; pointer-events: none; }
.brand .mark { width: 22px; height: 22px; fill: var(--accent); }
.brand h1 { margin: 0; font: 700 15px/1 var(--mono); letter-spacing: 0.22em; text-transform: uppercase; }
.brand p { margin: 4px 0 0; font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }

.viewbar { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; }

.readout { position: absolute; left: 20px; bottom: 18px; font: 11px/1.6 var(--mono); color: var(--muted); pointer-events: none; text-shadow: 0 1px 2px #000; }
.readout b { color: var(--text); font-weight: 600; }
.readout .acc { color: var(--accent); }
.readout .warn { color: #e0675c; }
.hint { position: absolute; right: 18px; bottom: 18px; font-size: 11px; color: var(--dim); pointer-events: none; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font: 12px var(--mono); letter-spacing: 0.08em; pointer-events: none; transition: opacity .3s; }
.loading.done { opacity: 0; }

/* ---------- panel ---------- */
#panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 6px 18px 16px; display: flex; flex-direction: column; }
#panel section { padding: 14px 0; border-bottom: 1px solid var(--line); }
#panel section.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lbl { display: flex; align-items: center; gap: 6px; font: 600 10px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 9px; }
.lbl .k { font-weight: 400; color: var(--dim); letter-spacing: 0; border: 1px solid var(--line2); border-radius: 3px; padding: 1px 4px; }
.mono { font-family: var(--mono); }

button { cursor: pointer; border: 1px solid var(--line2); background: var(--raise); border-radius: 4px; height: 32px; padding: 0 10px; transition: background .12s, border-color .12s, color .12s; }
button:hover { background: var(--hover); border-color: #3c4048; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
button.primary:hover { background: #ffb24d; }
button.primary kbd { background: rgba(0,0,0,.12); border-color: rgba(0,0,0,.25); color: var(--accent-ink); }
button.link { height: auto; padding: 0; border: 0; background: none; color: var(--dim); font: 10px var(--mono); letter-spacing: 0; text-transform: none; margin-left: auto; }
button.link:hover { color: var(--text); background: none; }
button.chip { height: 28px; font-size: 12px; color: var(--muted); background: rgba(19,20,22,.85); }
button.chip[aria-pressed="true"] { color: var(--text); border-color: var(--line2); box-shadow: inset 0 -2px 0 var(--accent); }

.seedrow { display: flex; gap: 8px; }
.seedrow input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; background: var(--bg); border: 1px solid var(--line2); border-radius: 4px; font-family: var(--mono); font-size: 13px; }
.seedrow input:focus { border-color: var(--accent); outline: none; }

.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 4px; overflow: hidden; background: rgba(19,20,22,.85); }
.seg button { border: 0; border-radius: 0; height: 28px; background: transparent; color: var(--muted); font-size: 12px; padding: 0 12px; }
.seg button + button { border-left: 1px solid var(--line2); }
.seg button[aria-pressed="true"] { color: var(--text); background: var(--hover); box-shadow: inset 0 -2px 0 var(--accent); }
.seg.full { display: flex; }
.seg.full button { flex: 1; height: 30px; font-family: var(--mono); }

.classes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.classes button { height: auto; padding: 7px 9px; text-align: left; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: baseline; }
.classes button .n { font: 10px var(--mono); color: var(--dim); }
.classes button .t { font-weight: 600; }
.classes button .d { grid-column: 2; font-size: 11px; color: var(--dim); }
.classes button[aria-pressed="true"] { border-color: var(--accent); background: #1d1a15; }
.classes button[aria-pressed="true"] .n { color: var(--accent); }

.sig #sigVal { font-size: 12px; color: var(--text); line-height: 1.35; min-height: 30px; display: flex; align-items: center; }

.slider { display: grid; grid-template-columns: 82px 1fr 36px; align-items: center; gap: 8px; height: 26px; }
.slider span { color: var(--muted); font-size: 12px; }
.slider output { font: 11px var(--mono); color: var(--text); text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--line2); }
input[type=range]::-moz-range-track { height: 2px; background: var(--line2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 2px; background: var(--text); border: 0; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 2px; background: var(--text); border: 0; }
input[type=range]:hover::-webkit-slider-thumb { background: var(--accent); }

.liveries { display: grid; gap: 4px; }
.liveries button { display: flex; align-items: center; gap: 10px; height: 30px; text-align: left; }
.liveries .chips { display: flex; }
.liveries .chips i { width: 12px; height: 14px; display: block; }
.liveries .chips i:first-child { border-radius: 2px 0 0 2px; }
.liveries .chips i:last-child { border-radius: 0 2px 2px 0; }
.liveries .name { flex: 1; }
.liveries button[aria-pressed="true"] { border-color: var(--accent); background: #1d1a15; }

.exports { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.exports .wide { grid-column: 1 / -1; background: #1d1a15; border-color: #5a4220; color: #ffd08a; font-weight: 600; }
.exports .wide:hover { border-color: var(--accent); }
.fine { margin: 8px 0 0; font-size: 11px; color: var(--dim); }

footer { margin-top: auto; padding-top: 14px; font-size: 12px; color: var(--muted); }
footer p { margin: 0 0 6px; }
footer strong { color: var(--text); }
footer a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--line2); text-underline-offset: 3px; }
footer a:hover { color: var(--accent); }
footer .keys { color: var(--dim); font-size: 11px; line-height: 2; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px); background: var(--text); color: var(--bg); font: 600 12px var(--sans); padding: 8px 14px; border-radius: 4px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- small screens: panel goes below the viewport ---------- */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; }
  #stage { height: 58vh; height: 58svh; min-height: 300px; }
  #panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 0 16px 24px; }
  .brand { top: 12px; left: 14px; }
  .brand p { display: none; }
  .viewbar { top: 10px; right: 10px; }
  .hint { display: none; }
  .readout { left: 14px; bottom: 10px; font-size: 10px; }
  .seg button { padding: 0 9px; }
}
@media (max-width: 1240px) { .hint { display: none; } }

/* ---------- clean capture mode (?shot or #...&ui=0): viewport only ---------- */
html.shot #app { grid-template-columns: 1fr; grid-template-rows: 1fr; height: 100vh; height: 100dvh; }
html.shot #stage { height: 100%; }
html.shot #panel, html.shot .brand, html.shot .viewbar, html.shot .readout, html.shot .hint, html.shot .toast { display: none; }
.exports .wide2 { grid-column: 1 / -1; }
.exports button:disabled { opacity: .55; cursor: progress; }
