:root {
  --ink: #eef0f2;
  --ink2: #c3c8ce;
  --ink3: #9aa1a9;
  --line: rgba(255, 255, 255, 0.10);
  --line2: rgba(255, 255, 255, 0.16);
  --field: rgba(255, 255, 255, 0.07);
  --field-hover: rgba(255, 255, 255, 0.11);
  --accent: #7fb6c9;
  --accent-ink: #0c1a20;
  --warn: #e3b552;
  --bad: #e7806f;
  --good: #86c99a;
  --glass: rgba(16, 18, 21, 0.38);
  --glass-solid: rgba(20, 22, 26, 0.95);
  --glass-filter: blur(2px) brightness(0.56) saturate(1.9);
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, 0.10), inset 0 -1px 0 rgba(0, 0, 0, 0.35), 0 6px 24px rgba(0, 0, 0, 0.25);
  --pop-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --menu-bg: #1d2024;
  --scroll: rgba(255, 255, 255, 0.2);
  --ring-fill: rgba(255, 255, 255, 0.05);
  --swatch-edge: rgba(255, 255, 255, 0.25);
  --loading-bg: #15171a;
  color-scheme: dark;
  --r: 10px;
  --gap: 8px;
  --edge: 12px;
  --top-h: 44px;
  --panel-w: 320px;
  --tools-w: 60px;
  font-family: Inter, system-ui, sans-serif;
  font-size: 13px;
  line-height: 18px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
:root[data-theme="light"] {
  --ink: #15171a;
  --ink2: #3b4148;
  --ink3: #646b74;
  --line: rgba(0, 0, 0, 0.09);
  --line2: rgba(0, 0, 0, 0.16);
  --field: rgba(0, 0, 0, 0.05);
  --field-hover: rgba(0, 0, 0, 0.09);
  --accent: #2b7891;
  --accent-ink: #ffffff;
  --warn: #946400;
  --bad: #b3402c;
  --good: #2a7a44;
  --glass: rgba(248, 248, 246, 0.62);
  --glass-solid: rgba(250, 250, 249, 0.97);
  --glass-filter: blur(6px) brightness(1.08) saturate(1.3);
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 0 0 1px rgba(0, 0, 0, 0.07), 0 6px 24px rgba(0, 0, 0, 0.12);
  --pop-shadow: 0 0 0 1px rgba(0, 0, 0, 0.07), 0 8px 28px rgba(0, 0, 0, 0.16);
  --menu-bg: #fafaf9;
  --scroll: rgba(0, 0, 0, 0.22);
  --ring-fill: rgba(0, 0, 0, 0.04);
  --swatch-edge: rgba(0, 0, 0, 0.18);
  --loading-bg: #eeeeec;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #6b6f74; }
body { -webkit-font-smoothing: antialiased; user-select: none; }
button, input, select { font: inherit; color: inherit; }
.ico { display: block; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#view:active { cursor: grabbing; }
body.placing #view { cursor: crosshair; }
body.stirring #view { cursor: cell; }
#gizmo { position: fixed; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; z-index: 1; }

.glass {
  position: fixed;
  background: var(--glass-sheen, linear-gradient(transparent, transparent)), var(--glass);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--lens,) var(--glass-filter);
  border-radius: var(--r);
  box-shadow: var(--glass-edge);
  transition: background-color 0.15s, color 0.15s;
}
.glass:hover, .glass.solid { background: var(--glass-sheen, linear-gradient(transparent, transparent)), var(--glass-solid); }

:root[data-glass="liquid"], :root[data-glass="clear"] {
  --glass-edge: inset 1px 1px 0 rgba(255, 255, 255, 0.55), inset -1px -1px 0 rgba(255, 255, 255, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.14), 0 10px 30px rgba(0, 0, 0, 0.16);
  --glass-sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0) 40%);
  --glass-solid: rgba(255, 255, 255, 0.72);
  --halo: rgba(255, 255, 255, 0.65);
}
:root[data-glass="liquid"][data-theme="dark"], :root[data-glass="clear"][data-theme="dark"] {
  --glass-edge: inset 1px 1px 0 rgba(255, 255, 255, 0.32), inset -1px -1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 10px 30px rgba(0, 0, 0, 0.28);
  --glass-sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 40%);
  --glass-solid: rgba(22, 24, 28, 0.8);
  --halo: rgba(0, 0, 0, 0.6);
}
:root[data-glass="liquid"] { --glass-filter: blur(7px) saturate(1.8) brightness(1.04); }
:root[data-glass="clear"] { --glass-filter: blur(1.2px) saturate(1.5) brightness(1.03); }
:root[data-glass="clear"] .glass { text-shadow: 0 0 5px var(--halo); }

.top { top: var(--edge); left: var(--edge); right: var(--edge); height: var(--top-h); display: flex; align-items: center; gap: var(--gap); padding: 0 6px 0 12px; z-index: 5; }
@font-face { font-family: 'Cloudtank Word'; src: url('fonts/fredoka-600-cloudtank.woff2') format('woff2'); font-weight: 600; font-display: block; }
.brand { display: flex; align-items: center; gap: 6.3px; font-size: 15px; font-weight: 600; letter-spacing: -0.009em; white-space: nowrap; color: var(--ink); text-decoration: none; }
.brand svg { display: block; flex: none; }
.brand .word { font-family: 'Cloudtank Word', Inter, sans-serif; font-weight: 600; font-size: 15.87px; letter-spacing: 0; line-height: 1; font-synthesis: none; }
.spacer { flex: 1; }
.top > :not(.spacer) { flex: none; }
.top.compact .speed span, .top.compact .tb .tx { display: none; }
.top.tiny .brand .word { display: none; }
.tb.confirm, .tb.confirm:hover { color: var(--bad); }
.more { z-index: 7; background: var(--glass-solid); min-width: 230px; padding: 6px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.more .group { flex-direction: column; align-items: stretch; gap: 2px; }
.more .tb, .more .ib { width: 100%; justify-content: flex-start; gap: 8px; padding: 0 8px; }
.more .ib::after { content: attr(data-label); }
.more .speed, .more .timer { display: flex; align-items: center; justify-content: space-between; min-height: 32px; padding: 0 8px; font-size: 13px; color: var(--ink2); }
.more .timer::before { content: 'Simulated time'; }
.more > select { width: 100%; }
.ctx { min-width: 200px; z-index: 8; }
.ctx .tb .k { margin-left: auto; color: var(--ink3); font-size: 12px; }
.group { display: flex; align-items: center; gap: 2px; }
.sep { width: 1px; height: 20px; background: var(--line2); margin: 0 6px; }
.ib { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 7px; background: none; color: var(--ink2); cursor: pointer; flex: none; }
.ib:hover { background: var(--field-hover); color: var(--ink); }
.ib:disabled { opacity: 0.35; cursor: default; background: none; }
.ib.on { background: var(--accent); color: var(--accent-ink); }
.tb { height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--ink2); cursor: pointer; white-space: nowrap; }
.tb:hover { background: var(--field-hover); color: var(--ink); }
.speed { display: flex; align-items: center; gap: 6px; color: var(--ink3); font-size: 12px; }
.speed select { height: 28px; }
select { background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; height: 28px; cursor: pointer; }
select option { background: var(--menu-bg); }
.timer { font-size: 12px; color: var(--ink3); min-width: 52px; text-align: right; }
.info-btn { position: relative; }
.info-btn .dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.info-btn .dot.warn { background: var(--warn); }

.tools { top: calc(var(--edge) + var(--top-h) + var(--gap)); left: var(--edge); width: var(--tools-w); padding: 6px; display: flex; flex-direction: column; gap: 2px; z-index: 4; }
.tool { width: 48px; min-height: 48px; padding: 6px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; border-radius: 8px; background: none; color: var(--ink2); cursor: pointer; font-size: 12px; line-height: 14px; }
.tool:hover { background: var(--field-hover); color: var(--ink); }
.tool.on { background: var(--accent); color: var(--accent-ink); }
.tools hr { width: 32px; border: 0; border-top: 1px solid var(--line2); margin: 4px auto; }

.flyout { z-index: 6; padding: 8px; display: grid; grid-template-columns: repeat(3, 72px); gap: 4px; max-height: calc(100vh - 64px); overflow-y: auto; scrollbar-width: thin; }
.flyout[data-kind="objects"], .flyout[data-kind="marks"] { grid-template-columns: repeat(4, 72px); }
.flyout[hidden] { display: none; }
.flyout .tool { width: 72px; }
.flyout .tool span { text-align: center; padding: 0 2px; }
.flyout .tool.pic svg { display: none; }
.flyout .tool img.thumb { width: 64px; height: 48px; border-radius: 6px; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; }
.flyout h4 { grid-column: 1 / -1; margin: 2px 4px 4px; font-size: 12px; font-weight: 500; color: var(--ink3); }
.ghost { position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none; display: flex; align-items: center; gap: 6px;
  margin: 12px 0 0 12px; padding: 4px 10px 4px 6px; border-radius: 8px; background: var(--glass-solid); color: var(--ink);
  font-size: 12px; line-height: 16px; white-space: nowrap; box-shadow: var(--pop-shadow); }
body.dragging-in, body.dragging-in * { cursor: grabbing !important; }
.flyout h5 { grid-column: 1 / -1; margin: 6px 4px 0; font-size: 12px; font-weight: 600; color: var(--ink2); }

.panel { top: calc(var(--edge) + var(--top-h) + var(--gap)); right: var(--edge); bottom: var(--edge); width: var(--panel-w); display: flex; flex-direction: column; z-index: 4; overflow: hidden; }
.tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { flex: 1 1 auto; height: 30px; padding: 0 6px; border: 0; border-radius: 7px; background: none; color: var(--ink3); cursor: pointer; font-size: 12px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); background: var(--field-hover); }
.tabs button.on { color: var(--ink); background: var(--field-hover); box-shadow: inset 0 -2px 0 var(--accent); }
.body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 12px 16px; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
.sec { padding: 12px 0; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec, .sec div:not([class]) { display: flex; flex-direction: column; gap: 6px; }
.sec h3 { margin: 0 0 2px; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sec h3 small { font-weight: 400; color: var(--ink3); font-size: 12px; }
.sec h3:not(:first-child) { margin-top: 10px; }
.note { margin: 0 0 8px; font-size: 12px; line-height: 16px; color: var(--ink3); }
.sec .note { margin: 2px 0 0; }
.note b { color: var(--ink2); font-weight: 500; }

.row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 44px; align-items: center; gap: 8px; min-height: 28px; }
.row.slider, .row.toggle { min-height: 24px; }
.row > label, .row .lab { color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row output { font-size: 12px; color: var(--ink3); text-align: right; }
.row input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); height: 20px; cursor: pointer; }
.row input[type=color] { width: 100%; height: 26px; padding: 0; border: 1px solid var(--line2); border-radius: 6px; background: none; cursor: pointer; }
.row input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
.row input[type=color]::-webkit-color-swatch { border: 0; border-radius: 4px; }
.row.stack { grid-template-columns: 92px minmax(0, 1fr); }
.row.nums { grid-template-columns: 92px minmax(0, 1fr); }
.numset { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 4px; }
.num { display: flex; align-items: center; background: var(--field); border: 1px solid var(--line); border-radius: 6px; height: 28px; overflow: hidden; }
.num:focus-within { border-color: var(--accent); }
.num .tag { flex: none; width: 18px; text-align: center; font-size: 12px; color: var(--ink3); cursor: ew-resize; }
.num input { width: 100%; min-width: 0; border: 0; background: none; padding: 0 4px 0 0; height: 26px; text-align: right; font-size: 12px; outline: none; -moz-appearance: textfield; }
.num input::-webkit-inner-spin-button { display: none; }
.row.toggle { grid-template-columns: 1fr 36px; cursor: pointer; position: relative; }
.row.toggle input { position: absolute; opacity: 0; width: 36px; height: 20px; right: 0; margin: 0; cursor: pointer; }
.row.toggle .knob { justify-self: end; width: 34px; height: 20px; border-radius: 10px; background: var(--field-hover); border: 1px solid var(--line2); position: relative; pointer-events: none; transition: background-color 0.15s; }
.row.toggle .knob::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink2); transition: transform 0.15s; }
.row.toggle input:checked ~ .knob { background: var(--accent); border-color: var(--accent); }
.row.toggle input:checked ~ .knob::after { transform: translateX(14px); background: var(--accent-ink); }
.row.toggle input:focus-visible ~ .knob { outline: 2px solid var(--accent); outline-offset: 2px; }
.row.dialrow { grid-template-columns: 92px 64px 1fr; min-height: 68px; }
.dial { cursor: pointer; touch-action: none; }
.dial-ring { fill: var(--ring-fill); stroke: var(--line2); stroke-width: 1.5; }
.dial-n { fill: var(--ink3); font-size: 9px; text-anchor: middle; }
.dial-hand { stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.dial-hub { fill: var(--accent); }
.deg { display: flex; align-items: center; gap: 2px; justify-self: end; color: var(--ink3); }
.deg input { width: 52px; height: 28px; text-align: right; background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; font-size: 12px; outline: none; }
.deg input:focus { border-color: var(--accent); }

.seg { display: flex; gap: 4px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { flex: 1 1 0; min-width: 0; height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); color: var(--ink2); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.seg.wrap button { flex: 1 1 calc(50% - 4px); }
.seg.fit button { flex: 1 1 auto; padding: 0 6px; }
.seg button:hover { color: var(--ink); background: var(--field-hover); }
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn { height: 30px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); border-radius: 7px; background: var(--field); color: var(--ink2); cursor: pointer; white-space: nowrap; }
.btn:hover { color: var(--ink); background: var(--field-hover); }
.btn.danger:hover { color: var(--bad); border-color: var(--bad); }
.btn.confirm { color: var(--bad); border-color: var(--bad); }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sec .btns { margin-top: 2px; }
.text-in { width: 100%; min-width: 0; background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; outline: none; font: inherit; font-size: 12px; color: var(--ink); resize: vertical; user-select: text; }
input.text-in { height: 28px; }
.text-in:focus { border-color: var(--accent); }
.row.stack select { width: 100%; min-width: 0; }
.swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.chip { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); color: var(--ink2); cursor: pointer; font-size: 12px; text-align: left; min-width: 0; }
.chip:hover { color: var(--ink); background: var(--field-hover); }
.chip i { flex: none; width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--swatch-edge); }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list { display: flex; flex-direction: column; gap: 1px; max-height: 220px; overflow-y: auto; margin: 0 -4px; scrollbar-width: thin; }
.item.off .nm { color: var(--ink3); }
.item { display: grid; grid-template-columns: 22px minmax(0, 1fr) 14px 28px; align-items: center; gap: 6px; height: 30px; padding: 0 4px 0 6px; border-radius: 6px; color: var(--ink2); cursor: pointer; }
.item:hover { background: var(--field-hover); color: var(--ink); }
.item.on { background: rgba(127, 182, 201, 0.22); color: var(--ink); }
.item .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .ib { width: 26px; height: 26px; }
.item .sw { width: 10px; height: 10px; border-radius: 3px; justify-self: center; }
.empty { color: var(--ink3); font-size: 12px; padding: 6px 2px; }
.name-in { width: 100%; height: 28px; background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; outline: none; }
.name-in:focus { border-color: var(--accent); }

.status { left: calc(var(--edge) + var(--tools-w) + var(--gap)); bottom: var(--edge); height: 32px; display: flex; align-items: center; gap: 10px; padding: 0 12px; font-size: 12px; color: var(--ink2); z-index: 3; white-space: nowrap; }
.status .k { color: var(--ink3); }
.status .warn { color: var(--warn); }
.compass { position: fixed; right: calc(var(--edge) + var(--panel-w) + var(--gap)); bottom: var(--edge); width: 76px; height: 76px; z-index: 3; pointer-events: none; }
.compass[hidden] { display: none; }
.compass .ring { fill: rgba(16, 18, 21, 0.45); stroke: rgba(255, 255, 255, 0.2); }
.compass .n { fill: #fff; font-size: 9px; text-anchor: middle; font-family: Inter, sans-serif; }
.compass .arrow { fill: var(--accent); }
.compass .spd { fill: #fff; font-size: 10px; text-anchor: middle; font-family: Inter, sans-serif; }
.hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--edge) + 44px); padding: 6px 12px; font-size: 12px; color: #f2f2f2; background: rgba(12, 14, 16, 0.6); border-radius: 8px; pointer-events: none; z-index: 3; white-space: nowrap; transition: opacity 0.4s; }
.hint.gone { opacity: 0; }
.toast { position: fixed; left: 50%; top: calc(var(--edge) + var(--top-h) + 16px); transform: translateX(-50%); padding: 8px 14px; border-radius: 8px; background: var(--glass-solid); color: var(--ink); box-shadow: var(--pop-shadow); z-index: 9; max-width: 560px; font-size: 13px; transition: opacity 0.3s; }
.toast[hidden] { display: none; }
.toast.bad { color: var(--bad); }
.drop { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(12, 26, 32, 0.55); color: #fff; font-size: 20px; line-height: 24px; pointer-events: none; border: 3px dashed var(--accent); }
.drop[hidden] { display: none; }

.dialog { position: fixed; top: calc(var(--edge) + var(--top-h) + var(--gap)); right: calc(var(--edge) + 4px); width: 380px; max-height: calc(100vh - 100px); overflow-y: auto; padding: 16px; z-index: 8; background: var(--glass-solid); border-radius: var(--r); box-shadow: var(--pop-shadow); }
.dialog[hidden] { display: none; }
.dialog h2 { margin: 0 0 4px; font-size: 15px; line-height: 20px; font-weight: 600; }
.dialog h3 { margin: 16px 0 6px; font-size: 13px; font-weight: 600; }
.dialog p, .dialog li { margin: 0 0 6px; color: var(--ink2); }
.dialog table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dialog td { padding: 4px 0; border-bottom: 1px solid var(--line); color: var(--ink2); vertical-align: top; }
.dialog td:first-child { color: var(--ink3); width: 46%; padding-right: 8px; }
.dialog kbd { font: 500 12px Inter, sans-serif; background: var(--field-hover); border: 1px solid var(--line2); border-radius: 4px; padding: 0 5px; }
.dialog .x { position: absolute; top: 8px; right: 8px; }
.plate { --plate-track: 0.08em; margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; line-height: 18px;
  color: var(--ink3); text-transform: uppercase; letter-spacing: var(--plate-track); white-space: nowrap; text-align: center; }
.plate span { display: block; }
.plate a { color: inherit; text-decoration: none; }
.plate a:hover, .plate a:focus-visible { color: var(--ink); text-decoration: underline; }

.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; background: var(--loading-bg); z-index: 30; color: var(--ink2); font-size: 15px; transition: opacity 0.4s; }
.loading.gone { opacity: 0; pointer-events: none; }
.loading .bar { width: 220px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.loading .bar i { display: block; height: 100%; width: 40%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.loading .err { color: var(--bad); max-width: 520px; white-space: pre-wrap; font-size: 13px; text-align: center; }

@media (max-width: 760px) {
  :root { --panel-w: 280px; }
}
