/* ==========================================================================
   DebugPal AI — Modern Dark Cyberpunk / Terminal Design System
   ========================================================================== */

:root {
  --bg-primary: #070a12;
  --bg-secondary: #0d1222;
  --bg-tertiary: #131b32;
  --bg-card: rgba(16, 24, 46, 0.75);
  --bg-card-hover: rgba(22, 33, 62, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(0, 242, 254, 0.5);
  
  --accent-cyan: #00f2fe;
  --accent-teal: #06b6d4;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;
  --accent-violet: #8b5cf6;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', ui-monospace, SFMono-Regular, monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px rgba(0, 242, 254, 0.2);
  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

/* Ambient glow orbs in background */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.15;
}
.glow-1 {
  top: -10%;
  left: -5%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-cyan), transparent);
}
.glow-2 {
  bottom: 5%;
  right: -5%;
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, var(--accent-violet), transparent);
}

/* ==========================================================================
   Header & Navbar
   ========================================================================== */

.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 2rem;
  background: rgba(7, 10, 18, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(0, 242, 254, 0.4);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.25);
}

.logo-sym {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-cyan);
}

.brand-title {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.badge-ai {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  color: #000;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: rgba(16, 24, 46, 0.8);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
}

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

/* ==========================================================================
   Buttons & Controls
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #000;
  box-shadow: 0 4px 18px rgba(0, 242, 254, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0, 242, 254, 0.45);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: var(--transition);
}
.btn-sm:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: rgba(0, 0, 0, 0.8);
  font-weight: 700;
  margin-left: 0.4rem;
}

/* ==========================================================================
   Hero Strip
   ========================================================================== */

.hero-strip {
  position: relative;
  z-index: 10;
  padding: 1.5rem 2rem 1rem;
  text-align: center;
  max-width: 900px;
  margin: 0 auto;
}

.hero-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.08);
  border: 1px solid rgba(0, 242, 254, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.6rem;
  letter-spacing: 0.02em;
}

.hero-title {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}
.hero-title code {
  font-family: var(--font-mono);
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.12);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.hero-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 720px;
  margin: 0 auto;
}
.hero-desc strong {
  color: var(--text-main);
}

/* ==========================================================================
   Main Workspace Grid Layout
   ========================================================================== */

.workspace-grid {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 1.5rem;
  padding: 1rem 2rem 2.5rem;
  flex: 1;
}

.panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.25s ease;
}
.panel:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: rgba(13, 18, 34, 0.6);
  border-bottom: 1px solid var(--border-subtle);
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dot-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot-indicator.green {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.panel-title {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

.file-chip {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.editor-actions {
  display: flex;
  gap: 0.4rem;
}

/* Presets Toolbar */
.presets-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  background: rgba(7, 10, 18, 0.4);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.preset-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
  margin-right: 0.25rem;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}
.preset-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}
.preset-btn.active {
  background: rgba(0, 242, 254, 0.12);
  color: var(--accent-cyan);
  border-color: rgba(0, 242, 254, 0.4);
}

/* Code Area */
.code-container {
  display: flex;
  flex: 1;
  min-height: 480px;
  background: #060912;
  position: relative;
  font-family: var(--font-mono);
}

.line-numbers {
  padding: 1rem 0.6rem 1rem 1rem;
  color: #3b4252;
  text-align: right;
  font-size: 0.85rem;
  line-height: 1.6;
  user-select: none;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(0, 0, 0, 0.2);
}

#codeEditor {
  flex: 1;
  padding: 1rem;
  background: transparent;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  border: none;
  resize: none;
  outline: none;
  white-space: pre;
  tab-size: 4;
}

.panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: rgba(13, 18, 34, 0.7);
  border-top: 1px solid var(--border-subtle);
}

.language-select-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.language-select-wrapper select {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
}

/* ==========================================================================
   Visualizer Panel & Tabs
   ========================================================================== */

.tab-header {
  display: flex;
  background: rgba(13, 18, 34, 0.7);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}
.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}
.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.05);
}

.tab-content {
  display: none;
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  max-height: 640px;
}
.tab-content.active {
  display: block;
}

/* Memory Summary Bar */
.memory-summary-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.mem-stat {
  background: rgba(7, 10, 18, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
}

.stat-lbl {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.stat-val {
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.text-red { color: var(--accent-rose); }
.text-yellow { color: var(--accent-amber); }
.text-green { color: var(--accent-emerald); }

/* Memory Diagram Columns (Stack vs Heap) */
.memory-diagram-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.mem-column {
  background: rgba(7, 10, 18, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.mem-column-header {
  display: flex;
  flex-direction: column;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 0.85rem;
}

.col-icon {
  font-size: 1.1rem;
}

.col-name {
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.col-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.mem-blocks-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 180px;
}

/* Individual Stack & Heap Item Blocks */
.mem-block {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  position: relative;
  transition: var(--transition);
}

.mem-block.invalid-target {
  border-color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
  box-shadow: 0 0 15px rgba(244, 63, 94, 0.25);
}

.mem-block.leaked {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
}

.mem-block.valid-active {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.06);
}

.mem-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
}

.mem-addr {
  color: var(--accent-cyan);
  font-weight: 600;
}

.mem-size {
  color: var(--text-dim);
  font-size: 0.65rem;
}

.mem-val-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.mem-var-name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #e2e8f0;
}

.mem-pointer-target {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.arrow-sym {
  color: var(--accent-cyan);
}
.arrow-sym.danger {
  color: var(--accent-rose);
}

.badge-tag {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 700;
}
.badge-tag.danger {
  background: var(--accent-rose);
  color: #fff;
}
.badge-tag.warning {
  background: var(--accent-amber);
  color: #000;
}
.badge-tag.success {
  background: var(--accent-emerald);
  color: #000;
}

/* Pointer Timeline */
.pointer-timeline {
  background: rgba(7, 10, 18, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.timeline-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.timeline-steps {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.825rem;
  color: var(--text-muted);
}
.timeline-steps li strong {
  color: var(--accent-cyan);
  font-family: var(--font-mono);
}
.timeline-steps li.crash-step {
  color: var(--accent-rose);
  font-weight: 600;
}

/* ==========================================================================
   Socratic Guidance Hints
   ========================================================================== */

.socratic-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.socratic-intro h3 {
  font-size: 1.15rem;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}
.socratic-intro p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hint-card {
  background: rgba(13, 18, 34, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
}
.hint-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.hint-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.1rem;
  background: rgba(7, 10, 18, 0.4);
}

.hint-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}
.hint-badge.level-1 {
  background: rgba(0, 242, 254, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 242, 254, 0.3);
}
.hint-badge.level-2 {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.hint-badge.level-3 {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.hint-toggle-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.hint-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.hint-body {
  padding: 1.1rem;
  font-size: 0.875rem;
  color: #cbd5e1;
  line-height: 1.6;
  border-top: 1px solid var(--border-subtle);
}
.hint-body code {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.08);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}
.hint-body.hidden {
  display: none;
}

/* ==========================================================================
   Everyday Analogy Card
   ========================================================================== */

.analogy-card {
  background: linear-gradient(135deg, rgba(22, 33, 62, 0.7), rgba(13, 18, 34, 0.8));
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.15);
}

.analogy-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-violet);
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.75rem;
}

.analogy-headline {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  color: #fff;
}

.analogy-illustration {
  font-size: 2.8rem;
  text-align: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  border: 1px dashed rgba(255, 255, 255, 0.1);
}

.analogy-narrative {
  font-size: 0.95rem;
  color: #e2e8f0;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.analogy-lesson {
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid var(--accent-cyan);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.analogy-lesson strong {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--accent-cyan);
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}
.analogy-lesson p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ==========================================================================
   Safe Patch & Diff
   ========================================================================== */

.fix-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.fix-header h3 {
  font-size: 1.15rem;
  margin-bottom: 0.35rem;
}
.fix-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.diff-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.diff-block {
  background: #060912;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: var(--font-mono);
}

.diff-bar {
  padding: 0.5rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 700;
}
.red-bar {
  background: rgba(244, 63, 94, 0.18);
  color: var(--accent-rose);
  border-bottom: 1px solid rgba(244, 63, 94, 0.3);
}
.green-bar {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-emerald);
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
}

.diff-block pre {
  padding: 1rem;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-x: auto;
  color: #cbd5e1;
}

.fix-checklist {
  background: rgba(7, 10, 18, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}
.fix-checklist h4 {
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}
.fix-checklist ul {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.fix-checklist code {
  font-family: var(--font-mono);
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* ==========================================================================
   Modal Dialog
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(7, 10, 18, 0.6);
  border-bottom: 1px solid var(--border-subtle);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.btn-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-group input, .form-group select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0.6rem 0.85rem;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(0, 242, 254, 0.15);
}

.form-help {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.test-connection-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-top: 0.5rem;
}

.test-feedback {
  font-size: 0.8rem;
  font-weight: 600;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: rgba(7, 10, 18, 0.6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

/* Spinner */
.spin-icon {
  animation: spin 1s linear infinite;
}
.spin-icon.hidden {
  display: none;
}
@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* Responsive queries */
@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .diff-view {
    grid-template-columns: 1fr;
  }
}
