/* ── Right Panel (Code) ─────────────────────────── */
#right-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Right panel view tabs ──────────────────────────── */
#right-panel > .panel-header.workspace-toolbar {
  min-height: 52px; padding: 7px 14px 0;
  align-items: flex-end; overflow: hidden;
  background: linear-gradient(180deg, #11161d 0%, #0d1218 100%) !important;
}
.view-tabs {
  display: flex; align-items: flex-end; align-self: stretch; gap: 3px;
  min-width: 0; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; scrollbar-color: auto;
}
.view-tabs::-webkit-scrollbar { display: none; }
.view-tab {
  position: relative; min-height: 38px; padding: 8px 13px 9px;
  border: 1px solid rgba(137,155,172,0.09); border-bottom-color: rgba(137,155,172,0.13);
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, rgba(25,32,41,0.48), rgba(13,18,24,0.3));
  color: #748394; font-size: 10.5px; font-weight: 680;
  letter-spacing: 0.045em; text-transform: none;
  cursor: pointer; transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
  font-family: inherit; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.view-tab::before {
  content: ''; position: absolute; inset: 0 8px auto; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(188,204,216,0.11), transparent);
  pointer-events: none;
}
.view-tab:hover {
  color: #a7b4c1; border-color: rgba(137,155,172,0.16);
  background: linear-gradient(180deg, rgba(30,39,49,0.62), rgba(15,21,28,0.42));
}
.view-tab.active {
  z-index: 1; color: #c3d7dd;
  border-color: rgba(69,183,207,0.25); border-bottom-color: #111820;
  background: linear-gradient(180deg, rgba(26,55,65,0.78) 0%, rgba(15,29,37,0.92) 72%, #111820 100%);
  box-shadow: inset 0 1px 0 rgba(130,221,236,0.12), 0 -5px 18px rgba(25,117,139,0.08);
}
.view-tab.active::after {
  content: ''; position: absolute; left: 10px; right: 10px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(76,197,220,0.72), transparent);
  box-shadow: 0 0 8px rgba(69,183,207,0.2);
}
.view-tab-icon {
  width: 17px; height: 17px; flex-shrink: 0; opacity: 0.56;
  stroke: currentColor; fill: none; stroke-width: 1.65;
  stroke-linecap: round; stroke-linejoin: round;
  transition: opacity 0.15s, filter 0.15s, transform 0.15s;
}
.view-tab:hover .view-tab-icon { opacity: 0.84; }
.view-tab.active .view-tab-icon {
  color: #59bfd2; opacity: 1; transform: translateY(-0.5px);
  filter: drop-shadow(0 0 5px rgba(69,183,207,0.26));
}
.view-toolbar-actions {
  display: flex; align-items: center; align-self: center; gap: 8px;
  margin-left: auto; padding: 0 0 7px 10px;
}
#file-count { color: var(--text-dim); font-size: 11px; white-space: nowrap; }

/* Wrapper that scopes the compile-error overlay below the tab bar */
#right-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

#files-view { container-type: inline-size; display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
#overview-view { display: none; flex: 1; min-height: 0; overflow: auto; background: #090d12; }
#overview-view.active { display: block; }
.overview-empty {
  min-height: 100%; padding: 40px; display: grid; place-content: center;
  justify-items: center; text-align: center; color: var(--text-dim);
}
.overview-empty-mark { color: var(--accent); font-size: 34px; opacity: 0.42; }
.overview-empty h2 { margin: 12px 0 8px; color: #dbe7ed; font: 500 23px/1.25 system-ui, sans-serif; }
.overview-empty p { max-width: 460px; margin: 0; font-size: 12px; line-height: 1.7; }
.template-overview { max-width: 1180px; margin: 0 auto; padding: clamp(18px, 3vw, 38px); color: #b5c2cd; }
.template-overview-hero {
  position: relative; min-height: clamp(300px, 45vh, 520px); overflow: hidden;
  border: 1px solid rgba(113,155,171,0.2); border-radius: 12px; background: #111820;
  box-shadow: 0 24px 70px rgba(0,0,0,0.3);
}
.template-overview-hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.template-overview-hero::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(4,8,12,0.94) 0%, rgba(4,8,12,0.72) 42%, rgba(4,8,12,0.14) 78%), linear-gradient(0deg, rgba(4,8,12,0.7), transparent 45%);
}
.template-overview-heading { position: relative; z-index: 1; max-width: 600px; padding: clamp(26px, 5vw, 64px); }
.template-overview-kicker { color: #64c4d5; font-size: 10px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; }
.template-overview-heading h1 { margin: 12px 0; color: #f2f7f9; font: 540 clamp(30px, 4.6vw, 54px)/1.04 system-ui, sans-serif; letter-spacing: -0.025em; }
.template-overview-summary { margin: 0; color: #c3d1d9; font-size: clamp(13px, 1.5vw, 16px); line-height: 1.65; text-wrap: pretty; }
.template-overview-status { display: inline-flex; margin-top: 20px; padding: 7px 10px; border: 1px solid rgba(85,194,212,0.3); border-radius: 999px; background: rgba(10,28,34,0.72); color: #9ddce6; font-size: 10px; }
.template-overview-specs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.template-overview-spec { padding: 15px; border: 1px solid rgba(118,150,164,0.16); border-radius: 7px; background: rgba(17,24,32,0.82); color: #d2dde4; font-size: 11px; line-height: 1.45; }
.template-overview-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.92fr); gap: 18px; }
.template-overview-card { overflow: hidden; border: 1px solid rgba(118,150,164,0.16); border-radius: 9px; background: rgba(15,21,28,0.9); }
.template-overview-card-copy { padding: 22px; }
.template-overview-card h2 { margin: 0 0 10px; color: #e1eaf0; font: 520 18px/1.3 system-ui, sans-serif; }
.template-overview-card p, .template-overview-card li { font-size: 11.5px; line-height: 1.7; }
.template-overview-card p { margin: 0; }
.template-overview-card ol { margin: 0; padding-left: 20px; }
.template-overview-card img { width: 100%; aspect-ratio: 16 / 9; display: block; object-fit: cover; border-bottom: 1px solid rgba(118,150,164,0.16); }
.template-overview-source { margin-top: 18px; color: #718694; font-size: 10px; line-height: 1.6; }
.template-overview-source a { color: #78c5d2; text-decoration: none; }
.template-overview-source a:hover { text-decoration: underline; }
#bom-view { display: none; flex: 1; min-height: 0; overflow: auto; background: var(--bg); }
#bom-view.active { display: block; }
#simulator-view { display: none; flex: 1; min-height: 0; overflow: hidden; }
#simulator-view.active { display: flex; }
#simulator-frame { width: 100%; height: 100%; border: none; flex: 1; }
#cad-view, #assembly-view {
  display: none; flex: 1; min-height: 0; overflow: hidden;
  flex-direction: column;
  container-type: inline-size;
}
#cad-view.active, #assembly-view.active { display: flex; }
#cad-frame, #assembly-frame { width: 100%; height: 100%; border: none; flex: 1; background: var(--bg); }
.viewer-context-toolbar {
  height: 42px; flex: 0 0 42px; min-width: 0; padding: 0 12px;
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, rgba(16,23,31,0.96), rgba(11,17,24,0.96));
  border-bottom: 1px solid rgba(137,155,172,0.14);
}
.viewer-context-primary {
  display: flex; align-items: center; flex: 1 1 auto; min-width: 0;
}
.viewer-context-object,
.model-context-picker {
  min-width: 0; height: 32px; padding: 3px 8px 3px 4px;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; border-radius: 4px;
  color: #aab8c6;
}
.model-context-picker {
  position: relative; display: none; flex: 0 1 auto; max-width: min(400px, 100%);
  transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.model-context-picker.is-visible { display: inline-flex; }
.model-context-picker:hover,
.model-context-picker:focus-within {
  color: #c8d6df; border-color: rgba(116,156,168,0.2);
  background: linear-gradient(100deg, rgba(74,100,112,0.12), rgba(25,34,43,0.08));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.025), 0 4px 14px rgba(0,0,0,0.13);
}
.viewer-context-object-icon {
  width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center;
  border: 1px solid rgba(91,133,146,0.16); border-radius: 3px;
  background: linear-gradient(145deg, rgba(63,94,106,0.13), rgba(10,15,21,0.05));
  color: #6d9daa;
}
.viewer-context-object-icon svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.55;
  stroke-linecap: round; stroke-linejoin: round;
}
.model-context-picker:hover .viewer-context-object-icon,
.model-context-picker:focus-within .viewer-context-object-icon {
  color: #68bdcb; border-color: rgba(89,181,199,0.25);
}
.viewer-context-object-copy {
  min-width: 0; display: flex; align-items: center; gap: 8px;
}
.viewer-context-object-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: inherit; font-size: 10.5px; font-weight: 680; letter-spacing: 0.018em;
}
.model-context-kind {
  flex: 0 0 auto; padding: 2px 5px; border: 1px solid rgba(106,139,149,0.15);
  border-radius: 999px; background: rgba(92,121,131,0.055); color: #748894;
  font-size: 7.5px; font-weight: 700; letter-spacing: 0.08em; line-height: 1.2;
  text-transform: uppercase;
}
.model-context-chevron {
  width: 14px; height: 14px; flex: 0 0 14px; margin-left: 1px;
  fill: none; stroke: #71808e; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  transition: stroke 0.15s, transform 0.15s;
}
.model-context-picker:hover .model-context-chevron,
.model-context-picker:focus-within .model-context-chevron { stroke: #a0b5c0; transform: translateY(1px); }
#cad-model-select {
  position: absolute; inset: 0; z-index: 2; display: block;
  width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer;
  font-size: 16px;
}
.viewer-context-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #aab8c6; font-size: 10px; font-weight: 650; letter-spacing: 0.02em;
}
.viewer-context-actions {
  display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 0 auto;
}
.viewer-context-status {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0;
  color: var(--text-dim); font-size: 10px; white-space: nowrap;
}
.viewer-context-status-icon {
  display: inline-grid; place-items: center; width: 14px; height: 14px;
  color: #708092; font-size: 11px; font-weight: 800;
}
.viewer-context-status[data-phase="ready"] { color: #65c493; }
.viewer-context-status[data-phase="ready"] .viewer-context-status-icon { color: #4fd39a; }
.viewer-context-status[data-phase="loading"] { color: #b5a477; }
.viewer-context-status[data-phase="loading"] .viewer-context-status-icon { color: #d2b36d; }
.viewer-context-status[data-phase="warning"] { color: #c3a56f; }
.viewer-context-status[data-phase="warning"] .viewer-context-status-icon { color: #d1a65d; }
.viewer-context-status[data-phase="error"] { color: #d88488; }
.viewer-context-status[data-phase="error"] .viewer-context-status-icon { color: #e66b71; }
.viewer-reload-btn {
  width: 32px; height: 32px; padding: 0; flex-shrink: 0;
  display: grid; place-items: center; border: 1px solid rgba(137,155,172,0.16);
  border-radius: 3px; background: rgba(255,255,255,0.012); color: #7d8d9e;
  cursor: pointer; transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.viewer-reload-btn:hover:not(:disabled) {
  color: #9ed1da; border-color: rgba(69,183,207,0.3);
  background: rgba(69,183,207,0.055); box-shadow: 0 0 9px rgba(69,183,207,0.08);
}
.viewer-reload-btn:focus-visible,
.model-context-picker:focus-within {
  outline: 2px solid rgba(69,183,207,0.72); outline-offset: 2px;
}
.viewer-reload-btn:disabled { cursor: wait; opacity: 0.62; }
.viewer-reload-btn.is-loading svg { animation: viewer-reload-spin 0.9s linear infinite; }
.viewer-reload-btn svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
@keyframes viewer-reload-spin { to { transform: rotate(360deg); } }
@container (max-width: 500px) {
  .viewer-context-toolbar { padding-inline: 9px; gap: 8px; }
  .viewer-context-status-text { max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
  .viewer-context-name { max-width: 190px; }
  .model-context-picker { max-width: 230px; }
  .model-context-kind { display: none; }
}

/* ── Bill of Materials ─────────────────────────────── */
.bom-shell {
  min-height: 100%; padding: 22px; display: flex; flex-direction: column; gap: 16px;
  background:
    radial-gradient(circle at 82% 4%, rgba(69,183,207,0.045), transparent 32%),
    linear-gradient(180deg, rgba(15,21,28,0.98), rgba(10,14,19,0.98));
}
.bom-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.bom-kicker {
  color: #55bfd1; font-size: 9px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase;
}
.bom-header h2 { margin: 5px 0 0; color: #d1dde3; font-size: 18px; line-height: 1.25; }
.bom-header p { margin: 7px 0 0; color: var(--text-dim); font-size: 11px; line-height: 1.55; }
.bom-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.bom-summary { display: flex; gap: 8px; min-height: 26px; flex-wrap: wrap; align-items: center; }
.bom-summary-chip {
  display: inline-flex; align-items: center; min-height: 25px; padding: 4px 8px;
  border: 1px solid rgba(111,143,155,0.16); border-radius: 999px;
  background: rgba(74,104,115,0.055); color: #8395a3; font-size: 9px;
  letter-spacing: 0.04em; white-space: nowrap;
}
.bom-summary-chip strong { margin-right: 5px; color: #b8c9d1; font-size: 10px; }
.bom-summary-path {
  min-width: 0; max-width: 420px; overflow: hidden; text-overflow: ellipsis;
  color: #6f828f; font-size: 9px; white-space: nowrap;
}
.bom-controls { max-width: 560px; }
.bom-controls input {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid rgba(137,155,172,0.15);
  border-radius: 3px; background: rgba(7,11,16,0.7); color: #b7c5ce;
  font: inherit; font-size: 10.5px; outline: none;
}
.bom-controls input:focus {
  border-color: rgba(69,183,207,0.42); box-shadow: 0 0 0 2px rgba(69,183,207,0.08);
}
.bom-controls input:disabled { cursor: not-allowed; opacity: 0.42; }
.bom-sections { display: flex; flex-direction: column; gap: 18px; }
.bom-sections[hidden], .bom-section[hidden] { display: none; }
.bom-section { display: flex; flex-direction: column; gap: 8px; }
.bom-section-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.bom-section-header h3 {
  margin: 0; color: #c8d6dd; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
}
.bom-section-header p { margin: 4px 0 0; color: #718591; font-size: 9.5px; line-height: 1.5; }
.bom-section-count {
  flex: 0 0 auto; color: #728792; font-size: 9px; letter-spacing: 0.05em; white-space: nowrap;
}
.bom-table-frame {
  position: relative; min-height: 0; overflow: auto; border: 1px solid rgba(137,155,172,0.14);
  border-radius: 4px; background: rgba(8,12,17,0.72); box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}
.bom-table { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: auto; }
.bom-table th {
  position: sticky; top: 0; z-index: 1; padding: 10px 12px; border-bottom: 1px solid rgba(137,155,172,0.18);
  background: #111821; color: #7f929f; font-size: 8.5px; font-weight: 800;
  letter-spacing: 0.09em; text-align: left; text-transform: uppercase; white-space: nowrap;
}
.bom-table td {
  padding: 11px 12px; border-bottom: 1px solid rgba(137,155,172,0.08);
  color: #9dacb7; font-size: 10.5px; line-height: 1.5; vertical-align: top;
}
.bom-table tbody tr { transition: background 0.12s; }
.bom-table tbody tr:hover { background: rgba(69,183,207,0.035); }
.bom-table tbody tr:last-child td { border-bottom: 0; }
.bom-cell-quantity { width: 74px; color: #d0dde3 !important; font-weight: 750; white-space: nowrap; }
.bom-cell-item { min-width: 170px; color: #c5d2d9 !important; font-weight: 680; }
.bom-cell-product { min-width: 250px; }
.bom-cell-notes { min-width: 250px; white-space: pre-line; overflow-wrap: anywhere; }
.bom-purchase-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.bom-purchase-link:hover, .bom-purchase-link:active { color: var(--text); }
.bom-purchase-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.bom-empty {
  flex: 1; min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px dashed rgba(137,155,172,0.12); border-radius: 4px; color: var(--text-dim); text-align: center;
}
.bom-empty[hidden] { display: none; }
.bom-empty-icon { color: #4ba9bb; font-size: 27px; line-height: 1; opacity: 0.38; transform: rotate(90deg); }
.bom-empty h3 { margin: 14px 0 0; color: #8e9faa; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.bom-empty p { max-width: 430px; margin: 8px 20px 0; font-size: 10.5px; line-height: 1.6; }
.bom-no-results { padding: 44px 20px; color: var(--text-dim); font-size: 11px; text-align: center; }

#pcb-view { display: none; flex: 1; min-height: 0; overflow: auto; background: var(--bg); }
#pcb-view.active { display: block; }

.pcb-shell { min-height: 100%; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.pcb-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.pcb-title { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.pcb-subtitle { color: var(--text-dim); font-size: 11px; line-height: 1.55; margin-top: 6px; max-width: 760px; }
.pcb-actions { display: flex; gap: 8px; flex-wrap: nowrap; flex-shrink: 0; justify-content: flex-end; }
.pcb-status-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.pcb-status { border: 1px solid var(--border); background: rgba(12,16,24,0.78); padding: 12px; min-height: 72px; }
.pcb-status-label { color: var(--text-dim); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.pcb-status-value { color: var(--text); font-size: 12px; margin-top: 8px; word-break: break-word; line-height: 1.45; }
.pcb-status-value.ok { color: var(--green); }
.pcb-status-value.warn { color: var(--yellow); }
.pcb-status-value.error { color: var(--red); }
.pcb-previews { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-height: 280px; }
.pcb-preview { border: 1px solid var(--border); background: rgba(12,16,24,0.72); min-height: 280px; display: flex; flex-direction: column; overflow: hidden; }
.pcb-preview-title { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.pcb-preview-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 10px; }
.pcb-preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 0 12px rgba(69,183,207,0.08)); }
.pcb-preview-empty { color: var(--text-dim); font-size: 11px; text-align: center; line-height: 1.6; padding: 20px; }
.pcb-file-list { border: 1px solid var(--border); background: rgba(12,16,24,0.72); }
.pcb-file-list-header { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.pcb-file-list-body { max-height: 220px; overflow: auto; padding: 8px 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; }
.pcb-file-row { color: var(--text-dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcb-notes { border: 1px solid rgba(255,184,108,0.18); background: rgba(255,184,108,0.035); color: var(--text-dim); padding: 12px; font-size: 11px; line-height: 1.65; }
@media (max-width: 980px) {
  .template-overview-specs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template-overview-grid { grid-template-columns: 1fr; }
  .pcb-status-row, .pcb-previews, .pcb-file-list-body { grid-template-columns: 1fr; }
  .pcb-header { flex-direction: column; }
  .pcb-actions { justify-content: flex-start; }
  .bom-shell { padding: 16px; }
  .bom-header { flex-direction: column; }
  .bom-controls { max-width: none; }
  .bom-section-header { align-items: flex-start; }
  #right-panel > .panel-header.workspace-toolbar { padding-inline: 8px; }
  .view-tab { padding-inline: 9px; gap: 6px; }
  .view-tab-icon { width: 16px; height: 16px; }
}

.file-tabs {
  display: flex; gap: 4px; min-height: 42px; padding: 6px 10px; border-bottom: 1px solid var(--border);
  overflow-x: auto; flex-shrink: 0; align-items: center;
  background: linear-gradient(180deg, rgba(18,24,31,0.94), rgba(13,18,24,0.94));
  scrollbar-width: thin; scrollbar-color: rgba(138,155,171,0.24) transparent;
}
.file-tabs-empty {
  color: var(--text-dim); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0 8px; white-space: nowrap;
}
.file-tab {
  min-height: 28px; padding: 0 6px 0 0; border-radius: 3px; font-size: 10.5px;
  color: var(--text-dim); white-space: nowrap; transition: all 0.15s;
  display: flex; align-items: center; gap: 5px; font-family: inherit;
  border: 1px solid rgba(174,190,204,0.08); background: rgba(255,255,255,0.012);
}
.file-tab:hover { color: var(--text); border-color: rgba(174,190,204,0.16); background: rgba(255,255,255,0.026); }
.file-tab.active { color: var(--text); border-color: rgba(69,183,207,0.28); background: rgba(69,183,207,0.06); }
.file-tab-open {
  min-height: 28px; padding: 4px 0 4px 10px; border: 0; border-radius: 2px;
  display: flex; align-items: center; gap: 5px; color: inherit; background: transparent; font: inherit; cursor: pointer;
}
.file-tab-name { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.file-tab-close {
  width: 17px; height: 17px; border: 0; border-radius: 2px; padding: 0;
  display: grid; place-items: center; background: transparent; color: var(--text-dim);
  font: inherit; font-size: 10px; opacity: 0.45; cursor: pointer; transition: all 0.15s;
}
.file-tab:hover .file-tab-close { opacity: 0.78; }
.file-tab-close:hover { color: var(--text); background: rgba(255,255,255,0.07); opacity: 1 !important; }
.artifact-version-badge {
  border: 1px solid rgba(136, 153, 173, 0.24); border-radius: 999px; padding: 1px 5px;
  color: var(--text-dim); font-size: 7px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
}
.artifact-version-badge.current { border-color: rgba(75, 183, 134, 0.32); color: #70c49a; }
.artifact-version-badge.archived { color: #758296; opacity: 0.82; }

#code-viewer { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
#code-editor {
  flex: 1; resize: none; border: none; outline: none; overflow: auto;
  background: var(--bg); color: var(--text);
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  font-size: 12.5px; line-height: 1.65;
  padding: 20px 24px;
  white-space: pre; tab-size: 2; -moz-tab-size: 2; caret-color: var(--accent);
}
#code-editor:focus { outline: none; }
.file-tab.unsaved > span:first-child::after { content: ' ●'; color: var(--accent); font-size: 8px; }

.right-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--text-dim); text-align: center; padding: 32px;
}
.right-empty h3 { font-size: 13px; color: var(--text); letter-spacing: 0.06em; text-transform: uppercase; }
.right-empty p { font-size: 11px; }

#file-tree {
  width: clamp(280px, 24vw, 340px); max-width: 38%; border-right: 1px solid var(--border); overflow-y: auto;
  flex-shrink: 0; display: none; padding: 0; background: linear-gradient(180deg, #10161d, #0d1319);
  scrollbar-width: thin; scrollbar-color: rgba(138,155,171,0.22) transparent;
}
#file-tree.visible { display: block; }
.file-browser-header {
  position: sticky; top: 0; z-index: 4; padding: 12px;
  border-bottom: 1px solid var(--border); background: rgba(15,21,28,0.96); backdrop-filter: blur(10px);
}
.file-browser-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.file-browser-title { color: var(--text); font-size: 10px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.file-browser-count { color: var(--text-dim); font-size: 9px; white-space: nowrap; }
.file-filter {
  width: 100%; height: 30px; border: 1px solid rgba(174,190,204,0.12); border-radius: 3px;
  background: rgba(5,9,13,0.42); color: var(--text); padding: 0 10px; outline: none;
  font: inherit; font-size: 10px; transition: border-color 0.15s, background 0.15s;
}
.file-filter::placeholder { color: #536273; }
.file-filter:focus { border-color: rgba(69,183,207,0.38); background: rgba(5,9,13,0.62); }
.file-browser-sections { padding: 7px 8px 14px; }
.file-section { margin-bottom: 5px; }
.file-section-header {
  width: 100%; min-height: 36px; padding: 7px 8px; border: 0; border-radius: 3px;
  display: flex; align-items: center; gap: 7px; background: transparent; color: var(--text);
  cursor: pointer; font: inherit; text-align: left; transition: background 0.15s, color 0.15s;
}
.file-section-header:hover { color: var(--text); background: rgba(255,255,255,0.025); }
.file-section-chevron { width: 10px; color: #607184; font-size: 9px; transition: transform 0.15s; }
.file-section-header[aria-expanded="true"] .file-section-chevron { transform: rotate(90deg); }
.file-section-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-dim); }
.file-section-title { min-width: 0; flex: 1; font-size: 11px; font-weight: 600; }
.file-section-count, .tree-folder-count { color: #8a9aaa; font-size: 9px; }
.file-section-content { padding: 2px 0 7px 4px; }
.file-section-empty { padding: 16px 8px; color: #9aaaba; font-size: 10px; line-height: 1.5; }
.tree-item {
  scroll-margin-top: 85px; scroll-margin-bottom: 8px;
  width: 100%; min-height: 28px; padding: 5px 7px; border: 0; border-radius: 3px; font-size: 10px; cursor: pointer;
  color: #9aaaba; text-align: left; background: transparent;
  transition: all 0.1s; display: flex; align-items: flex-start; gap: 6px; font-family: inherit;
}
.tree-item:hover { background: rgba(255,255,255,0.025); color: var(--text); }
.tree-item.active { background: rgba(69,183,207,0.1); color: #8fd0dc; box-shadow: inset 2px 0 var(--accent); }
.tree-file-label { min-width: 0; flex: 1; white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
.tree-folder {
  width: 100%; min-height: 28px; padding: 5px 7px; border: 0; border-radius: 3px;
  color: #9aaaba; background: transparent; font: inherit; font-size: 10px; font-weight: 650;
  display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; text-align: left;
}
.tree-folder:hover { color: var(--text); background: rgba(255,255,255,0.022); }
.tree-folder-chevron { width: 9px; color: #566678; font-size: 8px; transition: transform 0.15s; }
.tree-folder[aria-expanded="true"] .tree-folder-chevron { transform: rotate(90deg); }
.tree-folder-glyph {
  position: relative; width: 12px; height: 9px; margin-top: 2px; flex-shrink: 0;
  border: 1px solid currentColor; border-radius: 1px; opacity: 0.5;
}
.tree-folder-glyph::before {
  content: ''; position: absolute; left: 1px; top: -4px; width: 5px; height: 3px;
  border: 1px solid currentColor; border-bottom: 0; border-radius: 1px 1px 0 0;
}
.tree-folder-name { min-width: 0; flex: 1; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
.tree-children { padding-left: 12px; border-left: 1px solid rgba(174,190,204,0.055); margin-left: 11px; }
.tree-icon { width: 13px; font-size: 9px; opacity: 0.52; flex-shrink: 0; text-align: center; line-height: 1.45; }
@media (max-width: 1100px) {
  #file-tree { width: 280px; max-width: 42%; }
  .file-tab-name { max-width: 170px; }
}

#right-content { display: flex; flex: 1; min-height: 0; overflow: hidden; }


/* Files remain interactive while preview dependencies are still being written. */
.workspace-preview-pending { position: relative; }
.workspace-preview-pending > :not(.workspace-delivery-status) { visibility: hidden; }
.workspace-delivery-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 32px;
  color: var(--text-dim);
  text-align: center;
}
.workspace-delivery-status[hidden],
.workspace-delivery-status [hidden] { display: none; }

/* Deliverable navigation shares the workbench palette and keeps real paths intact. */
.file-filter-wrap { position: relative; }
.file-filter { padding-right: 30px; }
.file-filter::-webkit-search-cancel-button { -webkit-appearance: none; }
.file-filter-clear {
  position: absolute; right: 3px; top: 3px; width: 24px; height: 24px;
  border: 0; border-radius: 2px; background: transparent; color: var(--text);
  font: inherit; font-size: 15px; cursor: pointer;
}
.file-filter-clear[hidden] { display: none; }
.file-filter-clear:hover { background: var(--surface3); }
.file-tab-open:focus-visible, .file-tab-close:focus-visible,
.file-filter:focus-visible, .file-filter-clear:focus-visible,
.file-section-header:focus-visible, .tree-folder:focus-visible, .tree-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px;
}
.file-section.contains-active > .file-section-header { color: var(--accent); }
.file-section.contains-active > .file-section-header .file-section-icon { color: inherit; }
.file-section.metadata { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.file-section.metadata .file-section-header, .file-section.archived .file-section-header { color: #8a9aaa; }
.file-section.evidence .file-section-icon { color: var(--yellow); background: transparent; }
.artifact-version-badge.entry { color: var(--accent); border-color: var(--accent-dim); }
@container (max-width: 600px) {
  #right-content { flex-direction: column; }
  #file-tree { width: 100%; max-width: none; max-height: 45%; border-right: 0; border-bottom: 1px solid var(--border); }
  #code-viewer { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .file-filter, .file-section-header, .file-section-chevron, .tree-folder-chevron, .tree-item { transition: none; }
}

#pcb-quote-result[hidden], #pcb-quote-form[hidden] { display: none; }
/* Match the firmware action dropdown while keeping the PCB trigger descriptive. */
.pcb-gerber-menu summary.btn { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.pcb-gerber-menu summary svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.pcb-gerber-menu[open] summary svg { transform: rotate(180deg); }
.pcb-gerber-menu .fw-menu-items { font-size: 12px; }
.pcb-gerber-menu .fw-menu-items button { cursor: pointer; }
.pcb-gerber-menu .fw-menu-items button:disabled { opacity: .45; cursor: not-allowed; }
.pcb-actions { align-items: flex-start; }
#pcb-quote-form { margin-top: 20px; display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
#pcb-quote-form label { display: grid; gap: 6px; color: var(--text-dim); font-size: 11px; }
#pcb-quote-form label { flex: 1; min-width: 0; }
#pcb-quote-form select, #pcb-quote-form input { background: var(--bg); color: var(--text); border: 1px solid var(--border); padding: 8px; font: inherit; min-width: 0; }
#pcb-quote-form input { width: 110px; }
#pcb-quote-form select { width: 100%; }
.pcb-quote-note { margin: 10px 0; color: var(--text-dim); font-size: 11px; line-height: 1.6; }
#pcb-quote-status { color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
#pcb-quote-result { max-width: 620px; border-top: 1px solid var(--border); margin-top: 14px; }
#pcb-quote-result > p:not(.pcb-quote-note) { display: flex; justify-content: space-between; gap: 20px; margin: 10px 0; color: var(--text); font-size: 13px; }
#pcb-quote-result strong { color: var(--accent); font-size: 17px; }

#pcb-quote-dialog { position: fixed; inset: 0; margin: auto; width: min(620px, calc(100vw - 48px)); box-sizing: border-box; max-height: calc(100dvh - 48px); overflow: auto; padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg, #0c1018); color: var(--text); }
#pcb-quote-dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.pcb-quote-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.pcb-quote-heading h2 { margin: 0; font-size: 18px; }

#pcb-quote-result .pcb-quote-test-warning { color: #f87171; font-size: 11px; }
