/* ===== DESIGN TOKENS ===== */
:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-display: 'Space Grotesk', var(--font-sans);
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-bg: #eff6ff;
  --secondary: #7c3aed;
  --secondary-bg: #f5f3ff;
  --accent: #059669;
  --accent-bg: #ecfdf5;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text-900: #0f172a;
  --text-700: #334155;
  --text-600: #475569;
  --text-400: #94a3b8;
  --text-300: #cbd5e1;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-900);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ===== APP LAYOUT ===== */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
#sidebar {
  width: 260px;
  min-width: 260px;
  height: calc(100vh - 24px);
  margin: 12px 0 12px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, width 0.35s ease, min-width 0.35s ease, margin 0.35s ease;
  z-index: 20;
}

#sidebar.closed {
  transform: translateX(-100%);
  opacity: 0;
  width: 0;
  min-width: 0;
  margin-left: 0;
  margin-right: 0;
  border: none;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: var(--primary-bg);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-900);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-body::-webkit-scrollbar {
  width: 4px;
}

.sidebar-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--text-400);
}

.btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.category-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-600);
  cursor: pointer;
  transition: all var(--transition);
}

.category-btn:hover {
  background: #e8ecf2;
}

.category-btn.active {
  background: var(--primary-bg);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

select,
textarea,
input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-700);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

select:focus,
textarea:focus,
input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
  height: 70px;
  resize: none;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}

.edge-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.edge-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.edge-input {
  width: 100% !important;
  min-width: 0;
  padding: 6px 4px !important;
  font-size: 11px !important;
  text-align: center;
}

.edge-label {
  font-size: 10px;
  color: var(--text-400);
  font-weight: 700;
  min-width: 12px;
}

.btn-remove-edge {
  background: transparent;
  border: none;
  color: var(--text-400);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.btn-remove-edge:hover {
  color: #ef4444;
}

.btn-add-edge {
  width: 100%;
  background: var(--bg);
  border: 1px dashed var(--border);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition);
}

.btn-add-edge:hover {
  background: #fff;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-600);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  background: #e8ecf2;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  border: none;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  color: #fff;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.complexity-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.complexity-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--text-700);
}

.complexity-header span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.complexity-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-600);
  padding: 4px 0;
}

.complexity-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.complexity-value.time {
  color: var(--secondary);
}

.complexity-value.space {
  color: var(--primary);
}

/* ===== MAIN CONTENT ===== */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 12px 12px;
  gap: 10px;
  min-width: 0;
}

/* ===== TOP BAR ===== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  box-shadow: var(--shadow-sm);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.divider-v {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-600);
}

.breadcrumb-link {
  color: var(--primary);
}

.breadcrumb svg {
  color: var(--text-300);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-400);
  cursor: pointer;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--bg);
  color: var(--text-600);
}

.lang-switcher {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.lang-btn {
  padding: 5px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-400);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--transition);
}

.lang-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.lang-btn:hover:not(.active) {
  color: var(--text-600);
}

/* ===== CONTENT AREA ===== */
.content-area {
  flex: 1;
  display: flex;
  gap: 10px;
  min-height: 0;
}

/* ===== VISUALIZATION PANEL ===== */
.viz-panel {
  flex: 2;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.sim-header {
  padding: 18px 22px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-bottom: 1px solid transparent;
  /* Placeholder for future border if needed */
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
  }

  50% {
    opacity: 0.7;
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(37, 99, 235, 0);
  }
}

.sim-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--text-400);
}

.description-box {
  margin: 0 22px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  animation: fadeSlideIn 0.3s ease;
  min-height: 80px;
  max-height: 220px;
  overflow-y: auto;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#description-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-700);
  line-height: 1.6;
}

.desc-main-text {
  margin-bottom: 6px;
}

.merged-equations {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.merged-eq-item {
  display: flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 2px 0;
}

.merged-eq-item .math {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(37, 99, 235, 0.1);
}

.merged-eq-item .highlight-math {
  background: #eff6ff;
  border: 1px solid var(--primary);
  font-weight: 700;
}

.viz-canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Side-by-side mode for Dijkstra */
.viz-canvas-wrap.graph-side-mode {
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  padding: 0;
}

.viz-canvas-wrap.graph-side-mode #visualization-canvas {
  flex: 1.4;
  min-width: 0;
  border-right: 1px solid var(--border);
}

.viz-canvas-wrap.graph-side-mode #dijkstra-simulation-view:not(.hidden),
.viz-canvas-wrap.graph-side-mode #knapsack-simulation-view:not(.hidden),
.viz-canvas-wrap.graph-side-mode #job-sequencing-simulation-view:not(.hidden) {
  flex: 1;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
  min-width: 0;
  overflow: auto;
}

.simulation-table-view {
  width: fit-content;
  max-width: 98%;
  margin: 0 auto;
  border-collapse: collapse;
  font-family: var(--font-sans);
  background: #fff;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.dijkstra-table {
  width: auto;
  border-collapse: collapse;
}

.dijkstra-table th,
.dijkstra-table td {
  padding: 8px 12px;
  text-align: center;
  border: 1px solid #fff;
  font-size: 13px;
  white-space: nowrap;
}

.dijkstra-table th {
  background: #E67E22;
  /* Primary orange */
  color: #fff;
  font-weight: 700;
}

.dijkstra-table tr:nth-child(n+1) td {
  background: #FAD7C8;
  /* Soft beige/peach */
  color: #333;
}

.dijkstra-table .label-cell {
  background: #E67E22 !important;
  color: #fff !important;
  font-weight: 700;
  width: 50px;
  font-size: 11px;
}

.dijkstra-table .visited-true {
  color: #059669;
  font-weight: 700;
}

.dijkstra-table .visited-false {
  color: #DC2626;
  font-weight: 700;
}

.dijkstra-table .active-col {
  background: #fee2e2 !important;
  box-shadow: inset 0 0 0 2px var(--primary);
}

.array-view {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 20px 22px;
  padding-top: 10px;
  margin-bottom: 0;
  min-height: 70px;
  flex-wrap: wrap;
  z-index: 4;
}

.array-box {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-700);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.array-box.highlight {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.array-box.swap {
  border-color: var(--secondary);
  background: var(--secondary-bg);
  color: var(--secondary);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
}

.array-box.found {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.15);
}

.array-box.sorted {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  opacity: 0.8;
}

.array-box.dimmed {
  opacity: 0.25;
  filter: grayscale(1);
}

#visualization-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid var(--border-light);
  background: rgba(248, 250, 252, 0.6);
  backdrop-filter: blur(8px);
}

.controls-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ctrl-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  color: var(--text-600);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

.ctrl-btn:hover {
  background: var(--bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.play-btn {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  border-radius: 16px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: all var(--transition);
}

.play-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.play-btn:active {
  transform: scale(0.96);
}

.delay-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 160px;
}

.delay-labels {
  display: flex;
  justify-content: space-between;
}

.ctrl-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-400);
}

.ctrl-value {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.progress-info {
  text-align: right;
}

.progress-nums {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--secondary);
  margin-top: 2px;
}

.progress-sep {
  color: var(--text-300);
  margin: 0 2px;
}

/* Range Slider */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: -6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
  transition: transform 0.15s ease;
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ===== CODE PANEL ===== */
.code-panel {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.code-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.code-header span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-400);
}

.code-body {
  flex: 1;
  overflow: auto;
  position: relative;
  padding: 0;
}

.code-body::-webkit-scrollbar {
  width: 4px;
}

.code-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

#code-pre {
  margin: 0;
  padding: 16px;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  position: relative;
  z-index: 2;
  white-space: pre;
  color: var(--text-700);
}

#code-block {
  font-family: var(--font-mono);
}

/* Code Highlighting Tokens */
.code-kw {
  color: var(--primary);
  font-weight: 700;
}

.code-str {
  color: var(--accent);
}

.code-num {
  color: var(--secondary);
  font-weight: 600;
}

.code-com {
  color: var(--text-400);
  font-style: italic;
}

.line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(37, 99, 235, 0.08);
  border-left: 3px solid var(--primary);
  pointer-events: none;
  z-index: 1;
  transition: top 0.3s ease, opacity 0.2s ease;
}

/* ===== ANIMATIONS ===== */
@keyframes barAppear {
  from {
    transform: scaleY(0);
    opacity: 0;
  }

  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes glow {

  0%,
  100% {
    box-shadow: 0 0 5px rgba(37, 99, 235, 0.2);
  }

  50% {
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
  }
}

/* Sidebar entrance */
.sidebar-section {
  animation: slideUp 0.4s ease backwards;
}

.sidebar-section:nth-child(1) {
  animation-delay: 0.1s;
}

.sidebar-section:nth-child(2) {
  animation-delay: 0.2s;
}

.sidebar-section:nth-child(3) {
  animation-delay: 0.3s;
}

.complexity-card {
  animation: slideUp 0.4s ease 0.4s backwards;
}

/* ===== FINAL RESPONSIVE OVERRIDES (MOBILE ONLY) ===== */
@media (max-width: 768px) {
  body {
    overflow: auto !important;
    height: auto !important;
    min-height: 100vh;
  }

  #app {
    flex-direction: column !important;
    height: auto !important;
    min-height: 100vh;
  }

  #sidebar {
    position: relative !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    max-height: none !important;
    margin: 8px 8px 0 8px !important;
    flex: none !important;
    transform: none !important;
    opacity: 1 !important;
    z-index: 10 !important;
    box-shadow: var(--shadow) !important;
    border-radius: var(--radius) !important;
    transition: none !important;
  }

  #sidebar.closed .sidebar-body {
    display: none;
  }

  #sidebar.closed .sidebar-header {
    border-bottom: none;
  }

  /* Adjust body padding for smooth scroll */
  .sidebar-body {
    padding: 16px !important;
  }

  #main-content {
    padding: 8px !important;
    height: auto !important;
    flex: none !important;
    width: 100%;
    overflow: visible !important;
  }

  .top-bar {
    padding: 8px 12px !important;
    margin-bottom: 4px;
    background: var(--surface) !important;
  }

  .logo-text {
    font-size: 15px !important;
  }

  .content-area {
    flex-direction: column !important;
    height: auto !important;
    gap: 12px !important;
    overflow: visible !important;
  }

  .viz-panel {
    min-height: 480px !important;
    height: auto !important;
    flex: none !important;
    border-radius: var(--radius) !important;
  }

  .viz-canvas-wrap {
    height: 320px !important;
    min-height: 320px !important;
  }

  .viz-canvas-wrap.graph-side-mode {
    flex-direction: column !important;
  }

  .viz-canvas-wrap.graph-side-mode canvas {
    height: 250px !important;
    flex: none !important;
  }

  .viz-canvas-wrap.graph-side-mode .simulation-table-view {
    max-height: 250px !important;
    width: 100% !important;
    border-top: 1px solid var(--border);
  }

  .controls-bar {
    flex-direction: column !important;
    gap: 16px !important;
    padding: 16px 12px !important;
  }

  .controls-left,
  .controls-right {
    width: 100% !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }

  .delay-control {
    flex: 1 !important;
    max-width: none !important;
    width: auto !important;
  }

  .code-panel {
    min-height: 350px !important;
    max-height: 500px !important;
    flex: none !important;
  }

  .breadcrumb {
    font-size: 11px !important;
  }

  .lang-switcher button {
    padding: 5px 10px !important;
    font-size: 10px !important;
  }

  /* Remove overlay on mobile since we are stacking */
  .sidebar-overlay {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .logo-icon {
    width: 32px !important;
    height: 32px !important;
  }

  .breadcrumb svg {
    margin: 0 2px !important;
  }

  .controls-left {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) auto;
    gap: 8px !important;
  }

  .controls-left button {
    width: 100% !important;
    aspect-ratio: 1/1 !important;
  }

  .play-btn {
    grid-column: 4;
    width: 48px !important;
    height: 48px !important;
  }
}

/* Job Sequencing Styles */
.job-sequencing-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 10px;
}

.schedule-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--border-light);
}

.slot-box {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slot-box.filled {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.greedy-transposed-table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 20px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.greedy-transposed-table th,
.greedy-transposed-table td {
  border: 1px solid #e2e8f0;
  padding: 10px;
  text-align: center;
  font-size: 14px;
}

.greedy-transposed-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  min-width: 100px;
  text-align: left;
}

.greedy-transposed-table tr:hover {
  background: #f1f5f9;
}

.header-row th {
  background: #1e293b !important;
  color: white !important;
  text-align: center !important;
}

.highlight-cell {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  font-weight: 700;
  border: 2px solid var(--primary) !important;
}

/* DP Visualizations */
#dp-simulation-view {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: auto;
}

.dp-scroll-wrap {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dp-table {
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin: 0 auto;
}

.dp-table th,
.dp-table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: center;
  font-size: 13px;
  min-width: 40px;
}

.dp-table th {
  background: var(--text-900);
  color: white;
  font-weight: 600;
}

.dp-table .row-header {
  background: #f8fafc;
  color: var(--text-700);
  font-weight: 700;
  text-align: left;
}

.active-cell {
  background: var(--primary-bg) !important;
  color: var(--primary) !important;
  font-weight: 700 !important;
  box-shadow: inset 0 0 0 2px var(--primary);
}

.path-cell {
  background: var(--accent-bg) !important;
  color: var(--accent) !important;
  font-weight: 700;
}

.empty-cell {
  background: #f1f5f9;
}

.solution-text {
  margin-top: 20px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  font-size: 16px;
}

/* Assembly Lines specific styles */
.assembly-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.assembly-lines .line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.line-label {
  font-weight: 700;
  color: var(--text-600);
  width: 80px;
  font-size: 14px;
}

.station {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 700;
  color: var(--text-700);
  transition: all 0.3s ease;
}

.station.active-cell {
  transform: scale(1.1);
  z-index: 10;
}

/* ===== EQUATION VIEW (Multistage) ===== */
.equation-view {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-top: 2px solid var(--primary-bg);
  padding: 15px 25px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 10;
  font-family: var(--font-sans);
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.equation-view ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.equation-view li {
  font-size: 14px;
  color: var(--text-700);
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}



.equation-view .math {
  font-family: var(--font-mono);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-900);
  font-weight: 600;
}

.equation-view .highlight-math {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

/* Clear content area when hidden */
.equation-view.hidden {
  display: none !important;
}