@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Recursive:MONO,wght@1,300..1000&display=swap');

:root {
  color-scheme: dark;
  --obsidian: #090c0c; --paper: #f8fbf8; --soft-gray: #e9f0ec; --slate: #19222b;
  --twilight: #1a1b4d; --violet: #8a6bff; --dusk: #ff8a8a; --glow: #ffc48a; --aurora: #ccc7ff;
  --cell: 38px;
  font-family: "Recursive", ui-monospace, monospace;
  font-variation-settings: "MONO" 1;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; min-height: 100%; }
body { overflow: hidden; background: var(--obsidian); color: var(--paper); font-size: 15px; }
button, input, select { min-height: 38px; font: inherit; }
button { color: inherit; }

.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; background: var(--slate); border-bottom: 1px solid rgba(204,199,255,.28); }
.brand { display: flex; align-items: center; gap: 15px; min-width: 0; }
.brand-stamp { width: 92px; height: 50px; object-fit: contain; object-position: left center; }
.brand-copy { min-width: 0; padding-left: 15px; border-left: 1px solid rgba(248,251,248,.25); }
.brand-copy strong { display: block; overflow: hidden; color: var(--paper); font-family: "Fraunces", serif; font-size: clamp(20px, 2vw, 27px); font-weight: 600; letter-spacing: -.04em; white-space: nowrap; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 7px; align-items: center; }
.button { padding: 7px 13px; color: var(--paper); background: transparent; border: 1px solid rgba(248,251,248,.32); border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 750; transition: background .15s ease, border-color .15s ease; }
.button:hover { background: rgba(204,199,255,.12); border-color: var(--aurora); }
.button:disabled { opacity: .32; cursor: not-allowed; }
.danger-ghost { color: var(--dusk); }

.app-shell { display: grid; grid-template-columns: 282px minmax(560px, 1fr) 282px; height: calc(100vh - 76px); }
.sidebar, .export-panel { overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(204,199,255,.35) transparent; }
.sidebar { padding: 0 18px 28px; color: var(--paper); background: var(--slate); border-right: 1px solid rgba(204,199,255,.22); }
.sidebar section { padding: 20px 0; border-bottom: 1px solid rgba(204,199,255,.18); }
.sidebar section:last-child { border-bottom: 0; }
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-kicker, .eyebrow { color: var(--aurora); font-size: 10px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.field-label { display: block; margin: 11px 0 6px; color: var(--soft-gray); font-size: 11px; font-weight: 650; }
.text-input, select { width: 100%; padding: 8px 9px; outline: none; color: var(--paper); background: var(--obsidian); border: 1px solid rgba(204,199,255,.24); border-radius: 6px; }
.text-input:focus, select:focus { border-color: var(--violet); }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.two-fields .text-input { min-width: 0; font-size: 11px; }
.code-input { text-transform: uppercase; letter-spacing: .08em; font-weight: 850; }
.hint { margin: 9px 0 0; color: rgba(233,240,236,.65); font-size: 10px; line-height: 1.5; }
.mini-action { min-height: 30px; padding: 4px 9px; color: var(--paper); background: var(--twilight); border: 1px solid rgba(204,199,255,.28); border-radius: 6px; font-size: 10px; font-weight: 850; cursor: pointer; }
.mini-action:hover { border-color: var(--violet); }

.filename-preview { display: grid; gap: 4px; margin-top: 11px; }
.filename-row { display: grid; grid-template-columns: 12px minmax(0, 1fr); align-items: center; gap: 8px; padding: 7px 8px; color: var(--paper); background: var(--obsidian); border: 1px solid rgba(204,199,255,.16); border-radius: 5px; font-size: 10px; }
.filename-row span { width: 12px; height: 12px; background: var(--screen-color); }
.filename-row code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: inherit; }
.screen-list { display: grid; gap: 6px; margin-top: 11px; }
.screen-row { display: grid; grid-template-columns: 1fr 30px; gap: 5px; }
.screen-select { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 8px; color: var(--paper); background: var(--obsidian); border: 1px solid rgba(204,199,255,.2); border-radius: 6px; cursor: pointer; text-align: left; }
.screen-select:hover { border-color: rgba(204,199,255,.55); }
.screen-row.active .screen-select { border-color: var(--screen-color); background: color-mix(in srgb, var(--screen-color) 13%, var(--obsidian)); }
.screen-chip { width: 22px; height: 22px; flex: 0 0 22px; border: 1px solid rgba(248,251,248,.42); border-radius: 3px; background: linear-gradient(135deg, var(--screen-color) 0 50%, var(--screen-alt) 50%); }
.screen-copy { display: block; min-width: 0; }
.screen-copy b, .screen-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-copy b { font-size: 11px; }
.screen-copy small { margin-top: 3px; color: rgba(233,240,236,.66); font-size: 8px; }
.screen-remove { min-height: 38px; color: var(--dusk); background: transparent; border: 1px solid rgba(255,138,138,.38); border-radius: 6px; cursor: pointer; }
.screen-remove:hover { background: rgba(255,138,138,.12); }
.screen-remove:disabled { opacity: .3; cursor: not-allowed; }

.tool-grid { display: grid; gap: 7px; margin-top: 11px; }
.cabinet-tool { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; color: var(--paper); background: var(--obsidian); border: 1px solid rgba(204,199,255,.22); border-radius: 6px; text-align: left; cursor: pointer; transition: background .15s ease, border-color .15s ease; }
.cabinet-tool:hover { border-color: rgba(204,199,255,.55); }
.cabinet-tool.active { background: var(--twilight); border-color: var(--violet); }
.cabinet-tool b, .cabinet-tool small { display: block; }
.cabinet-tool b { font-size: 12px; }
.cabinet-tool small { margin-top: 2px; color: rgba(233,240,236,.62); font-size: 9px; }
.cab-icon { width: 22px; flex: 0 0 22px; border: 1.5px solid var(--aurora); background: transparent; }
.large-icon { height: 34px; }
.small-icon { height: 22px; }
.erase-icon { width: 22px; color: var(--aurora); text-align: center; font-size: 20px; }
.setting-row { display: grid; grid-template-columns: 1fr 61px; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid rgba(204,199,255,.15); }
.setting-row b, .setting-row small { display: block; }
.setting-row b { font-size: 11px; }
.setting-row small { margin-top: 2px; color: rgba(233,240,236,.62); font-size: 9px; line-height: 1.35; }
.setting-row select { min-height: 34px; padding: 5px; }
.setting-row.compact { grid-template-columns: 1fr 42px; }
.setting-note { margin-top: 10px; padding: 10px; color: var(--paper); background: var(--obsidian); border: 1px solid rgba(204,199,255,.18); border-radius: 6px; }
.setting-note b, .setting-note small { display: block; }
.setting-note b { font-size: 11px; }
.setting-note small { margin-top: 3px; color: rgba(233,240,236,.62); font-size: 9px; line-height: 1.4; }
input[type="checkbox"] { appearance: none; width: 42px; height: 24px; position: relative; background: var(--obsidian); border: 1px solid rgba(204,199,255,.35); border-radius: 999px; cursor: pointer; }
input[type="checkbox"]:after { content: ""; position: absolute; width: 16px; height: 16px; top: 3px; left: 3px; background: var(--soft-gray); border-radius: 50%; transition: left .15s ease; }
input[type="checkbox"]:checked { background: var(--violet); }
input[type="checkbox"]:checked:after { left: 21px; }
.legend { display: flex; align-items: center; gap: 9px; margin-top: 10px; color: rgba(233,240,236,.68); font-size: 10px; }
.swatch { width: 16px; height: 16px; }
.swatch.cabinet { background: var(--twilight); border: 1px solid var(--violet); }
.line-swatch { width: 22px; height: 2px; }
.line-swatch.data { background: var(--violet); }
.line-swatch.ac { height: 8px; border: 1px solid var(--aurora); background: transparent; }

.workspace { min-width: 0; display: flex; flex-direction: column; background: var(--obsidian); }
.workspace-head { min-height: 88px; display: flex; align-items: center; justify-content: space-between; padding: 17px 24px; border-bottom: 1px solid rgba(204,199,255,.2); }
.eyebrow { color: var(--dusk); }
h1 { margin: 5px 0 0; font-family: "Fraunces", serif; font-size: clamp(25px, 2.7vw, 37px); font-weight: 600; line-height: 1; letter-spacing: -.045em; }
.workspace-controls { display: flex; align-items: center; gap: 10px; }
.active-screen { display: flex; align-items: center; gap: 7px; max-width: 180px; color: var(--soft-gray); font-size: 10px; font-weight: 800; white-space: nowrap; overflow: hidden; }
.active-screen span { width: 11px; height: 11px; flex: 0 0 11px; background: var(--screen-color, var(--violet)); border-radius: 2px; }
.active-screen b { overflow: hidden; text-overflow: ellipsis; }
.view-switch { display: flex; padding: 3px; background: var(--slate); border: 1px solid rgba(204,199,255,.2); border-radius: 7px; }
.view-switch button { min-height: 32px; padding: 6px 11px; color: rgba(233,240,236,.65); background: transparent; border: 0; border-radius: 5px; cursor: pointer; font-size: 10px; font-weight: 800; }
.view-switch button.active { color: var(--obsidian); background: var(--aurora); }
.canvas-wrap { position: relative; flex: 1; min-height: 380px; overflow: auto; padding: 40px 30px 30px 44px; background-color: var(--obsidian); background-image: radial-gradient(rgba(204,199,255,.18) 1px, transparent 1px); background-size: 12px 12px; }
.led-grid { position: relative; width: calc(24 * var(--cell)); height: calc(12 * var(--cell)); border: 1px solid rgba(204,199,255,.48); background-color: var(--obsidian); background-image: linear-gradient(to right, rgba(204,199,255,.1) 1px, transparent 1px), linear-gradient(to bottom, rgba(204,199,255,.1) 1px, transparent 1px), linear-gradient(to right, rgba(138,107,255,.2) 1px, transparent 1px), linear-gradient(to bottom, rgba(138,107,255,.2) 1px, transparent 1px); background-size: var(--cell) var(--cell), var(--cell) var(--cell), calc(var(--cell) * 2) calc(var(--cell) * 2), calc(var(--cell) * 2) calc(var(--cell) * 2); user-select: none; touch-action: none; }
.axis { position: absolute; color: rgba(204,199,255,.64); font-size: 8px; font-weight: 750; pointer-events: none; }
.axis-x { left: 44px; top: 19px; display: grid; grid-template-columns: repeat(12, calc(var(--cell) * 2)); width: calc(24 * var(--cell)); }
.axis-y { left: 15px; top: 40px; display: grid; grid-template-rows: repeat(6, calc(var(--cell) * 2)); height: calc(12 * var(--cell)); }
.axis span { align-self: center; }
.axis-x span { justify-self: center; }
.cabinet-node { position: absolute; display: grid; place-items: center; overflow: hidden; color: var(--obsidian); background: var(--screen-color); border: 1px solid var(--obsidian); cursor: pointer; }
.cabinet-node.checker-alt { background: var(--screen-alt); }
.cabinet-node.active-screen-cabinet { outline: 2px solid var(--paper); outline-offset: -3px; }
.cabinet-node:after { content: ""; position: absolute; inset: 3px; border: 1px solid rgba(9,12,12,.24); }
.cabinet-node .cab-number { z-index: 2; padding: 2px 3px; color: var(--obsidian); background: rgba(248,251,248,.84); font-size: 9px; font-weight: 900; }
.cabinet-node.route .cab-number { position: absolute; right: 3px; bottom: 3px; }
.cabinet-node.route { border-color: currentColor; background: color-mix(in srgb, currentColor 18%, var(--slate)); }
.cabinet-node .route-label { position: absolute; z-index: 3; top: 3px; left: 4px; font-size: 8px; font-weight: 900; }
.route-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; z-index: 4; pointer-events: none; }
.empty-state { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -45%); display: flex; flex-direction: column; align-items: center; gap: 7px; color: rgba(233,240,236,.65); text-align: center; pointer-events: none; }
.empty-state[hidden] { display: none; }
.empty-state b { font-family: "Fraunces", serif; color: var(--paper); font-size: 21px; }
.empty-state > span { font-size: 10px; }
.empty-shape { width: 44px; height: 44px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-bottom: 6px; }
.empty-shape span { display: block; background: var(--twilight); border: 1px solid var(--violet); }
.empty-shape span:first-child { grid-row: span 2; background: var(--dusk); }

.status-strip { min-height: 68px; display: grid; grid-template-columns: repeat(4, minmax(100px, 1fr)) 140px; color: var(--paper); background: var(--slate); border-top: 1px solid rgba(204,199,255,.22); }
.status-strip > div { display: flex; flex-direction: column; justify-content: center; padding: 9px 14px; border-right: 1px solid rgba(204,199,255,.16); }
.status-strip > div:last-child { border: 0; }
.status-strip span { color: rgba(233,240,236,.58); font-size: 8px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.status-strip strong { margin-top: 4px; font-size: 14px; white-space: nowrap; }
.status-strip .validation { flex-direction: row; align-items: center; gap: 8px; background: var(--twilight); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--aurora); }
.validation.warning { color: var(--obsidian); background: var(--glow); }
.validation.error { color: var(--obsidian); background: var(--dusk); }

.export-panel { padding: 21px 18px; color: var(--paper); background: var(--slate); border-left: 1px solid rgba(204,199,255,.22); }
.export-panel .section-kicker { color: var(--dusk); }
.export-panel h2 { margin: 7px 0 6px; font-family: "Fraunces", serif; font-size: 27px; line-height: 1; font-weight: 600; letter-spacing: -.035em; }
.export-panel > p { margin: 0 0 19px; color: rgba(233,240,236,.63); font-size: 10px; line-height: 1.5; }
.export-card { width: 100%; display: grid; grid-template-columns: 38px 1fr 18px; gap: 9px; align-items: center; margin: 0 0 8px; padding: 11px 9px; color: var(--paper); background: var(--obsidian); border: 1px solid rgba(204,199,255,.22); border-radius: 7px; text-align: left; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.export-card:hover:not(:disabled) { border-color: var(--violet); background: var(--twilight); }
.export-card:disabled { opacity: .45; cursor: not-allowed; }
.export-card b, .export-card small { display: block; }
.export-card b { font-size: 11px; }
.export-card small { margin-top: 4px; color: rgba(233,240,236,.6); font-size: 9px; line-height: 1.35; }
.doc-icon { width: 34px; height: 41px; display: grid; place-items: center; color: var(--obsidian); background: var(--aurora); border-radius: 4px; font-size: 9px; font-weight: 900; }
.doc-icon.wiring { background: var(--violet); }
.download-icon { color: var(--aurora); font-size: 20px; }
.checklist { margin: 21px 0 16px; padding: 11px 0; border-top: 1px solid rgba(204,199,255,.18); border-bottom: 1px solid rgba(204,199,255,.18); }
.checklist div { display: flex; gap: 8px; padding: 5px 2px; color: rgba(233,240,236,.68); font-size: 10px; }
.checklist div span { color: var(--aurora); font-weight: 900; }
.summary-card { display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 12px; color: var(--paper); background: var(--twilight); border: 1px solid rgba(204,199,255,.2); border-radius: 7px; font-size: 9px; }
.summary-card span { color: var(--aurora); }
.summary-card strong { font-size: 9px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; padding: 10px 15px; color: var(--obsidian); background: var(--aurora); border-radius: 7px; font-size: 11px; font-weight: 800; opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  body { overflow: auto; }
  .app-shell { grid-template-columns: 270px minmax(520px, 1fr); grid-template-rows: minmax(650px, calc(100vh - 76px)) auto; height: auto; }
  .export-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 130px 1fr 1fr; gap: 12px; align-items: center; padding: 16px 18px; border-left: 0; border-top: 1px solid rgba(204,199,255,.22); }
  .export-panel .section-kicker, .export-panel h2, .export-panel > p, .checklist, .summary-card { display: none; }
  .export-card { margin: 0; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { height: auto; min-height: 88px; padding: 11px; align-items: flex-start; }
  .brand { gap: 9px; }
  .brand-stamp { width: 72px; height: 44px; }
  .brand-copy { padding-left: 9px; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 150px; }
  .button { min-height: 34px; padding: 6px 9px; font-size: 10px; }
  .button span, .top-actions .ghost:nth-child(2) { display: none; }
  .app-shell { display: block; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid rgba(204,199,255,.22); }
  .workspace { min-height: 670px; }
  .workspace-head { align-items: flex-start; gap: 13px; flex-direction: column; }
  .workspace-controls { width: 100%; justify-content: space-between; }
  .status-strip { grid-template-columns: repeat(2, 1fr); }
  .status-strip .validation { display: none; }
  .export-panel { display: block; border-top: 1px solid rgba(204,199,255,.22); }
  .export-panel .section-kicker { display: block; }
  .export-panel .export-card { margin-bottom: 8px; }
}
