  /* ---------- Pages ---------- */
  #pages { position: absolute; top: 74px; bottom: 0; left: 0; right: 0; overflow: hidden; }
  #pageTrack { display: flex; width: 300%; height: 100%; transition: transform 0.25s ease; }
  .page { width: 33.333%; height: 100%; position: relative; overflow: hidden; }

  /* ---------- Simulation page ---------- */
  .sim-layout { display: flex; height: 100%; }
  #sidebar { width: 270px; flex-shrink: 0; background: var(--bg); border-right: 1px solid var(--panel-line); overflow-y: auto; padding: 16px; }
  .sidebar-item {
    display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--panel-line);
    border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; cursor: pointer; color: var(--text);
    font-size: 15px; font-weight: 600;
  }
  .sidebar-item svg { width: 34px; height: 18px; color: var(--accent); flex-shrink: 0; }
  .sidebar-item.active {
    border: 2px solid var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(193,117,46,.28);
  }
  .sidebar-item.active svg { color: #fff; }

  [data-theme="dark"] .sidebar-item.active {
    background: var(--accent);
    border-color: var(--accent-strong);
    color: #17130b;
    box-shadow: 0 4px 14px rgba(216,166,63,.30);
  }
  [data-theme="dark"] .sidebar-item.active svg { color: #17130b; }
  .sidebar-more { justify-content: space-between; }
  .sidebar-more .more-icon { width: 34px; height: 18px; color: var(--accent); }
  .sidebar-more .chevron { width: 16px; height: 16px; margin-left: auto; color: var(--text-dim); transition: transform 0.15s; }
  .sidebar-more.expanded .chevron { transform: rotate(180deg); }
  #sidebarMoreItems { display: none; }
  #sidebarMoreItems.show { display: block; }

  #canvas-area { flex: 1; position: relative; overflow: hidden; background: var(--bg); }
  #canvas-wrap { position: absolute; inset: 0; overflow: hidden; background: var(--bg); touch-action: none; }
  svg#canvas { display: block; touch-action: none; width: 100%; height: 100%; }
  .pin { fill: var(--bg); stroke: var(--wire); stroke-width: 2; }
  .comp-body { stroke: var(--text); stroke-width: 2.2; fill: none; }
  .gnd-symbol {
    stroke: var(--text);
    stroke-width: 2.2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
  }
  .grid-dot-fill { fill: var(--grid-dot); }
  .is-selected .comp-body { stroke: var(--accent) !important; stroke-width: 3.2 !important; }
  .is-selected .pin { stroke: var(--accent) !important; stroke-width: 3 !important; fill: rgba(193,127,63,0.14); }
  .is-selected .comp-label { fill: var(--accent-strong) !important; font-weight: 800; }
  .transistor-arrow { fill: var(--text); }
  .is-selected .transistor-arrow { fill: var(--accent); }
  #pal-Q svg { width: 42px; height: 30px; }
  .comp-label { fill: var(--text-dim); font-size: 11px; font-family: monospace; }
  .wire-line { stroke: var(--wire); stroke-width: 2.5; stroke-linecap: round; fill: none; pointer-events: none; }
  .wire-hit { stroke: transparent; stroke-width: 24; fill: none; }
  .wire-bend-handle {
    fill: var(--panel);
    stroke: var(--accent);
    stroke-width: 2;
    cursor: move;
    vector-effect: non-scaling-stroke;
  }
  .wire-junction {
    fill: var(--accent);
    stroke: var(--panel);
    stroke-width: 1.5;
    cursor: move;
    vector-effect: non-scaling-stroke;
  }
  .wire-preview { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 3; fill: none; }
  #wireCrosshair {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 12;
    display: none;
    color: var(--accent);
    overflow: hidden;
  }
  #wireCrosshair.show { display: block; }
  #wireCrosshair.hot { color: #22c55e; }
  #wireCrosshairX, #wireCrosshairY {
    position: absolute;
    background: currentColor;
    opacity: .82;
    pointer-events: none;
  }
  #wireCrosshairX { left: 0; right: 0; height: 1px; top: 50%; }
  #wireCrosshairY { top: 0; bottom: 0; width: 1px; left: 50%; }
  #wireCrosshairDot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 9px;
    height: 9px;
    transform: translate(-50%,-50%);
    border-radius: 50%;
    background: var(--panel);
    border: 2px solid currentColor;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0,0,0,.22);
  }

  .canvas-text { fill: var(--text); font-size: 14px; font-family: 'Segoe UI', system-ui, sans-serif; }
  .canvas-text.is-selected { fill: var(--accent); }

  #status { position: absolute; top: 6px; left: 10px; right: 10px; text-align: center; font-size: 12px; color: var(--text-dim); pointer-events: none; z-index: 4; }

  #selection-bar {
    position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); padding: 8px 10px;
    background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    display: none; gap: 8px; align-items: center; font-size: 12px; z-index: 5;
  }
  #selection-bar.show { display: flex; }
  #selection-bar .sel-label { color: var(--accent-strong); font-family: monospace; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #selection-bar button { padding: 7px 12px; border-radius: 7px; border: 1px solid var(--panel-line); background: var(--bg); color: var(--text); font-size: 12px; }
  #selection-bar button.danger { color: var(--danger); border-color: var(--danger); }

