/* ══════════════════════════════════════════════════════════
   AutomataViz — Premium Dark Theme
   NFA→DFA Converter & Minimizer
   ══════════════════════════════════════════════════════════ */

:root {
  --bg-base: #09090f;
  --bg-surface: #0f0f1a;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.05);
  --bg-input: rgba(255, 255, 255, 0.05);

  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --border-active: rgba(139, 92, 246, 0.5);

  --text-primary: #f0f0fa;
  --text-secondary: #8b8ba7;
  --text-muted: #5a5a75;

  --accent: #8b5cf6;
  --accent-light: #a78bfa;
  --accent-dark: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.3);

  --cyan: #22d3ee;
  --cyan-light: #67e8f9;
  --green: #4ade80;
  --green-glow: rgba(74, 222, 128, 0.2);
  --red: #f87171;
  --red-glow: rgba(248, 113, 113, 0.2);
  --orange: #fb923c;
  --yellow: #fbbf24;

  --state-default: #8b5cf6;
  --state-start: #22d3ee;
  --state-accept: #4ade80;
  --state-current: #fbbf24;
  --state-dead: #f87171;

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);

  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Background Orbs ── */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.12;
  animation: float 20s ease-in-out infinite;
}
.orb-1 { width: 700px; height: 700px; background: radial-gradient(circle, #8b5cf6, #5b21b6); top: -200px; left: -150px; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: radial-gradient(circle, #22d3ee, #0891b2); bottom: -100px; right: -100px; animation-delay: -7s; }
.orb-3 { width: 400px; height: 400px; background: radial-gradient(circle, #4ade80, #059669); top: 50%; left: 50%; transform: translate(-50%, -50%); animation-delay: -14s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ── Header ── */
.app-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 15, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 14px; }
.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--cyber-blue, #22d3ee));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  padding: 8px;
  box-shadow: 0 0 20px var(--accent-glow);
}
.logo-icon svg { width: 100%; height: 100%; }
.logo-title {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}
.logo-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}
.header-badges { display: flex; gap: 8px; }
.badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-unit { background: rgba(139, 92, 246, 0.15); color: var(--accent-light); border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-toc { background: rgba(34, 211, 238, 0.1); color: var(--cyan); border: 1px solid rgba(34, 211, 238, 0.25); }

/* ── Tab Navigation ── */
.tab-nav {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px 24px;
  max-width: 1400px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
}
.tab-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.tab-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}
.tab-btn.active {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.4);
  color: var(--accent-light);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.1);
}
.tab-step {
  width: 20px; height: 20px;
  background: rgba(139, 92, 246, 0.2);
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-light);
}
.tab-btn.active .tab-step { background: var(--accent); color: white; }

.tab-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0 8px;
  flex-shrink: 0;
}

/* ── Tab Panels ── */
.app-main {
  position: relative;
  z-index: 5;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 40px;
}
.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* removed overflow:hidden — it was clipping scrollable inner lists */
  overflow: visible;
  transition: var(--transition);
  /* clip only the border-radius visually without blocking scroll */
  will-change: transform;
}
/* Re-apply clip only for canvases inside cards so they don't bleed */
.card .canvas-wrapper { border-radius: var(--radius-lg); overflow: hidden; }
.card:hover { border-color: var(--border-hover); }
/* Cards in the sidebar must not shrink — let the panel scroll instead */
.controls-panel .card { flex-shrink: 0; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.card-title svg { width: 16px; height: 16px; }
.card-body { padding: 16px 20px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent-dark);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}
.btn-primary:hover { background: var(--accent-light); box-shadow: 0 4px 16px rgba(139, 92, 246, 0.5); }

.btn-secondary {
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--cyan-light));
  color: #09090f;
  font-weight: 700;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  border: none;
}
.btn-accent:hover { transform: translateY(-1px); box-shadow: 0 8px 30px rgba(139, 92, 246, 0.6); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-hover); }

.full-width { width: 100%; justify-content: center; }

/* ── Form Elements ── */
.text-input, .select-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  transition: var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.text-input:focus, .select-input:focus { border-color: var(--border-active); background: rgba(139, 92, 246, 0.05); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1); }
.text-input.mono, .select-input.mono { font-family: var(--font-mono); }
.text-input.large { font-size: 1.1rem; padding: 12px 16px; }

.select-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4L6 8L10 4' stroke='%238b8ba7' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.select-input[multiple] { background-image: none; padding-right: 12px; min-height: 80px; }
.select-input option { background: #1a1a2e; color: var(--text-primary); }

.field-group { margin-bottom: 12px; }
.field-label { display: block; font-size: 0.78rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.field-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }

.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row .text-input { flex: 1; }

/* ── Panel Layout: NFA Builder ── */
.panel-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  height: calc(100vh - 180px);
  min-height: 600px;
}
/* Both grid children must have min-height:0 so overflow can activate */
.panel-layout > * { min-height: 0; }

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(139,92,246,0.4) transparent;
  padding-right: 6px;
  padding-bottom: 16px;
  /* fill the full grid cell height so overflow kicks in */
  height: 100%;
}
.controls-panel::-webkit-scrollbar { width: 5px; }
.controls-panel::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); border-radius: 4px; }
.controls-panel::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.35); border-radius: 4px; }
.controls-panel::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,0.6); }

.canvas-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

/* ── Canvas Toolbar ── */
.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 12px;
}
.canvas-label { font-size: 0.8rem; color: var(--text-muted); }
.toolbar-actions { display: flex; align-items: center; gap: 6px; }
.tool-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.tool-btn svg { width: 15px; height: 15px; }
.tool-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-hover); }
.tool-btn.active { background: rgba(139, 92, 246, 0.15); color: var(--accent-light); border-color: rgba(139, 92, 246, 0.4); }
.sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }

/* ── Canvas Wrapper ── */
.canvas-wrapper {
  flex: 1;
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: grab;          /* default: pan cursor for read-only canvases */
  min-height: 300px;
}
.canvas-wrapper canvas { display: block; width: 100%; height: 100%; }
/* Zoom hint badge pushed into bottom-right by JS */
.canvas-pan-hint {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  pointer-events: none;
  opacity: 0.6;
}
.canvas-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
  text-align: center;
  padding: 24px;
  transition: var(--transition);
}
.canvas-hint.hidden { opacity: 0; pointer-events: none; }
.hint-icon { font-size: 3rem; line-height: 1; filter: grayscale(0.3); }
.canvas-hint p { color: var(--text-muted); font-size: 0.9rem; }
.canvas-hint .hint-sub { font-size: 0.8rem; }
.link-btn { background: none; border: none; color: var(--accent-light); cursor: pointer; font-size: inherit; text-decoration: underline; pointer-events: auto; }

/* ── States List ── */
.states-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.state-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  transition: var(--transition);
}
.state-item:hover { border-color: var(--border-hover); }
.state-name { flex: 1; font-weight: 500; }
.state-badge {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-start { background: rgba(34, 211, 238, 0.15); color: var(--cyan); border: 1px solid rgba(34, 211, 238, 0.3); }
.badge-accept { background: rgba(74, 222, 128, 0.15); color: var(--green); border: 1px solid rgba(74, 222, 128, 0.3); }
.state-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.7rem;
  transition: var(--transition);
}
.icon-btn:hover { background: rgba(255,255,255,0.08); border-color: var(--border); color: var(--text-primary); }
.icon-btn.danger:hover { background: rgba(248, 113, 113, 0.1); color: var(--red); border-color: rgba(248, 113, 113, 0.3); }

/* ── Transitions List ── */
.transitions-list { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; max-height: 160px; overflow-y: auto; }
.transition-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.trans-from, .trans-to { color: var(--accent-light); font-weight: 600; }
.trans-sym { padding: 1px 6px; background: rgba(34, 211, 238, 0.1); color: var(--cyan); border-radius: 3px; font-weight: 600; }
.trans-arrow { color: var(--text-muted); }
.trans-del { margin-left: auto; }

/* ── Alphabet Preview ── */
.alphabet-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.alpha-chip {
  padding: 4px 10px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent-light);
  font-weight: 600;
}
.alpha-chip.epsilon { background: rgba(34, 211, 238, 0.1); border-color: rgba(34, 211, 238, 0.25); color: var(--cyan); }

/* ── Card Actions ── */
.card-actions .card-body { display: flex; flex-direction: column; gap: 10px; }

/* ── Convert Layout ── */
.convert-layout, .minimize-layout { padding-bottom: 24px; }
.convert-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.convert-controls { display: flex; gap: 10px; flex-wrap: wrap; }

.convert-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  grid-template-rows: auto auto;
  gap: 16px;
}
.step-log-card { max-height: 340px; overflow: hidden; display: flex; flex-direction: column; }
.step-log-card .card-header { flex-shrink: 0; }
.step-log {
  overflow-y: auto;
  flex: 1;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.step-log::-webkit-scrollbar { width: 4px; }
.step-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.step-entry {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  transition: var(--transition);
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
.step-entry.step-active { border-color: rgba(139, 92, 246, 0.3); background: rgba(139, 92, 246, 0.05); }
.step-entry.step-init { border-color: var(--border); }
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-top: 6px;
  flex-shrink: 0;
}
.step-active .step-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.step-content { flex: 1; min-width: 0; }
.step-label { font-size: 0.78rem; font-weight: 700; color: var(--accent-light); display: block; margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.05em; }
.step-content p { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }
.step-content code { font-family: var(--font-mono); background: rgba(255,255,255,0.07); padding: 1px 5px; border-radius: 3px; font-size: 0.8em; color: var(--cyan); }
.step-counter { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); background: rgba(255,255,255,0.05); padding: 3px 10px; border-radius: 4px; }

.dfa-graph-card { grid-column: 1 / -1; }
.dfa-graph-card .canvas-wrapper { height: 380px; border-radius: 0; border: none; }

.go-minimize-row { display: flex; justify-content: flex-end; margin-top: 20px; }

/* ── Table styles ── */
.table-scroll { overflow-x: auto; overflow-y: auto; max-height: 270px; padding: 12px; }
.table-scroll::-webkit-scrollbar { height: 4px; width: 4px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.subset-table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: nowrap;
}
.subset-table th {
  padding: 8px 12px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid var(--border);
  color: var(--accent-light);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}
.subset-table td {
  padding: 7px 12px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: background 0.3s;
}
.subset-table tr:hover td { background: rgba(255,255,255,0.03); }
.subset-table .td-state { font-weight: 600; color: var(--accent-light); }
.subset-table .td-accept { color: var(--green); }
.subset-table .td-new { background: rgba(139, 92, 246, 0.08); }
.subset-table .td-processing { background: rgba(251, 191, 36, 0.08); color: var(--yellow); }
.subset-table .td-mark { background: rgba(248, 113, 113, 0.08); color: var(--red); }
.subset-table .td-merge { background: rgba(74, 222, 128, 0.08); color: var(--green); }

.empty-table-hint { padding: 40px 24px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* ── Minimize Layout ── */
.minimize-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  grid-template-rows: auto auto;
  gap: 16px;
}
.minimize-grid .step-log-card { max-height: 300px; }

/* ── Equiv Classes ── */
#equiv-classes-container { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.equiv-class {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  animation: slideIn 0.3s ease;
}
.equiv-class.merged { background: rgba(74, 222, 128, 0.05); border-color: rgba(74, 222, 128, 0.25); }
.equiv-class.single { background: rgba(139, 92, 246, 0.05); border-color: rgba(139, 92, 246, 0.2); }
.equiv-class-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; min-width: 60px; }
.equiv-states { display: flex; gap: 6px; flex-wrap: wrap; }
.equiv-state-chip {
  padding: 3px 9px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255,255,255,0.07);
  color: var(--text-primary);
}

/* ── Test Layout ── */
.test-layout { display: flex; flex-direction: column; gap: 16px; }
.test-top { display: grid; grid-template-columns: 1fr auto; gap: 16px; }
.test-input-card .card-body { padding: 20px; }
.test-result-card { min-width: 220px; }
.test-result-body { height: 100%; display: flex; align-items: center; justify-content: center; }
.result-indicator { display: flex; align-items: center; gap: 16px; padding: 20px; }
.result-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  font-weight: 900;
  background: rgba(255,255,255,0.05);
  border: 2px solid var(--border);
  transition: var(--transition-slow);
  flex-shrink: 0;
}
.result-icon.accept { background: var(--green-glow); border-color: var(--green); color: var(--green); box-shadow: 0 0 20px var(--green-glow); }
.result-icon.reject { background: var(--red-glow); border-color: var(--red); color: var(--red); box-shadow: 0 0 20px var(--red-glow); }
.result-verdict { font-size: 1.1rem; font-weight: 700; transition: color 0.3s; }
.verdict-accept { color: var(--green); }
.verdict-reject { color: var(--red); }
.result-detail { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.test-automaton-selector { margin-bottom: 16px; }
.radio-group { display: flex; gap: 16px; margin-top: 6px; flex-wrap: wrap; }
.radio-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.875rem; color: var(--text-secondary); }
.radio-label input { accent-color: var(--accent); }
.radio-label:hover { color: var(--text-primary); }

.test-input-row { display: flex; gap: 10px; align-items: center; }
.test-input-row .text-input { flex: 1; }

.quick-tests { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.quick-test-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-chip {
  padding: 5px 12px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}
.quick-chip:hover { background: rgba(139, 92, 246, 0.1); border-color: rgba(139, 92, 246, 0.3); color: var(--accent-light); }
.quick-chip.accept { border-color: rgba(74, 222, 128, 0.3); color: var(--green); }
.quick-chip.reject { border-color: rgba(248, 113, 113, 0.3); color: var(--red); }

.test-bottom {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  min-height: 0;
}
.test-bottom .dfa-graph-card .canvas-wrapper { height: 400px; border-radius: 0; border: none; }

/* ── Trace ── */
.trace-container {
  overflow-y: auto;
  max-height: 200px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.trace-container::-webkit-scrollbar { width: 4px; }
.trace-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.trace-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border: 1px solid transparent;
  transition: background 0.3s;
  animation: slideIn 0.2s ease;
}
.trace-step.active { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.25); }
.trace-step.done { background: rgba(74, 222, 128, 0.05); border-color: rgba(74, 222, 128, 0.15); }
.trace-step.dead { background: rgba(248, 113, 113, 0.05); border-color: rgba(248, 113, 113, 0.15); }
.trace-idx { width: 20px; text-align: center; color: var(--text-muted); font-size: 0.72rem; }
.trace-state { color: var(--accent-light); font-weight: 600; min-width: 60px; }
.trace-sym { padding: 1px 6px; background: rgba(34, 211, 238, 0.1); color: var(--cyan); border-radius: 3px; }
.trace-arrow { color: var(--text-muted); }
.trace-next { color: var(--text-secondary); font-weight: 500; }
.trace-end { color: var(--text-muted); font-size: 0.72rem; font-style: italic; }

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  font-size: 0.82rem;
  border: 1px solid var(--border);
  animation: slideIn 0.2s ease;
}
.history-string { font-family: var(--font-mono); flex: 1; color: var(--text-secondary); }
.history-string.empty-str { color: var(--text-muted); font-style: italic; }
.history-verdict { font-weight: 700; font-size: 0.75rem; padding: 2px 8px; border-radius: 4px; }
.verdict-accept { background: rgba(74, 222, 128, 0.12); color: var(--green); }
.verdict-reject { background: rgba(248, 113, 113, 0.12); color: var(--red); }

/* ── Playback Controls ── */
.playback-controls { display: flex; gap: 4px; }

/* ── Dialog ── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.dialog {
  background: #13131f;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  min-width: 360px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: dialogIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes dialogIn { from { opacity: 0; transform: scale(0.9) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.dialog-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.dialog-desc { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 18px; }
.symbol-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.sym-chip {
  padding: 8px 16px;
  background: rgba(255,255,255,0.04);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}
.sym-chip:hover { border-color: var(--accent-light); color: var(--accent-light); background: rgba(139, 92, 246, 0.08); }
.sym-chip.selected { border-color: var(--accent); background: rgba(139, 92, 246, 0.15); color: var(--accent-light); box-shadow: 0 0 12px var(--accent-glow); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 18px;
  background: rgba(20, 20, 32, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  font-size: 0.875rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 340px;
}
.toast.success { border-color: rgba(74, 222, 128, 0.4); }
.toast.error { border-color: rgba(248, 113, 113, 0.4); }
.toast.info { border-color: rgba(139, 92, 246, 0.4); }
.toast-icon { font-size: 1rem; flex-shrink: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px) scale(0.9); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(30px); } }
.toast.removing { animation: toastOut 0.2s ease forwards; }

/* ── Scrollbar Global ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .panel-layout { grid-template-columns: 280px 1fr; }
  .convert-grid, .minimize-grid { grid-template-columns: 1fr; }
  .dfa-graph-card { grid-column: 1; }
  .test-top { grid-template-columns: 1fr; }
  .test-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .panel-layout { grid-template-columns: 1fr; height: auto; }
  .controls-panel { max-height: none; }
  .app-main { padding: 0 12px 40px; }
  .tab-nav { padding: 12px; }
  .header-inner { padding: 12px; }
  .convert-header-row { flex-direction: column; align-items: flex-start; }
  .logo-sub { display: none; }
}

/* ── NFA canvas cursor modes ── */
.canvas-wrapper.mode-addstate { cursor: crosshair; }
.canvas-wrapper.mode-edge { cursor: cell; }
.canvas-wrapper.mode-select { cursor: default; }
.canvas-wrapper.mode-drag { cursor: grabbing; }

/* ══════════════════════════════════════════════════════════
   PDA Simulator Panel
   ══════════════════════════════════════════════════════════ */

.pda-layout { padding-bottom: 32px; }
.pda-grid { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }

.pda-left {
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto; max-height: calc(100vh - 180px);
  scrollbar-width: thin; scrollbar-color: rgba(139,92,246,0.35) transparent; padding-right: 4px;
}
.pda-left::-webkit-scrollbar { width: 5px; }
.pda-left::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.35); border-radius: 4px; }
.pda-right { display: flex; flex-direction: column; gap: 14px; }

.pda-info-grid { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: start; }
.mono-val { font-family: var(--font-mono); font-size: 0.82rem; color: var(--accent-light); }
.pda-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pda-state-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  background: rgba(139,92,246,0.08); border: 1px solid rgba(139,92,246,0.2);
  border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-primary);
}

.pda-form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }

.pda-verdict-box {
  padding: 14px 20px; border-radius: var(--radius); display: flex; align-items: center;
  justify-content: center; min-height: 52px; font-size: 1.15rem; font-weight: 800;
  letter-spacing: 0.06em; border: 2px solid var(--border);
  background: rgba(255,255,255,0.02); transition: all 0.3s ease;
}
.pda-verdict-box.verdict-accept { background: rgba(74,222,128,0.07); border-color: var(--green); color: var(--green); box-shadow: 0 0 24px rgba(74,222,128,0.15); }
.pda-verdict-box.verdict-reject { background: rgba(248,113,113,0.07); border-color: var(--red);   color: var(--red);   box-shadow: 0 0 24px rgba(248,113,113,0.15); }

.pda-config-row { display: grid; grid-template-columns: auto auto 1fr; gap: 20px; align-items: start; }
.pda-config-item { display: flex; flex-direction: column; gap: 6px; }
.pda-pill {
  padding: 6px 14px; border-radius: var(--radius-sm);
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.3);
  font-family: var(--font-mono); font-size: 0.9rem; font-weight: 600;
  color: var(--accent-light); min-width: 60px; text-align: center;
}

.pda-stack { display: flex; flex-direction: column; gap: 3px; max-height: 200px; overflow-y: auto; }
.stack-empty { color: var(--text-muted); font-size: 0.8rem; font-style: italic; text-align: center; padding: 8px; }
.stack-cell {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px;
  border-radius: var(--radius-sm); background: rgba(255,255,255,0.04);
  border: 1px solid var(--border); animation: slideIn 0.2s ease;
}
.stack-cell.stack-top { background: rgba(139,92,246,0.12); border-color: rgba(139,92,246,0.35); }
.stack-sym { font-family: var(--font-mono); font-size: 0.9rem; font-weight: 700; color: var(--text-primary); flex: 1; text-align: center; }
.stack-label { font-size: 0.62rem; color: var(--accent-light); text-transform: uppercase; letter-spacing: 0.06em; }

tr.active td { background: rgba(251,191,36,0.1) !important; }

@media (max-width: 1100px) {
  .pda-grid { grid-template-columns: 1fr; }
  .pda-left { max-height: none; overflow-y: visible; }
  .pda-form-row { grid-template-columns: 1fr 1fr; }
  .pda-config-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .pda-form-row { grid-template-columns: 1fr; }
  .pda-config-row { grid-template-columns: 1fr; }
}
