/* KiCad-Web — chrome styling, KiCad-esque gray toolbars & dialogs */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #1a1a1a;
  background: #d4d0c8;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- menu bar ---------- */
#menubar {
  display: flex; align-items: stretch;
  background: linear-gradient(#f2f0ea, #e3e0d8);
  border-bottom: 1px solid #b5b1a6;
  padding: 0 4px;
  user-select: none;
  z-index: 60;
}
.menu-brand {
  align-self: center;
  font-weight: 700;
  color: #0a5c0a;
  padding: 0 10px 0 6px;
  letter-spacing: 0.2px;
}
.menu { position: relative; }
.menu-name {
  border: 0; background: transparent; padding: 6px 11px;
  font-size: 13px; cursor: default; border-radius: 3px;
}
.menu-name:hover, .menu.open .menu-name { background: #cfe0f1; }
.menu-drop {
  display: none; position: absolute; top: 100%; left: 0;
  min-width: 280px;
  background: #f7f6f2;
  border: 1px solid #a9a59a;
  box-shadow: 3px 4px 12px rgba(0,0,0,0.25);
  padding: 3px;
  z-index: 100;
}
.menu.open .menu-drop { display: block; }
.menu-item {
  display: flex; justify-content: space-between; gap: 24px;
  width: 100%; border: 0; background: transparent;
  padding: 5px 10px; font-size: 13px; text-align: left; cursor: default;
  border-radius: 3px; white-space: nowrap;
}
.menu-item:hover { background: #3b6ea5; color: #fff; }
.mi-accel { color: #777; font-size: 12px; }
.menu-item:hover .mi-accel { color: #dde8f5; }
.menu-sep { height: 1px; background: #c9c5ba; margin: 3px 6px; }

/* ---------- toolbars ---------- */
#maintoolbar {
  display: flex; align-items: center; gap: 2px;
  background: linear-gradient(#edebe4, #dcd9d0);
  border-bottom: 1px solid #b5b1a6;
  padding: 3px 6px;
}
#mid { flex: 1; display: flex; min-height: 0; }
#leftbar, #rightbar {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: linear-gradient(90deg, #edebe4, #dcd9d0);
  padding: 6px 4px;
  overflow-y: auto;
}
#leftbar { border-right: 1px solid #b5b1a6; }
#rightbar { border-left: 1px solid #b5b1a6; background: linear-gradient(270deg, #edebe4, #dcd9d0); }

.tb-btn {
  width: 34px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(#fbfaf6, #e7e4db);
  border: 1px solid #b5b1a6;
  border-radius: 4px;
  color: #333;
  cursor: default;
}
.tb-btn:hover { background: linear-gradient(#ffffff, #eef0f4); border-color: #8aa8c8; }
.tb-btn:active { background: #d5dce6; }
.tb-btn.active {
  background: linear-gradient(#bcd7f0, #9dc3e8);
  border-color: #3b6ea5;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}
.tb-icon { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.8; fill: none; }
.tb-sep { width: 26px; height: 0; border-top: 1px solid #b5b1a6; margin: 4px 0; }
#maintoolbar .tb-sep { width: 0; height: 22px; border-top: 0; border-left: 1px solid #b5b1a6; margin: 0 5px; }

/* ---------- canvas ---------- */
#canvas-wrap { flex: 1; position: relative; min-width: 0; background: #f5f4ec; }
#schem { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; cursor: crosshair; }

/* ---------- status bar ---------- */
#statusbar {
  display: flex; align-items: center;
  background: linear-gradient(#f2f0ea, #e3e0d8);
  border-top: 1px solid #b5b1a6;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  user-select: none;
}
.st-cell { padding: 4px 10px; border-right: 1px solid #c9c5ba; white-space: nowrap; }
.st-grow { flex: 1; overflow: hidden; text-overflow: ellipsis; font-family: "Helvetica Neue", Arial, sans-serif; color: #444; }
.st-flash { color: #0a5c0a; border-right: 0; font-family: "Helvetica Neue", Arial, sans-serif; }
.st-net { color: #840000; font-weight: 600; min-width: 90px; }

/* ---------- dialogs ---------- */
.dlg-overlay {
  position: fixed; inset: 0;
  background: rgba(30,30,25,0.28);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}
.dlg {
  background: #f0efe9;
  border: 1px solid #6f6a5e;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  min-width: 300px;
  display: flex; flex-direction: column;
  max-height: 86vh;
}
.dlg-title {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(#4a5a6a, #37424e);
  color: #fff; font-weight: 600; font-size: 13px;
  padding: 6px 10px;
  user-select: none;
}
.dlg-x {
  border: 0; background: transparent; color: #cfd8e2; font-size: 13px; cursor: default;
  padding: 0 4px;
}
.dlg-x:hover { color: #fff; }
.dlg-body { padding: 12px; overflow: auto; flex: 1; }
.dlg-buttons {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #c9c5ba;
  background: #e7e5dd;
}
.dlg-btn {
  padding: 5px 18px;
  border: 1px solid #8f8a7e;
  border-radius: 3px;
  background: linear-gradient(#fbfaf6, #e2dfd6);
  font-size: 13px;
  cursor: default;
}
.dlg-btn:hover { background: #fff; }
.dlg-btn.primary { background: linear-gradient(#5b84ad, #3b6ea5); color: #fff; border-color: #2d5583; }
.dlg-btn.primary:hover { background: #4a739c; }
.dlg-text { margin-bottom: 8px; line-height: 1.45; }
.dlg-note { margin-top: 8px; color: #666; font-size: 12px; }
.dlg-label { display: block; margin: 8px 0 3px; font-weight: 600; font-size: 12px; }
.dlg-input {
  width: 100%; padding: 5px 7px;
  border: 1px solid #a9a59a; border-radius: 2px;
  font-size: 13px; background: #fff;
}

/* chooser dialog */
.chooser-filter { margin-bottom: 8px; }
.chooser-mid { display: flex; gap: 10px; height: 330px; }
.chooser-tree {
  width: 300px; overflow-y: auto;
  background: #fff; border: 1px solid #a9a59a; padding: 4px;
}
.tree-lib { padding: 3px 4px; font-weight: 700; cursor: default; user-select: none; }
.tree-lib:hover { background: #e8eef5; }
.tree-twist { display: inline-block; width: 16px; color: #3b6ea5; }
.tree-kids { margin-left: 18px; }
.tree-sym { padding: 2px 6px; cursor: default; user-select: none; border-radius: 2px; }
.tree-sym:hover { background: #e8eef5; }
.tree-sym.sel { background: #3b6ea5; color: #fff; }
.chooser-right { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.chooser-preview { flex: 1; width: 100%; border: 1px solid #a9a59a; background: #f5f4ec; }
.chooser-desc { color: #444; font-size: 12px; min-height: 30px; }

/* ERC dialog */
.erc-info { margin-bottom: 8px; color: #333; }
.erc-list {
  height: 300px; overflow-y: auto;
  background: #fff; border: 1px solid #a9a59a; padding: 4px;
  font-family: Menlo, Consolas, monospace; font-size: 12px;
}
.erc-row { display: flex; gap: 8px; padding: 3px 5px; align-items: baseline; border-radius: 2px; }
.erc-row:hover { background: #eef2f8; }
.erc-badge {
  font-weight: 700; font-size: 10px; padding: 1px 5px; border-radius: 2px; color: #fff;
  flex: none;
}
.erc-err .erc-badge { background: #c00000; }
.erc-warn .erc-badge { background: #c88000; }
.erc-ok { color: #0a5c0a; padding: 6px; }
.erc-msg { white-space: normal; }

/* netlist dialog */
.net-tree {
  height: 340px; overflow-y: auto;
  background: #fff; border: 1px solid #a9a59a; padding: 4px;
  font-family: Menlo, Consolas, monospace; font-size: 12px;
}
.net-head { padding: 3px 4px; font-weight: 700; cursor: default; user-select: none; }
.net-head:hover { background: #e8eef5; }
.net-name { color: #043a8a; }
.net-kids { margin-left: 22px; }
.net-pin { padding: 1px 4px; color: #333; }

/* annotate */
.annotate-out {
  margin-top: 10px; min-height: 20px; color: #0a5c0a;
  font-family: Menlo, Consolas, monospace; font-size: 12px;
}
