:root {
  color-scheme: dark;
  --bg: #08111f;
  --panel: #142033;
  --panel-2: #182844;
  --card: #1f3470;
  --card-soft: #162235;
  --border: #30435f;
  --text: #e5eefc;
  --muted: #9fb1cf;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 18px 48px rgba(2, 6, 23, 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.25), transparent 32%),
    radial-gradient(circle at top right, rgba(139, 92, 246, 0.18), transparent 26%),
    var(--bg);
  color: var(--text);
}

body {
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  background: var(--card-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
}

button,
select,
input {
  min-height: 46px;
}

button {
  cursor: pointer;
  padding: 0.75rem 1rem;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

button:hover,
select:hover,
input:hover,
textarea:hover {
  border-color: rgba(129, 140, 248, 0.7);
}

button:hover {
  transform: translateY(-1px);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.sequence:focus-visible,
.branch-target:focus-visible,
.node-select:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.4);
  outline-offset: 2px;
}

textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  padding: 0.9rem 1rem;
}

input,
select {
  width: 100%;
  padding: 0 0.95rem;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
  padding: 0;
  accent-color: var(--warning);
}

pre {
  margin: 0;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-x: auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.95rem;
}

.app {
  max-width: 2600px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.panel {
  background: linear-gradient(180deg, rgba(24, 40, 68, 0.96), rgba(20, 32, 51, 0.96));
  border: 1px solid rgba(72, 93, 125, 0.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.topbar {
  padding: 0.65rem 0.85rem;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) auto 240px;
  gap: 1rem;
  align-items: center;
}

.topbar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.topbar-nav a {
  display: inline-flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(129, 140, 248, 0.28);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.38);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.topbar-nav a:hover {
  border-color: rgba(196, 181, 253, 0.72);
  text-decoration: none;
}

.topbar-nav span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.home-seo-links a small {
  margin-top: 0.35rem;
  color: #c4b5fd;
  font-size: 0.78rem;
  font-weight: 800;
}

.topbar-language-only {
  grid-template-columns: 1fr;
}

.topbar-language-only label {
  gap: 0.28rem;
}

.topbar-language-only select {
  min-width: 160px;
}

.topbar h1 {
  font-size: clamp(1.35rem, 2vw, 1.85rem);
}

.tagline {
  font-size: 0.92rem;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.brand-copy {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}

.topbar .site-title,
.tagline {
  white-space: nowrap;
}

.site-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  flex-shrink: 0;
}

.eyebrow {
  color: #a5b4fc;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
}

.tagline,
.note,
.empty-state,
.label {
  color: var(--muted);
}

.topbar-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  justify-self: end;
  width: 240px;
}

.topbar-actions label,
.toolbar-field,
.sidebar-left .stack-section,
.sidebar-right .stack-section {
  display: grid;
  gap: 0.4rem;
}

.label {
  font-size: 0.9rem;
}

.toolbar {
  position: sticky;
  /* top: 0.75rem; */
  top: 0.05rem;
  z-index: 50;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.toolbar-field {
  min-width: 160px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-left: auto;
}

.toolbar button {
  min-height: 42px;
  padding: 0.6rem 0.85rem;
}

.flags-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.flag-chip {
  min-height: 38px;
  /* padding: 0.42rem 0.65rem; */
}

.toolbar-field-wide {
  flex: 1 1 260px;
}

.flag-chip,
.chip,
.status-chip,
.small-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.75rem;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.small-chip {
  font-size: 0.78rem;
  padding: 0.25rem 0.55rem;
}

.layout {
  display: grid;
  /* grid-template-columns: 290px minmax(0, 1fr) 390px; */
  grid-template-columns: 340px minmax(0, 1fr) 460px;
  gap: 1rem;
  align-items: start;
}

.sidebar-left,
.main-panel,
.sidebar-right {
  padding: 1.15rem;
}

.sidebar-left,
.sidebar-right {
  position: sticky;
  top: 130px;
  align-self: start;

  max-height: calc(100vh - 145px);
  overflow-y: auto;

  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.sidebar-left,
.sidebar-right {
  display: grid;
  gap: 1rem;
}

.main-panel {
  overflow: visible;
  align-self: start;
}

.stack-section {
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem;
  border: 1px solid rgba(88, 110, 145, 0.72);
  border-radius: 18px;
  background: rgba(8, 17, 31, 0.42);
}

.stack-section h2 {
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.55);
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.stack-section h2::after {
  content: "−";
  color: var(--muted);
  font-weight: 700;
}

.item {
  width: 100%;
  text-align: left;
  padding: 0.85rem 0.9rem;
}

.stack-section.is-collapsed h2::after {
  content: "+";
}

.stack-section.is-collapsed > :not(h2) {
  display: none !important;
}

.main-panel {
  display: grid;
  gap: 1.1rem;
}

.workspace-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.builder-tree {
  display: grid;
  gap: 0.95rem;
}

.builder-container {
  display: grid;
  padding: 0.75rem;
  gap: 0.65rem;
  border: 1px solid rgba(71, 85, 105, 0.65);
  border-radius: 22px;
  background: rgba(8, 15, 30, 0.6);
}

.builder-root {
  background: linear-gradient(180deg, rgba(9, 16, 32, 0.75), rgba(15, 23, 42, 0.7));
}

.builder-nested {
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.58);
}

.builder-container-head {
  font-size: 0.9rem;
}

.builder-container-head,
.branch-head,
.match-head,
.compat-head,
.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.branch-list,
.editor-grid,
.result-grid,
.capture-grid,
.field-grid,
.wrap-actions,
.compat-list,
.compat-notes {
  display: grid;
  gap: 0.8rem;
}

.branch {
  display: grid;
  gap: 0.65rem;
  padding: 0.6rem;
  border-radius: 18px;
  border: 1px solid rgba(34, 50, 82, 0.85);
  background: rgba(15, 23, 42, 0.52);
}

.branch.is-active {
  border-color: rgba(129, 140, 248, 0.75);
  background: rgba(49, 46, 129, 0.18);
}

.branch-target,
.node-select,
.icon-button {
  background: transparent;
  min-height: auto;
  padding: 0;
  border: 0;
  color: inherit;
}

.branch-target {
  text-align: left;
  display: grid;
  gap: 0.12rem;
}

.node-select {
  text-align: left;
  display: block;
  width: 100%;
}

.sequence {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.6rem;
  min-height: 52px;
  border-radius: 16px;
  border: 1px dashed rgba(100, 116, 139, 0.75);
  background: rgba(2, 6, 23, 0.45);
}

.sequence-active {
  border-color: rgba(129, 140, 248, 0.9);
}

.empty-sequence {
  padding: 0.8rem;
  color: var(--muted);
}

.builder-node {
  flex: 0 1 180px;
  min-width: 180px;
}

.node-card {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.96));
  border: 1px solid var(--border);
  padding: 0.6rem;
  gap: 0.38rem;
  border-radius: 14px;
  display: grid;
  min-height: 100%;
}

.builder-node.is-selected .node-card {
  border-color: rgba(129, 140, 248, 0.9);
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.18) inset;
}

.node-title {
  font-size: 0.9rem;
}

.node-summary {
  color: var(--muted);
  font-size: 0.78rem;
}

.node-actions .icon-button {
  width: 1.75rem;
  height: 1.75rem;
  flex: 0 0 auto;
}

.node-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.icon-button {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid var(--border);
}

.secondary-button {
  background: rgba(15, 23, 42, 0.68);
}

.danger-button,
.warning-error {
  border-color: rgba(239, 68, 68, 0.55);
}

.node-children {
  display: grid;
  gap: 0.8rem;
}

.editor-grid,
.result-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-box {
  min-height: 220px;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(8, 15, 30, 0.78);
  overflow: auto;
  white-space: pre-wrap;
}

.split-row,
.match-card,
.capture-chip,
.warning,
.export-card,
.explain-line {
  border-radius: 16px;
}

.split-row {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
}

.match-card {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem;
  background: rgba(15, 23, 42, 0.74);
  border: 1px solid var(--border);
  margin-bottom: 0.85rem;
}

.match-value {
  padding: 0.85rem;
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.54);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.capture-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.capture-chip {
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0.8rem;
  background: rgba(2, 6, 23, 0.45);
  border: 1px solid rgba(51, 65, 85, 0.9);
}

.capture-chip em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.8rem;
}

.named-chip strong {
  color: #c4b5fd;
}

.warning {
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(71, 85, 105, 0.9);
  background: rgba(15, 23, 42, 0.7);
}

.warning-ok {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(20, 83, 45, 0.16);
}

.warning-warn {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(120, 53, 15, 0.16);
}

.warning-error {
  background: rgba(127, 29, 29, 0.18);
}

.warning-info {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(30, 64, 175, 0.16);
}

.explain-line {
  padding: 0.65rem 0.85rem;
  margin-left: calc(var(--depth, 0) * 0.8rem);
  background: rgba(15, 23, 42, 0.62);
  border: 1px solid rgba(51, 65, 85, 0.75);
}

.inspector-form,
.inspector-section {
  display: grid;
  gap: 0.85rem;
}

.field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid .span-2 {
  grid-column: span 2;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 46px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
}

.compat-head {
  margin-bottom: 0.75rem;
}

.export-card {
  overflow: hidden;
  border: 1px solid rgba(51, 65, 85, 0.9);
  background: rgba(15, 23, 42, 0.6);
}

.export-card summary {
  cursor: pointer;
  padding: 0.9rem 1rem;
  font-weight: 700;
}

mark {
  background: linear-gradient(90deg, rgba(129, 140, 248, 0.88), rgba(139, 92, 246, 0.88));
  color: white;
  border-radius: 8px;
  padding: 0.08rem 0.24rem;
}

.empty-match {
  display: inline-block;
  min-width: 1.3rem;
  text-align: center;
}

.hidden {
  display: none !important;
}

.dialog-box {
  width: min(760px, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 0;
  background: linear-gradient(180deg, rgba(17, 28, 52, 0.98), rgba(15, 23, 42, 0.98));
  color: var(--text);
}

.dialog-box::backdrop {
  background: rgba(2, 6, 23, 0.72);
}

.dialog-content {
  padding: 1rem;
  display: grid;
  gap: 0.9rem;
}

.dialog-textarea {
  min-height: 320px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  padding: 0;
  margin: 0;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  padding: 0.95rem 1.1rem;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(129, 140, 248, 0.55);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: min(440px, calc(100vw - 2rem));
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

[data-mode="beginner"] .sidebar-right .stack-section:nth-child(4),
[data-mode="beginner"] .sidebar-right .stack-section:nth-child(5) {
  opacity: 0.96;
}

@media (max-width: 1480px) {
  .layout {
    grid-template-columns: 260px minmax(0, 1fr) 340px;
  }
}

@media (max-width: 1240px) {
  .topbar,
  .toolbar,
  .layout,
  .editor-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .layout {
    align-items: stretch;
    height: auto;
    min-height: 0;
  }

  .sidebar-left,
  .main-panel,
  .sidebar-right {
    max-height: none;
    overflow-y: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}


/* =========================================================
   AVRB v2.0 - Targeted visual builder fixes
   ========================================================= */

.version-badge {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 0.6rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(129, 140, 248, 0.55);
  background: rgba(99, 102, 241, 0.16);
  color: #c4b5fd;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Le builder ne doit jamais déborder sur les côtés */
.builder-tree,
.builder-container,
.branch,
.sequence,
.builder-node,
.node-card,
.node-children {
  min-width: 0;
  max-width: 100%;
}

/* Structure globale du builder : plus lisible, moins "cartes qui se chevauchent" */
.builder-tree {
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 0.4rem;
}

.builder-node.is-atom-node {
  flex: 0 1 240px;
  min-width: 240px;
  max-width: 280px;
}

/* Les groupes / lookahead / alternatives prennent une vraie ligne complète */
.builder-node.is-container-node {
  flex: 1 1 100%;
  min-width: min(100%, 420px);
  max-width: 100%;
}

/* Les groupes imbriqués ne doivent plus se comporter comme des petites cartes écrasées */
.builder-node.is-container-node > .node-card {
  width: 100%;
  overflow: hidden;
}

/* Enfants de groupes : affichage vertical plus propre */
.builder-node.is-container-node .node-children {
  margin-top: 0.35rem;
  padding-left: 0.75rem;
  border-left: 2px solid rgba(129, 140, 248, 0.28);
}

/* Les containers imbriqués doivent respirer mais rester contenus */
.builder-node.is-container-node .builder-container {
  width: 100%;
  overflow: hidden;
}

.node-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;      /* Évite que les boutons prennent trop de place dans les blocs */
}

.node-delete-main {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
}

.node-title,
.node-summary {
  overflow-wrap: normal;
  word-break: normal;
  white-space: normal;
  display: block;
}

.node-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  margin-top: 0.15rem;
  align-items: center;
  gap: 0.35rem;
}

/* Les alternatives à l'intérieur d'un groupe sont mieux séparées */
.builder-nested .branch {
  background: rgba(2, 6, 23, 0.26);
}

.builder-nested .sequence {
  background: rgba(2, 6, 23, 0.34);
}

/* Changelog bas de page */
.changelog {
  padding: 1rem 1.2rem;
}

.changelog ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.changelog li {
  margin: 0.25rem 0;
}

/* Sur mobile, tous les blocs passent pleine largeur */
@media (max-width: 900px) {
  .app {
    padding: 0.75rem;
  }

  .topbar,
  .sidebar-left,
  .sidebar-right,
  .main-panel {
    padding: 1rem;
  }

  .sidebar-left,
  .sidebar-right {
    position: static;
    top: auto;
    max-height: none;
    overflow-y: visible;
    scrollbar-gutter: auto;
  }

  .toolbar {
    position: static;
    padding: 0.75rem;
    gap: 0.7rem;
  }

  .toolbar-field,
  .toolbar-field-wide {
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }

  .flags-bar {
    gap: 0.45rem;
  }

  .flag-chip {
    min-height: 38px;
    padding: 0.35rem 0.65rem;
  }

  .topbar-actions {
    grid-template-columns: 1fr;
  }

  .field-grid,
  .capture-grid {
    grid-template-columns: 1fr;
  }

  .field-grid .span-2 {
    grid-column: auto;
  }

  .builder-node,
  .builder-node.is-atom-node,
  .builder-node.is-container-node {
    flex: 1 1 100%;
    min-width: 100%;
    max-width: 100%;
  }

  .builder-node.is-container-node .node-children {
    padding-left: 0.45rem;
  }

  .version-badge {
    margin-left: 0.35rem;
  }

  .toolbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .toolbar-actions button {
    min-height: 42px;
    padding: 0.55rem 0.5rem;
    font-size: 0.92rem;
  }
}

@media (max-width: 480px) {
  .toolbar {
    padding: 0.65rem;
  }

  .toolbar-actions {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar-actions button {
    min-height: 38px;
    font-size: 0.86rem;
    padding: 0.45rem 0.4rem;
  }

  .flag-chip {
    min-height: 34px;
    padding: 0.3rem 0.55rem;
  }
}

@media (min-width: 1200px) and (min-resolution: 2dppx) {
  body {
    font-size: 10px;
  }

  .app {
    padding: 0.55rem;
    gap: 0.55rem;
  }

  .panel {
    border-radius: 12px;
    padding: 0.6rem;
  }

  .topbar {
    padding: 0.55rem 0.7rem;
  }

  .topbar h1 {
    font-size: 1.08rem;
  }

  .tagline,
  .label,
  .note,
  .empty-state {
    font-size: 0.68rem;
  }

  button,
  select,
  input,
  textarea {
    font-size: 0.72rem;
  }

  button,
  select,
  input {
    min-height: 34px;
  }

  .toolbar {
    padding: 0.55rem 0.65rem;
    gap: 0.45rem;
  }

  .toolbar button {
    min-height: 34px;
    padding: 0.4rem 0.62rem;
  }

  /* .layout {
    gap: 0.55rem;
    grid-template-columns: 300px minmax(0, 1fr) 390px;
  } */
  .layout {
    gap: 0.55rem;
    /* grid-template-columns: 300px minmax(0, 1fr) 390px; */
    grid-template-columns: 240px minmax(0, 1fr) 320px;    /* On agrandit la colonne centrale */
  }
  .sidebar-left,
  .main-panel,
  .sidebar-right {
    padding: 0.65rem;
  }

  .stack-section {
    padding: 0.45rem;
    gap: 0.45rem;
    border-radius: 12px;
  }

  .stack-section h2 {
    padding-bottom: 0.3rem;
    font-size: 0.78rem;
  }

  .item {
    padding: 0.42rem 0.55rem;
  }

  .builder-container,
  .branch,
  .sequence,
  .node-card {
    padding: 0.42rem;
    gap: 0.38rem;
    border-radius: 12px;
  }

  .builder-node.is-atom-node {
    flex: 0 1 200px;
    min-width: 200px;
    max-width: 230px;
  }

  .node-title {
    font-size: 0.74rem;
  }

  .node-summary {
    font-size: 0.65rem;
  }

  .icon-button,
  .node-actions .icon-button,
  .node-delete-main {
    width: 1.45rem;
    height: 1.45rem;
  }

  .result-box {
    min-height: 160px;
    padding: 0.65rem;
  }

  textarea {
    min-height: 120px;
    padding: 0.6rem;
  }

  .topbar .site-title {
    font-size: 1rem;
  }
}

/* =========================================================
   AVRB v2.4 - Toolbar history controls
   ========================================================= */

.toolbar-history-button {
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 0.35rem;
  row-gap: 0.05rem;
  align-items: center;
  justify-content: center;
  min-width: 76px;
}

.history-symbol {
  font-size: 1.05em;
  line-height: 1;
}

.history-info {
  grid-column: 1 / -1;
  display: block;
  max-width: 130px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button:disabled,
button[disabled] {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

button:disabled:hover,
button[disabled]:hover {
  border-color: var(--border);
  transform: none;
}

@media (max-width: 900px) {
  .toolbar-history-button {
    min-width: 0;
  }

  .history-info {
    max-width: 100%;
    font-size: 0.58rem;
  }
}

/* =========================================================
   AVRB v2.5 - Human explanation match diagnostics
   ========================================================= */

.match-diagnostic {
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.85rem;
  border: 1px solid rgba(51, 65, 85, 0.85);
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.35);
}

.diagnostic-panel-ok {
  border-color: rgba(34, 197, 94, 0.42);
  background: rgba(20, 83, 45, 0.14);
}

.diagnostic-panel-fail {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(127, 29, 29, 0.14);
}

.diagnostic-summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.diagnostic-steps {
  display: grid;
  gap: 0.4rem;
}

.diagnostic-step {
  display: grid;
  grid-template-columns: 1.35rem minmax(0, 1fr);
  gap: 0.5rem;
  align-items: start;
  margin-left: calc(var(--depth, 0) * 0.85rem);
  padding: 0.5rem 0.6rem;
  border-radius: 12px;
  border: 1px solid rgba(51, 65, 85, 0.68);
  background: rgba(15, 23, 42, 0.48);
}

.diagnostic-step strong {
  display: block;
  margin-bottom: 0.15rem;
}

.diagnostic-step code {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin-top: 0.25rem;
  color: #c4b5fd;
  font-size: 0.78rem;
  white-space: nowrap;
}

.diagnostic-step small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
}

.diagnostic-ok {
  border-color: rgba(34, 197, 94, 0.35);
}

.diagnostic-fail {
  border-color: rgba(239, 68, 68, 0.48);
}

.diagnostic-first-fail {
  display: inline-flex;
  margin-left: 0.4rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
  font-size: 0.72rem;
  font-weight: 700;
}

.diagnostic-icon {
  line-height: 1.35;
}

@media (max-width: 900px) {
  .diagnostic-step {
    margin-left: 0;
  }

  .diagnostic-step code {
    white-space: pre-wrap;
  }
}

/* =========================================================
   AVRB v2.6 - Merged explanation + diagnostics
   ========================================================= */

.compact-diagnostic {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.65rem;
}

.explain-line-diagnostic {
  display: grid;
  grid-template-columns: 1.4rem minmax(0, 1fr);
  gap: 0.55rem;
  align-items: start;
}

.explain-status-icon {
  line-height: 1.4;
}

.explain-line-body {
  min-width: 0;
}

.explain-main-text {
  font-weight: 600;
}

.explain-meta {
  display: grid;
  gap: 0.18rem;
  margin-top: 0.28rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.explain-meta code {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  color: #c4b5fd;
  font-size: 0.76rem;
  white-space: nowrap;
}

.explain-line-diagnostic.diagnostic-ok {
  border-color: rgba(34, 197, 94, 0.35);
}

.explain-line-diagnostic.diagnostic-fail {
  border-color: rgba(239, 68, 68, 0.48);
}

@media (max-width: 900px) {
  .explain-meta code {
    white-space: pre-wrap;
  }
}

/* =========================================================
   AVRB v3.2 - Static SEO content pages
   ========================================================= */

.content-page {
  padding: clamp(0.9rem, 1.6vw, 1.45rem);
  display: grid;
  gap: 0.9rem;
}

.content-breadcrumb {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.content-breadcrumb a {
  color: #c4b5fd;
  text-decoration: none;
}

.content-link-grid a {
  display: grid;
  gap: 0.35rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(51, 65, 85, 0.72);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.58);
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
}

.content-link-grid a span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.content-link-grid a small {
  display: inline-flex;
  margin-top: 0.25rem;
  color: #c4b5fd;
  font-size: 0.78rem;
  font-weight: 800;
}

.content-breadcrumb a:hover,
.content-link-grid a:hover {
  text-decoration: underline;
}

.content-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
}

.content-hero {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  /* max-width: 920px; */
  margin: 0 auto;
  text-align: center;
}

.content-hero .eyebrow {
  font-size: 0.7rem;
}

.content-hero h1 {
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  line-height: 1.05;
  max-width: 920px;
}

.content-intro {
  max-width: 760px;
  color: var(--muted);
  font-size: clamp(0.92rem, 1vw, 1.02rem);
  line-height: 1.55;
}

.content-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.15rem;
}

.content-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(129, 140, 248, 0.65);
  background: rgba(99, 102, 241, 0.18);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.content-button:hover {
  border-color: rgba(196, 181, 253, 0.9);
}

.content-card {
  display: grid;
  gap: 0.7rem;
  max-width: 1100px;
  padding: clamp(1rem, 1.5vw, 1.35rem);
  border: 1px solid rgba(51, 65, 85, 0.72);
  border-radius: 18px;
  background: rgba(2, 6, 23, 0.22);
}

.content-card p {
  color: var(--muted);
}

.content-card pre {
  max-width: 100%;
}

.content-related {
  margin-top: 0.4rem;
  justify-items: center;
  width: min(1400px, 100%);
  max-width: none;
  justify-self: center;
}

.content-related h2 {
  text-align: center;
}

.content-related .content-link-grid {
  width: 100%;
}

@media (max-width: 900px) {
  .content-page {
    padding: 1rem;
  }

  .site-logo {
    width: 42px;
    height: 42px;
  }

  .brand-wrap {
    gap: 0.75rem;
  }
}


/* =========================================================
   AVRB v3.2 - Open examples in Visual Builder
   ========================================================= */

.content-button-secondary {
  background: rgba(15, 23, 42, 0.68);
  border-color: rgba(99, 102, 241, 0.55);
}

.content-button-secondary::before {
  content: "🚀";
  margin-right: 0.45rem;
}


/* =========================================================
   AVRB v3.3 - Reusable mini playground
   ========================================================= */

.mini-playground {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid rgba(51, 65, 85, 0.72);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.mini-playground-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.mini-playground textarea {
  min-height: 110px;
}

.mini-playground-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid rgba(51, 65, 85, 0.8);
}

.mini-status-neutral {
  color: var(--muted);
  background: rgba(15, 23, 42, 0.7);
}

.mini-status-ok {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(20, 83, 45, 0.18);
}

.mini-status-fail {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(127, 29, 29, 0.18);
}

.mini-playground-preview {
  min-height: 72px;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.45);
  white-space: pre-wrap;
  overflow-x: auto;
}

.mini-playground-preview mark {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.82), rgba(99, 102, 241, 0.82));
}

.mini-playground-empty {
  color: var(--muted);
}


/* =========================================================
   AVRB v3.4 - Multi-example regex guide pages
   ========================================================= */

.content-examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
  gap: 1rem;
  align-items: start;
}

.regex-example-card {
  gap: 0.85rem;
  height: 100%;
  max-width: none;
}

.regex-example-head {
  display: grid;
  gap: 0.35rem;
}

.regex-example-head p {
  color: var(--muted);
}

.regex-example-list {
  display: grid;
  gap: 0.45rem;
}

.regex-example-list ul {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
}

.regex-example-list li {
  margin: 0.25rem 0;
}

.regex-example-list code {
  color: #c4b5fd;
}

.topbar .site-title {
  margin: 0;
  font-size: clamp(1.25rem, 1.65vw, 1.65rem);
  font-weight: 800;
  line-height: 1.15;
}

.site-title a {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
}

.site-title a:hover {
  color: var(--text);
  text-decoration: none;
}

/* =========================================================
   AVRB v3.5 - Homepage SEO content polish
   ========================================================= */

.seo-content {
  padding: clamp(1.2rem, 2vw, 2rem);
  display: grid;
  gap: 1.15rem;
}

.seo-content h2 {
  font-size: clamp(1.45rem, 2.2vw, 2rem);
  line-height: 1.15;
}

.seo-content p {
  max-width: 980px;
  color: var(--muted);
}

.home-seo-links {
  margin-top: 0.35rem;
}

.home-seo-links a {
  position: relative;
  display: grid;
  gap: 0.25rem;
  min-height: 86px;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(129, 140, 248, 0.34);
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(15, 23, 42, 0.62)),
    rgba(15, 23, 42, 0.72);
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
}

.home-seo-links a::after {
  content: "→";
  position: absolute;
  right: 1rem;
  top: 0.9rem;
  color: #c4b5fd;
  font-weight: 900;
}

.home-seo-links a:hover {
  border-color: rgba(196, 181, 253, 0.72);
  transform: translateY(-1px);
  text-decoration: none;
}

.home-seo-links a span {
  display: block;
  padding-right: 1.4rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

/* =========================================================
   AVRB v3.6 - Two-column guide sections
   ========================================================= */

.content-concepts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1rem;
  align-items: start;
}

.content-concepts .content-card {
  max-width: none;
  height: auto;
  align-self: start;
}

.site-footer {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.split-match-ok {
	color: #22c55e;
	font-weight: 600;
	margin-top: 0.5rem;
}

.split-match-fail {
	color: #ef4444;
	font-weight: 600;
	margin-top: 0.5rem;
}

.match-card .note {
	margin: 0.5rem 0 1rem;
	color: var(--muted);
	font-size: 0.9rem;
}

.split-row em {
	color: #f59e0b;
	font-style: italic;
}

.content-example-nav {
  max-width: none;
  /* width: min(860px, 100%); */
  width: 80%;
  margin: 0.45rem auto 0.35rem;
  padding: 0.75rem;
  border: 1px solid rgba(129, 140, 248, 0.28);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(15, 23, 42, 0.48)),
    rgba(8, 17, 31, 0.35);
}

.content-example-nav-title {
  margin-bottom: 0.55rem;
  color: #c4b5fd;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.content-example-nav-subtitle {
  margin: 0.7rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.content-example-nav-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.content-example-nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(129, 140, 248, 0.28);
  background: rgba(15, 23, 42, 0.62);
  color: var(--text);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
}

.content-example-nav-links a:hover {
  border-color: rgba(196, 181, 253, 0.78);
  background: rgba(24, 40, 68, 0.82);
  text-decoration: none;
  transform: translateY(-1px);
}

.content-seo-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1rem;
  align-items: start;
}

.content-seo-section {
  max-width: none;
  height: auto;
}

.content-seo-section h2 {
  font-size: 1.05rem;
  line-height: 1.25;
}

.content-seo-section p {
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 900px) {
  .content-seo-sections {
    grid-template-columns: 1fr;
  }
}

/******************* Regex Library *******************/
.regex-library-page {
  gap: 1rem;
}

.library-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.library-stats span,
.library-chip-list a,
.library-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid rgba(48, 67, 95, 0.85);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
}

.library-stats span {
  padding: 0.35rem 0.6rem;
}

.library-index {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.85rem;
  padding: 0.75rem;
  border: 1px solid rgba(48, 67, 95, 0.75);
  border-radius: 16px;
  background: rgba(8, 17, 31, 0.32);
}

.library-index h2 {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.library-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.library-chip-list a {
  padding: 0.3rem 0.55rem;
  text-decoration: none;
}

.library-chip-list a:hover {
  color: var(--text);
  border-color: rgba(129, 140, 248, 0.55);
  background: rgba(24, 40, 68, 0.72);
}

.library-chip-list small {
  color: #c4b5fd;
}

.library-section {
  display: grid;
  gap: 0.9rem;
}

.library-section > h2 {
  font-size: 1.25rem;
}

.library-category,
.library-tag-section {
  display: grid;
  gap: 0.7rem;
  scroll-margin-top: 1rem;
}

.library-category h3,
.library-tag-section h3 {
  color: var(--text);
  font-size: 1.05rem;
}

.library-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.85rem;
}

.library-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.9rem;
  border: 1px solid rgba(48, 67, 95, 0.75);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.48);
}

.library-card-title {
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.library-card-title:hover {
  color: #c4b5fd;
}

.library-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

.library-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.library-card-meta span {
  padding: 0.28rem 0.5rem;
}

.library-mini-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

.library-mini-list a {
  color: #c4b5fd;
  text-decoration: none;
}

.library-result-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.55rem;
}

.library-result-list a {
  display: grid;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(48, 67, 95, 0.75);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.42);
  color: var(--text);
  text-decoration: none;
}

.library-result-list span {
  color: var(--muted);
  font-size: 0.82rem;
}

.library-result-list small {
  color: #c4b5fd;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.library-category,
.library-tag-section {
  padding: 1rem;
  border: 1px solid rgba(48, 67, 95, 0.75);
  border-radius: 18px;
  background: rgba(8, 17, 31, 0.28);
}

.library-result-group {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
  border: 1px solid rgba(48, 67, 95, 0.55);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.35);
}

.library-result-group + .library-result-group {
  margin-top: 0.75rem;
}

.library-result-group h4 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
}

.library-result-group h4 span {
  display: inline-flex;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(129, 140, 248, 0.16);
  color: #c4b5fd;
  font-size: 0.72rem;
}
/******************* END Regex Library *******************/
