:root {
    --text-primary: #e8f0ff;
    --text-secondary: #b9d4f2;
    --text-muted: #8aabc9;
    --text-accent: #77b1f6;
    --control-border: rgba(150, 192, 242, .23);
    --control-surface: rgba(11, 28, 49, .96);
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text-primary);
    background: #050f23;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
button, input, select { font: inherit; touch-action: manipulation; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
svg { display: block; }

.banner {
    flex: none;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px max(22px, env(safe-area-inset-right)) 11px max(22px, env(safe-area-inset-left));
}
.banner-actions { display: flex; align-items: center; gap: inherit; margin-left: auto; }
.banner-title { flex: 1; min-width: 0; }
.banner h1 { margin: 0; font-size: 20px; line-height: 1.13; font-weight: 670; }
.panel-toggle, .icon-button {
    flex: none;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid #45658b;
    border-radius: 8px;
    background: #0b1c31;
    color: var(--text-secondary);
}
.panel-toggle { width: 44px; height: 44px; border-color: #9fc5ff4d; border-radius: 11px; background: #102440; }
.panel-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-button { width: 34px; height: 34px; }
.icon-button svg { width: 18px; height: 18px; }
.panel-toggle:hover, .icon-button:hover { border-color: #9acbff; background: #193453; color: var(--text-primary); }

#lab { flex: 1; min-height: 0; position: relative; overflow: hidden; isolation: isolate; background: #050f23; }
#stage { position: absolute; inset: 0; overflow: hidden; }
.controls-open #stage { right: 292px; }
.field-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.field-canvas[data-tool="pan"] { cursor: grab; }
.field-canvas.dragging { cursor: grabbing; }
.canvas-legend { position: absolute; top: 20px; }
.canvas-legend {
    right: max(22px, env(safe-area-inset-right));
    display: grid;
    gap: 5px;
    padding: 8px 12px;
    font-size: 11px;
    pointer-events: none;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-hidden { opacity: .4; }
.key-symbol { flex: none; width: 26px; white-space: nowrap; text-align: center; font-size: 14px; line-height: 1; }
.electric { color: #ff7a1a; }
.magnetic { color: #50b8f0; }

.placement-message, .canvas-empty, .toast {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 28px);
    padding: 9px 13px;
    font-size: 12px;
    text-align: center;
    pointer-events: none;
}
.placement-message, .canvas-empty { top: 50%; transform: translate(-50%, -50%); }
.toast { top: 20px; visibility: hidden; z-index: 1; }
.toast.visible { visibility: visible; }

.pointer-tools {
    grid-area: 1 / 1;
    justify-self: start;
    width: 168px;
    pointer-events: auto;
}
@container (max-width: 360px) {
    .pointer-tools { width: 148px; }
}
@container (max-width: 295px) {
    .canvas-dock .pointer-tools { grid-area: 2 / 1 / auto / -1; }
    .canvas-dock .time-bar { grid-row: 3; }
}
.canvas-dock .hud { display: grid; justify-items: end; gap: 5px; }

@media (pointer: coarse) {
    .icon-button { min-height: 44px; }
    .icon-button { width: 44px; }
}
@media (max-width: 750px), (max-height: 500px) and (max-width: 950px) {
    .banner { gap: 8px; padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
    .banner h1 { font-size: 18px; }
    .controls-open #stage { right: 0; }
    .canvas-legend { top: 12px; }
    .canvas-legend { right: max(12px, env(safe-area-inset-right)); }
    .toast { top: 92px; }
}
@media (max-width: 360px) {
    .banner { flex-wrap: wrap; gap: 5px; padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
    .banner h1 { font-size: 16px; }
}
