/* ==========================================================================
   T-Deck Circuit Studio — Design System
   Obsidian + amber + cyan. Hairline borders, quiet surfaces, technical density.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* Surfaces — light: warm drafting paper · dark: obsidian */
  --bg-app-light: #efece5;
  --bg-app-dark: #08090c;
  --bg-surface-light: #f7f5f0;
  --bg-surface-dark: #0c0f15;
  --bg-elevated-light: #eceae2;
  --bg-elevated-dark: #12161e;
  --bg-canvas-light: #f2efe8;
  --bg-canvas-dark: #06070a;

  --border-subtle-light: #e0dbce;
  --border-subtle-dark: #1b2028;
  --border-strong-light: #cbc4b3;
  --border-strong-dark: #2b323d;

  --text-primary-light: #1a1a17;
  --text-primary-dark: #f2f3f6;
  --text-secondary-light: #55534c;
  --text-secondary-dark: #aeb5c1;
  --text-muted-light: #7d786c;
  --text-muted-dark: #767e8d;

  /* Accent — burnt amber (primary) · cyan (technical) */
  --accent-light: #a55f16;
  --accent-dark: #e8a85c;
  --accent-2-light: #0b6b7d;
  --accent-2-dark: #7dd3fc;

  --grid-minor-light: #ddd7c9;
  --grid-minor-dark: #13171e;
  --grid-major-light: #c6bdab;
  --grid-major-dark: #222832;

  --wire-halo-light: rgba(242, 239, 232, 0.94);
  --wire-halo-dark: rgba(6, 7, 10, 0.92);
  --label-bg-light: rgba(247, 245, 240, 0.9);
  --label-bg-dark: rgba(12, 15, 21, 0.9);

  --zone-bg-light: rgba(26, 26, 23, 0.015);
  --zone-bg-dark: rgba(148, 163, 184, 0.025);
  --zone-stroke-light: rgba(125, 120, 108, 0.24);
  --zone-stroke-dark: rgba(148, 163, 184, 0.14);

  --scrollbar-thumb-light: #c0b8a6;
  --scrollbar-thumb-dark: #333b47;
  --scrollbar-track-light: transparent;
  --scrollbar-track-dark: transparent;

  /* Light fallbacks (browsers without light-dark()) */
  --bg-app: var(--bg-app-light);
  --bg-surface: var(--bg-surface-light);
  --bg-elevated: var(--bg-elevated-light);
  --bg-canvas: var(--bg-canvas-light);
  --border-subtle: var(--border-subtle-light);
  --border-strong: var(--border-strong-light);
  --text-primary: var(--text-primary-light);
  --text-secondary: var(--text-secondary-light);
  --text-muted: var(--text-muted-light);
  --accent: var(--accent-light);
  --accent-2: var(--accent-2-light);
  --grid-minor: var(--grid-minor-light);
  --grid-major: var(--grid-major-light);
  --wire-halo: var(--wire-halo-light);
  --label-bg: var(--label-bg-light);
  --zone-bg: var(--zone-bg-light);
  --zone-stroke: var(--zone-stroke-light);
  --scrollbar-thumb: var(--scrollbar-thumb-light);
  --scrollbar-track: var(--scrollbar-track-light);

  /* Derived accents (theme-aware) */
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 38%, transparent);
  --hover: color-mix(in srgb, var(--text-primary) 5%, transparent);

  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Consolas", ui-monospace, monospace;

  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 12px;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;

  --header-h: 56px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.18), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-app: var(--bg-app-dark);
    --bg-surface: var(--bg-surface-dark);
    --bg-elevated: var(--bg-elevated-dark);
    --bg-canvas: var(--bg-canvas-dark);
    --border-subtle: var(--border-subtle-dark);
    --border-strong: var(--border-strong-dark);
    --text-primary: var(--text-primary-dark);
    --text-secondary: var(--text-secondary-dark);
    --text-muted: var(--text-muted-dark);
    --accent: var(--accent-dark);
    --accent-2: var(--accent-2-dark);
    --grid-minor: var(--grid-minor-dark);
    --grid-major: var(--grid-major-dark);
    --wire-halo: var(--wire-halo-dark);
    --label-bg: var(--label-bg-dark);
    --zone-bg: var(--zone-bg-dark);
    --zone-stroke: var(--zone-stroke-dark);
    --scrollbar-thumb: var(--scrollbar-thumb-dark);
    --scrollbar-track: var(--scrollbar-track-dark);
    --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
}
:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

@supports (color: light-dark(white, black)) {
  :root {
    --bg-app: light-dark(var(--bg-app-light), var(--bg-app-dark));
    --bg-surface: light-dark(var(--bg-surface-light), var(--bg-surface-dark));
    --bg-elevated: light-dark(var(--bg-elevated-light), var(--bg-elevated-dark));
    --bg-canvas: light-dark(var(--bg-canvas-light), var(--bg-canvas-dark));
    --border-subtle: light-dark(var(--border-subtle-light), var(--border-subtle-dark));
    --border-strong: light-dark(var(--border-strong-light), var(--border-strong-dark));
    --text-primary: light-dark(var(--text-primary-light), var(--text-primary-dark));
    --text-secondary: light-dark(var(--text-secondary-light), var(--text-secondary-dark));
    --text-muted: light-dark(var(--text-muted-light), var(--text-muted-dark));
    --accent: light-dark(var(--accent-light), var(--accent-dark));
    --accent-2: light-dark(var(--accent-2-light), var(--accent-2-dark));
    --grid-minor: light-dark(var(--grid-minor-light), var(--grid-minor-dark));
    --grid-major: light-dark(var(--grid-major-light), var(--grid-major-dark));
    --wire-halo: light-dark(var(--wire-halo-light), var(--wire-halo-dark));
    --label-bg: light-dark(var(--label-bg-light), var(--label-bg-dark));
    --zone-bg: light-dark(var(--zone-bg-light), var(--zone-bg-dark));
    --zone-stroke: light-dark(var(--zone-stroke-light), var(--zone-stroke-dark));
    --scrollbar-thumb: light-dark(var(--scrollbar-thumb-light), var(--scrollbar-thumb-dark));
    --scrollbar-track: light-dark(var(--scrollbar-track-light), var(--scrollbar-track-dark));
  }
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
html {
  accent-color: var(--accent);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
}

::selection {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.scroller {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
@supports not (scrollbar-color: auto) {
  .scroller { scrollbar-width: auto; }
  .scroller::-webkit-scrollbar { width: 8px; height: 8px; }
  .scroller::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
  .scroller::-webkit-scrollbar-track { background: var(--scrollbar-track); }
}

/* Theme icon branching follows system + meta override */
.theme-to-light { display: none; }
.theme-to-dark { display: inline-flex; align-items: center; }

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-to-dark { display: none; }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-to-light { display: inline-flex; align-items: center; }
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-to-dark { display: none; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-to-light { display: inline-flex; align-items: center; }

/* --------------------------------------------------------------------------
   3. Components — buttons & segmented controls
   -------------------------------------------------------------------------- */
.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-inline-size: 28px;
  block-size: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}

.tb-btn svg { flex-shrink: 0; opacity: 0.9; }

.tb-btn--icon {
  inline-size: 30px;
  padding: 0;
}

.tb-btn--ghost {
  color: var(--text-muted);
}
.tb-btn--ghost:hover {
  color: var(--text-primary);
}

.tb-btn--primary {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}

@media (hover: hover) {
  .tb-btn:hover {
    background: var(--hover);
    color: var(--text-primary);
  }
  .tb-btn--primary:hover {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border-color: var(--accent);
  }
}

.tb-btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Segmented control */
.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg-elevated) 70%, transparent);
}

.seg > .tb-btn {
  block-size: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
}

.seg > .tb-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

@media (hover: hover) {
  .seg > .tb-btn:hover { background: var(--hover); color: var(--text-primary); }
  .seg > .tb-btn[aria-pressed="true"]:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
}

/* --------------------------------------------------------------------------
   4. Header
   -------------------------------------------------------------------------- */
.app-header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  block-size: var(--header-h);
  padding: 0 var(--s-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  z-index: 20;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  inline-size: 32px;
  block-size: 32px;
  border-radius: 8px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--border-subtle);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text-primary);
}
.brand-text h1 span {
  color: var(--text-muted);
  font-weight: 500;
}

.brand-badge {
  display: block;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.01em;
  margin-top: 1px;
}

.main-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  margin-inline: auto;
  flex-wrap: nowrap;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Menu (native popover) */
.header-actions > [popovertarget="app-menu"] {
  anchor-name: --app-menu-anchor;
}

.menu {
  position-anchor: --app-menu-anchor;
  position-area: block-end span-inline-end;
  margin: 6px 0 0;
  inset: auto;
  min-inline-size: 208px;
  padding: var(--s-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-pop);
}

.menu-label {
  display: block;
  padding: 6px 9px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.menu-item {
  display: flex;
  align-items: center;
  inline-size: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  text-align: start;
  cursor: pointer;
}

@media (hover: hover) {
  .menu-item:hover { background: var(--hover); color: var(--text-primary); }
}

.menu-sep {
  block-size: 1px;
  margin: 5px 4px;
  background: var(--border-subtle);
}

[interestfor] { interest-delay: 0.35s 0.1s; }

[popover="hint"] {
  inset: auto;
  position-area: block-end;
  position-try-fallbacks: flip-block;
  margin-block-start: 8px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 11px;
  max-inline-size: 260px;
  box-shadow: var(--shadow-pop);
}

/* Status toast */
.status-toast {
  position: fixed;
  inset-block-end: 24px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 60;
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--text-primary);
  color: var(--bg-surface);
  font-size: 11.5px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms var(--ease);
}

.status-toast.visible { opacity: 1; }

/* --------------------------------------------------------------------------
   5. Workspace & sidebars
   -------------------------------------------------------------------------- */
.workspace {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 340px;
  flex: 1;
  min-height: 0;
}

.sidebar {
  background: var(--bg-surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-left { border-inline-end: 1px solid var(--border-subtle); }
.sidebar-right { border-inline-start: 1px solid var(--border-subtle); overflow: hidden; }

.sidebar-section {
  padding: var(--s-3) var(--s-3) var(--s-3);
}

.sidebar-section--search {
  position: relative;
  border-bottom: 1px solid var(--border-subtle);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Collapsible panel component (details/summary) */
.panel { border-bottom: 1px solid var(--border-subtle); }

.panel-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px var(--s-3);
  list-style: none;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
  transition: color 140ms var(--ease), background-color 140ms var(--ease);
}
.panel-head::-webkit-details-marker { display: none; }

.panel-head::after {
  content: "";
  inline-size: 10px;
  block-size: 10px;
  flex-shrink: 0;
  background-color: currentColor;
  opacity: 0.55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3 1.5L7.5 5 3 8.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3 1.5L7.5 5 3 8.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: rotate 160ms var(--ease);
}

.panel[open] > .panel-head::after { rotate: 90deg; }

@media (hover: hover) {
  .panel-head:hover { color: var(--text-primary); background: var(--hover); }
}

.panel-head:focus-visible { outline-offset: -2px; }

.panel-title {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.075em;
  text-transform: uppercase;
  color: inherit;
}

.panel-meta {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0;
}

.panel-body { padding: 0 10px 12px; }

.panel-actions {
  display: flex;
  gap: var(--s-3);
  padding: 2px 2px 7px;
}

.link-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  padding: 0;
  opacity: 0.9;
}
.link-btn:hover { opacity: 1; text-decoration: underline; text-underline-offset: 2px; }

/* Search */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  inset-inline-start: 9px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  block-size: 30px;
  padding: 0 10px 0 28px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease);
}
#search-input::placeholder { color: var(--text-muted); }
#search-input:focus-visible {
  outline: none;
  border-color: var(--accent-line);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#search-input::-webkit-search-cancel-button { filter: grayscale(1); opacity: 0.6; }

.search-results {
  position: absolute;
  inset-inline: 12px;
  inset-block-start: calc(100% - 3px);
  z-index: 30;
  max-height: 260px;
  overflow-y: auto;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--shadow-pop);
}

.search-hit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 11.5px;
  text-align: start;
  cursor: pointer;
}
.search-hit:hover { background: var(--accent-soft); }

.search-hit-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Bus list */
.bus-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bus-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  padding: 5px 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  text-align: start;
  transition: background-color 120ms var(--ease), opacity 120ms var(--ease);
}

@media (hover: hover) {
  .bus-row:hover { background: var(--hover); color: var(--text-primary); }
}

.bus-row[aria-pressed="false"] { opacity: 0.35; }

.bus-row-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.bus-swatch {
  inline-size: 8px;
  block-size: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 8%, transparent);
}

.bus-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Component / model list */
.component-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.comp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: background-color 120ms var(--ease);
}

@media (hover: hover) {
  .comp-item:hover { background: var(--hover); }
}

.comp-item.active {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.comp-item-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.comp-item-title {
  font-size: 11.8px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comp-item-sub {
  font-size: 10.3px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comp-ref-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  flex-shrink: 0;
}

.comp-item.active .comp-ref-badge {
  border-color: var(--accent-line);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   6. Canvas
   -------------------------------------------------------------------------- */
.canvas-stage {
  position: relative;
  overflow: hidden;
  background: var(--bg-canvas);
}

.canvas-viewport {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.canvas-viewport.dragging { cursor: grabbing; }
.canvas-viewport.move-mode .component-node { cursor: move; }

#schematic-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.grid-dot-minor { fill: var(--grid-minor); }
.grid-dot-major { fill: var(--grid-major); }
.canvas-viewport:not(.show-grid) #grid-bg { opacity: 0; }

/* En tema claro, las pistas necesitan un poco más de cuerpo sobre el papel */
@media (prefers-color-scheme: light) {
  :root:not(:has(> head > meta[name="color-scheme"][content="dark"])) :is(#layer-wires, #layer-junctions) {
    filter: brightness(0.86) saturate(1.12);
  }
}
:root:has(> head > meta[name="color-scheme"][content="light"]) :is(#layer-wires, #layer-junctions) {
  filter: brightness(0.86) saturate(1.12);
}

/* Zones */
.zone-rect {
  fill: var(--zone-bg);
  stroke: var(--zone-stroke);
  stroke-width: 1;
  stroke-dasharray: 3 5;
  rx: 12;
}

.zone-label {
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  fill: var(--text-muted);
  opacity: 0.85;
  pointer-events: none;
}

/* Wires */
.wire-halo {
  fill: none;
  stroke: var(--wire-halo);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.wire-path {
  fill: none;
  stroke-width: 2.2;
  opacity: 0.95;
  stroke-linecap: round;
  stroke-linejoin: round;
  cursor: pointer;
  transition: stroke-width 120ms var(--ease), opacity 120ms var(--ease);
}

/* Trazas de cobre dentro de la PCB: más finas que un cable esquemático */
.pcb-trace {
  stroke-width: 1.7;
  opacity: 0.9;
}

/* A poco zoom, la microtipografía solo genera ruido */
.zoom-far .pin-text,
.zoom-far .zone-label { display: none; }

.wire-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 13;
  cursor: pointer;
}

.wire-group.dimmed { opacity: 0.12; }
.wire-group.hidden-bus { display: none; }

.wire-group.highlighted .wire-path {
  stroke-width: 3.6;
  filter: url(#glow-active);
}

.junction-dot {
  /* Decorativos: no deben robar el clic a la traza de debajo */
  pointer-events: none;
}

.junction-dot.dimmed { opacity: 0.12; }
.junction-dot.hidden-bus { display: none; }

@keyframes flowDash { to { stroke-dashoffset: -36; } }

@media (prefers-reduced-motion: no-preference) {
  .flow-active .wire-path:not(.dimmed-flow) {
    stroke-dasharray: 9 9;
    animation: flowDash 0.9s linear infinite;
  }
}

/* Wire labels — quiet text chips */
.wire-label-group { pointer-events: none; }

.wire-label-group.dimmed { opacity: 0.12; }
.wire-label-group.hidden-bus,
.labels-hidden .wire-label-group,
.labels-zoomed .wire-label-group { display: none; }

.wire-label-bg {
  fill: var(--label-bg);
  stroke: none;
  rx: 3;
}

.wire-label-text {
  font-family: var(--font-mono);
  font-size: 8.6px;
  font-weight: 500;
  letter-spacing: -0.01em;
  fill: var(--text-secondary);
  text-anchor: middle;
  dominant-baseline: central;
}

/* Component nodes */
.component-node { cursor: pointer; }
.component-node.dimmed { opacity: 0.3; }

.component-node.selected .comp-outline {
  stroke: var(--accent) !important;
  stroke-width: 2 !important;
  filter: url(#glow-active);
}

.pin-group { cursor: pointer; }
.pin-pad { stroke-width: 1.4; }

.pin-group:hover .pin-pad,
.pin-group.highlighted .pin-pad {
  stroke: #ffffff;
  stroke-width: 2;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(1.22);
}

.pin-text {
  font-family: var(--font-mono);
  font-size: 9.2px;
  font-weight: 500;
  fill: #dfe4ec;
  pointer-events: none;
}

.pin-text-dark { fill: #1b2028; }

/* Tooltip */
.canvas-tooltip {
  position: absolute;
  z-index: 40;
  pointer-events: none;
  max-width: 300px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-pop);
  color: var(--text-primary);
  font-size: 11.5px;
}

.tt-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 3px;
}

.tt-dot {
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tt-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-2);
  margin-bottom: 4px;
}

.tt-desc {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}

/* Docks (floating tool clusters) */
.canvas-dock {
  position: absolute;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.dock-tools {
  inset-block-start: 12px;
  inset-inline-start: 12px;
}

.dock-seg { display: flex; gap: 2px; }

.dock-sep {
  inline-size: 1px;
  block-size: 16px;
  margin-inline: 4px;
  background: var(--border-subtle);
}

.canvas-dock .tb-btn { color: var(--text-muted); }
.canvas-dock .tb-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.dock-zoom {
  inset-block-end: 122px;
  inset-inline-end: 14px;
}

.zoom-readout {
  min-inline-size: 52px;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* HUD */
.canvas-hud-bottom {
  position: absolute;
  inset-block-end: 14px;
  inset-inline-start: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  pointer-events: none;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 10.5px;
  box-shadow: none;
}

.hud-meta { font-family: var(--font-mono); font-size: 10px; }
.hud-meta strong { color: var(--text-secondary); font-weight: 500; }

.dot-live {
  inline-size: 6px;
  block-size: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Minimap */
.minimap-box {
  position: absolute;
  inset-block-end: 14px;
  inset-inline-end: 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg-surface) 90%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  padding: 4px;
}

#minimap-svg { display: block; cursor: crosshair; }

#minimap-viewport {
  fill: color-mix(in srgb, var(--accent) 10%, transparent);
  stroke: var(--accent);
  stroke-width: 26;
  opacity: 0.9;
}

/* PCB face bar */
.pcb-face-bar {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  white-space: nowrap;
  gap: 1px;
  padding: 3px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.pcb-face-bar[hidden] { display: none; }

.cam-btn {
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}

@media (hover: hover) {
  .cam-btn:hover { background: var(--hover); color: var(--text-primary); }
}

.cam-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.cam-sep {
  inline-size: 1px;
  block-size: 16px;
  margin-inline: 4px;
  background: var(--border-subtle);
}

.cam-hint {
  font-size: 10px;
  color: var(--text-muted);
  padding-inline: 6px;
}

/* --------------------------------------------------------------------------
   7. Right panel — tabs, inspector, tables
   -------------------------------------------------------------------------- */
.tabs-bar {
  display: flex;
  align-items: stretch;
  gap: var(--s-4);
  padding: 0 var(--s-3);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.tab-btn {
  position: relative;
  padding: 12px 1px 11px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color 140ms var(--ease);
}

.tab-btn::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: -1px;
  block-size: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 180ms var(--ease);
}

.tab-btn[aria-selected="true"] {
  color: var(--text-primary);
  font-weight: 600;
}

.tab-btn[aria-selected="true"]::after { transform: scaleX(1); }

@media (hover: hover) {
  .tab-btn:hover { color: var(--text-primary); }
}

.tab-panel {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-3) var(--s-3) var(--s-4);
}

.panel-intro {
  margin-bottom: var(--s-3);
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.panel-intro p { margin: 0; }

.panel-intro code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

/* Inspector */
.insp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.insp-kicker {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.insp-title {
  margin: 4px 0 4px;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.insp-subtitle {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}

.insp-subtitle code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

.insp-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 11px;
  margin-bottom: var(--s-2);
}

.insp-card h3 {
  margin: 0 0 8px;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.insp-card--warn {
  border-color: var(--accent-line);
  background: color-mix(in srgb, var(--accent) 5%, var(--bg-elevated));
}
.insp-card--warn h3 { color: var(--accent); }

.kv-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1fr);
  align-items: baseline;
  gap: 5px 12px;
  font-size: 11px;
}

.kv-key {
  color: var(--text-muted);
  font-weight: 400;
  min-width: 0;
}

.kv-val {
  font-family: var(--font-mono);
  font-size: 10.3px;
  color: var(--text-secondary);
  text-align: end;
  word-break: break-word;
}

.note-callout {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border-inline-start: 2px solid var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 5%, transparent);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: var(--s-2);
}

.note-callout strong {
  display: block;
  margin-bottom: 3px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.note-callout code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-primary);
}

.pin-chips {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pin-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  text-align: start;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}

@media (hover: hover) {
  .pin-chip:hover { border-color: var(--border-subtle); background: var(--hover); }
}

.pin-chip-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.pin-chip-code {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10.5px;
  color: var(--accent-2);
}

.pin-chip-net {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-block-wrap { position: relative; margin-top: 8px; }

.code-block {
  margin: 0;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  background: #0a0d12;
  color: #cdd6e4;
  color-scheme: dark;
  accent-color: var(--accent-dark);
  font-family: var(--font-mono);
  font-size: 10.4px;
  line-height: 1.6;
  overflow-x: auto;
  border: 1px solid #1b2129;
}

.code-copy-btn {
  position: absolute;
  inset-block-start: 6px;
  inset-inline-end: 6px;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #262e3a;
  background: #12161e;
  color: #aeb5c1;
  font-size: 9.5px;
  font-weight: 500;
  cursor: pointer;
}

.code-copy-btn:hover {
  background: #1b212b;
  color: #f2f3f6;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.stat-card {
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border-subtle);
  text-align: center;
}

.stat-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.stat-lbl {
  font-size: 9.5px;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

/* Tables */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: calc(100vh - 190px);
  container-type: inline-size;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 10.5px;
  text-align: left;
}

.data-table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.data-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
}

.data-table th,
.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table thead th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--border-subtle);
}

.data-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10px;
  color: var(--accent-2);
  white-space: nowrap;
}

.data-table tbody td code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

.data-table tbody tr { cursor: pointer; }

@media (hover: hover) {
  .data-table tbody tr:hover td,
  .data-table tbody tr:hover th { background: var(--hover); }
}

.data-table tbody tr.active-row td,
.data-table tbody tr.active-row th {
  background: var(--accent-soft);
}
.data-table tbody tr.active-row th { box-shadow: inset 2px 0 0 var(--accent); }

.bus-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
  opacity: 0.95;
}

.pinout-table {
  --label-1: "GPIO";
  --label-2: "Señal / Red";
  --label-3: "Módulo";
  --label-4: "Bus";
}

.bom-table {
  --label-1: "Ref";
  --label-2: "Componente";
  --label-3: "Función";
  --label-4: "Riel";
}

@container (width < 270px) {
  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td { display: block; }

  .data-table thead { display: none; }

  .data-table tr {
    margin: 6px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
  }

  .data-table tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--bg-elevated);
  }

  .data-table td:nth-child(2)::before { content: var(--label-2) ": "; font-weight: 600; color: var(--text-muted); }
  .data-table td:nth-child(3)::before { content: var(--label-3) ": "; font-weight: 600; color: var(--text-muted); }
  .data-table td:nth-child(4)::before { content: var(--label-4) ": "; font-weight: 600; color: var(--text-muted); }
}

/* --------------------------------------------------------------------------
   8. 3D viewer panel
   -------------------------------------------------------------------------- */
.shell3d-stage {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg-canvas);
}
.shell3d-stage[hidden] { display: none; }

.shell3d-canvas {
  width: 100%;
  height: 100%;
  cursor: grab;
}
.shell3d-canvas:active { cursor: grabbing; }
.shell3d-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.shell3d-hud-top {
  position: absolute;
  inset-block-start: 14px;
  inset-inline-start: 14px;
  pointer-events: none;
}

.shell3d-hud-bottom {
  position: absolute;
  inset-block-end: 14px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 1px;
  padding: 3px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.ctrl-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-line input[type="checkbox"] {
  inline-size: 13px;
  block-size: 13px;
  margin: 0;
  cursor: pointer;
}

.slider-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.mono-val {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
}

.slider-field input[type="range"] {
  width: 100%;
  margin: 0;
  block-size: 14px;
  cursor: pointer;
}

.finish-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.finish-btn {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background-color 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
}

@media (hover: hover) {
  .finish-btn:hover { background: var(--hover); color: var(--text-primary); }
}

.finish-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
}

.parts-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.part-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  font-size: 10.5px;
  color: var(--text-secondary);
  cursor: pointer;
}
.part-row:hover { background: var(--hover); }

.part-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.part-row-left input[type="checkbox"] { margin: 0; inline-size: 12px; block-size: 12px; }

.part-row-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.part-role-tag {
  font-family: var(--font-mono);
  font-size: 8.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   9. Accessibility & responsive
   -------------------------------------------------------------------------- */
@media (pointer: coarse) {
  .tb-btn { min-inline-size: 40px; block-size: 38px; }
  .tb-btn--icon { inline-size: 38px; }
  .seg > .tb-btn { block-size: 34px; }
  .panel-head { padding-block: 12px; }
  .bus-row, .comp-item, .pin-chip { padding-block: 8px; }
}

@media (forced-colors: active) {
  .tb-btn[aria-pressed="true"],
  .comp-item.active,
  .bus-row[aria-pressed="true"] {
    background: Highlight;
    color: HighlightText;
    border-color: ButtonText;
  }
  .dock-sep, .cam-sep, .menu-sep { background: ButtonText; }
  [popover="hint"], .menu { border: 1px solid CanvasText; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr) 300px; }
  .brand-badge { display: none; }
}

@media (max-width: 1080px) {
  /* El logo basta: así los segmentos conservan su texto */
  .brand-text { display: none; }
}

@media (max-width: 900px) {
  .seg > .tb-btn span { display: none; }
  .seg > .tb-btn { padding: 0 8px; }
}

@media (max-width: 860px) {
  html, body { overflow: auto; block-size: auto; min-block-size: 100%; }
  body { display: block; }
  .app-header {
    block-size: auto;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
    position: sticky;
    inset-block-start: 0;
  }
  .main-toolbar { order: 3; width: 100%; justify-content: flex-start; margin: 0; }
  .header-actions { margin-inline-start: auto; }
  .workspace { display: flex; flex-direction: column; flex: none; height: auto; }
  .sidebar { overflow: visible; max-block-size: none; height: auto; }
  .canvas-stage { height: 72vh; }
  .sidebar-left, .sidebar-right { border: 0; border-bottom: 1px solid var(--border-subtle); }
  .sidebar-right { overflow: visible; }
  .table-wrapper { max-block-size: none; }
  .pcb-face-bar { inset-block-start: 56px; max-inline-size: calc(100% - 24px); overflow-x: auto; }
  .canvas-hud-bottom { inset-block-end: 10px; inset-inline-start: 10px; }
  #hud-selection-hint { display: none; }
  .minimap-box { inset-block-end: 10px; inset-inline-end: 10px; }
  .dock-zoom { inset-block-end: 118px; inset-inline-end: 10px; }
  .dock-tools { inset-block-start: 10px; inset-inline-start: 10px; }
}
