:root {
    color-scheme: dark;
    font-family: "Segoe UI", system-ui, sans-serif;
    color: #e9eef7;
    background: #101620;
    --panel: #151d2a;
    --border: #303b4c;
    --muted: #a9b7ca;
    --accent: #81ebcf;
    --input: #101721;
}

* { box-sizing: border-box; }
body { margin: 0; }
#main { display: flex; flex-direction: column; min-height: 100dvh; height: 100dvh; }
.loading { padding: 1.5rem; }
button, .file-button, .export, input {
    font: inherit;
    color: inherit;
    background: var(--input);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 7px 10px;
}
button, .file-button, .export { cursor: pointer; text-decoration: none; }
button:hover:not(:disabled), .file-button:hover, .export:hover { border-color: #8f9db0; }
button:disabled { opacity: .42; cursor: default; }
button.active { color: var(--accent); border-color: #438f83; background: #1a353a; }
:focus-visible, .file-button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
h2 { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; margin: 16px 0 9px; }
.top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { font-weight: 800; color: var(--accent); letter-spacing: .12em; }
.title { width: min(240px, 50vw); }
nav, .files { display: flex; gap: 5px; flex-wrap: wrap; }
.files { margin-left: auto; }
.file-button { position: relative; }
.file-button input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 174px minmax(0, 1fr) 207px; }
.tools, .properties { background: var(--panel); padding: 0 12px 14px; overflow: auto; }
.tools { border-right: 1px solid var(--border); }
.properties { border-left: 1px solid var(--border); }
.tools button, .properties button { display: block; width: 100%; text-align: left; margin-bottom: 6px; }
.properties label { display: block; color: var(--muted); margin: 10px 0; }
.properties input { width: 100%; margin-top: 5px; color: #e9eef7; }
.selection-name { margin: 10px 0; font-weight: 650; overflow-wrap: anywhere; }
.muted { color: var(--muted); margin: 10px 0; font-size: .85rem; }
.danger { color: #ffaca9; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.front { background: #ff877d; }
.back { background: #72aeff; }
.editor { overflow: auto; background: #0e141e; }
.editor svg { display: block; background: radial-gradient(circle, #455469 1px, transparent 1.3px) 10px 10px / 20px 20px; user-select: none; }
.editor.pcb { background: #101a20; }
.editor.pcb svg { background-image: radial-gradient(circle, #405962 1px, transparent 1.3px); }
.crosshair { cursor: crosshair; }
.board-outline { stroke: #619284; stroke-width: 1; fill: #23433d30; pointer-events: none; }
.connection, .edge-target, .airwire, .preview { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.connection, .airwire, .preview { pointer-events: none; }
.wire { stroke: #63dab7; stroke-width: 3; }
.copper-front { stroke: #ff877d; stroke-width: 6; }
.copper-back { stroke: #72aeff; stroke-width: 6; }
.airwire { stroke: #bacbd0; stroke-width: 1; stroke-dasharray: 5 5; opacity: .65; }
.preview { stroke: #f4d484; stroke-width: 2; stroke-dasharray: 5 5; }
.edge-target { stroke: transparent; stroke-width: 15; pointer-events: stroke; cursor: pointer; }
.part { cursor: pointer; }
.crosshair .part { cursor: crosshair; }
.symbol-target { fill: #15212b; }
.symbol { fill: none; stroke: #d7e3f2; stroke-width: 2.5; }
.footprint { fill: #263e3d; stroke: #87aa99; }
.pin { fill: #0e141e; stroke: #a2f1d9; stroke-width: 2; }
.pad { fill: #c99a5a; stroke: #ffda85; stroke-width: 1.5; }
.pad-number { fill: #13120e; font-size: 8px; }
.reference, .value, .pad-number { text-anchor: middle; pointer-events: none; }
.reference { fill: #e4eefb; font: 700 13px monospace; }
.value { fill: #b0c0d4; font: 11px monospace; }
.part[data-selected="true"] .symbol, .part[data-selected="true"] .footprint,
.connection[data-selected="true"] { stroke: #f4d484; }
circle[data-started="true"], .crosshair circle:hover { fill: #f4d484; }
footer { display: flex; align-items: center; gap: 10px; min-height: 43px; padding: 5px 14px; background: var(--panel); border-top: 1px solid var(--border); font-size: .83rem; }
.counts { margin-left: auto; display: flex; gap: 14px; color: var(--muted); flex-shrink: 0; }
.overlay { position: fixed; inset: 0; z-index: 1; display: grid; place-items: center; background: #0009; padding: 14px; }
.overlay section { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.overlay h2 { margin: 0; font-size: 1rem; text-transform: none; }
.overlay button + button { margin-left: 8px; }
@media (max-width: 760px) {
    .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(200px, 1fr) auto; }
    .tools, .properties { border: 0; display: flex; align-items: center; gap: 5px; padding: 6px; overflow-x: auto; }
    .tools h2, .properties h2 { margin: 0 5px; }
    .tools button, .properties button { margin: 0; width: auto; flex-shrink: 0; }
    .properties label { display: flex; gap: 4px; align-items: center; margin: 0; }
    .properties input { width: 112px; margin: 0; }
    .selection-name, .muted { flex-shrink: 0; margin: 0 4px; }
    .files { margin-left: 0; }
    .counts { display: none; }
}
