:root {
  --bg: #101a2b;
  --panel: #1a2233;
  --panel2: #202a3e;
  --border: #2e3a52;
  --text: #d8dee9;
  --muted: #8a94a8;
  --accent: #4d9fec;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, sans-serif;
  overflow: hidden;
}

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

/* ---------- toolbar ---------- */

#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

#toolbar button {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 10px;
  cursor: pointer;
  font: inherit;
}
#toolbar button:hover { border-color: var(--accent); }
#toolbar button.toggled {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}


#board-title { margin-left: auto; color: var(--muted); font-weight: 600; }
#status { color: var(--accent); }

/* ---------- main area ---------- */

#content { position: relative; flex: 1 1 auto; display: flex; min-height: 0; }

#pcb-pane {
  position: relative;
  flex: 1 1 auto;
  min-width: 120px;
  display: flex;
}

#view, #sch-view {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  min-width: 0;
  min-height: 0;
}

.hidden { display: none !important; }

/* ---------- schematic pane ---------- */

#splitter {
  flex: 0 0 6px;
  cursor: col-resize;
  background: var(--border);
}
#splitter:hover { background: var(--accent); }

#sch-pane {
  flex: 0 0 auto;
  flex-basis: 33.3%;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  background: #31363b;
  border-left: 1px solid var(--border);
}

#sch-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  user-select: none;
}
#sch-header .spacer { flex: 1 1 auto; }
#sch-header button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  padding: 0 4px;
}
#sch-header button:hover { color: #fff; }

#sch-pane.pip {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 45%;
  height: 45%;
  min-width: 220px;
  min-height: 140px;
  z-index: 20;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  resize: both;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
#sch-pane.pip #sch-header { cursor: move; }

/* ---------- sidebar / layers ---------- */

#sidebar {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 168px;
  max-height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  backdrop-filter: blur(3px);
}

.sidebar-title {
  padding: 7px 10px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

#layer-list { overflow-y: auto; }

.layer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.layer-row:hover { background: var(--panel2); }
.layer-row.active { border-left-color: var(--accent); background: var(--panel2); }

.eye {
  width: 20px; height: 20px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  position: relative;
  padding: 0;
}
.eye.on { background: var(--accent); border-color: var(--accent); }
.eye.on::after {
  content: '';
  position: absolute; inset: 5px;
  border-radius: 50%;
  background: #fff;
}

.swatch {
  width: 14px; height: 14px;
  flex: 0 0 auto;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.25);
}

.lname {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.opacity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}

/* slim slider, no big round knob */
#alpha-all {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  min-width: 0;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
#alpha-all::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
#alpha-all::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}

.sidebar-hint {
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}

/* ---------- part info panel ---------- */

#part-panel {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 320px;
  max-height: 55%;
  overflow-y: auto;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: none;
  backdrop-filter: blur(3px);
}
#part-panel.show { display: block; }

.pp-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; font-size: 15px; }
.pp-head .muted { flex: 1 1 auto; }
#pp-close {
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 0 2px;
}
#pp-close:hover { color: #fff; }

#part-panel table { border-collapse: collapse; width: 100%; }
#part-panel td { padding: 2px 6px 2px 0; vertical-align: top; word-break: break-word; }
#part-panel td:first-child { color: var(--muted); white-space: nowrap; width: 80px; }
#part-panel a { color: var(--accent); }

.pp-desc { margin-top: 6px; color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }

/* ---------- drop hint ---------- */

#drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#drop-hint.hidden { display: none; }
#drop-hint.over .dh-inner { border-color: var(--accent); }

.dh-inner {
  pointer-events: auto;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px 48px;
  text-align: center;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}
.dh-inner h2 { margin: 0 0 8px; color: var(--text); }
.dh-inner button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font: inherit;
  cursor: pointer;
}
.dh-inner .small { font-size: 11px; }
.dh-inner code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; }

/* ---------- status bar ---------- */

#statusbar {
  display: flex;
  gap: 24px;
  padding: 3px 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  flex: 0 0 auto;
  min-height: 22px;
}
#netinfo { color: var(--accent); }
