/* PatchPlaner – Werkstatt-Look: Gaffa-Gelb auf Rack-Grau.
   Layout: App-Shell mit Seitenleiste | Editor im Vollbild (Bibliothek · Plan · Inspektor) */
:root {
  --bg: #e9ecef; --panel: #f6f7f8; --surface: #ffffff; --sunk: #eef1f3; --line: #d3d8dd; --line-2: #b8c0c8;
  --fg: #1a2026; --muted: #5a646e; --accent: #f0b21c; --accent-ink: #1a2026; --accent-text: #8a5b00;
  --canvas: #dfe3e7; --grid: rgba(40,60,80,.09); --grid-major: rgba(40,60,80,.2); --nav: #1c2228; --nav-fg: #c9d1d9; --nav-dim: #8893a0;
  --ok: #2d8a55; --warn: #a86a12; --bad: #c23b32; --plan-filter: none; --shadow: 0 8px 28px rgba(20,30,40,.18); --shadow-sm: 0 1px 3px rgba(20,30,40,.12);
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 8px;
  --item-bg: #ffffff; --item-fg: #161b20; --item-muted: #4f5964; --item-line: #aab3bc;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #101317; --panel: #161a1f; --surface: #1d232a; --sunk: #13171b; --line: #2b333c; --line-2: #3d4752;
  --fg: #e3e7eb; --muted: #97a2ad; --accent-text: #f3c24f; --canvas: #0d1013; --nav: #0b0e11; --nav-fg: #c9d1d9; --nav-dim: #6f7a86;
  --grid: rgba(180,200,220,.06); --grid-major: rgba(180,200,220,.14); --plan-filter: invert(.9) hue-rotate(180deg);
  --ok: #4bb376; --warn: #e0a23a; --bad: #e5675e; --shadow: 0 10px 30px rgba(0,0,0,.5); --item-bg: #252c34; --item-fg: #f1f4f7; --item-muted: #b4bec8; --item-line: #4a5562; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #101317; --panel: #161a1f; --surface: #1d232a; --sunk: #13171b; --line: #2b333c; --line-2: #3d4752;
  --fg: #e3e7eb; --muted: #97a2ad; --accent-text: #f3c24f; --canvas: #0d1013; --nav: #0b0e11; --nav-fg: #c9d1d9; --nav-dim: #6f7a86;
  --grid: rgba(180,200,220,.06); --grid-major: rgba(180,200,220,.14); --plan-filter: invert(.9) hue-rotate(180deg);
  --ok: #4bb376; --warn: #e0a23a; --bad: #e5675e; --shadow: 0 10px 30px rgba(0,0,0,.5); --item-bg: #252c34; --item-fg: #f1f4f7; --item-muted: #b4bec8; --item-line: #4a5562; color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--f-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
a { color: var(--accent-text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { text-wrap: balance; }
.mono { font-family: var(--f-mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn-t { color: var(--warn); }

/* ---------- Bausteine ---------- */
.inp { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0; }
.inp:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.inp.sm { padding: 4px 7px; font-size: 13px; }
textarea.inp { resize: vertical; }
input[type=color] { width: 46px; height: 32px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 2px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 6px; padding: 7px 12px; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--fg); white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--sunk); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.pri:hover:not(:disabled) { filter: brightness(.95); background: var(--accent); }
.btn.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn.armed { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.lg { padding: 10px 16px; font-size: 15px; }
.icon-btn { border: 0; background: none; color: var(--muted); border-radius: 4px; padding: 3px 6px; font-size: 13px; line-height: 1; }
.icon-btn:hover:not(:disabled) { background: var(--sunk); color: var(--fg); }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; }
.inline { display: flex; gap: 6px; align-items: center; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; font: 600 11px var(--f-mono); padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); white-space: nowrap; color: var(--fg); letter-spacing: 0; text-transform: none; vertical-align: middle; }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.chip.acc { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; vertical-align: middle; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 10px; font-size: 12.5px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg.full { display: flex; } .seg.full button { flex: 1; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.swatches button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); padding: 0; }
.swatches button.on { box-shadow: 0 0 0 2px var(--accent); }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin: 0; }
.hint b { color: var(--fg); font-weight: 600; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 3px; }
.warnbox { border: 1px solid color-mix(in srgb, var(--warn) 50%, var(--line)); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); border-radius: var(--r); padding: 8px 10px; font-size: 12.5px; }
.errbox { border: 1px solid color-mix(in srgb, var(--bad) 50%, var(--line)); background: color-mix(in srgb, var(--bad) 9%, var(--surface)); border-radius: var(--r); padding: 8px 10px; font-size: 13px; }
kbd { font: 500 11px var(--f-mono); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--muted); background: var(--surface); white-space: nowrap; }
.fld { display: grid; gap: 4px; min-width: 0; }
.fld > span { font-size: 12px; color: var(--muted); }
.fld em { font-style: normal; opacity: .8; }
.row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: center; }
.row > span:first-child { font-size: 12px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.chk.big { font-size: 14px; font-weight: 500; }
.chkrow { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.h3, .sec > h3 { font: 600 13px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sec { display: grid; gap: 8px; }
.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 9px 14px; border-radius: 8px; font-size: 13px; z-index: 100; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.ov { position: fixed; inset: 0; background: rgba(10,14,18,.5); display: grid; place-items: center; padding: 16px; z-index: 80; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { width: min(1020px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font: 700 20px var(--f-display); letter-spacing: .04em; text-transform: uppercase; }
.modal .mb { overflow: auto; padding: 16px; display: grid; gap: 16px; }
.modal .mb.two { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
.modal .mb .col { display: grid; gap: 10px; min-width: 0; }
.modal .preview { position: sticky; top: 0; background: var(--sunk); border-radius: var(--r); padding: 12px; }
.modal footer { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); }
.modal img { max-width: 100%; }
table.keys { border-collapse: collapse; width: 100%; font-size: 13px; }
table.keys td { padding: 5px 4px; border-bottom: 1px solid var(--line); }
table.keys td:first-child { width: 42%; }

/* Port-Editor */
.prows { display: grid; gap: 5px; }
.prows .pr { display: grid; grid-template-columns: auto minmax(0, 1fr) 96px 130px auto auto; gap: 5px; align-items: center; }
.prows .ord { display: inline-flex; flex-direction: column; }
.prows .ord .icon-btn { padding: 0 4px; font-size: 10px; line-height: 1.2; }
.bulk { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r); padding: 8px; margin-top: 8px; }
.bulk .inp { width: auto; }

/* ---------- App-Shell ---------- */
#app { height: 100%; }
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); height: 100%; }
.nav { background: var(--nav); color: var(--nav-fg); display: flex; flex-direction: column; padding-block: 14px 12px; padding-inline: 10px; gap: 2px; overflow: auto; }
.brand { display: flex; align-items: baseline; gap: 6px; padding: 4px 10px 16px; text-decoration: none; color: #fff; }
.brand b, .brand-mini { font: 700 24px/1 var(--f-display); letter-spacing: .03em; text-transform: uppercase; color: inherit; text-decoration: none; }
.brand b i, .brand-mini i { font-style: normal; color: var(--accent); }
.brand-mini { font-size: 20px; color: var(--fg); }
.brand .tape { width: 22px; height: 12px; background: var(--accent); border-radius: 2px; transform: rotate(-6deg); align-self: center; }
.nav a.ni { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--nav-fg); text-decoration: none; font-weight: 500; }
.nav a.ni:hover { background: rgba(255,255,255,.06); }
.nav a.ni.on { background: rgba(240,178,28,.14); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav a.ni svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav .grow { flex: 1; }
.nav .me { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); margin-top: 8px; color: var(--nav-fg); }
.nav .me .who { min-width: 0; font-size: 13px; line-height: 1.3; }
.nav .me .who small { display: block; color: var(--nav-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .me button { margin-left: auto; background: none; border: 1px solid rgba(255,255,255,.15); color: var(--nav-fg); border-radius: 6px; padding: 4px 8px; font-size: 12px; }
.av { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font: 600 12px var(--f-body); flex: none; border: 2px solid var(--panel); }
.av.more { background: var(--line-2); color: var(--fg); }
.main-area { overflow: auto; min-width: 0; }
.page { padding-inline: 28px; padding-block: 24px 48px; max-width: 1280px; margin: 0 auto; display: grid; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head h1 { margin: 0; font: 700 34px/1 var(--f-display); letter-spacing: .02em; text-transform: uppercase; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .inp { width: auto; }
.toolbar .search { flex: 1 1 220px; max-width: 360px; }
.mobile-bar { display: none; }

/* Plan-Karten */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; position: relative; transition: border-color .15s, box-shadow .15s; }
.pcard:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.pcard .thumb { aspect-ratio: 16 / 9; max-width: 100%; background: var(--sunk) center / cover no-repeat; border-bottom: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); cursor: pointer; position: relative;
  background-image: repeating-linear-gradient(0deg, transparent 0 19px, var(--grid) 19px 20px), repeating-linear-gradient(90deg, transparent 0 19px, var(--grid) 19px 20px); }
.pcard .thumb { overflow: hidden; }
.pcard .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard .thumb .ph { font: 600 13px var(--f-display); letter-spacing: .12em; text-transform: uppercase; }
.pcard .body { padding: 10px 12px 12px; display: grid; gap: 6px; flex: 1; align-content: start; }
.pcard .title { font-weight: 600; font-size: 15px; line-height: 1.3; cursor: pointer; overflow-wrap: anywhere; }
.pcard .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.pcard .dates { display: flex; flex-wrap: wrap; gap: 6px; font: 500 12px var(--f-mono); font-variant-numeric: tabular-nums; }
.pcard .dates span { background: var(--sunk); border-radius: 4px; padding: 1px 6px; }
.pcard .dates span.soon { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--fg); }
.pcard .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 2px; }
.pcard .menu-btn { position: absolute; top: 8px; right: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; width: 30px; height: 28px; display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.pcard .badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 4px; }
.menu { position: fixed; z-index: 90; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); padding: 5px; min-width: 210px; display: grid; gap: 1px; }
.menu button { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 5px; font-size: 13px; }
.menu button:hover { background: var(--sunk); }
.menu button.bad { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 3px 0; }
.empty { background: var(--surface); border: 1px dashed var(--line-2); border-radius: 12px; padding: 36px 20px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.empty h2 { margin: 0; font: 700 22px var(--f-display); text-transform: uppercase; letter-spacing: .04em; }
.empty p { margin: 0; color: var(--muted); max-width: 52ch; }

/* Listen/Tabellen */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.lrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.lrow:last-child { border-bottom: 0; }
.lrow .t { font-weight: 600; overflow-wrap: anywhere; }
.lrow .s { font-size: 12px; color: var(--muted); }
.tscroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
table.tbl th { font: 600 11px var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.num { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.card-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: grid; gap: 14px; }
.card-panel > h2 { margin: 0; font: 700 18px var(--f-display); letter-spacing: .06em; text-transform: uppercase; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 14px; }
.colors label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.colors input[type=color] { width: 34px; height: 26px; }

/* Geräte */
.gcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.gcard .gprev { background: var(--sunk); padding: 12px; display: grid; place-items: center; border-bottom: 1px solid var(--line); min-height: 120px; max-height: 230px; overflow: hidden; }
.gcard .gprev svg { max-height: 200px; }
.gcard .gbody { padding: 10px 12px; display: grid; gap: 6px; align-content: start; }
.gcard .gname { font-weight: 600; overflow-wrap: anywhere; }
.gcard .gmeta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.gcard .btnrow { margin-top: 4px; }
.gimg { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.catchips { display: flex; flex-wrap: wrap; gap: 6px; }
.catchips button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 3px 11px; font-size: 12.5px; }
.catchips button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.builder { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.builder .preview-panel { position: sticky; top: 16px; }
.itemsvg { display: block; margin: 0 auto; height: auto; }

/* Auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 600px at 110% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 26px; display: grid; gap: 14px; }
.auth-card .brand { color: var(--fg); padding: 0; }
.auth-card h1 { margin: 0; font: 700 26px var(--f-display); text-transform: uppercase; letter-spacing: .03em; }
.auth-card p { margin: 0; color: var(--muted); }
.auth-card form { display: grid; gap: 12px; }
.auth-card .links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13px; }

/* ---------- Editor ---------- */
.ed-loading { height: 100%; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); text-align: center; padding: 16px; }
.editor { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); padding-inline: 12px; padding-block: 0 12px; gap: 0; }
.ed-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-block: 8px; }
.ed-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 320px; }
.ed-name { font: 600 16px var(--f-body); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 7px; min-width: 0; width: 100%; max-width: 30ch; }
.ed-name:hover:not([readonly]), .ed-name:focus { border-color: var(--line); background: var(--surface); outline: none; }
.savestate { font: 500 11.5px var(--f-mono); color: var(--muted); white-space: nowrap; }
.savestate.ok::before { content: '● '; color: var(--ok); }
.savestate.bad { color: var(--bad); }
.presence { display: flex; }
.presence .av { width: 26px; height: 26px; font-size: 11px; margin-left: -6px; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.grp { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); }
.grp button { border: 0; background: transparent; padding: 6px 10px; font-size: 13px; border-right: 1px solid var(--line); white-space: nowrap; }
.grp button:last-child { border-right: 0; }
.grp button:hover:not(:disabled) { background: var(--sunk); }
.grp button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ed-main { display: grid; grid-template-columns: 250px minmax(0, 1fr) 360px; gap: 12px; min-height: 0; }
.editor.readonly .ed-main { grid-template-columns: minmax(0, 1fr) 360px; }
.side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.lib-head { padding: 10px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.lib-list { overflow: auto; padding: 8px 10px 14px; display: grid; gap: 12px; align-content: start; }
.cat h4 { font: 600 12px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 4px 2px 6px; display: flex; align-items: center; gap: 6px; }
.cat h4 span { width: 8px; height: 8px; border-radius: 2px; }
.card { display: grid; gap: 1px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; margin-bottom: 5px; cursor: grab; user-select: none; }
.card:hover { border-color: var(--accent); }
.card .n { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .m { font: 11px var(--f-mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-sm { display: grid; gap: 8px; justify-items: start; padding: 4px; }
.empty-sm p { margin: 0; }
.stage { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--canvas); min-height: 0; touch-action: none; }
#svg { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; }
#svg.mode-calib, #svg.mode-measure, #svg.mode-draw { cursor: crosshair; }
#svg.panning { cursor: grabbing; }
.floorimg.inv { filter: var(--plan-filter); }
.floorimg.unlocked { cursor: move; outline: 2px dashed var(--accent); }
.gridline { stroke: var(--grid); } .gridmaj { stroke: var(--grid-major); }
.item { cursor: move; }
.item .body { fill: var(--item-bg); stroke: var(--item-line); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.item.sel .body { stroke: var(--accent); stroke-width: 3; }
.t-head { font: 600 14px var(--f-display); letter-spacing: .04em; }
.t-sub { font: 500 10.5px var(--f-body); opacity: .85; }
.t-el { font: 10px var(--f-body); fill: var(--item-muted); }
.t-port { font: 600 11px var(--f-body); fill: var(--item-fg); pointer-events: none; }
.ptab { cursor: crosshair; }
.ptab .tab-bg { fill: var(--item-bg); }
.ptab .tab-fg { stroke-width: 1.4; }
.ptab:hover .tab-fg { stroke-width: 2.6; }
.editor.readonly .ptab, .editor.readonly .item { cursor: default; }
.row .seg { flex-wrap: nowrap; } .row .seg button { padding: 5px 8px; }
.wire { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.wire.adapt { stroke-dasharray: 7 4; }
.wire.radio { stroke-dasharray: 2 5; }
.arrow { fill: none; stroke-width: 2.4; vector-effect: non-scaling-stroke; }
.hit { fill: none; stroke: transparent; stroke-width: 14; vector-effect: non-scaling-stroke; cursor: pointer; }
.cable:hover .wire { stroke-width: 4.5; }
.cable.sel .wire { stroke-width: 5; }
.pill { fill: var(--surface); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.t-pill { font-family: var(--f-mono); font-weight: 600; fill: var(--fg); }
.t-pill.halo { paint-order: stroke; stroke: var(--surface); }
#svg.hl .cable { opacity: .15; } #svg.hl .cable.hl { opacity: 1; }
.wp { fill: var(--accent); stroke: var(--accent-ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: grab; }
.handle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; cursor: pointer; }
.rotline { stroke: var(--accent); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.selbox { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.selrect { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.shape { cursor: move; }
.shape .s { vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.zone .zfill { pointer-events: none; vector-effect: non-scaling-stroke; }
.zone .zedge { fill: none; stroke: transparent; stroke-width: 12; vector-effect: non-scaling-stroke; }
.t-shape { font: 600 14px var(--f-display); letter-spacing: .03em; }
.t-zone { font: 700 15px var(--f-display); letter-spacing: .08em; text-transform: uppercase; fill: #fff; }
.t-free { font-family: var(--f-body); fill: var(--fg); }
.symg * { vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.symg .sf { fill: var(--sf); fill-opacity: var(--sfo); }
.symg .beam { fill-opacity: calc(var(--sfo) * .6); }
.symg .solid { fill: var(--col); fill-opacity: 1; stroke: none; }
.measure { stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-dasharray: 8 5; }
.mdot { fill: var(--accent); stroke: var(--accent-ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.templink, .measure, .mdot, .selbox { pointer-events: none; }
.templink { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.hud { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 9px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: calc(100% - 24px); font-size: 13px; z-index: 3; }
.hud b { font: 600 14px var(--f-display); letter-spacing: .05em; text-transform: uppercase; }
.hud .big { font: 600 18px var(--f-mono); color: var(--accent-text); }
.hud .inp { width: 100px; }
.banner { position: absolute; left: 12px; right: 12px; top: 12px; background: var(--surface); border: 1px solid var(--bad); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; z-index: 4; font-size: 13px; }
.scalebar { position: absolute; left: 12px; bottom: 12px; font: 600 11px var(--f-mono); color: var(--muted); pointer-events: none; }
.scalebar div { height: 6px; border: 2px solid var(--muted); border-top: 0; margin-top: 2px; }
.zoomlbl { position: absolute; right: 12px; bottom: 12px; font: 11px var(--f-mono); color: var(--muted); background: var(--panel); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); }
.legend { position: absolute; right: 12px; top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; display: grid; gap: 3px; max-height: calc(100% - 60px); overflow: auto; z-index: 2; }
.legend h5 { margin: 0 0 2px; font: 600 11px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.legend .li { display: flex; align-items: center; gap: 7px; padding: 1px 3px; border-radius: 4px; }
.legend .li:hover { background: var(--sunk); }
.legend .sw { width: 16px; height: 3px; border-radius: 2px; }
.legend .ct { font: 11px var(--f-mono); color: var(--muted); margin-left: auto; padding-left: 8px; }
.dtb { position: absolute; left: 12px; top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: grid; grid-template-columns: repeat(2, 34px); gap: 4px; box-shadow: var(--shadow); max-height: calc(100% - 60px); overflow: auto; z-index: 2; }
.dtb .sep { grid-column: 1 / -1; font: 600 10px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 4px 2px 0; }
.dtb button { width: 34px; height: 34px; border: 1px solid transparent; border-radius: 6px; background: transparent; display: grid; place-items: center; color: var(--fg); padding: 0; }
.dtb button:hover { background: var(--sunk); border-color: var(--line); }
.dtb button.on { background: var(--accent); color: var(--accent-ink); }
.dtb svg { width: 22px; height: 22px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 6px; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px 4px 9px; font: 600 13px var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--fg); border-bottom-color: var(--accent); }
.pane { overflow: auto; padding: 14px; display: grid; gap: 16px; align-content: start; min-height: 0; }
.calc { width: 100%; border-collapse: collapse; font-size: 13px; }
.calc td { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.calc td:last-child { text-align: right; font: 500 13px var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc tr.tot td { border-bottom: 0; border-top: 1.5px solid var(--fg); font-weight: 600; padding-top: 6px; }
.calc tr.pack td { border-bottom: 0; }
.calc tr.pack td:last-child { font-size: 16px; color: var(--accent-text); }
.plist { display: grid; gap: 3px; }
.prow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; user-select: none; }
.prow:hover { border-color: var(--line-2); }
.prow.ro { cursor: default; }
.prow.done { opacity: .6; }
.prow.done .pn > :not(small) { text-decoration: line-through; }
.prow .box2 { width: 16px; height: 16px; border: 1.5px solid var(--line-2); border-radius: 4px; display: grid; place-items: center; font-size: 11px; line-height: 1; }
.prow.done .box2 { background: var(--ok); border-color: var(--ok); color: #fff; }
.prow .pn { min-width: 0; font-size: 13px; }
.prow .pn small { display: block; font: 11px var(--f-mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.prow .q { font: 600 13px var(--f-mono); font-variant-numeric: tabular-nums; }
.prow .rm { border: 0; background: none; color: var(--muted); padding: 0 2px; }
.zonehead { font: 600 12px var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); margin: 6px 0 2px; }
.progress { height: 8px; border-radius: 999px; background: var(--sunk); overflow: hidden; border: 1px solid var(--line); }
.progress div { height: 100%; background: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.stat b { display: block; font: 600 20px var(--f-mono); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
table.patch { border-collapse: collapse; font-size: 12px; min-width: 560px; width: 100%; }
table.patch th { font: 600 11px var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
table.patch td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.patch .num { font-family: var(--f-mono); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.patch tr:hover td { background: var(--sunk); cursor: pointer; }
.portlist { display: grid; gap: 2px; font-size: 12px; }
.portlist > div { display: grid; grid-template-columns: auto 38px minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 3px 2px; border-bottom: 1px dashed var(--line); }
.portlist > div.link { cursor: pointer; } .portlist > div.link:hover { background: var(--sunk); }
.dir { font: 600 10px var(--f-mono); color: var(--muted); }
.floorrow { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; }
.fr-head { display: flex; gap: 8px; align-items: center; }
.ctx { position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); padding: 5px; min-width: 210px; display: grid; gap: 1px; }
.ctx button { border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: 5px; font-size: 13px; display: flex; justify-content: space-between; gap: 12px; }
.ctx button:hover { background: var(--sunk); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 3px 0; }
.ctx .swatches { padding: 4px 8px; }
.ctx .seg { margin: 3px 8px; }
.ctx .seg button { padding: 4px 9px; display: block; }
.ctx-sub { font: 600 10px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 4px 10px 0; }

/* ---------- Responsiv ---------- */
@media (max-width: 1180px) { .ed-main { grid-template-columns: 220px minmax(0, 1fr) 320px; } }
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .nav { display: none; position: fixed; inset: 0 30% 0 0; z-index: 70; box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--nav); color: #fff; }
  .mobile-bar button { background: none; border: 1px solid rgba(255,255,255,.2); color: #fff; border-radius: 6px; padding: 5px 10px; }
  .page { padding-inline: 16px; }
  .builder { grid-template-columns: 1fr; }
  .builder .preview-panel { position: static; }
  .modal .mb.two { grid-template-columns: 1fr; }
  .editor { height: auto; min-height: 100%; }
  .ed-main, .editor.readonly .ed-main { display: flex; flex-direction: column; }
  .stage { height: 68vh; order: 1; }
  .insp { order: 2; max-height: none; }
  .lib { order: 3; max-height: 420px; }
  .ed-name { max-width: none; }
}
@media (max-width: 560px) {
  .row { grid-template-columns: 1fr; gap: 4px; }
  .row2 { grid-template-columns: 1fr; }
  .prows .pr { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .prows .pr select { grid-column: 2 / 3; }
  .page-head h1 { font-size: 28px; }
  .grp button { padding: 6px 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
