/* Modern Minimalist Clean UI for Web ngspice */
:root {
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-light: #ccfbf1;
  --bg-app: #f8fafc;
  --bg-canvas: #ffffff;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sub: #94a3b8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --accent-blue: #2563eb;
  --accent-amber: #d97706;
  
  --scope-bg: #090d16;
  --scope-grid: #1e293b;
  --scope-text: #94a3b8;
  --ch1-color: #facc15;
  --ch2-color: #38bdf8;
  --ch3-color: #4ade80;
  --ch4-color: #f472b6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* Header */
.app-header {
  height: 60px;
  flex: 0 0 60px;
  min-width: 0;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 #f1f5f9;
  position: relative;
  z-index: 500;
}

.app-header > *,
.header-actions > *,
.header-right > * {
  flex-shrink: 0;
}

.app-header .action-btn,
.app-header .action-btn > * {
  white-space: nowrap;
  flex-shrink: 0;
}

.app-header::-webkit-scrollbar { height: 6px; }
.app-header::-webkit-scrollbar-track { background: #f1f5f9; }
.app-header::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 30px;
  height: 30px;
}

.brand-logo-3d {flex-direction:column;gap:0;}
.brand-logo-image {display:block;width:120px;height:42px;object-fit:contain;}
.brand-logo-3d .brand-sub {font-size:10px;line-height:12px;}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.2px;
  display: block;
  line-height: 1.1;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.header-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.action-btn .btn-icon {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

.btn-help-pill {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
  font-weight: 600;
  padding: 0 12px;
  gap: 8px;
}

.btn-help-pill:hover {
  background: #fde68a;
  border-color: #fcd34d;
  color: #78350f;
}

.help-bulb {
  font-size: 14px;
}

.help-badge {
  font-size: 10px;
  background: #dc2626;
  color: #ffffff;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* Dropdown Menu */
.dropdown-wrapper {
  position: relative;
}

.dropdown-menu {
  position: fixed;
  top: 60px;
  left: 0;
  margin-top: 0;
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  width: 280px;
  max-width: calc(100vw - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  display: none;
  z-index: 50;
}

.dropdown-menu.show {
  display: block;
}

.template-menu-heading {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border-color);
}

.dropdown-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}

.dropdown-item:hover {
  background: #f8fafc;
}

.dropdown-item strong {
  display: block;
  font-size: 13px;
  color: #1e293b;
  margin-bottom: 2px;
}

.dropdown-item small {
  display: block;
  font-size: 11px;
  color: #64748b;
}

/* Main Workspace Split */
.workspace-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Left Palette */
.component-palette {
  width: 170px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.palette-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  background: #f8fafc;
}

.palette-header small {
  font-size: 10px;
  font-weight: normal;
  color: var(--primary);
  background: var(--primary-light);
  padding: 1px 5px;
  border-radius: 4px;
}

.palette-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
}

.palette-group-title {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 10px 4px 6px;
}

.palette-group-title:first-child {
  margin-top: 2px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.palette-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.palette-item:hover {
  background: #f8fafc;
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(15, 118, 110, 0.08);
}

.palette-item.active {
  background: var(--primary-light);
  border-color: var(--primary);
}

.sym-svg {
  width: 44px;
  height: 26px;
  display: block;
}

.palette-item span {
  font-size: 11px;
  font-weight: 500;
  color: #475569;
  margin-top: 3px;
  text-align: center;
}

.palette-item.item-probe {
  grid-column: span 2;
  border-color: #bae6fd;
  background: #f0f9ff;
}

.palette-item.item-probe:hover {
  border-color: #0284c7;
  background: #e0f2fe;
}

/* Center Schematic Canvas */
.schematic-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
  position: relative;
  overflow: hidden;
}

.canvas-infobar {
  height: 30px;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 12px;
  color: #475569;
}

.info-tip strong {
  color: var(--primary);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #10b981;
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
}

.status-indicator.busy .status-dot {
  background: #f59e0b;
  animation: pulse 1s infinite;
}

.status-indicator.busy {
  color: #f59e0b;
}

.status-indicator.error .status-dot {
  background: #ef4444;
}

.status-indicator.error {
  color: #ef4444;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}

/* Floating Zoom & Fit Controls */
.canvas-zoom-controls {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  padding: 3px;
  gap: 4px;
  z-index: 20;
  backdrop-filter: blur(4px);
}

.zoom-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: 4px;
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.zoom-btn:hover {
  background: #f1f5f9;
  border-color: var(--primary);
  color: var(--primary);
}

.zoom-btn.btn-fit {
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.zoom-badge {
  font-size: 11px;
  font-family: monospace;
  font-weight: 600;
  color: #64748b;
  padding: 0 6px;
}

.schematic-svg {
  display: block;
}

/* Component Node Cursor Styles (Grab & Grabbing Hand) */
.comp-node {
  cursor: grab;
  user-select: none;
  transition: filter 0.15s ease;
}

.comp-node:hover {
  filter: drop-shadow(0 0 3px rgba(15, 118, 110, 0.45));
}

.comp-node.selected {
  filter: drop-shadow(0 0 5px #0f766e);
}

.comp-node.multi-selected {
  filter: drop-shadow(0 0 6px #f59e0b) !important;
}

.wire-line.multi-selected {
  stroke: #f59e0b !important;
  stroke-width: 3.5px !important;
  filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.7)) !important;
}

/* Multi-Selection Marquee & Floating Delete Bar */
.multi-select-menu {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 45;
  font-size: 12px;
  font-weight: 600;
  animation: modalSlide 0.15s ease;
}

.btn-del-multi {
  background: #dc2626;
  color: #ffffff;
  border: none;
  border-radius: 5px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-del-multi:hover {
  background: #b91c1c;
}

.btn-copy-multi {
  background: #0d9488;
  color: #ffffff;
  border: none;
  border-radius: 5px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-copy-multi:hover {
  background: #0f766e;
}

.btn-close-multi {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #475569;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}

.btn-close-multi:hover {
  color: #ffffff;
  background: #334155;
}

.btn-action-tool {
  height: 28px;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-action-tool:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
}

/* Grabbing hand while dragging component */
body.is-dragging-comp,
body.is-dragging-comp * {
  cursor: grabbing !important;
  user-select: none !important;
}

/* Ghost Component attached to mouse */
#ghostLayer {
  filter: drop-shadow(0 4px 10px rgba(15, 118, 110, 0.4));
  pointer-events: none;
}

/* Preview paths must never intercept the click intended for a pin. */
#tempWirePath, #marqueeRect { pointer-events: none; }

/* Component Action Menu (Rotate, Del) */
.comp-action-menu {
  position: absolute;
  background: #1e293b;
  border-radius: 6px;
  padding: 3px;
  display: flex;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 30;
  transform: translate(-50%, -100%);
  margin-top: -8px;
}

.comp-action-menu button {
  background: transparent;
  border: none;
  color: #f8fafc;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.comp-action-menu button:hover {
  background: #334155;
}

.comp-action-menu button.btn-del:hover {
  background: #dc2626;
}

/* Parameter Edit Popover */
.param-popover {
  position: absolute;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  z-index: 35;
  width: 220px;
}

.popover-title {
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 6px;
}

.param-input {
  width: 100%;
  height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0 8px;
  font-size: 13px;
  font-family: monospace;
  font-weight: 600;
  outline: none;
}

.param-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.15);
}

.popover-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.btn-save {
  flex: 1;
  height: 28px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-cancel {
  height: 28px;
  background: #f1f5f9;
  color: #475569;
  border: none;
  border-radius: 4px;
  padding: 0 10px;
  font-size: 12px;
  cursor: pointer;
}

.popover-hint {
  display: block;
  font-size: 10px;
  color: #94a3b8;
  margin-top: 6px;
}

/* Netlist Code Drawer */
.netlist-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  background: #ffffff;
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.drawer-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-header h3 {
  font-size: 14px;
  color: #0f172a;
}

.drawer-close {
  background: none;
  border: none;
  font-size: 16px;
  color: #94a3b8;
  cursor: pointer;
}

.drawer-body {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-desc {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 10px;
}

.netlist-textarea {
  flex: 1;
  background: #0f172a;
  color: #38bdf8;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 6px;
  border: 1px solid #334155;
  padding: 10px;
  resize: none;
  outline: none;
}

.drawer-footer {
  margin-top: 12px;
}

/* Oscilloscope Panel (LTspice style: Floating, Resizable & Multi-Pane) */
.oscilloscope-panel {
  background: var(--scope-bg);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: opacity 0.15s ease;
}

.oscilloscope-panel.floating {
  position: fixed !important;
  right: 24px;
  bottom: 24px;
  width: 760px;
  height: 440px;
  min-width: 380px;
  min-height: 220px;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1);
  resize: both;
  overflow: hidden;
  border: 1px solid #334155;
  z-index: 85;
}

.oscilloscope-panel.popped-out {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  resize: none !important;
  margin: 0 !important;
  z-index: 10 !important;
}

.oscilloscope-panel.popped-out .scope-resize-handle,
.oscilloscope-panel.popped-out #btnScopeDockToggle,
.oscilloscope-panel.popped-out #btnScopeMaximize,
.oscilloscope-panel.popped-out #btnToggleScope {
  display: none !important;
}

.oscilloscope-panel.docked {
  position: static;
  width: 100%;
  height: 300px;
  min-height: 180px;
  border-radius: 0;
  border-top: 2px solid #1e293b;
  resize: vertical;
}

.oscilloscope-panel.maximized {
  position: absolute !important;
  top: 56px !important;
  left: 170px !important;
  right: 0 !important;
  bottom: 0 !important;
  width: auto !important;
  height: auto !important;
  border-radius: 0 !important;
  z-index: 60 !important;
  resize: none !important;
}

.oscilloscope-panel.collapsed {
  height: 38px !important;
  min-height: 38px !important;
  overflow: hidden !important;
  resize: none !important;
}

.oscilloscope-panel.collapsed .scope-body,
.oscilloscope-panel.collapsed .scope-resize-handle {
  display: none !important;
}

.scope-header {
  height: 38px;
  background: #0b1120;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.scope-drag-grip {
  cursor: grab;
  color: #64748b;
  font-size: 14px;
  letter-spacing: -2px;
  padding: 0 4px;
}

.scope-title-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scope-brand {
  font-size: 12px;
  font-weight: 700;
  color: #f8fafc;
}

.scope-badge {
  font-size: 10px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.scope-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scope-readout {
  font-size: 11px;
  color: #94a3b8;
  font-family: monospace;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scope-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Multi-Pane Panes Track */
.panes-header-bar {
  display: flex;
  flex-direction: column;
  background: #090e17;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}

.pane-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 10px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.7);
  background: rgba(15, 23, 42, 0.6);
  min-height: 28px;
  transition: background 0.15s ease;
}

.pane-strip.drag-over {
  background: rgba(2, 132, 199, 0.25) !important;
  outline: 1px dashed #38bdf8;
}

.pane-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.pane-title {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  background: #1e293b;
  padding: 1px 5px;
  border-radius: 3px;
}

.pane-traces {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.pane-empty-hint {
  font-size: 10px;
  color: #64748b;
  font-style: italic;
}

.btn-del-pane {
  background: none;
  border: none;
  color: #64748b;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 8px;
}

.btn-del-pane:hover {
  background: #dc2626;
  color: #ffffff;
}

.trace-pill {
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #1e293b;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: grab;
  user-select: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.trace-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.trace-pill:active {
  cursor: grabbing;
}

.trace-pill.dragging {
  opacity: 0.4;
}

.trace-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.scope-resize-handle {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 14px;
  height: 14px;
  cursor: se-resize;
  background: linear-gradient(135deg, transparent 50%, #64748b 50%, #64748b 65%, transparent 65%, transparent 80%, #64748b 80%);
  z-index: 10;
}

.btn-highlight {
  background: #0f766e !important;
  color: #ffffff !important;
  border-color: #14b8a6 !important;
}

.btn-highlight:hover {
  background: #115e59 !important;
}

.scope-btn {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.scope-btn:hover {
  background: #334155;
  color: #ffffff;
}

.scope-btn.btn-popout {
  background: #0369a1;
  color: #f0f9ff;
  border-color: #0284c7;
  font-weight: 600;
}

.scope-btn.btn-popout:hover {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
}

.scope-btn.btn-popout.is-popped {
  background: #0d9488;
  border-color: #14b8a6;
  color: #ffffff;
}

.scope-btn.btn-popout.is-popped:hover {
  background: #0f766e;
  border-color: #2dd4bf;
}

/* Cross-screen Pop-out Placeholder in Main Window */
.scope-popout-placeholder {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 360px;
  padding: 16px 18px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px dashed #0284c7;
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
  z-index: 70;
  color: #f8fafc;
  animation: fadeIn 0.2s ease;
}

.popout-placeholder-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popout-placeholder-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.popout-placeholder-icon {
  font-size: 18px;
  color: #38bdf8;
}

.popout-placeholder-title {
  font-size: 13px;
  font-weight: 700;
  color: #38bdf8;
}

.popout-placeholder-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.5;
  margin: 0;
}

.popout-placeholder-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

body.is-dragging-scope {
  user-select: none !important;
}

body.is-dragging-scope svg,
body.is-dragging-scope iframe,
body.is-dragging-scope canvas {
  pointer-events: none !important;
}

.scope-btn:hover {
  background: #334155;
  color: #ffffff;
}

.scope-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.scope-canvas {
  width: 100%;
  height: 0;
  min-height: 0;
  flex: 1 1 0;
  display: block;
}

/* Online Help Drawer */
.help-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 580px;
  max-width: 96vw;
  background: #ffffff;
  box-shadow: -10px 0 32px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  animation: slideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.help-drawer-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.help-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.help-title-icon {
  font-size: 20px;
}

.help-drawer-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.help-subtitle {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.help-close-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}

.help-close-btn:hover {
  color: #334155;
  background: #e2e8f0;
}

.help-tabs {
  display: flex;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  padding: 0 4px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

.help-tabs::-webkit-scrollbar {
  height: 3px;
}
.help-tabs::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.help-tab {
  flex: 0 0 auto;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: all 0.15s;
}

.help-tab:hover {
  color: #0f172a;
  background: #f1f5f9;
}

.help-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #ffffff;
}

.help-drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.help-banner {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: #0f766e;
  line-height: 1.5;
  margin-bottom: 14px;
}

.help-sec-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin: 16px 0 10px 0;
  padding-bottom: 5px;
  border-bottom: 1px solid #f1f5f9;
}

.help-sec-title:first-child {
  margin-top: 0;
}

.help-steps {
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.6;
  color: #334155;
  margin-bottom: 14px;
}

.help-steps li {
  margin-bottom: 12px;
}

.help-tip-text {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #475569;
  line-height: 1.45;
}

.help-alert {
  display: block;
  background: #fef2f2;
  border-left: 3px solid #ef4444;
  color: #991b1b;
  padding: 6px 10px;
  margin-top: 6px;
  border-radius: 0 4px 4px 0;
  font-size: 11px;
  line-height: 1.4;
}

/* Feature Mini Cards */
.help-feature-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 14px;
}

.mini-feat-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.mini-feat-icon {
  font-size: 16px;
  line-height: 1;
  margin-top: 2px;
}

.mini-feat-card strong {
  font-size: 12px;
  color: #1e293b;
  display: block;
  margin-bottom: 2px;
}

.mini-feat-card p {
  font-size: 11px;
  color: #64748b;
  line-height: 1.35;
  margin: 0;
}

/* Shortcut Tables */
.shortcut-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.sc-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px;
  background: #f8fafc;
  border-radius: 4px;
  font-size: 12px;
  transition: background 0.15s;
}

.sc-row:hover {
  background: #f1f5f9;
}

.sc-key {
  flex: 0 0 140px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #0f766e;
}

.sc-desc {
  flex: 1;
  color: #334155;
  line-height: 1.45;
  font-size: 12px;
}

kbd {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  box-shadow: 0 1px 1px rgba(0,0,0,0.06);
}

/* Detailed Feature Cards */
.feat-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.feat-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.feat-card-header h4 {
  margin: 0 !important;
  font-size: 13px !important;
  font-weight: 700;
  color: #0f172a;
  flex: 1;
}

.feat-icon {
  font-size: 16px;
}

.feat-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: #e0f2fe;
  color: #0369a1;
}

.feat-card p {
  font-size: 12px;
  color: #334155;
  line-height: 1.5;
  margin: 0 0 6px 0;
}

.feat-list {
  margin: 6px 0 0 18px;
  font-size: 12px;
  color: #475569;
  line-height: 1.55;
}

.feat-list li {
  margin-bottom: 4px;
}

/* Template Cards */
.template-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 14px;
}

.template-card {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 12px;
  background: #f8fafc;
  transition: all 0.15s;
}

.template-card:hover {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 118, 110, 0.08);
}

.tc-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}

.tc-desc {
  font-size: 11px;
  color: #64748b;
  line-height: 1.45;
  margin-bottom: 8px;
}

.tc-btn {
  background: var(--primary);
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.tc-btn:hover {
  background: #0d9488;
}

/* FAQ */
.faq-item {
  margin-bottom: 14px;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 12px;
}

.faq-q {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 5px;
}

.faq-a {
  font-size: 12px;
  color: #475569;
  line-height: 1.55;
}

.code-box {
  background: #0f172a;
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  padding: 12px;
  border-radius: 6px;
  line-height: 1.55;
  overflow-x: auto;
  margin-bottom: 14px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.3);
  z-index: 990;
}

/* ==========================================
   Simulation Settings Pill & Badge
   ========================================== */
.btn-sim-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-sim-pill:hover {
  background: #f1f5f9;
  border-color: var(--primary);
}

.sim-badge {
  background: #0f172a;
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #334155;
  font-weight: 600;
}

/* ==========================================
   Wire Selection, Routing & Net Labels
   ========================================== */
.wire-line {
  transition: stroke 0.15s ease, stroke-width 0.15s ease;
  cursor: grab;
}

.wire-line:hover {
  stroke: #38bdf8;
  stroke-width: 3.5px;
  cursor: grab;
}

.wire-line.selected {
  stroke: #f59e0b !important;
  stroke-width: 3.6px !important;
  filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.65));
}

.wire-hitbox {
  cursor: grab;
}

.wire-hitbox:active {
  cursor: grabbing;
}

body.is-dragging-wire,
body.is-dragging-wire * {
  cursor: grabbing !important;
  user-select: none !important;
}

body.is-wiring,
body.is-wiring * {
  cursor: crosshair !important;
}

.wire-junction-dot {
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Circled Port Node (Auto-created on mid-air double click, auto-disappears on reconnect) */
.circled-port-node {
  cursor: crosshair;
  transition: transform 0.15s ease;
}

.circled-port-node:hover .port-outer-ring {
  stroke: #f59e0b !important;
  fill: #fef3c7 !important;
  stroke-width: 2.6px !important;
  r: 8.5px !important;
}

.port-outer-ring {
  transition: all 0.15s ease;
}

.port-hotspot {
  cursor: crosshair;
}

.wire-drag-handle {
  cursor: grab;
  transition: r 0.15s ease, fill 0.15s ease;
}

.wire-drag-handle:hover {
  r: 8.5px;
  fill: #f59e0b;
  cursor: grab;
}

.wire-action-menu {
  position: absolute;
  background: #1e293b;
  border-radius: 6px;
  padding: 3px 4px;
  display: flex;
  gap: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  z-index: 32;
  transform: translate(-50%, -100%);
  margin-top: -8px;
}

.wire-action-menu button {
  background: transparent;
  border: none;
  color: #f8fafc;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
}

.wire-action-menu button:hover {
  background: #334155;
}

.wire-action-menu button.btn-del:hover {
  background: #dc2626;
}

.net-label-tag {
  cursor: grab;
  user-select: none;
  transition: filter 0.15s ease;
}

.net-label-tag:hover {
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.9)) brightness(1.15);
  cursor: grab;
}

.net-label-tag:active,
body.is-dragging-wire-label,
body.is-dragging-wire-label * {
  cursor: grabbing !important;
}

.comp-text-labels {
  cursor: grab;
  user-select: none;
  transition: filter 0.15s ease;
}

.comp-text-labels:hover {
  filter: drop-shadow(0 0 5px rgba(2, 132, 199, 0.9));
  cursor: grab;
}

.comp-text-labels:active,
body.is-dragging-comp-text,
body.is-dragging-comp-text * {
  cursor: grabbing !important;
}

/* ==========================================
   Modern Component Property Dialog
   ========================================== */
.modern-property-dialog {
  position: absolute;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 16px 36px -4px rgba(15, 23, 42, 0.22), 0 6px 16px -2px rgba(15, 23, 42, 0.1);
  z-index: 50;
  width: 330px;
  max-width: 90vw;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: propFadeIn 0.12s ease-out;
}

@keyframes propFadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.popover-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comp-type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #0f766e;
  background: #ccfbf1;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #99f6e4;
}

.popover-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.popover-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.popover-close-btn:hover {
  color: #ef4444;
  background: #fee2e2;
}

.prop-form-group {
  margin-bottom: 10px;
}

.prop-row-split {
  display: flex;
  gap: 8px;
}

.prop-field-half {
  flex: 1;
}

.prop-field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.param-input-sm {
  width: 100%;
  height: 28px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  outline: none;
  box-sizing: border-box;
}

.param-input-sm.readonly {
  background: #f8fafc;
  color: #64748b;
  border-color: #e2e8f0;
  cursor: default;
}

.param-input-sm:focus:not(.readonly) {
  border-color: #0f766e;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.15);
}

.param-input {
  width: 100%;
  height: 34px;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  color: #0f172a;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.param-input:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.quick-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.preset-chip {
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-weight: 600;
  color: #334155;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f766e;
}

.preset-chip:active {
  background: #0f766e;
  color: #ffffff;
  border-color: #0f766e;
}

.param-unit-helper {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 10px;
  color: #64748b;
  margin-top: 6px;
  line-height: 1.3;
}

.unit-helper-title {
  color: #94a3b8;
  font-size: 10px;
  margin-right: 2px;
}

.unit-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-weight: 700;
  color: #0f766e;
  cursor: pointer;
  transition: all 0.12s ease;
  line-height: 1.4;
}

.unit-btn:hover {
  background: #ccfbf1;
  border-color: #0f766e;
  color: #0f766e;
}

.unit-btn:active {
  background: #0f766e;
  color: #ffffff;
}

.prop-orient-group {
  border-top: 1px dashed #e2e8f0;
  padding-top: 8px;
  margin-top: 8px;
}

.orient-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.btn-orient-tool {
  height: 28px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-orient-tool:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

.popover-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #f1f5f9;
  padding-top: 10px;
  margin-top: 10px;
}

.action-btn-right {
  display: flex;
  gap: 6px;
}

.btn-primary {
  height: 30px;
  background: #0f766e;
  color: #ffffff;
  border: none;
  border-radius: 5px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-primary:hover {
  background: #115e59;
}

.btn-secondary {
  height: 30px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.btn-del-outline {
  height: 30px;
  background: #fff;
  color: #ef4444;
  border: 1px solid #fca5a5;
  border-radius: 5px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-del-outline:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

.quick-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.tag-pill {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  font-family: monospace;
  color: #334155;
  cursor: pointer;
}

.tag-pill:hover {
  background: #ecfdf5;
  border-color: #10b981;
  color: #047857;
}

/* ==========================================
   Simulation Settings Modal (LTspice Style)
   ========================================== */
.sim-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.sim-modal-dialog {
  background: #ffffff;
  width: 620px;
  max-width: 95vw;
  border-radius: 12px;
  box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlide 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 12px 18px;
  background: #0f172a;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-icon {
  width: 18px;
  height: 18px;
  color: #38bdf8;
}

.modal-header h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}

.lt-badge {
  font-size: 10px;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.modal-tabs {
  display: flex;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border-color);
  padding: 0 12px;
}

.modal-tab {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-tab:hover {
  color: #0f172a;
}

.modal-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #ffffff;
}

.modal-content {
  padding: 18px 20px;
  background: #ffffff;
  min-height: 240px;
  overflow-y: auto;
}

.sim-tab-pane {
  display: none;
}

.sim-tab-pane.active {
  display: block;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
}

.form-field.checkbox-field {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 5px;
}

.form-field label .req {
  color: #ef4444;
}

.form-input {
  height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  font-family: monospace;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.15);
}

.field-desc {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #1e293b;
  cursor: pointer;
}

.preset-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed #e2e8f0;
}

.preset-title {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 8px;
}

.preset-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-btn,
.preset-btn-ac,
.preset-btn-dc {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover,
.preset-btn-ac:hover,
.preset-btn-dc:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.op-intro-box {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  color: #0f766e;
  font-size: 12px;
  line-height: 1.6;
}

.op-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.modal-footer {
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-label {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

.preview-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  background: #0f172a;
  color: #38bdf8;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.modal-btn-group {
  display: flex;
  gap: 8px;
}

/* ==========================================
   Right-Click SPICE Model Picker Context Menu
   ========================================== */
.model-context-menu {
  position: absolute;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  width: 290px;
  max-width: 90vw;
  z-index: 60;
  overflow: hidden;
  animation: modalSlide 0.12s cubic-bezier(0.16, 1, 0.3, 1);
}

.model-menu-header {
  padding: 10px 14px;
  background: #0f172a;
  color: #ffffff;
  border-bottom: 1px solid #334155;
}

.model-menu-header span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #f8fafc;
}

.model-menu-header small {
  display: block;
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
}

.model-menu-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 0;
}

.model-menu-item {
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.12s ease;
}

.model-menu-item:hover {
  background: #f0fdfa;
}

.model-menu-item.active {
  background: #ecfdf5;
}

.model-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.model-item-name {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  font-family: monospace;
}

.model-item-tag {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #e0f2fe;
  color: #0284c7;
  font-weight: 600;
}

.model-item-tag.ideal-tag {
  background: #dcfce7;
  color: #15803d;
}

.model-item-desc {
  font-size: 10px;
  color: #64748b;
  margin-top: 2px;
  line-height: 1.3;
}

/* ==========================================
   Right Property Inspector Panel
   ========================================== */
.property-inspector-panel {
  width: 280px;
  min-width: 280px;
  max-width: 320px;
  background: #ffffff;
  border-left: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
  transition: width 0.2s ease, min-width 0.2s ease, margin-right 0.2s ease;
  user-select: none;
}

.property-inspector-panel.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border-left: none;
  visibility: hidden;
}

.inspector-header {
  height: 40px;
  padding: 0 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.inspector-header-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
}

.inspector-icon {
  font-size: 14px;
}

.inspector-badge {
  font-size: 10px;
  font-weight: 700;
  background: #e0f2fe;
  color: #0284c7;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #bae6fd;
}

.inspector-collapse-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.inspector-collapse-btn:hover {
  background: #fee2e2;
  color: #ef4444;
}

.inspector-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 12px;
  box-sizing: border-box;
}

.insp-section {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.insp-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.insp-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.insp-form-group {
  margin-bottom: 9px;
}

.insp-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 3px;
}

.insp-label-sym {
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: #0f766e;
  font-weight: 700;
  font-size: 10px;
  background: #f0fdfa;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid #ccfbf1;
}

.insp-input {
  width: 100%;
  height: 29px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 0 8px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  color: #0f172a;
  outline: none;
  box-sizing: border-box;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.insp-input:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.15);
}

.insp-input.readonly {
  background: #f8fafc;
  color: #64748b;
  border-color: #e2e8f0;
  cursor: default;
}

.insp-select {
  width: 100%;
  height: 29px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #0f172a;
  background: #ffffff;
  outline: none;
  box-sizing: border-box;
}

.insp-select:focus {
  border-color: #0f766e;
}

.insp-spice-preview {
  background: #0f172a;
  color: #38bdf8;
  padding: 8px 10px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  word-break: break-all;
  margin-top: 8px;
  border: 1px solid #1e293b;
  line-height: 1.4;
}

.insp-preview-label {
  display: block;
  font-size: 9px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.insp-stat-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #0f766e;
  background: #f0fdfa;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid #ccfbf1;
  margin-top: 4px;
}

.insp-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.insp-slider {
  flex: 1;
  accent-color: #0f766e;
}

.insp-slider-val {
  font-family: monospace;
  font-weight: 700;
  font-size: 11px;
  color: #0f766e;
  width: 40px;
  text-align: right;
}

/* Empty State */
.inspector-empty-state {
  text-align: center;
  padding: 24px 8px;
  color: #94a3b8;
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.empty-title {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 16px;
}

.empty-hint {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  color: #475569;
}

.empty-hint ul {
  margin: 6px 0 0 16px;
  padding: 0;
  line-height: 1.6;
}

.empty-hint li {
  margin-bottom: 2px;
}


/* =========================================================
   LTspice Waveform Arithmetic & Trace Expression Styles
   ========================================================= */

.trace-pill.is-expr {
  border: 1px dashed rgba(56, 189, 248, 0.5) !important;
  background: rgba(15, 23, 42, 0.8) !important;
}

.trace-expr-badge {
  font-size: 10px;
  font-family: serif;
  font-style: italic;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  padding: 0 4px;
  border-radius: 3px;
  line-height: 14px;
  margin-right: 2px;
}

.trace-action-btn {
  font-size: 10px;
  padding: 0 3px;
  border-radius: 2px;
  cursor: pointer;
  opacity: 0.6;
  margin-left: 2px;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.trace-action-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
}

.trace-action-btn.del:hover {
  background: #dc2626;
  color: #fff;
}

.math-modal-symbol {
  font-size: 24px;
  font-family: serif;
  font-style: italic;
  font-weight: 700;
  color: #38bdf8;
  line-height: 1;
}

.math-status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.math-status-badge.valid {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.math-status-badge.invalid {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.math-error-tip {
  margin-top: 5px;
  font-size: 11px;
  color: #fb7185;
  background: rgba(244, 63, 94, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(244, 63, 94, 0.25);
  font-family: monospace;
}

.math-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 90px;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.6);
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #1e293b;
}

.math-signal-chip {
  font-size: 11px;
  font-family: monospace;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.math-signal-chip.volt {
  background: rgba(250, 204, 21, 0.12);
  color: #fde047;
  border-color: rgba(250, 204, 21, 0.3);
}

.math-signal-chip.volt:hover {
  background: rgba(250, 204, 21, 0.25);
  transform: translateY(-1px);
}

.math-signal-chip.curr {
  background: rgba(74, 222, 128, 0.12);
  color: #86efac;
  border-color: rgba(74, 222, 128, 0.3);
}

.math-signal-chip.curr:hover {
  background: rgba(74, 222, 128, 0.25);
  transform: translateY(-1px);
}

.math-signal-chip.time {
  background: rgba(167, 139, 250, 0.12);
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.3);
}

.math-signal-chip.time:hover {
  background: rgba(167, 139, 250, 0.25);
  transform: translateY(-1px);
}

.math-tools-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(15, 23, 42, 0.6);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #1e293b;
}

.math-chip-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.math-chip-group .group-title {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  width: 85px;
  flex-shrink: 0;
}

.math-tool-btn {
  font-size: 11px;
  font-family: monospace;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  transition: all 0.12s ease;
}

.math-tool-btn:hover {
  background: #334155;
  color: #fff;
  transform: translateY(-1px);
}

.math-tool-btn.op-chip {
  color: #38bdf8;
  font-weight: 700;
}

.math-tool-btn.calc-chip {
  color: #c084fc;
  border-color: rgba(192, 132, 252, 0.3);
  background: rgba(192, 132, 252, 0.08);
}

.math-tool-btn.calc-chip:hover {
  background: rgba(192, 132, 252, 0.2);
}

.math-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.math-preset-chip {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 4px;
  border: 1px solid #1e293b;
  background: #0f172a;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.math-preset-chip:hover {
  background: #1e293b;
  color: #38bdf8;
  border-color: #38bdf8;
}

.math-color-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
}

.math-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.math-color-dot:hover {
  transform: scale(1.15);
}

.math-color-dot.selected {
  border-color: #ffffff;
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}


/* =========================================================
   Model Selector & Description Card in Property Popover
   ========================================================= */

.param-select {
  width: 100%;
  height: 34px;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  background: #ffffff;
  outline: none;
  box-sizing: border-box;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.param-select:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.model-desc-card {
  font-size: 11px;
  color: #475569;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  margin-top: 8px;
  line-height: 1.45;
}

.model-desc-title {
  font-weight: 700;
  color: #0f766e;
}

.model-desc-body {
  margin-top: 3px;
  color: #64748b;
  font-size: 10.5px;
}

.preset-chip.active {
  background: #0f766e !important;
  color: #ffffff !important;
  border-color: #0f766e !important;
  font-weight: 700;
}

/* =========================================================
   Waveform Trace Selection & Deletion in Scope
   ========================================================= */

.trace-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  user-select: none;
  font-size: 11px;
  transition: all 0.15s ease;
}

.trace-pill:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(255, 255, 255, 0.25);
}

.trace-pill.selected {
  background: rgba(56, 189, 248, 0.2) !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 1.5px #38bdf8, 0 0 10px rgba(56, 189, 248, 0.45) !important;
  font-weight: 700;
}

.trace-sel-badge {
  font-size: 9px;
  background: #38bdf8;
  color: #090d16;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  margin-left: 2px;
}

.trace-action-btn.del {
  margin-left: 2px;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1;
  color: #94a3b8;
  transition: all 0.15s ease;
}

.trace-action-btn.del:hover {
  color: #ffffff;
  background: #ef4444;
}

/* =========================================================
   User Role & Permissions System
   ========================================================= */

.btn-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  color: #f1f5f9;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-user-pill:hover {
  background: #334155;
  border-color: #475569;
}

.user-avatar {
  font-size: 14px;
}

.user-name {
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.user-role-badge.guest {
  background: #475569;
  color: #e2e8f0;
}

.user-role-badge.registered {
  background: #2563eb;
  color: #ffffff;
}

.user-role-badge.admin {
  background: #7c3aed;
  color: #ffffff;
}

.user-arrow {
  font-size: 9px;
  color: #94a3b8;
}

/* Role Switcher Cards Grid */
.role-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

@media (max-width: 768px) {
  .role-cards-grid {
    grid-template-columns: 1fr;
  }
}

.role-card {
  background: #0f172a;
  border: 1.5px solid #1e293b;
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.role-card:hover {
  border-color: #38bdf8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.role-card.active-role {
  border-color: #10b981;
  background: #062b24;
}

.role-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.role-icon {
  font-size: 24px;
}

.role-title {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
}

.role-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 2px;
}

.tag-guest {
  background: #334155;
  color: #cbd5e1;
}

.tag-registered {
  background: #1e3a8a;
  color: #93c5fd;
}

.tag-admin {
  background: #4c1d95;
  color: #d8b4fe;
}

.role-perms-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 12px 0;
  font-size: 11px;
  line-height: 1.6;
}

.perm-item.ok {
  color: #86efac;
}

.perm-item.no {
  color: #fca5a5;
}

.role-switch-btn {
  width: 100%;
  height: 32px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 5px;
}

/* Warning Box */
.perm-warning-box {
  background: #1e1b4b;
  border: 1px solid #4338ca;
  border-radius: 6px;
  padding: 12px 14px;
  color: #e0e7ff;
  font-size: 12.5px;
}

/* Admin Request List Cards */
.admin-req-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-req-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 12px 14px;
}

.admin-req-card.status-approved {
  border-color: #059669;
  background: #022c22;
}

.admin-req-card.status-rejected {
  border-color: #dc2626;
  opacity: 0.65;
}

.admin-req-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.admin-req-title {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
}

.admin-req-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.admin-req-badge.pending {
  background: #b45309;
  color: #fef3c7;
}

.admin-req-badge.approved {
  background: #047857;
  color: #d1fae5;
}

.admin-req-badge.rejected {
  background: #b91c1c;
  color: #fee2e2;
}

.admin-req-meta {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 6px;
}

.admin-req-code {
  background: #020617;
  border: 1px solid #1e293b;
  border-radius: 4px;
  padding: 6px 8px;
  font-family: monospace;
  font-size: 11px;
  color: #38bdf8;
  max-height: 80px;
  overflow-y: auto;
  margin: 6px 0;
  white-space: pre-wrap;
}

.admin-req-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

/* =========================================================
   User Project Dropdown (Inherited from www.nuli199.com)
   ========================================================= */
.user-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.user-project-dropdown {
  position: fixed;
  top: 60px;
  right: auto;
  width: 390px;
  max-width: min(400px, calc(100vw - 20px));
  max-height: calc(100vh - 70px);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 20px 48px -6px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 23, 42, 0.08);
  z-index: 2000;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: dropdownFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
  color: #1e293b;
}

.user-project-dropdown::before {
  content: "";
  position: absolute;
  top: -5px;
  right: 28px;
  width: 10px;
  height: 10px;
  background: #f8fafc;
  border-left: 1px solid #cbd5e1;
  border-top: 1px solid #cbd5e1;
  transform: rotate(45deg);
  z-index: 2;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.upd-header {
  position: relative;
  padding: 14px 18px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid #e2e8f0;
  border-top-left-radius: 11px;
  border-top-right-radius: 11px;
}

.upd-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.upd-avatar {
  font-size: 20px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.upd-meta {
  flex: 1;
  min-width: 0;
}

.upd-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.upd-name-row strong {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upd-folder-path {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: #0f766e;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.upd-guest-tip {
  padding: 14px 18px;
  background: #fffbeb;
  border-bottom: 1px solid #fef3c7;
}

.upd-guest-tip-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #b45309;
  margin-bottom: 6px;
}

.upd-guest-tip p {
  font-size: 11.5px;
  color: #78350f;
  line-height: 1.5;
  margin: 0 0 10px 0;
}

.upd-guest-btn-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upd-btn-login {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  background: #0284c7;
  color: #ffffff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 6px;
  transition: background 0.15s;
}

.upd-btn-login:hover {
  background: #0369a1;
}

.upd-btn-mock {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.upd-btn-mock:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* Current project bar */
.upd-current-project-bar {
  padding: 12px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.curr-proj-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #475569;
  margin-bottom: 8px;
  min-width: 0;
}

.curr-dot {
  color: #10b981;
  font-size: 10px;
}

.curr-proj-label strong {
  color: #0f172a;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.curr-proj-btns {
  display: flex;
  gap: 8px;
}

.upd-action-btn {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s;
}

.upd-action-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.upd-action-btn.primary {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
  box-shadow: 0 2px 5px rgba(15, 118, 110, 0.25);
}

.upd-action-btn.primary:hover {
  background: #0d9488;
  border-color: #0d9488;
}

/* Section Title */
.upd-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px 6px 18px;
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.upd-icon-btn {
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  color: #64748b;
  transition: all 0.15s;
}

.upd-icon-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* Project List */
.upd-project-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 0 10px 6px 10px;
}

.upd-project-list::-webkit-scrollbar {
  width: 4px;
}
.upd-project-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.upd-project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 7px;
  margin-bottom: 5px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.15s;
}

.upd-project-item:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.upd-project-item.active {
  background: #f0fdfa;
  border-color: #5eead4;
  box-shadow: 0 0 0 1px #5eead4;
}

.upd-proj-main {
  flex: 1;
  min-width: 0;
}

.upd-proj-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.upd-proj-icon {
  font-size: 12px;
  color: #0f766e;
}

.upd-proj-title {
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upd-proj-badge {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  background: #ccfbf1;
  color: #0f766e;
}

.upd-proj-desc {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  gap: 4px;
}

.upd-proj-actions {
  display: flex;
  gap: 4px;
  opacity: 1;
  transition: opacity 0.15s;
}

.upd-project-item:hover .upd-proj-actions {
  opacity: 1;
}

.upd-item-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 12px;
  padding: 3px 6px;
  cursor: pointer;
  color: #64748b;
  transition: all 0.12s;
}

.upd-item-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.upd-item-btn.btn-del-item:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.upd-empty, .upd-loading {
  padding: 18px 12px;
  text-align: center;
  font-size: 11.5px;
  color: #94a3b8;
}

/* Tools Row */
.upd-tools-row {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.upd-tool-btn {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s;
}

.upd-tool-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

/* Footer */
.upd-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 18px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  gap: 8px;
}

.upd-footer-btn {
  background: none;
  border: none;
  font-size: 11.5px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 5px;
  white-space: nowrap;
  transition: all 0.15s;
}

.upd-footer-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.upd-footer-btn.text-muted {
  color: #94a3b8;
}
.upd-footer-btn.text-muted:hover {
  color: #ef4444;
}

/* ==========================================================================
   Tutorial Mode Switcher & Real Screen Recording Video Player
   ========================================================================== */

.tutorial-mode-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.t-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.t-mode-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.t-mode-btn.active {
  background: #0f766e;
  border-color: #0d9488;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.3);
}

.tutorial-video-container {
  margin-bottom: 20px;
}

.video-player-card {
  background: #0f172a;
  border-radius: 12px;
  border: 1px solid #1e293b;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
}

.video-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 1px solid #334155;
  gap: 10px;
  flex-wrap: wrap;
}

.video-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.video-badge-rec {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
}

.video-main-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
}

.video-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-video-download {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

.btn-video-download:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
}

.video-media-wrapper {
  position: relative;
  background: #000000;
  width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-video-el {
  width: 100%;
  height: 100%;
  max-height: 480px;
  object-fit: contain;
  background: #000;
  outline: none;
}

.video-card-footer {
  padding: 12px 16px;
  background: #131c2e;
  border-top: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.video-step-indicators {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
}

.v-step-pill {
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 2px 7px;
  border-radius: 4px;
}

.v-arrow {
  color: #64748b;
  font-size: 10px;
}

.video-tip {
  font-size: 11.5px;
  color: #94a3b8;
}

.video-tip a {
  color: #38bdf8;
  text-decoration: underline;
}

/* ==========================================================================
   Interactive SVG Tutorial & Voice Theater (Active Low-Pass Filter Walkthrough)
   ========================================================================== */

.tutorial-theater {
  margin-bottom: 20px;
  background: #0f172a;
  border-radius: 12px;
  border: 1px solid #1e293b;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  color: #f8fafc;
}

.theater-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 1px solid #334155;
  gap: 10px;
}

.theater-title-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theater-title-badge .badge-icon {
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.theater-title {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.theater-subtitle {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 1px;
  line-height: 1.3;
}

.theater-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-load-circuit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
}

.btn-load-circuit:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.45);
}

.btn-theater-fullscreen {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid #475569;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-theater-fullscreen:hover {
  background: #334155;
  color: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* Stepper Chips */
.tutorial-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #090d16;
  border-bottom: 1px solid #1e293b;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tutorial-stepper::-webkit-scrollbar {
  height: 4px;
}
.tutorial-stepper::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

.t-step-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 20px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.t-step-chip:hover {
  background: #2d3748;
  color: #f1f5f9;
  border-color: #475569;
}

.t-step-chip.active {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.5);
}

.t-step-chip .chip-num {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 700;
}

.t-step-chip.active .chip-num {
  background: #ffffff;
  color: #2563eb;
}

/* Screen Wrapper */
.theater-screen-wrapper {
  position: relative;
  background: #070b14;
  width: 100%;
  aspect-ratio: 900 / 520;
  max-height: 380px;
  overflow: hidden;
  border-bottom: 1px solid #1e293b;
}

.tutorial-svg-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Captions & Speech Bubble */
.theater-caption-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: #131c2e;
  border-bottom: 1px solid #1e293b;
}

.caption-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.caption-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: transparent;
  border: none;
  border-radius: 0;
  flex-shrink: 0;
}

.mos-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

@keyframes mosfetBreathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.mosfet-breathe {
  animation: mosfetBreathe 3s ease-in-out infinite;
}

.audio-wave-bars {
  position: absolute;
  bottom: -2px;
  right: -2px;
  display: flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 12px;
  background: rgba(15, 23, 42, 0.85);
  padding: 2px 3px;
  border-radius: 4px;
}

.audio-wave-bars i {
  width: 2px;
  background: #10b981;
  border-radius: 1px;
  animation: soundwave 0.8s infinite ease-in-out;
}
.audio-wave-bars i:nth-child(1) { height: 4px; animation-delay: 0.1s; }
.audio-wave-bars i:nth-child(2) { height: 10px; animation-delay: 0.3s; }
.audio-wave-bars i:nth-child(3) { height: 6px; animation-delay: 0.2s; }
.audio-wave-bars i:nth-child(4) { height: 8px; animation-delay: 0.4s; }

@keyframes soundwave {
  0%, 100% { height: 3px; }
  50% { height: 11px; }
}

.caption-body {
  flex: 1;
  min-width: 0;
}

.caption-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.caption-speaker {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
}

.caption-step-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-weight: 600;
}

.caption-status {
  font-size: 10px;
  color: #94a3b8;
  margin-left: auto;
}

.caption-text {
  font-size: 12px;
  line-height: 1.5;
  color: #e2e8f0;
  margin: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Playback Toolbar */
.theater-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #0f172a;
  gap: 8px;
  flex-wrap: wrap;
}

.ctrl-left, .ctrl-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.t-ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #f1f5f9;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.t-ctrl-btn:hover {
  background: #334155;
  border-color: #475569;
}

.t-ctrl-btn.primary {
  background: #2563eb;
  border-color: #3b82f6;
  font-weight: 600;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.t-ctrl-btn.primary:hover {
  background: #1d4ed8;
}

.t-ctrl-btn.voice-btn.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.t-speed-select {
  background: #1e293b;
  border: 1px solid #334155;
  color: #f1f5f9;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  outline: none;
}
.t-speed-select:focus {
  border-color: #3b82f6;
}

/* Tutorial Theater Fullscreen Mode */
.tutorial-theater:fullscreen,
.tutorial-theater.fullscreen-mode {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  z-index: 9999999 !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  background: #0f172a !important;
  box-shadow: none !important;
}

.tutorial-theater:fullscreen .theater-screen-wrapper,
.tutorial-theater.fullscreen-mode .theater-screen-wrapper {
  flex: 1 1 0% !important;
  max-height: none !important;
  height: 100% !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.tutorial-theater:fullscreen .tutorial-svg-canvas,
.tutorial-theater.fullscreen-mode .tutorial-svg-canvas {
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
}

.tutorial-theater:fullscreen .theater-header,
.tutorial-theater.fullscreen-mode .theater-header {
  padding: 10px 18px !important;
  flex-shrink: 0 !important;
}

.tutorial-theater:fullscreen .tutorial-stepper,
.tutorial-theater.fullscreen-mode .tutorial-stepper {
  padding: 8px 18px !important;
  flex-shrink: 0 !important;
}

.tutorial-theater:fullscreen .theater-caption-bar,
.tutorial-theater.fullscreen-mode .theater-caption-bar {
  padding: 12px 20px !important;
  flex-shrink: 0 !important;
}

.tutorial-theater:fullscreen .caption-text,
.tutorial-theater.fullscreen-mode .caption-text {
  font-size: 13.5px !important;
}

.tutorial-theater:fullscreen .theater-controls,
.tutorial-theater.fullscreen-mode .theater-controls {
  padding: 10px 20px !important;
  flex-shrink: 0 !important;
}



/* Keep a single toolbar row at every width; overflow stays inside the header. */
.workspace-body { min-height: 0; }
@media (max-width: 700px) {
  .app-header { gap: 12px; padding-inline: 10px; }
}

/* Chapter tutorials keep navigation and teaching material outside the circuit. */
.chapter-nav {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;padding:16px;background:#f0fdfa;}
.chapter-nav button {text-align:left;border:1px solid #b4d8d4;border-radius:8px;padding:12px;background:white;color:#164e4a;cursor:pointer;font:inherit;}
.chapter-nav button[aria-current="true"] {background:#0f766e;color:white;border-color:#0f766e;}
.chapter-nav small {display:block;margin-top:4px;opacity:.8;}
.chapter-intro,.chapter-status {font-size:13px;color:#475569;line-height:1.7;margin:8px 0;}
.chapter-heading {padding:4px 16px;font-size:17px;color:#134e4a;}
.chapter-controls {display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 16px;}
.chapter-controls button,.chapter-controls select {padding:8px 12px;border-radius:6px;border:1px solid #cbd5e1;background:white;cursor:pointer;}
.chapter-controls button:disabled {opacity:.4;cursor:default;}
.chapter-status {padding:0 16px;}
.chapter-checklist {padding:16px;border-top:1px solid #e2e8f0;}
.chapter-checklist summary {cursor:pointer;font-weight:600;color:#0f766e;}
.chapter-checklist ol {padding-left:24px;}
.chapter-checklist li {padding:8px 0;line-height:1.7;color:#475569;font-size:14px;}
.chapter-checklist button {border:0;background:none;color:#0f766e;text-align:left;padding:0;cursor:pointer;font:inherit;font-weight:700;}
.chapter-checklist p {margin:4px 0;}
.oscilloscope-panel.maximized {position:fixed!important;top:var(--app-header-height,130px)!important;}
@media(max-width:700px){.chapter-nav{grid-template-columns:repeat(2,minmax(0,1fr));}.video-card-header{flex-wrap:wrap;}.chapter-controls{gap:4px;font-size:12px;}}
/* Give the detailed lessons enough room inside the help drawer. */
.help-drawer:has(#tab-quickstart.active) {width:1240px;max-width:98vw;}
.video-player-card {background:#fff;border-color:#cbd5e1;}
.video-card-header {background:#f8fafc;border-color:#dbe7e5;}
.video-main-title {color:#134e4a;font-size:16px;}
.chapter-nav {grid-template-columns:repeat(9,minmax(0,1fr));gap:5px;padding:10px;}
.chapter-nav button {padding:8px 5px;font-size:12px;white-space:nowrap;}
.chapter-nav small {font-size:10px;}
.chapter-heading {margin:8px 0;}
.tutorial-video-el {max-height:none;}
.video-player-card .video-media-wrapper {aspect-ratio:auto;height:min(55vw,calc(100vh - 320px));min-height:220px;}
@media(max-width:900px){.chapter-nav{grid-template-columns:repeat(3,minmax(0,1fr));}.video-player-card .video-media-wrapper{height:auto;aspect-ratio:16/9;min-height:0;}}

.help-window-actions{display:flex;align-items:center;gap:8px;}
.help-popout-btn{border:1px solid #9bc9c1;border-radius:7px;background:#ecfdf5;color:#115e59;padding:8px 12px;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap;}
.help-window-actions [hidden],.help-window-notice[hidden]{display:none!important;}
.help-window-notice{margin:0;padding:9px 18px;background:#ecfdf5;color:#115e59;font-size:12px;line-height:1.6;border-bottom:1px solid #cce5dd;}
.help-window-mode .app-header,.help-window-mode .workspace-body,.help-window-mode #scopePanel{display:none!important;}
.help-window-mode .help-drawer{position:fixed;inset:0;width:100vw!important;max-width:100vw!important;display:flex!important;animation:none;box-shadow:none;}
.help-window-mode .help-drawer-content{min-height:0;}
.help-window-mode .video-player-card .video-media-wrapper{height:min(60vw,calc(100vh - 300px));}
@media(max-width:650px){.help-drawer-header{gap:8px;flex-wrap:wrap;}.help-window-actions{margin-left:auto;}.help-window-mode .video-player-card .video-media-wrapper{height:auto;aspect-ratio:16/9;}}

.help-fullscreen-btn{background:#0f766e;color:#fff;border-color:#0f766e;font-weight:600;}
.help-fullscreen-btn:hover{background:#115e59;}
.help-drawer:fullscreen{inset:0;width:100vw!important;max-width:none!important;height:100vh;display:flex;animation:none;box-shadow:none;background:#fff;}
.help-drawer:fullscreen .help-drawer-content{min-height:0;}
@media(max-width:650px){.help-window-actions{flex-wrap:wrap;}}

/* Measurement tools travel with the scope into the second-screen window. */
.scope-measurement-bar {display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:7px 12px;background:#101827;border-bottom:1px solid #263449;color:#cbd5e1;font-size:11px;flex-shrink:0;}
.scope-measurement-bar label {display:flex;align-items:center;gap:5px;white-space:nowrap;}
.scope-measurement-bar select {max-width:220px;background:#182438;color:#e2e8f0;border:1px solid #475569;border-radius:4px;padding:4px;font-size:11px;}
.scope-measurement-bar button:disabled {opacity:.4;cursor:default;}
#scopeCoordinateReadout {color:#bae6fd;font-family:monospace;overflow-wrap:anywhere;}
#scopeCanvas {touch-action:none;cursor:crosshair;}

.site-credits {flex-shrink:0;padding:4px 12px;text-align:center;color:#64748b;background:#f8fafc;border-top:1px solid #e2e8f0;font-size:11px;line-height:16px;}
.site-credits a,.video-credits a {color:#0f766e;user-select:text;}
.video-credits {padding:10px 16px;color:#475569;font-size:12px;border-top:1px solid #dce8e6;}
.scope-help-note {padding:12px 16px;line-height:1.8;background:#eef8f6;color:#285953;border-radius:6px;margin:8px 0;}
.scope-tools {min-width:0;gap:6px;overflow-x:auto;}
.scope-tools .scope-btn {white-space:nowrap;flex-shrink:0;}
.scope-readout {display:none;}
.scope-title-area {flex-shrink:0;white-space:nowrap;}
.vip-dialog{max-width:960px;width:min(96vw,960px);max-height:90vh;display:flex;flex-direction:column;}
.vip-content{overflow:auto;line-height:1.65;}
.vip-plans{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:12px;}
.vip-plans>div{padding:14px;background:#eef8f6;color:#134e4a;border:1px solid #b9dfd7;border-radius:8px;}
.vip-payment-grid{display:grid;grid-template-columns:260px 1fr;gap:24px;margin:16px 0;}
.vip-payment-grid[hidden]{display:none;}
.vip-qr img{display:block;width:220px;max-width:100%;margin:0 auto 8px;}
.vip-qr p,.vip-small{font-size:12px;color:#64748b;}
.vip-content form label{display:flex;flex-direction:column;gap:4px;margin:10px 0;}
.vip-content input:not([type=checkbox]),.vip-content textarea{width:100%;padding:8px;border:1px solid #cbd5e1;border-radius:5px;font:inherit;font-size:13px;}
.vip-content .vip-confirm{display:flex;flex-direction:row;align-items:flex-start;gap:7px;font-size:12px;margin:10px 0;}
.vip-confirm input{margin-top:5px;}
.vip-section-title{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:18px 0 8px;}
.vip-request-card{border:1px solid #cbd5e1;padding:14px;border-radius:7px;margin:10px 0;overflow-wrap:anywhere;}
.vip-request-card .action-btn{margin:8px 6px 0 0;}
#vipStatus{padding:10px;background:#e9f7ef;color:#166534;border-radius:5px;}
#vipStatus.error{background:#fff1f2;color:#9f1239;}
.user-role-badge.vip{background:#fef3c7;color:#92400e;}.user-role-badge.basic{background:#e2e8f0;color:#475569;}
@media(max-width:680px){.vip-plans,.vip-payment-grid{grid-template-columns:1fr}.vip-qr img{width:180px}}
.vip-modal [hidden] { display: none !important; }
/* Digital teaching library */
.palette-category {border-bottom:1px solid #dbe3ef;padding-bottom:8px;margin-bottom:8px;}
.palette-category>summary {cursor:pointer;padding:11px 6px;font-size:15px;font-weight:750;color:#334155;position:sticky;top:0;background:#f8fafc;z-index:2;}
.palette-category>summary small {display:block;margin-left:17px;font-size:10px;font-weight:400;color:#64748b;}
#digitalPalette>summary {color:#6d28d9;}
.digital-palette-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;padding:0 5px;}
.digital-item {min-height:75px;height:auto;padding:6px 3px;}
.digital-item span {font-size:10px;white-space:normal;line-height:1.4;}
.digital-item .sym-svg {width:48px;height:28px;}
.digital-palette-tip,.digital-description {font-size:11px;line-height:1.7;color:#64748b;margin:8px 5px;}
.digital-help-link {display:block;padding:14px 8px;font-size:12px;color:#6d28d9;}
.digital-playback {display:flex;align-items:center;gap:10px;padding:7px 12px;background:#f5f3ff;border-bottom:1px solid #ddd6fe;font-size:12px;color:#6d28d9;}
.digital-playback[hidden] {display:none;}
.digital-playback input {flex:1;min-width:70px;accent-color:#7c3aed;}
.digital-playback button {border:1px solid #c4b5fd;border-radius:5px;background:white;padding:4px 8px;color:#6d28d9;cursor:pointer;}
.digital-playback output {min-width:110px;font-variant-numeric:tabular-nums;}
@media(max-width:700px){.digital-playback label{display:none}.digital-playback{gap:5px;padding:5px}.digital-playback output{min-width:90px}}

/* Readable split panes without expanding over the circuit canvas. */
.scope-body {min-height:0;}
.multi-waveform .scope-body {overflow-y:auto;}
.multi-waveform .panes-header-bar {max-height:96px;overflow-y:auto;}
.scope-btn:disabled {opacity:.4;cursor:default;}
.scope-bus-dialog {width:min(540px,90vw);max-height:85vh;overflow:auto;border:1px solid #64748b;border-radius:10px;padding:20px;background:#f8fafc;color:#1e293b;font:14px/1.6 system-ui;}
.scope-bus-dialog::backdrop {background:#02061799;}
.scope-bus-dialog h3 {margin:0 0 8px;}
.scope-bus-dialog label {display:flex;gap:8px;align-items:center;margin:8px 0;}
.scope-bus-dialog input:not([type=checkbox]),.scope-bus-dialog select {min-width:0;padding:5px;border:1px solid #94a3b8;border-radius:4px;}
.scope-bus-dialog input[name=busName] {flex:1;}
.bus-thresholds {display:flex;gap:12px;}
.bus-thresholds label {flex-direction:column;align-items:flex-start;flex:1;}
.bus-thresholds input {width:100%;box-sizing:border-box;}
.bus-members {max-height:230px;overflow:auto;border-block:1px solid #cbd5e1;margin-top:12px;}
.bus-members>div {display:flex;align-items:center;gap:8px;}
.bus-members label {flex:1;overflow-wrap:anywhere;}
.bus-members input[type=number] {width:60px;}
.bus-error {color:#b91c1c;}
.scope-bus-dialog footer {display:flex;justify-content:flex-end;gap:12px;}
.scope-bus-dialog button {padding:7px 14px;border:1px solid #94a3b8;border-radius:4px;cursor:pointer;}
.scope-bus-dialog button[type=submit] {background:#0f766e;color:white;}

/* Stable identity and an accessible help cue while the toolbar scrolls. */
.app-header .header-left { position:sticky;left:0;z-index:4;background:#fff;align-self:stretch;display:flex;align-items:center;padding-right:12px;box-shadow:8px 0 10px #fff; }
.mos-help-hint[hidden],.scope-result-notice[hidden] { display:none; }
.help-window-mode .mos-help-hint { display:none; }
.workspace-projects { display:flex;align-items:center;gap:8px;padding:5px 10px;background:#f0fdfa;border-bottom:1px solid #cce9e3;font-size:11px;min-width:0;flex-wrap:wrap; }
.workspace-projects > span { flex:1;min-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:#115e59; }
.workspace-projects button,.workspace-projects select { font-size:11px;border:1px solid #b8d8d0;border-radius:5px;padding:4px;background:#fff;color:#115e59;max-width:230px; }
.workspace-projects button:disabled { opacity:.45; }
.scope-result-notice { padding:7px 12px;background:#fff4ce;color:#854d0e;border-bottom:1px solid #f5d580;font-size:12px;flex-shrink:0; }
.template-real-btn { padding:5px 8px;border:1px solid #d5c6ed;border-radius:4px;background:#faf5ff;color:#6b21a8;font-size:11px;cursor:pointer;margin-top:5px; }
.template-access { color:#0f766e !important; }

/* Reserve a separate slot: the mascot must never intercept toolbar buttons. */
.header-shell {display:flex;flex:0 0 60px;min-width:0;position:relative;z-index:500;background:transparent;}
.header-shell .app-header {flex:1 1 auto;width:0;}
/* A permanent help character has its own transparent slot beside the account. */
.header-shell .mos-help-hint {position:relative;flex:0 0 78px;width:78px;height:60px;overflow:hidden;padding:0;border:0;background:transparent;cursor:pointer;}
.mos-body {position:absolute;left:1px;bottom:1px;width:54px;height:54px;transform-origin:50% 88%;animation:mos-thinking-sway 9s ease-in-out infinite;}
.mos-body img {display:block;width:100%;height:100%;object-fit:contain;transform-origin:50% 90%;animation:mos-thinking-breathe 4.6s ease-in-out infinite;}
.mos-question {position:absolute;right:8px;top:6px;width:20px;height:32px;font:900 30px/1 Arial,sans-serif;color:#ffe68a;text-shadow:0 1px 0 #e0a82d,1px 2px 0 #c8891c,2px 3px 0 #9d6413,2px 4px 3px #8b651f38;transform-origin:50% 80%;animation:mos-question-think 9s ease-in-out infinite;pointer-events:none;}
.mos-help-hint:is(:hover,:focus-visible) .mos-question {color:#fff0b2;}
.mos-help-hint:focus-visible {outline:2px solid #0f766e;outline-offset:-3px;border-radius:8px;}
@keyframes mos-thinking-sway {0%,12%,50%,100%{transform:translateY(0) rotate(0);}23%,32%{transform:translateY(-1px) rotate(-5deg);}40%{transform:translateY(0) rotate(2deg);}63%,71%{transform:translateY(-2px) rotate(4deg);}82%{transform:translateY(0) rotate(-2deg);}}
@keyframes mos-thinking-breathe {0%,100%{transform:scale(1);}50%{transform:scale(1.018,1.025);}}
@keyframes mos-question-think {0%,12%,50%,100%{transform:translateY(0) rotate(8deg) scale(1);}23%,32%{transform:translateY(-3px) rotate(-7deg) scale(1.06);}63%,71%{transform:translateY(-2px) rotate(13deg) scale(1.03);}}
@media(prefers-reduced-motion:reduce){.mos-body,.mos-body img,.mos-question{animation:none!important;}}
.help-window-mode .header-shell {display:none;}

/* Keep account/admin controls outside the toolbar clipping and mascot slot. */
.header-shell > .user-dropdown-wrapper {flex:0 0 auto;align-self:center;margin:0 6px;z-index:501;}
.header-shell > .user-dropdown-wrapper .btn-user-pill {max-width:260px;}
.header-shell > .user-dropdown-wrapper .user-name {min-width:0;max-width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
@media(max-width:800px){.header-shell > .user-dropdown-wrapper .user-role-badge{display:none;}.header-shell > .user-dropdown-wrapper .btn-user-pill{padding:0 8px;gap:4px;}.header-shell > .user-dropdown-wrapper .user-name{max-width:72px;}}
@media(max-width:480px){.header-shell > .user-dropdown-wrapper .user-name{display:none;}.header-shell > .user-dropdown-wrapper{margin:0 3px;}}

/* Electronic Technology textbook projects. */
.book-examples-dialog{background:white;color:#1e293b;border-radius:12px;width:min(720px,94vw);max-height:85vh;overflow:auto;box-shadow:0 18px 60px #0f172a44;padding:20px;}
#bookExampleStatus{padding:16px 0;line-height:1.7;}
#bookExampleList{display:grid;gap:12px;}
.book-example-card{display:flex;flex-direction:column;align-items:flex-start;gap:9px;text-align:left;padding:18px;border:1px solid #cbd5e1;border-radius:8px;background:#f8fafc;color:#1e293b;cursor:pointer;font:inherit;}
.book-example-card:hover{border-color:#0f766e;background:#f0fdfa;}
.book-example-card small{color:#0f766e;font-weight:600;}
.book-exercise-brief{background:#f0fdfa;border-bottom:1px solid #99f6e4;padding:8px 16px;max-height:190px;overflow:auto;flex-shrink:0;line-height:1.7;}
.book-exercise-brief[hidden]{display:none;}
.book-exercise-brief summary{cursor:pointer;font-weight:600;}
.book-exercise-brief ol{padding-left:22px;}

/* Unified example library: category > subject/chapter > circuits. */
.example-library-intro{font-size:13px;line-height:1.7;color:#64748b;margin:14px 0;}
.example-category{border:1px solid #cbd5e1;border-radius:9px;margin:12px 0;overflow:hidden;}
.example-category>summary{padding:15px;background:#f0fdfa;color:#115e59;cursor:pointer;font-weight:700;}
.example-category summary small{font-size:12px;font-weight:400;margin-left:10px;color:#64748b;}
.example-subgroup{margin:12px;border:1px solid #e2e8f0;border-radius:6px;}
.example-subgroup>summary{padding:12px;cursor:pointer;font-weight:650;background:#f8fafc;}
.example-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;padding:10px;}
.classic-examples-list .dropdown-item{white-space:normal;border:1px solid #e2e8f0;border-radius:6px;padding:14px;}
.classic-examples-list .dropdown-item strong,.classic-examples-list .dropdown-item small{display:block;line-height:1.6;}
.classic-examples-list .dropdown-item strong{font-size:13px;}
.classic-examples-list .dropdown-item small{font-size:12px;}
.example-category #bookExampleStatus{padding:0 15px;margin:12px 0;font-size:13px;}
.example-category #bookExampleList{gap:0;}
.example-category .book-example-card{padding:14px;min-width:0;font-size:13px;line-height:1.6;}
.example-category :focus-visible{outline:2px solid #0f766e;outline-offset:-2px;}
@media(max-width:600px){.example-grid{grid-template-columns:1fr}.book-examples-dialog{padding:12px}.example-category>summary{font-size:14px}.example-subgroup{margin:8px}}
#bookExamplesModal{position:fixed;inset:0;z-index:2000;align-items:center;justify-content:center;background:#0f172a66;padding:16px;}
#bookExamplesModal .book-examples-dialog{box-sizing:border-box;max-height:calc(100dvh - 32px);}
