*, *::before, *::after { box-sizing: border-box }
:root { color-scheme: light; --paper: #e8e8e7; --ink: #1c1c1c; --soft: #5d5d5b; --line: #b4b4b1; --blue: #0a2a6c }
html, body { height: 100% }
body {
  margin: 0; display: grid; grid-template: auto minmax(0, 1fr) / minmax(0, 1fr) 340px;
  background: var(--paper); color: var(--ink); font: 14px/1.4 Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, input, select { font: inherit; color: inherit }
button, select, input[type=text], input[type=number] { height: 32px; border: 1px solid var(--line); background: #f7f7f6; border-radius: 3px; padding: 0 10px }
button { cursor: pointer; white-space: nowrap }
button:hover:enabled { border-color: var(--ink) }
button:disabled { opacity: .4; cursor: default }
button.main { background: var(--blue); border-color: var(--blue); color: #fff }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px }
a { color: inherit }
header { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 16px; border-bottom: 2px solid var(--ink) }
h1 { font-size: 16px; margin: 0; margin-right: auto }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center }

#stage { position: relative; overflow: hidden; touch-action: none; cursor: grab; user-select: none }
#stage.drag { cursor: grabbing }
#stage.clear { background: repeating-conic-gradient(#fff 0 25%, #dcdcda 0 50%) 0 0 / 24px 24px }
#stage:focus-visible { outline-offset: -3px }
#holder { position: absolute; left: 50%; top: 50% }
#holder > * { position: absolute !important; display: block }
#holder img, #holder svg { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; -webkit-user-drag: none; pointer-events: none }
#zoombar { position: absolute; left: 50%; bottom: 14px; translate: -50% 0; display: flex; gap: 6px; align-items: center; padding: 6px; background: var(--paper); border: 1px solid var(--ink); border-radius: 4px; cursor: default }
#zoombar input { accent-color: var(--blue); width: clamp(60px, 14vw, 150px) }
#zval { min-width: 66px; font-variant-numeric: tabular-nums }

#panel { overflow: auto; border-left: 2px solid var(--ink) }
details { border-bottom: 1px solid var(--line) }
summary { padding: 11px 16px; font-weight: 600; cursor: pointer }
.body { padding: 0 16px 16px; display: grid; gap: 9px }
.body h3 { font-size: 13px; margin: 8px 0 0; padding-top: 9px; border-top: 1px solid var(--line) }
.body h3:first-child { margin: 0; padding: 0; border: 0 }
.ctl { display: grid; grid-template-columns: 96px minmax(0, 1fr) 62px; gap: 8px; align-items: center }
.ctl > label { color: var(--soft) }
.ctl input[type=range] { width: 100%; margin: 0; accent-color: var(--blue) }
.ctl input[type=number] { width: 62px; height: 28px; padding: 0 4px; text-align: right; font-variant-numeric: tabular-nums }
.ctl .wide { grid-column: 2 / -1; width: 100% }
.ctl .chk { justify-self: start; width: 18px; height: 18px; accent-color: var(--blue) }
.color { display: flex; gap: 6px }
.color input[type=color] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--line); background: #f7f7f6; border-radius: 3px; flex: none }
.color input[type=text] { width: 100%; min-width: 0; font-family: ui-monospace, Consolas, monospace }
.color button { padding: 0 9px }
.presets { grid-template-columns: repeat(3, minmax(0, 1fr)) }
.presets button { height: auto; padding: 0 0 5px; overflow: hidden; font-size: 12px }
.presets button[aria-pressed=true] { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); font-weight: 600 }
.presets img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; margin-bottom: 5px }
.key { display: flex; justify-content: space-between; gap: 12px; align-items: center; color: var(--soft) }
.key > span:first-child { display: flex; gap: 4px; flex: none }
kbd { font: 12px ui-monospace, Consolas, monospace; color: var(--ink); background: #f7f7f6; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 1px 6px }
header a { text-decoration: none } header a:hover { text-decoration: underline }
.note { margin: 0; color: var(--soft); font-size: 13px }
[hidden] { display: none !important }
#toast { position: fixed; left: 50%; top: 64px; translate: -50% 0; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 4px; opacity: 0; transition: opacity .2s; pointer-events: none; width: max-content; max-width: 90vw }
#toast.on { opacity: 1 }

@media (max-width: 760px) {
  body { grid-template: auto 46vh minmax(0, 1fr) / minmax(0, 1fr) }
  header { padding: 8px 12px }
  h1 { font-size: 15px }
  #panel { border-left: 0; border-top: 2px solid var(--ink) }
}
