/* Site Plan Studio — design system and layout.
   Brand colours can be overridden from config.js (applyTheme sets the same custom properties). */
:root {
  --primary: #0e1116;        /* top bar / ink */
  --primary-text: #ffffff;
  --accent: #ffe500;         /* VPS yellow: primary actions, selection */
  --accent-text: #111418;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --surface-2: #f7f8fa;
  --text: #111418;
  --text-2: #3d4652;
  --muted: #5b6472;          /* 6.0:1 on white */
  --border: #e2e5ea;
  --border-strong: #c9ced6;
  --focus: #2563eb;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --success: #1e7b45;
  --success-bg: #ecfdf3;
  --warn: #9a5b00;
  --warn-bg: #fff8e6;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 12px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, .18);
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --topbar-h: 56px;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { margin: 0; height: 100% }
body { font-family: var(--font); font-size: 13px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer }
a { color: inherit }
.num, .stats td:last-child, table.list td.n, #zoomLabel, #coords { font-variant-numeric: tabular-nums }
:focus { outline: none }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0 }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border-strong); background: var(--panel); border-radius: var(--radius); font-weight: 500; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s }
.btn:hover { background: var(--surface-2); border-color: #b3bac4 }
.btn:active { transform: translateY(1px) }
.btn:disabled { opacity: .5; cursor: default; transform: none }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: #e6cf00; font-weight: 600 }
.btn.primary:hover { background: #f5dc00 }
.btn.dark { background: var(--primary); color: var(--primary-text); border-color: var(--primary) }
.btn.dark:hover { background: #262b33 }
.btn.danger { color: var(--danger) }
.btn.danger:hover { background: var(--danger-bg); border-color: #f4b4ae }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none }
.btn.ghost:hover { background: var(--surface-2) }
.btn.lg { height: 40px; padding: 0 16px; font-size: 14px }
.btn.block { width: 100% }
.btn .spin, .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block }
@keyframes spin { to { transform: rotate(360deg) } }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px }
.linkbtn { border: 0; background: none; padding: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 2px }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea, .input {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff; transition: border-color .12s, box-shadow .12s }
textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical }
input:hover, select:hover, textarea:hover { border-color: #aab1bc }
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15) }
input[type=range] { width: 100%; accent-color: var(--primary); height: 20px }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary) }
.field { display: block; margin-bottom: 12px }
.field > span { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px }
.field > span b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: 11.5px }
.row { display: flex; gap: 10px }
.row > * { flex: 1; min-width: 0 }
.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer }
kbd { font-family: inherit; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px }
.seg { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; gap: 2px; margin-bottom: 12px }
.seg button { flex: 1; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; color: var(--muted); font-weight: 500 }
.seg button:hover { color: var(--text) }
.seg button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm) }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-rows: var(--topbar-h) 1fr; grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden }
.topbar { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 14px; background: var(--primary); color: var(--primary-text); min-width: 0 }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none }
.brand img { height: 28px }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; flex: none }
.brand-mark svg { width: 18px; height: 18px }
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -.01em; line-height: 1.1; white-space: nowrap }
.brand-sub { font-size: 11px; color: rgba(255, 255, 255, .6); white-space: nowrap }
.tb-sep { width: 1px; height: 24px; background: rgba(255, 255, 255, .14); margin: 0 6px; flex: none }
.project-name { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 440px; background: transparent; border: 1px solid transparent; color: inherit; border-radius: var(--radius); padding: 5px 8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.project-name:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .12) }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .1); color: rgba(255, 255, 255, .78); flex: none }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #4ade80 }
.badge.saving::before { background: #fbbf24 }
.badge.dirty { background: var(--accent); color: var(--accent-text) }
.badge.dirty::before, .badge.error::before { background: currentColor }
.badge.error { background: #fecaca; color: #7f1d1d }
.badge.readonly::before { background: #93c5fd }
.spacer { flex: 1 }
.tb-group { display: flex; gap: 2px; align-items: center }
.tb-btn { position: relative; background: transparent; border: 0; color: rgba(255, 255, 255, .86); height: 34px; padding: 0 10px; border-radius: var(--radius); display: flex; align-items: center; gap: 7px; white-space: nowrap; font-weight: 500 }
.tb-btn:hover { background: rgba(255, 255, 255, .1); color: #fff }
.tb-btn:disabled { opacity: .35; background: transparent; cursor: default }
.tb-btn svg { width: 18px; height: 18px; flex: none }
.tb-btn .chev { width: 12px; height: 12px; opacity: .6 }
.tb-btn.primary { background: var(--accent); color: var(--accent-text); font-weight: 600 }
.tb-btn.primary:hover { background: #f5dc00 }
.tb-btn:focus-visible { outline-color: #93c5fd }
.tb-btn[aria-expanded=true] { background: rgba(255, 255, 255, .14) }
.drawer-btn { display: none }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #2b313b; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; letter-spacing: .02em }

/* dropdown menus */
.menu-wrap { position: relative }
.menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50 }
.menu.left { left: 0; right: auto }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 6px; font-weight: 500; text-decoration: none }
.menu button:hover, .menu a:hover, .menu button:focus-visible { background: var(--bg) }
.menu button svg { width: 16px; height: 16px; color: var(--muted); flex: none }
.menu button kbd { margin-left: auto }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px }
.menu .who b { display: block }
.menu .who span { color: var(--muted); font-size: 12px }
.role-pill { display: inline-block; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px; border-radius: 999px; background: var(--bg); color: var(--text-2); margin-top: 4px }

.layout { display: grid; grid-template-columns: 272px 1fr 320px; min-height: 0; position: relative }
aside { background: var(--panel); display: flex; flex-direction: column; min-height: 0 }
.catalogue { border-right: 1px solid var(--border) }
.inspector { border-left: 1px solid var(--border) }
.side-head { padding: 14px 14px 12px; border-bottom: 1px solid var(--border) }
.side-head h2 { margin: 0 0 10px; font-size: 13px; font-weight: 600 }
.search { padding-left: 32px !important; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6472' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 10px center / 15px }
.scroll { overflow: auto; flex: 1; min-height: 0 }
.cat-h { display: flex; align-items: center; gap: 8px; padding: 14px 14px 6px; font-weight: 600; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em }
.cat-h i { width: 8px; height: 8px; border-radius: 2px }
.prod { display: flex; gap: 10px; align-items: center; padding: 8px; margin: 0 8px 2px; border-radius: var(--radius); cursor: grab; user-select: none; border: 1px solid transparent; transition: background .1s, border-color .1s }
.prod:hover { background: var(--surface-2); border-color: var(--border) }
.prod:focus-visible { outline-offset: 0 }
.prod.armed { border-color: var(--primary); background: #fffbd1; box-shadow: inset 3px 0 0 var(--accent) }
.prod svg { flex: none; background: var(--bg); border-radius: 8px }
.prod b { display: block; font-size: 13px; font-weight: 600 }
.prod span { display: block; color: var(--muted); font-size: 12px; line-height: 1.35 }
.prod em { display: block; font-style: normal; color: var(--text-2); font-size: 11.5px; margin-top: 2px }

.stage { position: relative; min-width: 0; min-height: 0; display: grid; grid-template-rows: 1fr 40px 28px }
#canvas { width: 100%; height: 100%; display: block; background: #eceef1; touch-action: none; cursor: default }
#canvas.crosshair { cursor: crosshair }
#canvas.grab, #canvas.panning { cursor: grabbing }
.float { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow) }
.toolbar { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 2px; padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow) }
.tool { width: 38px; height: 38px; border: 0; background: transparent; border-radius: var(--radius); display: grid; place-items: center; color: var(--text-2); position: relative }
.tool:hover { background: var(--bg); color: var(--text) }
.tool.active { background: var(--primary); color: var(--primary-text) }
.tool svg { width: 19px; height: 19px }
.tool .key { position: absolute; right: 3px; bottom: 1px; font-size: 9px; font-weight: 600; opacity: .5 }
.tool-sep { height: 1px; background: var(--border); margin: 3px 6px }
.zoombox { position: absolute; right: 12px; bottom: 80px; display: flex; align-items: center; padding: 3px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow) }
.zoombox button { width: 30px; height: 30px; border: 0; background: transparent; border-radius: 6px; font-size: 16px; color: var(--text-2) }
.zoombox button:hover { background: var(--bg); color: var(--text) }
.zoombox span { min-width: 48px; text-align: center; font-size: 12px; font-weight: 500; color: var(--muted) }
.legend { pointer-events: none; user-select: none; position: absolute; left: 12px; bottom: 80px; background: rgba(255, 255, 255, .96); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 12px; font-size: 12px; box-shadow: var(--shadow) }
.legend div { display: flex; align-items: center; gap: 8px; margin: 2px 0 }
.legend i { width: 12px; height: 12px; border-radius: 3px; opacity: .8 }
.legend small { color: var(--muted) }
.empty-hint { position: absolute; inset: 0 0 68px 0; display: grid; place-items: center; pointer-events: none; text-align: center }
.empty-card { pointer-events: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px 32px; max-width: 420px; box-shadow: var(--shadow) }
.empty-card .ico { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 12px; background: #fffbd1; display: grid; place-items: center }
.empty-card .ico svg { width: 24px; height: 24px }
.empty-card h3 { margin: 0 0 6px; font-size: 16px }
.empty-card p { margin: 0 0 16px; color: var(--muted); line-height: 1.55 }
.empty-card .btn-row { justify-content: center; margin: 0 }
.empty-card small { display: block; margin-top: 12px; color: var(--muted) }
.floors { display: flex; align-items: center; gap: 4px; padding: 0 10px; background: var(--panel); border-top: 1px solid var(--border); overflow-x: auto }
.ftab { border: 1px solid transparent; background: transparent; height: 28px; padding: 0 12px; border-radius: 6px; white-space: nowrap; color: var(--muted); font-weight: 500 }
.ftab:hover { background: var(--bg); color: var(--text) }
.ftab.active { background: var(--bg); color: var(--text); border-color: var(--border); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent) }
.ftab.add { color: var(--text-2) }
.statusbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 12px; font-size: 12px; color: var(--muted); background: var(--panel); border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden }
#status { overflow: hidden; text-overflow: ellipsis }
#status.warn { color: var(--warn); font-weight: 500 }

/* inspector */
.tabs { display: flex; gap: 4px; padding: 8px 10px 0; border-bottom: 1px solid var(--border) }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px 8px 11px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px }
.tabs button:hover { color: var(--text) }
.tabs button.active { color: var(--text); border-bottom-color: var(--primary) }
.pane { padding: 14px 16px 28px }
.pane h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px }
.pane h3:first-child { margin-top: 2px }
.sel-head { display: flex; gap: 12px; align-items: center; padding: 2px 0 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px }
.sel-head svg { flex: none; background: var(--bg); border-radius: 10px }
.sel-head b { display: block; font-size: 15px }
.sel-head span { color: var(--muted); font-size: 12px }
.stats { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin: 8px 0 4px }
.stats table { width: 100%; border-collapse: collapse }
.stats td { padding: 4px 0; font-size: 12.5px }
.stats td:last-child { text-align: right; font-weight: 600 }
.stats i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px }
.stats small { color: var(--muted) }
.note { background: var(--warn-bg); border: 1px solid #f7d58b; color: #6b4300; border-radius: var(--radius); padding: 10px 12px; font-size: 12.5px; margin: 8px 0 }
.tips { color: var(--muted); padding-left: 16px; margin: 0; line-height: 1.75; font-size: 12.5px }
table.list { width: 100%; border-collapse: collapse; font-size: 12.5px }
table.list th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--border) }
table.list td { padding: 7px 4px; border-bottom: 1px solid var(--border); vertical-align: top }
table.list td.n, table.list th.n { text-align: right; white-space: nowrap }
table.list tr.total td { font-weight: 700; border-bottom: 0 }
table.list small { color: var(--muted); display: block }
.checks { list-style: none; padding: 0; margin: 0 }
.checks li { display: flex; gap: 8px; padding: 7px 0; font-size: 12.5px; border-bottom: 1px solid var(--border) }
.checks li:last-child { border: 0 }
.checks .ok { color: var(--success) }
.checks .bad { color: var(--warn) }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow-lg); color: var(--text) }
dialog::backdrop { background: rgba(14, 17, 22, .5); backdrop-filter: blur(2px) }
dialog form { padding: 20px 22px }
dialog h2 { margin: 0 0 16px; font-size: 17px; letter-spacing: -.01em }
dialog.wide { width: min(820px, calc(100vw - 32px)) }
dialog.mapdlg { width: min(1150px, calc(100vw - 32px)) }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border) }
.dlg-head h2 { margin: 0; font-size: 17px }
.dlg-head .who { margin-left: auto; font-size: 12px; color: var(--muted) }
.dlg-body { padding: 18px 22px 22px; overflow: auto; max-height: calc(100vh - 160px) }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px }
.x { margin-left: auto; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; font-size: 20px; line-height: 1; color: var(--muted) }
.dlg-head .who + .x { margin-left: 0 }
.x:hover { background: var(--bg); color: var(--text) }
.lib-tabs { padding: 14px 20px 0 }
.lib-tabs .seg { margin: 0; max-width: 440px }
.lib-body { padding: 4px 20px 20px; max-height: 62vh; overflow: auto; min-height: 220px }
.lib-intro { color: var(--muted); font-size: 12.5px; margin: 12px 0 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap }
.lib-intro .spacer { flex: 1 }
.lib-row { display: flex; gap: 14px; align-items: center; padding: 12px 8px; margin: 0 -8px; border-bottom: 1px solid var(--border); border-radius: 6px }
.lib-row:hover { background: var(--surface-2) }
.lib-row .thumb { width: 40px; height: 40px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; color: var(--muted); flex: none }
.lib-row .thumb svg { width: 20px; height: 20px }
.lib-row .info { flex: 1; min-width: 0 }
.lib-row b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px }
.lib-row small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.lib-row .acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end }
.lib-row .acts .btn { height: 28px; padding: 0 10px; font-size: 12px }
.tag { font-size: 10.5px; background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 1px 7px; margin-left: 6px; font-weight: 700; vertical-align: 1px }
.tag.grey { background: var(--bg); color: var(--text-2) }
.empty { color: var(--muted); text-align: center; padding: 40px 10px }
.empty b { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px }
.skeleton { height: 56px; border-radius: 8px; margin: 10px 0; background: linear-gradient(90deg, var(--bg) 0%, #e9ebef 50%, var(--bg) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite }
@keyframes shimmer { to { background-position: -200% 0 } }
.map-search { display: flex; gap: 8px; padding: 14px 20px }
.map-search input { height: 40px; font-size: 14px }
.map-search .btn { height: 40px }
.map-wrap { position: relative }
.mapbox { height: min(60vh, 620px); background: #dde1e6 }
.map-results { position: absolute; z-index: 1000; top: 10px; left: 56px; right: 20px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-height: 260px; overflow: auto }
.map-results button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 14px; border-bottom: 1px solid var(--border) }
.map-results button:hover, .map-results button:focus-visible { background: var(--bg) }
.map-results .msg { padding: 12px 14px; color: var(--muted) }
.map-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px; flex-wrap: wrap }
.map-foot .seg { margin: 0 }
.map-foot #mapInfo { font-size: 12px; color: var(--muted) }
.frame { position: absolute; inset: 0; pointer-events: none; z-index: 500; box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 0 4px rgba(0, 0, 0, .6) }

/* ---------- toasts & loading ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; width: min(460px, calc(100vw - 32px)) }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; background: var(--primary); color: #fff; padding: 11px 14px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); font-weight: 500; animation: toastIn .18s ease-out }
.toast.error { background: #7f1d1d }
.toast.success::before, .toast.error::before, .toast.info::before { content: ""; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; flex: none; background: #4ade80 }
.toast.error::before { background: #fca5a5 }
.toast.info::before { background: var(--accent) }
.toast button { margin-left: auto; background: rgba(255, 255, 255, .14); border: 0; color: #fff; border-radius: 6px; padding: 3px 9px; font-weight: 600 }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) } }
.boot { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: grid; place-items: center; transition: opacity .2s }
.boot.out { opacity: 0; pointer-events: none }
.boot-card { text-align: center; color: var(--muted) }
.boot-card .brand-mark { width: 44px; height: 44px; border-radius: 12px; margin: 0 auto 16px }
.boot-card .brand-mark svg { width: 24px; height: 24px }
.boot-card .spin { color: var(--text); margin-top: 14px; width: 18px; height: 18px }
.boot-card.error { color: var(--text) }

/* ---------- responsive ---------- */
@media (max-width: 1280px) { .tb-btn .lbl.opt { display: none } }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr }
  .catalogue, .inspector { position: absolute; top: 0; bottom: 0; z-index: 30; width: min(320px, 88vw); box-shadow: var(--shadow-lg); transition: transform .2s ease }
  .catalogue { left: 0; transform: translateX(-102%) }
  .inspector { right: 0; transform: translateX(102%) }
  .layout.show-catalogue .catalogue, .layout.show-inspector .inspector { transform: none }
  .drawer-btn { display: flex }
  .tb-btn .lbl { display: none }
  .project-name { max-width: 300px; min-width: 0; flex: 0 1 auto }
  .project-name > span:first-child { min-width: 48px }
  .topbar .brand > div:not(.brand-mark) { display: none }
}
.show-sm { display: none !important }
@media (max-width: 640px) {
  :root { --topbar-h: 52px }
  .show-sm { display: flex !important }
  .brand-name, .brand-sub, .tb-sep, .hide-sm, #btnUndo, #btnRedo, #btnPlan, #exportWrap { display: none !important }
  .topbar { gap: 2px; padding: 0 6px; overflow: hidden }
  .tb-btn { padding: 0 8px }
  .project-name { max-width: 150px; padding: 5px 4px }
  .project-name .badge { display: none }
  .project-name > span:first-child { min-width: 0 }
  .toolbar { top: 8px; left: 8px }
  .zoombox { right: 8px; bottom: 76px }
  .legend { display: none }
  .statusbar #coords { display: none }
}

/* ---------- sign-in pages ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); background: var(--panel) }
.auth-side { background: var(--primary); color: #fff; padding: 48px; display: flex; flex-direction: column; position: relative; overflow: hidden }
.auth-side .brand-name { font-size: 16px }
.auth-side h1 { font-size: 34px; line-height: 1.15; letter-spacing: -.025em; margin: auto 0 14px; max-width: 420px }
.auth-side p { color: rgba(255, 255, 255, .7); font-size: 15px; max-width: 400px; margin: 0 0 32px; line-height: 1.6 }
.auth-side .grid-art { position: absolute; inset: 0; opacity: .5; pointer-events: none; background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px); background-size: 32px 32px; mask-image: radial-gradient(circle at 70% 30%, #000, transparent 70%) }
.auth-side .cone { position: absolute; right: -60px; top: 60px; width: 360px; height: 360px; border-radius: 50%; background: conic-gradient(from 200deg, rgba(255, 229, 0, .28), rgba(255, 229, 0, 0) 22%); filter: blur(1px) }
.auth-side .foot { font-size: 12px; color: rgba(255, 255, 255, .5); position: relative }
.auth-main { display: grid; place-items: center; padding: 32px 20px }
.auth-card { width: 100%; max-width: 380px }
.auth-card h2 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 6px }
.auth-card .lead { color: var(--muted); margin: 0 0 24px; font-size: 14px; line-height: 1.55 }
.auth-card .field input { height: 42px; font-size: 14px }
.auth-card .btn.lg { width: 100%; margin-top: 4px }
.auth-card .alt { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center }
.code-input { letter-spacing: .4em; text-align: center; font-size: 22px !important; font-weight: 600; font-variant-numeric: tabular-nums; height: 52px !important }
.alert { border-radius: var(--radius); padding: 10px 12px; font-size: 13px; margin-bottom: 16px; display: flex; gap: 8px }
.alert.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecdca }
.alert.success { background: var(--success-bg); color: var(--success); border: 1px solid #abefc6 }
.alert.info { background: #eff4ff; color: #1d3f8f; border: 1px solid #c7d7fe }
.steps { display: flex; gap: 6px; margin-bottom: 22px }
.steps i { height: 4px; flex: 1; border-radius: 2px; background: var(--border) }
.steps i.on { background: var(--primary) }
.qr { display: flex; gap: 16px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; margin-bottom: 18px }
.qr .box { width: 136px; height: 136px; flex: none; background: #fff; border-radius: 8px; padding: 6px; display: grid; place-items: center }
.qr .box img, .qr .box canvas { width: 124px !important; height: 124px !important }
.qr code, .codes code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; word-break: break-all; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; display: inline-block }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 16px }
.codes code { text-align: center; font-size: 14px; padding: 8px }
.pw-meter { height: 4px; border-radius: 2px; background: var(--border); margin-top: 6px; overflow: hidden }
.pw-meter i { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s, background .2s }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr } .auth-side { padding: 16px 20px; min-height: 0 } .auth-side .brand-name { display: block !important } .auth-main { place-items: start center; padding-top: 40px } .auth-side h1, .auth-side p, .auth-side .cone, .auth-side .foot { display: none } }

/* ---------- print / PDF ---------- */
#printArea { display: none }
@media print {
  @page { size: A4 landscape; margin: 10mm }
  body { overflow: visible; background: #fff }
  .app, dialog, .toasts, .boot { display: none !important }
  #printArea { display: block }
  .page { page-break-after: always; break-after: page; display: flex; flex-direction: column; height: 188mm }
  .page:last-child { page-break-after: auto; break-after: auto }
  .tblock { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid var(--primary); padding-bottom: 6px; margin-bottom: 6px }
  .tblock .l { display: flex; align-items: center; gap: 10px }
  .tblock h1 { font-size: 16px; margin: 0 }
  .tblock .meta { font-size: 10px; color: #444; text-align: right; line-height: 1.4 }
  .pbody { flex: 1; display: flex; gap: 10px; min-height: 0 }
  .pbody .plan { flex: 1; min-width: 0; border: 1px solid #ccc; display: flex; align-items: center; justify-content: center }
  .pbody .plan svg { max-width: 100%; max-height: 100%; width: 100%; height: 100% }
  .pbody .key { width: 52mm; font-size: 9.5px }
  .key h4 { margin: 4px 0; font-size: 10px; text-transform: uppercase; color: #555 }
  .key div { display: flex; gap: 5px; align-items: center; margin: 2px 0 }
  .key i { width: 10px; height: 10px; display: inline-block; border-radius: 2px }
  .page table.list { font-size: 10px }
  .pfoot { font-size: 9px; color: #666; border-top: 1px solid #ccc; padding-top: 3px; margin-top: 4px; display: flex; justify-content: space-between }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition: none !important } }
