:root {
  color-scheme: dark;
  --bg: #0b141b;
  --surface: #111d25;
  --surface-2: #16242d;
  --surface-3: #1b2b35;
  --surface-4: #21343f;
  --line: #263944;
  --line-strong: #38505c;
  --text: #e7f0f1;
  --muted: #91a7ad;
  --muted-2: #6f858d;
  --accent: #2bd3b2;
  --accent-strong: #1ba98f;
  --accent-soft: rgba(43, 211, 178, .13);
  --blue: #70a6ff;
  --warning: #f4b85f;
  --danger: #f07178;
  --success: #55d69e;
  --info: #6da8ff;
  --shadow: 0 18px 48px rgba(0, 0, 0, .33);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-height: 58px;
  --sidebar-left: 292px;
  --sidebar-right: 344px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
body { min-width: 940px; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
svg { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

::selection { background: rgba(43, 211, 178, .3); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b414c; border: 3px solid transparent; background-clip: padding-box; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #3a5562; border: 2px solid transparent; background-clip: padding-box; }

.app-shell { display: grid; grid-template-rows: var(--topbar-height) 1fr; width: 100%; height: 100%; background: var(--bg); }

.topbar {
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(218px, var(--sidebar-left)) 1fr auto 1fr;
  align-items: center;
  min-height: var(--topbar-height);
  padding: 0 10px 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 22, 29, .96);
  box-shadow: 0 3px 16px rgba(0, 0, 0, .14);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  padding: 5px 7px 5px 2px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--accent); }
.brand-mark svg { width: 32px; height: 32px; stroke-width: 1.65; }
.brand-word { font-size: 16px; font-weight: 790; letter-spacing: -.035em; }

.project-identity { display: flex; align-items: center; min-width: 0; gap: 7px; justify-self: start; }
.project-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px rgba(244,184,95,.1); flex: 0 0 auto; }
.project-status-dot.published { background: var(--success); box-shadow: 0 0 0 3px rgba(85,214,158,.1); }
.project-name-button { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; padding: 5px 4px; background: transparent; font-size: 13px; font-weight: 650; color: #dbe8ea; cursor: pointer; }
.project-name-button:hover { color: #fff; }
.save-indicator { color: var(--muted-2); font-size: 11px; white-space: nowrap; }

.mode-switcher { justify-self: center; display: inline-flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #0d181f; }
.mode-button { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 13px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; transition: background .15s ease, color .15s ease; }
.mode-button span { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #1c2b34; color: #8fa4aa; font-size: 10px; }
.mode-button:hover { color: var(--text); }
.mode-button.is-active { background: var(--surface-3); color: #f2ffff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.035); }
.mode-button.is-active span { background: var(--accent); color: #08231d; }
.mode-button:disabled { opacity: .35; cursor: not-allowed; }

.top-actions { justify-self: end; display: flex; align-items: center; gap: 4px; }
.icon-button, .tool-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover, .tool-button:hover { background: var(--surface-3); color: var(--text); border-color: var(--line); }
.icon-button:disabled { opacity: .25; cursor: default; background: transparent; }
.icon-button svg, .tool-button svg { width: 17px; height: 17px; }

.workspace { display: grid; grid-template-columns: var(--sidebar-left) minmax(360px, 1fr) var(--sidebar-right); min-height: 0; }
.sidebar { min-width: 0; display: grid; grid-template-rows: auto 1fr; min-height: 0; background: var(--surface); }
.left-sidebar { border-right: 1px solid var(--line); }
.right-sidebar { border-left: 1px solid var(--line); }
.panel-heading { min-height: 58px; padding: 14px 15px 11px; border-bottom: 1px solid var(--line); background: rgba(17,29,37,.96); }
.panel-heading h2 { margin: 0; font-size: 14px; letter-spacing: -.015em; }
.panel-heading p { margin: 4px 0 0; color: var(--muted-2); font-size: 11px; line-height: 1.35; }
.panel-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-content { min-height: 0; overflow: auto; }
.panel-section { padding: 15px; border-bottom: 1px solid var(--line); }
.panel-section:last-child { border-bottom: 0; }
.section-label { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; color: var(--muted); font-size: 10px; font-weight: 760; text-transform: uppercase; letter-spacing: .095em; }
.section-label .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 10px; letter-spacing: 0; }

.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #101a22; }
#assemblyCanvas { display: block; width: 100%; height: 100%; outline: 0; cursor: default; touch-action: none; }
#assemblyCanvas:focus-visible { box-shadow: inset 0 0 0 2px rgba(43,211,178,.65); }
#assemblyCanvas.placing { cursor: crosshair; }

.viewport-toolbar { position: absolute; z-index: 5; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.tool-group { display: flex; gap: 3px; padding: 4px; border: 1px solid rgba(80,107,119,.65); border-radius: 10px; background: rgba(10,20,27,.84); box-shadow: 0 7px 22px rgba(0,0,0,.22); backdrop-filter: blur(12px); pointer-events: auto; }
.tool-button { width: 32px; height: 32px; }
.tool-button.is-active { color: var(--accent); background: rgba(43,211,178,.1); border-color: rgba(43,211,178,.22); }
.view-help { padding: 8px 10px; border: 1px solid rgba(80,107,119,.45); border-radius: 8px; background: rgba(10,20,27,.7); color: #8fa5ab; font-size: 10px; backdrop-filter: blur(10px); }

.stage-footer { position: absolute; z-index: 5; left: 12px; right: 12px; bottom: 10px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.stage-stats, .coordinate-readout { display: inline-flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid rgba(80,107,119,.5); border-radius: 8px; background: rgba(10,20,27,.78); color: #9db0b5; font-size: 10px; backdrop-filter: blur(10px); }
.stage-stats strong { color: #d8e8e8; }
.axis { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; color: #061111; font-size: 9px; font-weight: 800; }
.axis.x { background: #ed7065; }.axis.y { background: #66b891; }.axis.z { background: #6f8ee8; }

.placement-banner { position: absolute; z-index: 8; left: 50%; top: 68px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; min-width: 330px; max-width: 70%; padding: 9px 10px 9px 12px; border: 1px solid rgba(43,211,178,.38); border-radius: 11px; background: rgba(13,32,35,.94); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.placement-banner[hidden] { display: none; }
.placement-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(43,211,178,.13); }
.placement-banner div { min-width: 0; display: flex; flex-direction: column; }
.placement-banner strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.placement-banner span { color: var(--muted); font-size: 10px; }
.placement-banner button { margin-left: auto; border: 1px solid rgba(43,211,178,.25); border-radius: 6px; background: rgba(43,211,178,.08); color: #aaf4e3; font-size: 10px; padding: 5px 7px; cursor: pointer; }

.search-box { position: relative; margin: 12px 12px 8px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); pointer-events: none; }
.search-box input { width: 100%; height: 36px; padding: 0 10px 0 33px; border: 1px solid var(--line); border-radius: 9px; outline: 0; background: #0e1920; color: var(--text); font-size: 12px; }
.search-box input:focus { border-color: rgba(43,211,178,.52); box-shadow: 0 0 0 3px rgba(43,211,178,.08); }
.search-box input::placeholder { color: #627881; }

.filter-row { display: flex; gap: 6px; margin: 0 12px 10px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip { flex: 0 0 auto; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.filter-chip:hover { color: var(--text); border-color: var(--line-strong); }
.filter-chip.is-active { color: #bff8eb; border-color: rgba(43,211,178,.4); background: rgba(43,211,178,.1); }

.component-list { display: grid; gap: 8px; padding: 2px 12px 14px; }
.component-card { display: grid; grid-template-columns: 52px minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 68px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: #14212a; cursor: grab; transition: transform .12s ease, border-color .12s ease, background .12s ease; }
.component-card:hover { transform: translateY(-1px); border-color: #3d5965; background: #172731; }
.component-card.is-active { border-color: rgba(43,211,178,.62); background: rgba(31,66,65,.58); box-shadow: 0 0 0 2px rgba(43,211,178,.06); }
.component-card:active { cursor: grabbing; }
.component-thumb { position: relative; display: grid; place-items: center; width: 52px; height: 48px; overflow: hidden; border: 1px solid rgba(255,255,255,.05); border-radius: 8px; background: radial-gradient(circle at 50% 35%, #263c47, #111c24 70%); }
.component-thumb-shape { display: block; width: 30px; height: 22px; border-radius: 3px; transform: skewY(-13deg) rotate(-8deg); box-shadow: 5px 5px 0 rgba(0,0,0,.24); }
.component-thumb-shape.rail { width: 38px; height: 9px; }
.component-thumb-shape.post { width: 11px; height: 34px; }
.component-thumb-shape.round { width: 27px; height: 27px; border-radius: 50%; }
.component-card-copy { min-width: 0; }
.component-card-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dce9eb; font-size: 11px; line-height: 1.35; }
.component-card-copy span { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted-2); font-size: 9.5px; }
.component-price { align-self: start; color: #a6d8cc; font-size: 10px; font-weight: 650; }
.component-port-count { display: inline-flex; align-items: center; gap: 3px; color: #6f8790; font-size: 9px; }
.component-port-count::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-strong); }

.empty-panel { display: grid; justify-items: center; gap: 8px; padding: 42px 20px; color: var(--muted); text-align: center; }
.empty-panel svg { width: 34px; height: 34px; color: #546c76; }
.empty-panel strong { color: #cbdadd; font-size: 12px; }
.empty-panel span { max-width: 230px; font-size: 10px; line-height: 1.5; }

.primary-button, .secondary-button, .danger-button, .ghost-button, .mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s ease, filter .1s ease, border-color .1s ease;
}
.primary-button { border: 1px solid #35ddbb; background: var(--accent); color: #06241d; }
.primary-button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.secondary-button { border: 1px solid var(--line-strong); background: var(--surface-3); color: #d8e5e7; }
.secondary-button:hover { border-color: #4c6875; background: var(--surface-4); }
.ghost-button { border: 1px solid var(--line); background: transparent; color: var(--muted); }
.ghost-button:hover { color: var(--text); border-color: var(--line-strong); }
.danger-button { border: 1px solid rgba(240,113,120,.34); background: rgba(240,113,120,.1); color: #f7a6aa; }
.danger-button:hover { background: rgba(240,113,120,.15); }
.mini-button { min-height: 28px; padding: 0 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 10px; }
.mini-button:hover { color: var(--text); border-color: var(--line-strong); }
button:disabled, .primary-button:disabled, .secondary-button:disabled { opacity: .42; cursor: not-allowed; transform: none; filter: none; }
.button-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.button-row > .primary-button, .button-row > .secondary-button { flex: 1 1 auto; }
.full-button { width: 100%; }

.tab-bar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 6px; border-bottom: 1px solid var(--line); background: #0f1a22; }
.tab-button { min-width: 0; padding: 7px 5px; border: 0; border-radius: 6px; background: transparent; color: var(--muted-2); font-size: 10px; font-weight: 680; cursor: pointer; }
.tab-button:hover { color: var(--text); }
.tab-button.is-active { background: var(--surface-3); color: #dff8f3; }
.tab-button .badge { display: inline-grid; place-items: center; min-width: 17px; height: 17px; margin-left: 3px; padding: 0 4px; border-radius: 999px; background: #2d414b; font-size: 9px; }
.tab-button .badge.error { background: rgba(240,113,120,.18); color: #f2a1a6; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
.field label, .field-label { color: var(--muted); font-size: 9.5px; font-weight: 640; }
.field input, .field select, .field textarea, .inline-input {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  background: #0d181f;
  color: #dfecee;
  font-size: 11px;
}
.field textarea { min-height: 70px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .inline-input:focus { border-color: rgba(43,211,178,.52); box-shadow: 0 0 0 3px rgba(43,211,178,.07); }
.field input[type="color"] { padding: 4px; min-height: 34px; cursor: pointer; }
.field small { color: var(--muted-2); font-size: 9px; line-height: 1.4; }

.checkbox-row { display: flex; align-items: center; gap: 8px; min-height: 30px; color: #b6c7cb; font-size: 10px; cursor: pointer; }
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--accent); }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(38,57,68,.65); }
.switch-row:last-child { border-bottom: 0; }
.switch-copy strong { display: block; color: #cfdddf; font-size: 10px; }
.switch-copy span { display: block; margin-top: 3px; color: var(--muted-2); font-size: 9px; line-height: 1.35; }
.switch { position: relative; width: 34px; height: 20px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border: 1px solid #38505c; border-radius: 999px; background: #1b2a33; transition: .18s ease; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #8da0a6; transition: .18s ease; }
.switch input:checked + span { border-color: var(--accent-strong); background: rgba(43,211,178,.25); }
.switch input:checked + span::after { transform: translateX(14px); background: var(--accent); }

.inspector-title { display: grid; grid-template-columns: 40px minmax(0,1fr); gap: 10px; align-items: center; }
.inspector-swatch { width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.08); border-radius: 8px; box-shadow: inset 0 0 12px rgba(0,0,0,.2); }
.inspector-title h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.inspector-title p { margin: 3px 0 0; color: var(--muted-2); font-size: 9.5px; }
.property-list { display: grid; gap: 0; }
.property-row { display: grid; grid-template-columns: 95px 1fr; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid rgba(38,57,68,.58); font-size: 10px; }
.property-row:last-child { border-bottom: 0; }
.property-row span:first-child { color: var(--muted-2); }
.property-row span:last-child { color: #cbdadd; text-align: right; overflow-wrap: anywhere; }

.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.metric-card { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: #14212a; }
.metric-card b { display: block; overflow: hidden; text-overflow: ellipsis; color: #e3efef; font-size: 17px; letter-spacing: -.025em; white-space: nowrap; }
.metric-card span { display: block; margin-top: 3px; color: var(--muted-2); font-size: 9px; }
.metric-card.accent b { color: #7ae6d0; }

.connection-item { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid rgba(38,57,68,.58); }
.connection-item:last-child { border-bottom: 0; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(43,211,178,.08); }
.connection-copy strong { display: block; font-size: 10px; }
.connection-copy span { display: block; margin-top: 2px; color: var(--muted-2); font-size: 9px; }

.bom-table-wrap { overflow: auto; }
.bom-table { width: 100%; border-collapse: collapse; }
.bom-table th { position: sticky; top: 0; z-index: 1; padding: 7px 6px; background: #111d25; color: var(--muted-2); font-size: 8.5px; text-transform: uppercase; letter-spacing: .06em; text-align: left; border-bottom: 1px solid var(--line); }
.bom-table td { padding: 9px 6px; border-bottom: 1px solid rgba(38,57,68,.58); color: #bfcfd2; font-size: 9.5px; vertical-align: top; }
.bom-table td:last-child, .bom-table th:last-child { text-align: right; }
.bom-name { display: block; color: #dbe8ea; font-weight: 620; }
.bom-sku { display: block; margin-top: 2px; color: var(--muted-2); font-size: 8.5px; }
.bom-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0 0; }
.bom-total span { color: var(--muted); font-size: 10px; }
.bom-total b { color: #8debd7; font-size: 17px; }

.issue-list { display: grid; gap: 7px; }
.issue-card { display: grid; grid-template-columns: 7px minmax(0,1fr); gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #142129; cursor: pointer; }
.issue-card:hover { border-color: var(--line-strong); }
.issue-bar { width: 4px; min-height: 100%; border-radius: 999px; background: var(--info); }
.issue-card.error .issue-bar { background: var(--danger); }
.issue-card.warning .issue-bar { background: var(--warning); }
.issue-copy strong { display: block; color: #dbe8ea; font-size: 10px; }
.issue-copy span { display: block; margin-top: 4px; color: var(--muted-2); font-size: 9px; line-height: 1.45; }
.issue-summary { display: flex; gap: 7px; margin-bottom: 10px; }
.issue-pill { display: inline-flex; align-items: center; gap: 4px; padding: 5px 7px; border-radius: 999px; background: #1a2b34; color: var(--muted); font-size: 9px; }
.issue-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--info); }
.issue-pill.error::before { background: var(--danger); }.issue-pill.warning::before { background: var(--warning); }

.step-list { display: grid; gap: 8px; }
.step-card { display: grid; grid-template-columns: 27px minmax(0,1fr) auto; align-items: start; gap: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: #14212a; cursor: pointer; }
.step-card:hover, .step-card.is-active { border-color: var(--line-strong); }
.step-card.is-active { box-shadow: 0 0 0 2px rgba(43,211,178,.06); border-color: rgba(43,211,178,.48); }
.step-number { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: #263b45; color: #bdd0d4; font-size: 10px; font-weight: 750; }
.step-copy strong { display: block; color: #dbe8ea; font-size: 10px; }
.step-copy span { display: -webkit-box; margin-top: 3px; overflow: hidden; color: var(--muted-2); font-size: 9px; line-height: 1.35; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.step-actions { display: flex; gap: 2px; }
.step-actions button { display: grid; place-items: center; width: 23px; height: 23px; border: 0; border-radius: 5px; background: transparent; color: var(--muted-2); cursor: pointer; }
.step-actions button:hover { background: var(--surface-3); color: var(--text); }

.component-editor-header { display: grid; grid-template-columns: 38px minmax(0,1fr); gap: 10px; align-items: center; }
.component-editor-header .component-thumb { width: 38px; height: 38px; }
.component-editor-header h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.component-editor-header span { display: block; margin-top: 3px; color: var(--muted-2); font-size: 9px; }

.port-list { display: grid; gap: 8px; }
.port-card { padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: #14212a; }
.port-card-header { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.port-card-header .port-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.port-card-header strong { font-size: 10px; }
.port-card-header button { margin-left: auto; border: 0; background: transparent; color: var(--muted-2); font-size: 10px; cursor: pointer; }
.port-card-header button:hover { color: var(--danger); }
.port-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
.port-grid .wide { grid-column: span 2; }
.port-grid input, .port-grid select { min-width: 0; width: 100%; height: 29px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #0d181f; color: #d9e7e9; font-size: 9px; }
.port-grid label { display: flex; flex-direction: column; gap: 3px; color: var(--muted-2); font-size: 8px; }

.publish-hero { padding: 16px; border: 1px solid rgba(43,211,178,.22); border-radius: 11px; background: linear-gradient(145deg, rgba(43,211,178,.11), rgba(73,108,126,.05)); }
.publish-hero .eyebrow { color: #79d9c6; font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .09em; }
.publish-hero h3 { margin: 6px 0 6px; font-size: 17px; letter-spacing: -.025em; }
.publish-hero p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.readiness-row { display: flex; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid rgba(38,57,68,.58); }
.readiness-row:last-child { border-bottom: 0; }
.readiness-icon { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: rgba(85,214,158,.12); color: var(--success); }
.readiness-row.warning .readiness-icon { background: rgba(244,184,95,.12); color: var(--warning); }
.readiness-row.error .readiness-icon { background: rgba(240,113,120,.12); color: var(--danger); }
.readiness-copy strong { display: block; font-size: 10px; }
.readiness-copy span { display: block; margin-top: 2px; color: var(--muted-2); font-size: 9px; }
.publish-link { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.publish-link input, .code-box { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: #0d181f; color: #a9bdc1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.code-box { min-height: 76px; resize: none; line-height: 1.45; }
.export-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
.export-card { display: flex; flex-direction: column; gap: 5px; min-height: 76px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: #14212a; cursor: pointer; }
.export-card:hover { border-color: var(--line-strong); background: #172731; }
.export-card svg { width: 18px; height: 18px; color: var(--accent); }
.export-card strong { font-size: 10px; }
.export-card span { color: var(--muted-2); font-size: 8.5px; line-height: 1.3; }

.library-toolbar { display: flex; gap: 7px; padding: 12px 12px 7px; }
.library-toolbar button { flex: 1; }
.author-component-item { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 9px; align-items: center; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: #14212a; cursor: pointer; }
.author-component-item:hover { border-color: var(--line-strong); }
.author-component-item.is-active { border-color: rgba(43,211,178,.5); background: rgba(43,211,178,.07); }
.author-component-item .component-thumb { width: 34px; height: 34px; }
.author-component-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.author-component-item span { display: block; margin-top: 2px; color: var(--muted-2); font-size: 8.5px; }
.author-component-item .port-badge { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: #223640; color: #98adb2; font-size: 9px; }

.project-card { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #14212a; }
.project-card h3 { margin: 0 0 5px; font-size: 13px; }
.project-card p { margin: 0; color: var(--muted-2); font-size: 9.5px; line-height: 1.45; }

.callout { display: grid; grid-template-columns: 18px 1fr; gap: 8px; padding: 10px; border: 1px solid rgba(109,168,255,.22); border-radius: 8px; background: rgba(109,168,255,.07); color: #b8cce6; }
.callout.warning { border-color: rgba(244,184,95,.25); background: rgba(244,184,95,.07); color: #dfc69f; }
.callout.danger { border-color: rgba(240,113,120,.25); background: rgba(240,113,120,.07); color: #e5afb2; }
.callout svg { margin-top: 1px; width: 16px; height: 16px; }
.callout strong { display: block; font-size: 10px; }
.callout span { display: block; margin-top: 3px; color: inherit; opacity: .76; font-size: 9px; line-height: 1.45; }

.menu-popover { position: fixed; z-index: 60; min-width: 210px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 10px; background: #14212a; box-shadow: var(--shadow); }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 0 9px; border: 0; border-radius: 7px; background: transparent; color: #c7d7da; font-size: 10.5px; text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--surface-3); }
.menu-item svg { width: 15px; height: 15px; color: var(--muted); }
.menu-item.danger { color: #efa0a5; }
.menu-separator { height: 1px; margin: 5px 3px; background: var(--line); }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(3,10,14,.74); backdrop-filter: blur(6px); }
.modal { width: min(560px, 96vw); max-height: min(760px, 94vh); display: grid; grid-template-rows: auto minmax(0,1fr) auto; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 14px; background: #132029; box-shadow: 0 28px 90px rgba(0,0,0,.55); }
.modal.wide { width: min(780px, 96vw); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px 15px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 17px; letter-spacing: -.025em; }
.modal-header p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.modal-close { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.modal-close:hover { color: var(--text); border-color: var(--line-strong); }
.modal-body { min-height: 0; overflow: auto; padding: 18px 20px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--line); background: rgba(9,17,23,.35); }

.toast-region { position: fixed; z-index: 140; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(350px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: grid; grid-template-columns: 8px 1fr auto; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: rgba(20,34,43,.97); box-shadow: var(--shadow); animation: toast-in .2s ease both; }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--info); }
.toast.success .toast-dot { background: var(--success); }.toast.warning .toast-dot { background: var(--warning); }.toast.error .toast-dot { background: var(--danger); }
.toast span { color: #d7e5e7; font-size: 10.5px; line-height: 1.4; }
.toast button { border: 0; background: transparent; color: var(--muted-2); cursor: pointer; pointer-events: auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.readonly-banner { position: absolute; z-index: 9; top: 12px; left: 50%; transform: translateX(-50%); padding: 8px 12px; border: 1px solid rgba(109,168,255,.28); border-radius: 999px; background: rgba(20,40,55,.9); color: #c8dcf5; font-size: 10px; backdrop-filter: blur(8px); }

.app-shell.embed-mode { grid-template-rows: 0 1fr; }
.app-shell.embed-mode .topbar { display: none; }
.app-shell.embed-mode .workspace { grid-template-columns: 0 minmax(0,1fr) 270px; }
.app-shell.embed-mode .left-sidebar { display: none; }
.app-shell.embed-mode .view-help { display: none; }
.app-shell.public-mode .mode-button[data-mode="author"], .app-shell.public-mode .mode-button[data-mode="publish"], .app-shell.public-mode #undoButton, .app-shell.public-mode #redoButton { display: none; }

@media (max-width: 1200px) {
  :root { --sidebar-left: 255px; --sidebar-right: 310px; }
  .project-identity .save-indicator { display: none; }
  .view-help { display: none; }
}

@media (max-width: 1000px) {
  body { min-width: 760px; }
  :root { --sidebar-left: 220px; --sidebar-right: 280px; }
  .brand-word { display: none; }
  .topbar { grid-template-columns: 48px 1fr auto 1fr; }
  .mode-button { padding: 0 9px; }
  .mode-button span { display: none; }
}
