/* ==========================================================================
   FIBRE OPTIC MST DESIGNER & PRIM'S ALGORITHM VISUALIZER
   Dark Fibre Theme, Optical Pulse Animations & Single-Screen Responsive Layout
   ========================================================================== */

:root {
  --bg-main: #080c14;
  --bg-panel: #0d1525;
  --bg-card: #131e33;
  --bg-card-hover: #1a2844;
  --border-color: #1e2e4a;
  --border-focus: #00f0ff;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Optical Laser Palette */
  --laser-cyan: #00f0ff;
  --laser-cyan-glow: rgba(0, 240, 255, 0.45);
  --laser-emerald: #00ff88;
  --laser-emerald-glow: rgba(0, 255, 136, 0.45);
  --laser-amber: #ffb800;
  --laser-amber-glow: rgba(255, 184, 0, 0.4);
  --laser-ruby: #ff3366;
  --laser-ruby-glow: rgba(255, 51, 102, 0.4);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Consolas, Monaco, monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --shadow-glow: 0 0 15px var(--laser-cyan-glow);
  --shadow-emerald: 0 0 15px var(--laser-emerald-glow);
}

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

html, body {
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.4;
}

/* App Header & Navigation (Fixed Compact 50px, Zero Overflow) */
.app-header {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  padding: 4px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  flex-shrink: 0;
  z-index: 100;
  gap: 8px;
  overflow: hidden;
  box-sizing: border-box;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-icon {
  width: 28px;
  height: 28px;
  background: radial-gradient(circle, var(--laser-cyan) 0%, rgba(0, 240, 255, 0.2) 70%, transparent 100%);
  border: 1px solid var(--laser-cyan);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 16px;
  height: 16px;
  fill: var(--laser-cyan);
}

.brand-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-tag {
  font-size: 0.58rem;
  background: rgba(0, 240, 255, 0.15);
  color: var(--laser-cyan);
  border: 1px solid var(--laser-cyan);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  font-weight: 800;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 3px;
  background: var(--bg-main);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.nav-tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: var(--text-main);
}

.nav-tab-btn.active {
  background: var(--bg-card);
  color: var(--laser-cyan);
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* Header Controls Bar */
.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 1;
  min-width: 0;
  justify-content: flex-end;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.control-label {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.74rem;
  white-space: nowrap;
}

select, input[type="text"], input[type="number"] {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

#select-preset {
  max-width: 145px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#select-start-node {
  max-width: 120px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#input-cost-per-km {
  width: 66px;
}

select:focus, input:focus {
  border-color: var(--laser-cyan);
}

.btn-action-small {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 3px 6px;
  font-size: 0.74rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-action-small:hover {
  background: var(--bg-card-hover);
  border-color: var(--laser-cyan);
  color: var(--laser-cyan);
}

@media (max-width: 1240px) {
  .btn-action-small .btn-text {
    display: none;
  }
  .btn-action-small {
    padding: 3px 5px;
  }
  #select-preset {
    max-width: 125px;
  }
  #select-start-node {
    max-width: 100px;
  }
}

@media (max-width: 1040px) {
  .control-label {
    display: none;
  }
  .rate-group {
    display: none;
  }
  #select-preset {
    max-width: 110px;
  }
  #select-start-node {
    max-width: 90px;
  }
}

@media (max-width: 820px) {
  .brand-title {
    font-size: 0.82rem;
  }
  .brand-tag {
    display: none;
  }
  .nav-tab-btn {
    padding: 3px 6px;
    font-size: 0.72rem;
  }
  #select-preset {
    max-width: 95px;
  }
  #select-start-node {
    max-width: 80px;
  }
}

@media (max-width: 650px) {
  .brand-title {
    display: none;
  }
  .btn-action-small {
    padding: 3px 4px;
    font-size: 0.7rem;
  }
  #select-preset {
    max-width: 85px;
  }
  #select-start-node {
    max-width: 75px;
  }
}

/* Main Container (Fits exactly inside viewport) */
.main-content {
  height: calc(100vh - 50px);
  padding: 8px 12px;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-panel {
  display: none;
  height: 100%;
  width: 100%;
}

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

/* Dedicated scrolling for Theory & Notes and Quiz panels */
#tab-panel-theory,
#tab-panel-quiz {
  height: 100%;
  overflow-y: auto !important;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--laser-cyan) var(--bg-card);
}

#tab-panel-theory::-webkit-scrollbar,
#tab-panel-quiz::-webkit-scrollbar {
  width: 8px;
}

#tab-panel-theory::-webkit-scrollbar-track,
#tab-panel-quiz::-webkit-scrollbar-track {
  background: var(--bg-main);
  border-radius: 4px;
}

#tab-panel-theory::-webkit-scrollbar-thumb,
#tab-panel-quiz::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

#tab-panel-theory::-webkit-scrollbar-thumb:hover,
#tab-panel-quiz::-webkit-scrollbar-thumb:hover {
  background: var(--laser-cyan);
}

/* Visualizer Workspace Grid (Single-Screen) */
.viz-workspace {
  display: grid;
  grid-template-columns: 1fr 440px;
  height: 100%;
  gap: 10px;
  overflow: hidden;
}

/* Left Column: Canvas Panel */
.canvas-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  position: relative;
}

/* Canvas Toolbar */
.canvas-toolbar {
  background: rgba(13, 21, 37, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 8px;
  z-index: 10;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-tool {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.btn-tool:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--laser-cyan);
  color: var(--laser-cyan);
}

.btn-tool:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-calculate {
  background: linear-gradient(135deg, #00b4d8 0%, #0077b6 100%);
  color: #fff;
  border: 1px solid var(--laser-cyan);
  font-weight: 700;
  box-shadow: 0 0 10px rgba(0, 180, 216, 0.4);
}

.btn-calculate:hover {
  background: linear-gradient(135deg, #00f0ff 0%, #0096c7 100%);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.6);
  color: #080c14;
}

/* SVG Canvas Area */
.svg-canvas-wrapper {
  flex: 1;
  min-height: 0;
  position: relative;
  background-color: #070b12;
  background-image:
    radial-gradient(rgba(0, 240, 255, 0.08) 1px, transparent 1px),
    radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 28px 28px, 14px 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#svg-network-canvas {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}

/* Integrated Canvas Bottom HUD */
.canvas-hud {
  background: rgba(13, 21, 37, 0.96);
  border-top: 1px solid var(--border-color);
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

.hud-narrative-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-narrative-text {
  flex: 1;
  font-size: 0.83rem;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-metrics-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.hud-metric {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
}

.hud-metric-label {
  color: var(--text-muted);
}

.hud-metric-val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
}

.text-emerald { color: var(--laser-emerald) !important; }
.text-cyan    { color: var(--laser-cyan) !important; }
.text-amber   { color: var(--laser-amber) !important; }

/* SVG Graph Elements Styling */
.edge-cable .edge-line {
  transition: stroke 0.3s, stroke-width 0.3s;
}

.edge-chosen .edge-line {
  stroke: #00ff88;
  stroke-dasharray: 8, 4;
  animation: laserFlow 1s linear infinite;
  filter: drop-shadow(0 0 6px rgba(0, 255, 136, 0.85));
}

@keyframes laserFlow {
  from { stroke-dashoffset: 24; }
  to { stroke-dashoffset: 0; }
}

.edge-considered .edge-line {
  stroke: var(--laser-amber);
  animation: laserPulse 1.2s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 6px rgba(255, 184, 0, 0.85));
}

.edge-candidate .edge-line {
  filter: drop-shadow(0 0 5px rgba(0, 240, 255, 0.75));
}

@keyframes laserPulse {
  from { opacity: 0.7; stroke-width: 3.5; }
  to { opacity: 1; stroke-width: 5; }
}

.edge-badge-bg {
  fill: #0d1525;
  stroke: #1e2e4a;
  stroke-width: 1;
}

.edge-badge-bg.badge-chosen {
  stroke: var(--laser-emerald);
  fill: rgba(0, 255, 136, 0.15);
}

.edge-badge-bg.badge-considered {
  stroke: var(--laser-amber);
  fill: rgba(255, 184, 0, 0.2);
}

.edge-badge-bg.badge-rejected {
  stroke: var(--laser-ruby);
  fill: rgba(255, 51, 102, 0.2);
}

.edge-badge-bg.badge-candidate {
  stroke: var(--laser-cyan);
  fill: rgba(0, 240, 255, 0.1);
}

.edge-badge-text {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  fill: var(--text-main);
  pointer-events: none;
}

.city-node {
  cursor: grab;
  transition: transform 0.15s ease-out;
}

.city-node:active {
  cursor: grabbing;
}

.node-pulse-ring {
  animation: ringPulse 1.5s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}

@keyframes ringPulse {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

.node-circle {
  transition: fill 0.25s, stroke 0.25s, stroke-width 0.25s;
}

.city-node:hover .node-circle {
  stroke-width: 3.5;
  filter: drop-shadow(0 0 8px var(--laser-cyan));
}

.node-initial {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 11px;
  fill: #ffffff;
  pointer-events: none;
}

.node-label-bg {
  fill: rgba(13, 21, 37, 0.85);
  stroke: var(--border-color);
  stroke-width: 1;
}

.node-label-text {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  fill: var(--text-main);
  pointer-events: none;
}

/* Right Column: Side Panel (Fits 100% height, Never scrolls as a whole) */
.side-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

/* 1. Code Viewer Card (Top Right) */
.code-viewer-card {
  flex: 1.1;
  min-height: 160px;
  max-height: 42%;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.code-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.code-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.lang-tabs {
  display: flex;
  gap: 3px;
}

.lang-tab {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.lang-tab.active {
  background: var(--bg-main);
  color: var(--laser-cyan);
}

.code-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: #060a10;
}

.code-line {
  display: flex;
  padding: 2px 8px;
  line-height: 1.4;
  transition: background-color 0.2s;
}

.code-line:hover {
  background: rgba(255, 255, 255, 0.03);
}

.code-line-highlight {
  background: rgba(0, 240, 255, 0.18) !important;
  border-left: 3px solid var(--laser-cyan);
  box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.15);
}

.line-number {
  width: 28px;
  text-align: right;
  padding-right: 10px;
  color: var(--text-dim);
  user-select: none;
}

.line-content {
  flex: 1;
  color: #cbd5e1;
  white-space: pre;
}

/* Syntax Highlighting */
.tok-keyword { color: #f472b6; font-weight: 600; }
.tok-type    { color: #38bdf8; font-weight: 500; }
.tok-comment { color: #64748b; font-style: italic; }
.tok-str     { color: #a7f3d0; }
.tok-number  { color: #38bdf8; }
.tok-bool    { color: #fb923c; }

/* 2. Inspector Card (Middle Right) */
.inspector-card {
  flex: 1;
  min-height: 120px;
  max-height: 35%;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inspector-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.inspector-tabs {
  display: flex;
  gap: 4px;
}

.insp-tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.insp-tab-btn.active {
  background: var(--bg-main);
  color: var(--laser-cyan);
}

.insp-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px;
}

/* Priority Queue Table */
.queue-table-wrapper {
  height: 100%;
  overflow-y: auto;
}

.pq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  text-align: left;
}

.pq-table th {
  color: var(--text-dim);
  font-weight: 600;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border-color);
}

.pq-table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.pq-row-min {
  background: rgba(0, 240, 255, 0.08);
}

.pq-row-cycle {
  background: rgba(255, 184, 0, 0.04);
}

.pq-row-omitted {
  opacity: 0.65;
}

.pq-badge {
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
}

.pq-badge-min {
  background: rgba(0, 240, 255, 0.2);
  color: var(--laser-cyan);
  border: 1px solid rgba(0, 240, 255, 0.35);
}

.pq-badge-next {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.pq-badge-candidate {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
}

.pq-badge-alt {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.pq-badge-cycle {
  background: rgba(255, 184, 0, 0.15);
  color: var(--laser-amber);
  border: 1px solid rgba(255, 184, 0, 0.3);
}

.pq-badge-omitted {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-dim);
  border: 1px solid rgba(100, 116, 139, 0.25);
}

.pq-badge-wait {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-dim);
}

.pq-empty-msg {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-style: italic;
  padding: 14px 0;
  text-align: center;
}

/* Variables Scope List */
.variables-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.variable-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.76rem;
}

.var-name {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.var-value {
  color: var(--text-main);
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: right;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 3. Fixed Compact Player Card (Right Bottom — Never Scrolls!) */
.player-card {
  flex-shrink: 0;
  margin-top: auto;
  background: var(--bg-panel);
  border: 1px solid var(--laser-cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-scrubber-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--laser-cyan);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.timeline-slider {
  flex: 1;
  accent-color: var(--laser-cyan);
  cursor: pointer;
  height: 5px;
}

.speed-control-group {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.speed-slider {
  width: 55px;
  accent-color: var(--laser-cyan);
  cursor: pointer;
  height: 4px;
}

.player-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-player {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  width: 32px;
  height: 30px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-player:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--laser-cyan);
  color: var(--laser-cyan);
}

.btn-player:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-player-play {
  width: 76px;
  font-weight: 700;
  font-size: 0.8rem;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2) 0%, rgba(0, 119, 182, 0.4) 100%);
  border-color: var(--laser-cyan);
  color: var(--laser-cyan);
  gap: 4px;
}

.btn-player-play.is-playing {
  background: rgba(255, 184, 0, 0.2);
  border-color: var(--laser-amber);
  color: var(--laser-amber);
}

.player-action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-edit-mode {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-edit-mode:hover {
  border-color: var(--laser-cyan);
  color: var(--laser-cyan);
}

.btn-player-action-calc {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Action Badges */
.action-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  flex-shrink: 0;
}

.badge-ready        { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }
.badge-start        { background: rgba(0, 240, 255, 0.2); color: var(--laser-cyan); border: 1px solid var(--laser-cyan); }
.badge-candidate    { background: rgba(0, 240, 255, 0.15); color: var(--laser-cyan); }
.badge-considered   { background: rgba(255, 184, 0, 0.2); color: var(--laser-amber); border: 1px solid var(--laser-amber); }
.badge-added        { background: rgba(0, 255, 136, 0.2); color: var(--laser-emerald); border: 1px solid var(--laser-emerald); }
.badge-rejected     { background: rgba(255, 51, 102, 0.2); color: var(--laser-ruby); border: 1px solid var(--laser-ruby); }
.badge-done         { background: rgba(0, 255, 136, 0.25); color: var(--laser-emerald); box-shadow: var(--shadow-emerald); }
.badge-disconnected { background: rgba(255, 184, 0, 0.25); color: var(--laser-amber); }

/* Theory Tab Styles (Scrollable) */
.theory-container {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px 20px 80px 20px;
  min-height: min-content;
}

.theory-hero {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.1) 0%, rgba(13, 21, 37, 0.8) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.theory-hero h1 {
  font-size: 1.8rem;
  color: #fff;
  margin-bottom: 8px;
}

.theory-hero p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.theory-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.theory-section h2 {
  font-size: 1.25rem;
  color: var(--laser-cyan);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theory-section p, .theory-section li {
  color: #cbd5e1;
  line-height: 1.6;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.theory-section ul {
  padding-left: 20px;
  margin-bottom: 14px;
}

.theory-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.85rem;
}

.theory-table th, .theory-table td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.theory-table th {
  background: var(--bg-card);
  color: var(--laser-cyan);
}

.theory-callout {
  background: rgba(0, 255, 136, 0.08);
  border-left: 4px solid var(--laser-emerald);
  padding: 12px 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 14px 0;
  font-size: 0.88rem;
}

/* Quiz Tab Styles (Scrollable) */
.quiz-container {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 20px 80px 20px;
  min-height: min-content;
}

.quiz-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quiz-progress-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.quiz-score-badge {
  background: var(--bg-card);
  color: var(--laser-cyan);
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
}

.quiz-progress-bar-bg {
  width: 100%;
  height: 5px;
  background: var(--bg-main);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.quiz-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--laser-cyan), var(--laser-emerald));
  transition: width 0.3s ease;
}

.quiz-question-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.45;
  color: #fff;
}

.quiz-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: #e2e8f0;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
}

.quiz-option-btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--laser-cyan);
  transform: translateX(3px);
}

.quiz-option-letter {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--laser-cyan);
}

.quiz-option-btn.option-correct {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--laser-emerald);
  color: #fff;
}

.quiz-option-btn.option-correct .quiz-option-letter {
  background: var(--laser-emerald);
  color: #080c14;
}

.quiz-option-btn.option-wrong {
  background: rgba(255, 51, 102, 0.15);
  border-color: var(--laser-ruby);
  color: #fff;
}

.quiz-option-btn.option-wrong .quiz-option-letter {
  background: var(--laser-ruby);
  color: #fff;
}

.quiz-option-btn.option-dimmed {
  opacity: 0.45;
}

.quiz-feedback-box {
  padding: 14px;
  border-radius: var(--radius-md);
  animation: fadeIn 0.3s ease;
}

.feedback-correct {
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid var(--laser-emerald);
}

.feedback-wrong {
  background: rgba(255, 51, 102, 0.1);
  border: 1px solid var(--laser-ruby);
}

.feedback-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.feedback-correct .feedback-title { color: var(--laser-emerald); }
.feedback-wrong .feedback-title { color: var(--laser-ruby); }

.feedback-body {
  font-size: 0.83rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
}

.btn-quiz-next {
  background: linear-gradient(135deg, var(--laser-cyan) 0%, #0284c7 100%);
  color: #080c14;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}

.btn-quiz-next:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

/* Quiz Results Card */
.quiz-results-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.results-badge {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  font-weight: 800;
  color: var(--laser-cyan);
  background: rgba(0, 240, 255, 0.15);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.results-title {
  font-size: 1.4rem;
  color: #fff;
}

.results-score-circle {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-full);
  border: 3px solid var(--laser-emerald);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-emerald);
  background: var(--bg-card);
  margin: 6px 0;
}

.score-number {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--laser-emerald);
  line-height: 1;
}

.score-denom {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.results-buttons {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn-quiz-retry, .btn-quiz-back-viz {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-quiz-retry {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-quiz-back-viz {
  background: var(--laser-cyan);
  border: none;
  color: #080c14;
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(13, 21, 37, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--laser-cyan);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), var(--shadow-glow);
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1000;
}

.toast-notification.visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive Media Queries */
@media (max-width: 960px) {
  html, body {
    height: auto;
    overflow-y: auto;
  }
  .main-content {
    height: auto;
    overflow: visible;
  }
  .viz-workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .canvas-panel {
    min-height: 480px;
  }
  .side-panel {
    height: auto;
    overflow: visible;
  }
  .code-viewer-card {
    max-height: none;
    height: 280px;
  }
  .inspector-card {
    max-height: none;
    height: 180px;
  }
}

/* --- HUD Summary Button & Order Badges --- */
.btn-hud-summary {
  background: rgba(0, 255, 136, 0.12);
  color: var(--laser-emerald);
  border: 1px solid rgba(0, 255, 136, 0.4);
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  flex-shrink: 0;
  animation: summaryPulse 2s infinite alternate;
}

.btn-hud-summary:hover {
  background: rgba(0, 255, 136, 0.25);
  border-color: var(--laser-emerald);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

@keyframes summaryPulse {
  from { box-shadow: 0 0 4px rgba(0, 255, 136, 0.2); }
  to { box-shadow: 0 0 12px rgba(0, 255, 136, 0.5); }
}

.node-order-badge {
  pointer-events: none;
  animation: orderBadgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.node-order-badge circle {
  stroke: #080c14;
}

@keyframes orderBadgePop {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* --- City Order Table --- */
.city-order-table th {
  background: var(--bg-card);
  font-size: 0.72rem;
}

.city-order-table td {
  font-size: 0.74rem;
}

.order-row-current {
  background: rgba(255, 184, 0, 0.12) !important;
}

.order-cable-hub {
  color: var(--laser-cyan);
  font-style: italic;
  font-weight: 500;
}

.order-city-name strong {
  color: #f1f5f9;
}

.order-cumulative {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--laser-emerald);
}

/* --- Modal Backdrop & Card --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 13, 0.85);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 240, 255, 0.1);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  background: var(--bg-card);
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-icon {
  font-size: 1.5rem;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.modal-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 2px 0 0 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  background: var(--bg-card);
  padding: 10px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.btn-primary {
  background: var(--laser-cyan) !important;
  color: #080c14 !important;
  font-weight: 600;
  border-color: var(--laser-cyan) !important;
}

.btn-primary:hover {
  background: #38bdf8 !important;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

/* Modal Inner Summary Components */
.summary-heading {
  font-size: 0.86rem;
  color: var(--laser-cyan);
  font-weight: 600;
  margin: 0 0 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-sequence-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: #060a10;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.seq-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 14px;
  font-size: 0.76rem;
}

.seq-num {
  background: var(--laser-emerald);
  color: #080c14;
  font-weight: 800;
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 10px;
}

.seq-name {
  font-weight: 600;
  color: var(--text-main);
}

.seq-dist {
  color: var(--laser-cyan);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.seq-arrow {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.summary-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.summary-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.stat-val {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.summary-table-wrapper {
  background: #060a10;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.summary-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.72rem;
}

.summary-table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.summary-table tr:last-child td {
  border-bottom: none;
}
