:root {
  --bg: #0d1b2a; --bar: #11202f; --field: #1b263b; --btn: #202f46; --hover: #415a77;
  --sand: #b3af8f; --text: #e0e1dd; --muted: #9ea8b8; --line: #28374e;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { display: flex; background: #000; color: var(--text); font: 14px/1.4 "Noto Sans", "Segoe UI", system-ui, sans-serif; }
body.bare #panel, body.bare #toolbar { display: none; }
#panel { width: 320px; flex: none; background: var(--bg); padding: 10px 14px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
h1 { font-size: 16px; margin: 0 0 8px; }
h1 span { color: var(--sand); }
#head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px; }
#head h1 { margin: 0; }
#help-open { width: 28px; padding: 0; font-weight: 600; }
.label { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
#help { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: #0d1b2a99; }
#help-box { background: var(--bg); border-radius: 6px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
#help-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
#help-head h2 { font-size: 16px; margin: 0; }
#help-close { width: 30px; padding: 0; }
#help-body { overflow-y: auto; padding: 4px 18px 14px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
#help-body h3 { color: var(--sand); font-size: 14px; margin: 14px 0 4px; }
#help-body p { margin: 3px 0; font-size: 13.5px; }
#help-body b { font-weight: 600; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 12.5px; white-space: pre-line; overflow-wrap: anywhere; }
pre { font-family: ui-monospace, Consolas, monospace; margin: 4px 0; }
.row { display: flex; gap: 4px; margin: 5px 0; align-items: center; }
.row > * { flex: 1 1 auto; min-width: 0; padding-inline: 6px; }
button, select, input[type=number] {
  font: inherit; color: var(--text); background: var(--btn); border: 0; border-radius: 4px; padding: 4px 8px; min-height: 28px;
}
select, input[type=number] { background: var(--field); width: 100%; }
button { cursor: pointer; }
button:hover:enabled { background: var(--hover); }
button:disabled, select:disabled { opacity: .45; cursor: default; }
button.on, button.primary { background: var(--sand); color: var(--bg); }
button.primary { width: 100%; min-height: 34px; font-weight: 600; margin: 4px 0; }
button.primary:hover:enabled { background: #c7c39f; }
:focus-visible { outline: 2px solid var(--sand); outline-offset: 1px; }
details { margin-top: 8px; }
summary { background: var(--field); border-radius: 4px; padding: 4px 8px; font-weight: 600; cursor: pointer; }
label.ctl { display: grid; grid-template-columns: 1fr 58px 92px; gap: 6px; align-items: center; margin: 5px 0; }
label.ctl.two { grid-template-columns: 156px 92px; }
label.ctl output { font-size: 12px; text-align: right; color: var(--muted); }
label.chk { display: inline-flex; gap: 6px; align-items: center; margin: 3px 12px 3px 0; }
input[type=range] { width: 100%; accent-color: var(--sand); }
input[type=checkbox] { accent-color: var(--sand); }
input[type=color] { border: 0; padding: 0; width: 36px; height: 24px; background: none; }
#grad { width: 100%; height: 8px; border-radius: 2px; display: block; }
#progress { height: 4px; background: var(--field); border-radius: 2px; overflow: hidden; margin: 6px 0; visibility: hidden; }
#progress.on { visibility: visible; }
#progress i { display: block; height: 100%; width: 0; background: var(--sand); }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#toolbar { flex: none; background: var(--bar); min-height: 44px; padding: 5px 8px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
#toolbar button { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
#toolbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; }
#toolbar .sep { width: 1px; height: 24px; background: #546b87; margin: 0 4px; }
#toolbar .sep.wide { margin: 0 16px; }
#toolbar label { display: flex; gap: 5px; align-items: center; color: var(--muted); font-size: 13px; margin-left: 6px; }
#toolbar input[type=number] { width: 96px; }
#readout { color: var(--sand); margin-left: 10px; background: none; width: auto !important; font-weight: 400 !important; padding: 0 6px !important; }
#view { flex: 1; min-height: 0; position: relative; overflow: hidden; }
#view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#overlay { pointer-events: none; }
#drop { position: absolute; inset: 0; display: grid; place-items: center; color: var(--sand); pointer-events: none; }
#hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: #080e16c8; color: #d6d2af; padding: 4px 12px; border-radius: 5px; pointer-events: none; }
#status { position: absolute; left: 12px; bottom: 10px; color: var(--sand); pointer-events: none; text-shadow: 0 0 4px #000; }
#busy { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: #0d1b2a99; text-align: center; }
#busy > div { background: var(--bg); border-radius: 6px; padding: 14px 28px 18px; min-width: 320px; }
#error { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: #0d1b2ae6; white-space: pre-line; }
