/* ============================================================
   CircuitForge Professional v4.1 — Panels & Instruments UI
   Timing Diagram Analyzer · Custom Combinational Builder ·
   Instrument chrome. All surfaces consume the theme tokens so
   every theme stays human-readable.
   ============================================================ */

/* ============================================================
   Timing Diagram Analyzer (top-right dock, draggable)
   ============================================================ */
#timing-analyzer-panel {
  position: fixed;
  top: 56px;
  right: 300px;
  width: 560px;
  height: 380px;
  min-height: 240px;
  background: var(--grad-panel);
  border: 1px solid var(--border-color);
  border-top: 2px solid var(--accent-green);
  border-radius: 10px;
  box-shadow: var(--shadow-panel);
  z-index: 4800;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-ui);
  user-select: none;
}
#timing-analyzer-panel.open { display: flex; }

.ta-header {
  height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--grad-header);
  border-bottom: 1px solid var(--border-color);
  cursor: move;
  touch-action: none;
}
.ta-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent-green);
  white-space: nowrap;
}
.ta-sub {
  font-size: 9px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ta-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ta-window-val {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 34px;
  text-align: center;
}
.ta-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  background: rgba(128, 152, 170, 0.10);
  border: 1px solid var(--border-color-light);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
.ta-btn:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.ta-btn.ta-clear { width: auto; padding: 0 7px; font-size: 9px; letter-spacing: 0.5px; }
.ta-btn.ta-close:hover { border-color: var(--accent-red); color: var(--accent-red); }

.ta-canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}
#ta-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.ta-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-muted);
  pointer-events: none;
}

/* ============================================================
   Custom Combinational Builder dialog
   ============================================================ */
#custom-comb-modal {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  width: 460px;
  max-width: calc(100vw - 40px);
  background: var(--grad-panel);
  border: 1px solid var(--border-color);
  border-top: 2px solid var(--accent-purple);
  border-radius: 10px;
  box-shadow: var(--shadow-panel);
  z-index: 5400;
  display: none;
  overflow: hidden;
  font-family: var(--font-ui);
}
#custom-comb-modal.open { display: block; }

.cc-header {
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--grad-header);
  border-bottom: 1px solid var(--border-color);
}
.cc-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent-purple);
}
.cc-close {
  margin-left: auto;
  width: 24px;
  height: 24px;
  background: transparent;
  border: 1px solid var(--border-color-light);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
}
.cc-close:hover { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }

.cc-body { padding: 14px 16px 16px; }
.cc-field { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cc-field label {
  width: 110px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.cc-field select {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 6px 8px;
  border-radius: 5px;
  outline: none;
}
.cc-field select:focus { border-color: var(--accent-purple); }

.cc-hint {
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--text-muted);
  background: rgba(128, 152, 170, 0.08);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
#cc-error {
  display: none;
  font-size: 11px;
  color: var(--accent-red);
  background: rgba(255, 51, 68, 0.10);
  border: 1px solid rgba(255, 51, 68, 0.35);
  border-radius: 5px;
  padding: 6px 10px;
  margin-bottom: 10px;
}
.cc-create-btn {
  width: 100%;
  padding: 9px 0;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, #7e22ce, #4f46e5);
  color: #ffffff;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.cc-create-btn:hover { filter: brightness(1.15); }

.palette-builder-item {
  border-top: 1px dashed var(--border-color-light);
  margin-top: 4px;
  color: var(--accent-purple);
}
.palette-item-sub {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ============================================================
   Menubar polish: professional gradient accents
   ============================================================ */
#top-menubar {
  background: var(--grad-header);
  box-shadow: 0 1px 0 rgba(128, 152, 170, 0.08), 0 4px 18px rgba(0, 0, 0, 0.35);
}
.mb-app-title {
  background: var(--grad-title);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mb-app-title .lite {
  background: none;
  -webkit-text-fill-color: var(--text-muted);
}
.mb-btn.sim-run {
  background: var(--grad-btn-run);
}
.mb-btn.active {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.18), rgba(0, 255, 136, 0.10));
}
.mb-sim-pill.active {
  background: var(--grad-btn-run);
}

/* Right sidebar header polish */
.sidebar-header {
  background: var(--grad-header);
}
