/* ==========================================================================
   ICTONE Practical Lab - Logic Gate Designer Stylesheet
   Clean Educational Digital Logic Circuit Simulator Theme
   White/Light Canvas, Standard 2px Outline Symbols, No Cyber/Neon Glow.
   ========================================================================== */

/* Root tokens */
:root {
  --lg-bg: #F8FAFC;
  --lg-panel-bg: #FFFFFF;
  --lg-border-subtle: #E2E8F0;
  --lg-border-medium: #CBD5E1;
  --lg-border-dark: #94A3B8;
  
  --lg-text-primary: #0F172A;
  --lg-text-secondary: #475569;
  --lg-text-muted: #64748B;
  
  /* ICTONE Theme Colors */
  --lg-accent-blue: #2563EB;
  --lg-accent-blue-hover: #1D4ED8;
  --lg-accent-blue-light: #EFF6FF;
  
  /* Signal Colors (Clean Textbook Logic) */
  --lg-signal-low: #334155;        /* 0 state: standard dark slate */
  --lg-signal-high: #2563EB;       /* 1 state: ICTONE standard blue */
  --lg-signal-unconn: #94A3B8;     /* unconnected: light slate */
  
  --lg-wire-stroke: 2px;
  --lg-wire-stroke-selected: 3px;
  
  --lg-radius-sm: 6px;
  --lg-radius-md: 8px;
  --lg-radius-lg: 12px;
  
  --lg-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --lg-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --lg-shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.12);
  
  --header-height: 56px;
}

/* Base resets & layout */
*, *::before, *::after {
  box-sizing: border-box;
}

body.logic-lab-page {
  background-color: var(--lg-bg);
  color: var(--lg-text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.logic-lab-main {
  padding-top: 5rem;
  padding-bottom: 0;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

/* ── Workspace Header ── */
.logic-workspace-header {
  background: #FFFFFF;
  border-bottom: 1px solid var(--lg-border-subtle);
  padding: 0.65rem 1.5rem;
  box-shadow: 0 1px 3px rgba(24, 31, 58, 0.04);
}

.logic-header-inner {
  max-width: 1700px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.logic-title-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.lab-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--lg-text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: var(--lg-radius-sm);
  background: #F1F5F9;
  border: 1px solid var(--lg-border-subtle);
  transition: all 0.15s ease;
}

.lab-back-link:hover {
  color: var(--lg-accent-blue);
  background: var(--lg-accent-blue-light);
  border-color: #BFDBFE;
}

.logic-title-wrapper {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logic-page-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--lg-text-primary);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}

.lab-tag-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: #DCFCE7;
  color: #15803D;
  border: 1px solid rgba(34, 197, 94, 0.3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.logic-page-subtitle {
  font-size: 0.82rem;
  color: var(--lg-text-muted);
  margin: 0;
}

/* ── Header Actions & Toolbars ── */
.logic-actions-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.lab-actions-divider {
  width: 1px;
  height: 22px;
  background: var(--lg-border-subtle);
  margin: 0 0.25rem;
}

.logic-btn-group {
  display: inline-flex;
  align-items: center;
  background: #FFFFFF;
  border: 1px solid var(--lg-border-medium);
  border-radius: var(--lg-radius-sm);
  overflow: hidden;
}

.logic-btn-group .btn-logic-action {
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--lg-border-subtle);
}

.logic-btn-group .btn-logic-action:last-child {
  border-right: none;
}

.btn-logic-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--lg-text-primary);
  background: #FFFFFF;
  border: 1px solid var(--lg-border-medium);
  border-radius: var(--lg-radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  user-select: none;
}

.btn-logic-action:hover:not(:disabled) {
  background: var(--lg-accent-blue-light);
  border-color: #BFDBFE;
  color: var(--lg-accent-blue);
}

.btn-logic-action:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-logic-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-logic-primary {
  background: var(--lg-accent-blue);
  color: #FFFFFF;
  border-color: var(--lg-accent-blue);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-logic-primary:hover:not(:disabled) {
  background: var(--lg-accent-blue-hover);
  border-color: var(--lg-accent-blue-hover);
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.btn-logic-accent {
  background: #F0FDF4;
  color: #166534;
  border-color: #BBF7D0;
}

.btn-logic-accent:hover:not(:disabled) {
  background: #DCFCE7;
  color: #14532D;
  border-color: #86EFAC;
}

.btn-logic-danger:hover:not(:disabled) {
  background: #FEF2F2;
  border-color: #EF4444;
  color: #EF4444;
}

.logic-zoom-val {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0 0.5rem;
  color: var(--lg-text-muted);
  min-width: 48px;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}

.logic-mobile-add-btn {
  display: none;
}

/* ── Main Workspace Layout ── */
.logic-workspace-body {
  max-width: 1700px;
  margin: 0 auto;
  height: calc(100vh - 128px);
  min-height: 580px;
  display: flex;
  background: #FFFFFF;
  border: 1px solid var(--lg-border-medium);
  border-top: none;
  border-bottom: none;
  overflow: hidden;
  position: relative;
  width: 100%;
}

/* ── Left Components Palette ── */
.logic-palette-panel {
  width: 250px;
  flex-shrink: 0;
  background: #F8FAFC;
  border-right: 1px solid var(--lg-border-medium);
  display: flex;
  flex-direction: column;
  height: 100%;
  user-select: none;
}

.logic-palette-header {
  height: 38px;
  background: #F1F5F9;
  border-bottom: 1px solid var(--lg-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.logic-palette-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.palette-category-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748B;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0.4rem 0 0.1rem 0.25rem;
}

.palette-item {
  background: #FFFFFF;
  border: 1px solid var(--lg-border-medium);
  border-radius: var(--lg-radius-sm);
  padding: 0.5rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: grab;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.palette-item:hover {
  border-color: var(--lg-accent-blue);
  background: #F0F7FF;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(37, 99, 235, 0.1);
}

.palette-item:active {
  cursor: grabbing;
}

.palette-preview-svg {
  width: 48px;
  height: 30px;
  flex-shrink: 0;
}

.palette-preview-badge {
  width: 48px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
  border: 1.5px solid #0F172A;
}

.palette-preview-badge.input-badge {
  background: #FFFFFF;
  color: #0F172A;
}

.palette-preview-badge.output-badge {
  background: #F8FAFC;
  color: #2563EB;
  border-color: #2563EB;
}

.palette-item-info {
  display: flex;
  flex-direction: column;
}

.palette-item-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--lg-text-primary);
}

.palette-item-hint {
  font-size: 0.7rem;
  color: var(--lg-text-muted);
}

.logic-palette-footer {
  padding: 0.65rem 0.85rem;
  border-top: 1px solid var(--lg-border-subtle);
  font-size: 0.72rem;
  color: var(--lg-text-muted);
  text-align: center;
  background: #F8FAFC;
  line-height: 1.35;
}

/* ── Right Canvas Area (Clean White Textbook Style) ── */
.logic-canvas-panel {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-color: #FFFFFF;
  background-image: radial-gradient(#CBD5E1 1.2px, transparent 1.2px);
  background-size: 20px 20px;
  display: flex;
  flex-direction: column;
}

.logic-canvas-viewport {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  cursor: default;
}

.logic-svg-root {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}

/* ── SVG Component Symbols (Standard Textbook IEC/ANSI) ── */
.lg-node-group {
  cursor: move;
  user-select: none;
}

/* Gate Body Paths */
.lg-gate-symbol {
  fill: #FFFFFF;
  stroke: #0F172A;
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lg-gate-lead {
  fill: none;
  stroke: #0F172A;
  stroke-width: 2px;
}

.lg-inversion-bubble {
  fill: #FFFFFF;
  stroke: #0F172A;
  stroke-width: 2px;
}

/* Selection indicator: Subtle ICTONE Blue box outline */
.lg-selection-outline {
  fill: none;
  stroke: var(--lg-accent-blue);
  stroke-width: 1.5px;
  stroke-dasharray: 4 3;
  pointer-events: none;
  opacity: 0;
}

.lg-node-group.selected .lg-selection-outline {
  opacity: 1;
}

.lg-node-group.selected .lg-gate-symbol {
  stroke: var(--lg-accent-blue);
}

.lg-node-group.selected .lg-gate-lead {
  stroke: var(--lg-accent-blue);
}

.lg-node-group.selected .lg-inversion-bubble {
  stroke: var(--lg-accent-blue);
}

/* Gate Subtitle / Label */
.lg-gate-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  fill: #64748B;
  text-anchor: middle;
  dominant-baseline: hanging;
  pointer-events: none;
}

/* ── Ports / Terminals ── */
.lg-port {
  cursor: crosshair;
  transition: r 0.12s ease, fill 0.12s ease;
}

.lg-port-input {
  fill: #0F172A;
  stroke: #0F172A;
  stroke-width: 1px;
}

.lg-port-output {
  fill: #0F172A;
  stroke: #0F172A;
  stroke-width: 1px;
}

.lg-port:hover {
  r: 5.5px !important;
  fill: var(--lg-accent-blue) !important;
  stroke: var(--lg-accent-blue) !important;
}

.lg-port.signal-high {
  fill: var(--lg-accent-blue);
  stroke: var(--lg-accent-blue);
}

/* ── Input Component (Toggle Switch 0/1) ── */
.lg-input-body {
  fill: #FFFFFF;
  stroke: #0F172A;
  stroke-width: 1.8px;
  rx: 5px;
  cursor: pointer;
}

.lg-input-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  fill: #0F172A;
  text-anchor: middle;
  pointer-events: none;
}

.lg-input-toggle-box {
  fill: #F1F5F9;
  stroke: #0F172A;
  stroke-width: 1.5px;
  rx: 4px;
  cursor: pointer;
}

.lg-input-toggle-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 800;
  fill: #334155;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* Input HIGH state */
.lg-input-high .lg-input-toggle-box {
  fill: var(--lg-accent-blue);
  stroke: var(--lg-accent-blue);
}

.lg-input-high .lg-input-toggle-text {
  fill: #FFFFFF;
}

.lg-input-high .lg-input-body {
  stroke: var(--lg-accent-blue);
}

/* ── Output Component (Result Indicator 0/1/?) ── */
.lg-output-body {
  fill: #FFFFFF;
  stroke: #0F172A;
  stroke-width: 1.8px;
  rx: 5px;
}

.lg-output-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  fill: #0F172A;
  text-anchor: middle;
  pointer-events: none;
}

.lg-output-circle {
  fill: #F8FAFC;
  stroke: #0F172A;
  stroke-width: 1.6px;
  transition: fill 0.15s ease, stroke 0.15s ease;
}

.lg-output-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 800;
  fill: #475569;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* Output HIGH state */
.lg-output-high .lg-output-circle {
  fill: var(--lg-accent-blue);
  stroke: var(--lg-accent-blue);
}

.lg-output-high .lg-output-text {
  fill: #FFFFFF;
}

.lg-output-high .lg-output-body {
  stroke: var(--lg-accent-blue);
}

/* ── Wires & Routing ── */
.lg-wire-group {
  cursor: pointer;
}

.lg-wire-hitbox {
  fill: none;
  stroke: transparent;
  stroke-width: 14px;
  cursor: pointer;
}

.lg-wire-path {
  fill: none;
  stroke: var(--lg-signal-low);
  stroke-width: var(--lg-wire-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.12s ease, stroke-width 0.12s ease;
}

.lg-wire-group:hover .lg-wire-path {
  stroke: var(--lg-accent-blue);
  stroke-width: 3px;
}

.lg-wire-group.selected .lg-wire-path {
  stroke: var(--lg-accent-blue) !important;
  stroke-width: var(--lg-wire-stroke-selected) !important;
}

/* Active HIGH wire */
.lg-wire-path.signal-high {
  stroke: var(--lg-signal-high);
  stroke-width: 2.5px;
}

/* Active LOW wire */
.lg-wire-path.signal-low {
  stroke: var(--lg-signal-low);
  stroke-width: 2px;
}

/* Branch / Fan-out Junction Dot */
.lg-junction-dot {
  fill: #0F172A;
  pointer-events: none;
}

.lg-junction-dot.signal-high {
  fill: var(--lg-signal-high);
}

/* Dragging Temporary Wire */
.lg-wire-temp {
  fill: none;
  stroke: var(--lg-accent-blue);
  stroke-width: 2px;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

/* ── Empty State ── */
.logic-empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  user-select: none;
  max-width: 360px;
  display: none;
}

.logic-empty-state.show {
  display: block;
}

.logic-empty-icon {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
  opacity: 0.6;
}

.logic-empty-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--lg-text-primary);
  margin-bottom: 0.35rem;
}

.logic-empty-subtext {
  font-size: 0.82rem;
  color: var(--lg-text-muted);
  line-height: 1.4;
}

/* ── Modals & Drawers ── */
.lab-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lab-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.lab-modal-card {
  background: #FFFFFF;
  border-radius: var(--lg-radius-lg);
  box-shadow: var(--lg-shadow-lg);
  width: 90%;
  max-width: 480px;
  padding: 1.5rem;
  border: 1px solid var(--lg-border-subtle);
  transform: scale(0.96);
  transition: transform 0.2s ease;
}

.lab-modal-overlay.active .lab-modal-card {
  transform: scale(1);
}

.lab-modal-card h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--lg-text-primary);
}

.lab-modal-card p {
  margin: 0 0 1rem 0;
  font-size: 0.86rem;
  color: var(--lg-text-secondary);
  line-height: 1.45;
}

.lab-modal-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.lab-modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

/* Truth Table Modal */
.truth-table-modal-card {
  max-width: 640px;
  width: 92%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.truth-table-modal-header {
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--lg-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
}

.truth-table-modal-header h3 {
  margin: 0 0 0.2rem 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--lg-text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.truth-table-subtitle {
  font-size: 0.8rem;
  color: var(--lg-text-muted);
  font-weight: 500;
}

.truth-table-modal-body {
  padding: 1.25rem 1.4rem;
  overflow-y: auto;
  flex: 1;
  background: #FAFCFF;
}

.truth-table-wrapper {
  overflow-x: auto;
  background: #FFFFFF;
  border-radius: 10px;
  border: 1px solid var(--lg-border-medium);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

/* Clean Textbook Truth Table */
.logic-truth-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.92rem;
  text-align: center;
}

/* Table Header */
.logic-truth-table thead tr:first-child th {
  padding: 0.45rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--lg-border-medium);
}

.logic-truth-table th.header-group-inputs {
  background: #F1F5F9;
  color: #475569;
  border-right: 2px solid var(--lg-border-medium);
}

.logic-truth-table th.header-group-outputs {
  background: #EFF6FF;
  color: #1D4ED8;
}

.logic-truth-table thead tr:last-child th {
  padding: 0.65rem 0.75rem;
  font-size: 0.95rem;
  font-weight: 800;
  border-bottom: 2px solid var(--lg-border-medium);
  background: #F8FAFC;
  color: var(--lg-text-primary);
}

.logic-truth-table th.th-input {
  background: #F8FAFC;
  color: #0F172A;
  border-right: 1px solid var(--lg-border-subtle);
}

.logic-truth-table th.th-input-last {
  border-right: 2px solid var(--lg-border-medium);
}

.logic-truth-table th.th-output {
  background: #F0F7FF;
  color: #1E40AF;
  border-right: 1px solid #DBEAFE;
}

.logic-truth-table th.th-output:last-child {
  border-right: none;
}

/* Table Cells */
.logic-truth-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--lg-border-subtle);
  border-right: 1px solid var(--lg-border-subtle);
  transition: background-color 0.15s ease;
}

.logic-truth-table td.td-input-last {
  border-right: 2px solid var(--lg-border-medium);
}

.logic-truth-table td:last-child {
  border-right: none;
}

.logic-truth-table tbody tr:last-child td {
  border-bottom: none;
}

.logic-truth-table tbody tr:nth-child(even) td {
  background: #FAFCFF;
}

.logic-truth-table tbody tr:hover td {
  background: #F0F7FF;
}

/* Values inside table */
.logic-truth-table .tt-val-0 {
  color: #64748B;
  font-weight: 500;
}

.logic-truth-table .tt-val-1 {
  color: #0F172A;
  font-weight: 700;
}

.logic-truth-table .tt-out-val-1 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  background: #EFF6FF;
  color: #2563EB;
  font-weight: 800;
  border-radius: 4px;
  border: 1px solid #BFDBFE;
}

.logic-truth-table .tt-out-val-0 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  color: #94A3B8;
  font-weight: 600;
}

/* ── Drawers (Practice & Guide) ── */
.lab-drawer {
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0.3s;
}

.lab-drawer.active {
  pointer-events: auto;
  visibility: visible;
}

.lab-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lab-drawer.active .lab-drawer-backdrop {
  opacity: 1;
}

.lab-drawer-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 90vw;
  height: 100%;
  background: #FFFFFF;
  box-shadow: -4px 0 24px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1;
}

.lab-drawer.active .lab-drawer-content {
  transform: translateX(0);
}

.lab-drawer-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--lg-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #F8FAFC;
}

.lab-drawer-title-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lab-drawer-icon {
  font-size: 1.4rem;
}

.lab-drawer-title-box h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--lg-text-primary);
}

.lab-drawer-subtitle {
  font-size: 0.76rem;
  color: var(--lg-text-muted);
}

.lab-drawer-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--lg-text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--lg-radius-sm);
  transition: all 0.15s ease;
}

.lab-drawer-close:hover {
  background: #E2E8F0;
  color: var(--lg-text-primary);
}

.lab-drawer-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.drawer-intro {
  font-size: 0.84rem;
  color: var(--lg-text-secondary);
  line-height: 1.45;
  margin-bottom: 1.25rem;
}

/* Practice Task Cards */
.practice-cards-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.practice-card {
  background: #FFFFFF;
  border: 1px solid var(--lg-border-medium);
  border-radius: var(--lg-radius-md);
  padding: 1rem;
  transition: all 0.15s ease;
  position: relative;
}

.practice-card:hover {
  border-color: var(--lg-accent-blue);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.08);
}

.practice-card-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #EFF6FF;
  color: #2563EB;
  margin-bottom: 0.45rem;
}

.practice-card h4 {
  margin: 0 0 0.35rem 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--lg-text-primary);
}

.practice-card p {
  margin: 0 0 0.75rem 0;
  font-size: 0.8rem;
  color: var(--lg-text-secondary);
  line-height: 1.4;
}

.practice-card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--lg-accent-blue);
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: var(--lg-radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.practice-card-btn:hover {
  background: var(--lg-accent-blue);
  color: #FFFFFF;
}

/* Gate Reference Guide Cards */
.ref-tags-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ref-tag-item {
  background: #FFFFFF;
  border: 1px solid var(--lg-border-medium);
  border-radius: var(--lg-radius-md);
  padding: 1rem;
}

.ref-tag-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.ref-tag-code {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--lg-text-primary);
}

.ref-tag-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: #F1F5F9;
  color: #334155;
  border: 1px solid var(--lg-border-subtle);
}

.ref-tag-desc {
  font-size: 0.8rem;
  color: var(--lg-text-secondary);
  margin: 0 0 0.75rem 0;
  line-height: 1.4;
}

.ref-gate-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F8FAFC;
  border: 1px solid var(--lg-border-subtle);
  border-radius: var(--lg-radius-sm);
  padding: 0.75rem;
}

.ref-gate-preview svg {
  width: 100px;
  height: 55px;
}

/* Toast Notification */
.logic-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.logic-toast {
  background: #0F172A;
  color: #FFFFFF;
  padding: 0.6rem 1rem;
  border-radius: var(--lg-radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--lg-shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.logic-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.logic-toast.success {
  background: #15803D;
}

.logic-toast.warning {
  background: #B45309;
}

/* Responsive Styles */
@media (max-width: 1024px) {
  .logic-palette-panel {
    width: 220px;
  }
}

@media (max-width: 768px) {
  .logic-mobile-add-btn {
    display: inline-flex;
  }

  .logic-palette-panel {
    display: none;
  }

  .logic-workspace-body {
    height: calc(100vh - 160px);
  }

  .lab-drawer-content {
    width: 100%;
    max-width: 100%;
  }
}
