:root {
  --bg: #0b0f19;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: rgba(255,255,255,0.10);
  /* Hint browsers to render native form controls (including <select> dropdowns) in dark mode. */
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

code { color: #93c5fd; }
pre { margin: 0; }

.container {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 23, 42, 0.75);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 16px;
}

.brand .title { font-size: 18px; font-weight: 800; }
.brand .subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

.nav { display: flex; gap: 10px; align-items: center; flex-wrap: nowrap; }
.nav-link {
  text-decoration: none;
  color: #d1d5db;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.nav-link:hover { transform: translateY(-1px); border-color: rgba(255,255,255,0.20); background: rgba(255,255,255,0.06); }
.nav-link.active { border-color: rgba(59,130,246,0.55); background: rgba(59,130,246,0.18); }

.main { padding: 18px 0 10px; }

.page-head { margin: 8px 0 14px; }
.page-head h1 { margin: 0 0 6px; font-size: 22px; }
.page-sub { color: var(--muted); font-size: 13px; line-height: 1.45; }
.page-sub--tree{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 720px){
  .page-sub--tree{ white-space: normal; }
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

.panel {
  background: linear-gradient(180deg, rgba(17,24,39,0.95), rgba(15,23,42,0.95));
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
}

.panel-title {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 800;
  color: #cbd5e1;
  border-bottom: 1px solid var(--border);
  background: rgba(2,6,23,0.25);
}

.panel-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,0.20); background: rgba(255,255,255,0.06); }
.btn.primary { border-color: rgba(59,130,246,0.45); background: rgba(59,130,246,0.18); }
.btn.small { padding: 8px 10px; border-radius: 10px; font-size: 12px; }

.toolbar { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.badge {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.output {
  overflow: auto;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(2,6,23,0.55);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre;
}
.fixed-output { height: 520px; }

.examples { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 10px; }
.examples-title { font-size: 12px; font-weight: 800; color: #cbd5e1; margin-bottom: 8px; }
.examples-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.hint { font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; line-height: 1.45; }

.CodeMirror {
  height: 520px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(2,6,23,0.55);
  font-size: 12.5px;
  line-height: 1.45;
  overflow: hidden;
}

.graph-toolbar { display: flex; gap: 8px; align-items: center; }
.graph-canvas {
  height: 380px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(2,6,23,0.55);
  overflow: hidden;
}


.mini-title { margin-top: 8px; font-size: 12px; font-weight: 800; color: #cbd5e1; }
.entity-table-wrap {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: auto;
  max-height: 220px;
  background: rgba(2,6,23,0.35);
}
.entity-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.entity-table th, .entity-table td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  vertical-align: top;
}
.entity-table th { text-align: left; font-weight: 800; color: #cbd5e1; background: rgba(255,255,255,0.03); }

.doc h2 { margin: 18px 0 10px; font-size: 16px; }
.doc h3 { margin: 14px 0 8px; font-size: 14px; }
.codeblock {
  border: 1px solid var(--border);
  background: rgba(2,6,23,0.55);
  padding: 12px;
  border-radius: 14px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre;
}
.callout { border: 1px solid var(--border); background: rgba(255,255,255,0.03); padding: 12px; border-radius: 16px; margin: 10px 0; }
.callout-title { font-weight: 900; margin-bottom: 6px; }
.callout-body { color: #d1d5db; font-size: 13px; line-height: 1.45; }

.footer { color: var(--muted); font-size: 12px; padding: 14px 0 22px; }

.segmented { display: inline-flex; gap: 6px; padding: 4px; border: 1px solid var(--border); background: rgba(255,255,255,0.03); border-radius: 12px; }
.segmented .seg { border-radius: 10px; }
.segmented .seg.active { border-color: rgba(59,130,246,0.65); background: rgba(59,130,246,0.22); }

.fixed-output-small { height: 140px; }

.brand-link { color: var(--text); text-decoration: none; }
.brand-link:hover { text-decoration: underline; }

.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.tg-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
  text-decoration: none;
}
.tg-link:hover { background: rgba(15, 23, 42, 0.75); }
.tg-icon { width: 18px; height: 18px; fill: #93c5fd; }


/* Fallback editor (when CodeMirror is unavailable) */
.plain-editor {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.55);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  outline: none;
}
.plain-editor:focus { border-color: rgba(59, 130, 246, 0.65); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }

.feature-grid{
  margin: 14px 0 18px;
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 14px;
}

.feature-card{
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.35);
  padding: 16px 16px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  transform: translateZ(0);
}

.feature-card--big{
  grid-row: 1 / span 2;
  padding: 18px 18px 16px;
}

.feature-head{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.feature-title{
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0.1px;
}

.feature-title--sm{
  font-size: 16px;
}

.feature-text{
  margin: 0;
  line-height: 1.45;
  color: var(--muted); 
  font-size: 13px; 
  line-height: 1.45;
}

.feature-icon{
  width: 38px;
  height: 38px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.feature-icon svg{
  width: 18px;
  height: 18px;
  fill: #93c5fd;
}

.feature-tags{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.feature-tag{
  font-size: 12px;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.45);
  color: rgba(229, 231, 235, 0.92);
}

.feature-card::before{
  content: "";
  position: absolute;
  inset: -120px -160px auto auto;
  width: 420px;
  height: 320px;
  background: radial-gradient(closest-side, rgba(56, 189, 248, 0.18), transparent 70%);
  transform: translate3d(0,0,0);
  animation: glowDrift 8.5s ease-in-out infinite;
  pointer-events: none;
}

.feature-card::after{
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), transparent 55%);
  opacity: 0.55;
  pointer-events: none;
}

@keyframes glowDrift{
  0%   { transform: translate(0,0); opacity: 0.75; }
  50%  { transform: translate(-46px, 26px); opacity: 1; }
  100% { transform: translate(0,0); opacity: 0.75; }
}

.feature-card:hover{
  border-color: rgba(147, 197, 253, 0.45);
  box-shadow: 0 14px 40px rgba(0,0,0,0.28);
}

@media (max-width: 1100px){
  .feature-grid{
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
  }
  .feature-card--big{
    grid-row: auto;
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px){
  .feature-grid{
    grid-template-columns: 1fr;
  }
}

.topbar .title { min-width: 0; }

.topbar .title .brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar .title .brand-logo {
  display: block;
  height: 90px;
  width: auto;
  max-width: 100%;
  flex: 0 1 auto;
}

@media (max-width: 610px){
  .topbar-inner{
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 0;
  }

  .brand{ width: 100%; display: flex; justify-content: center; }

  .topbar .title .brand-logo{
    height: clamp(56px, 10vw, 76px);
  }

  .nav{
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-link{
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .nav::-webkit-scrollbar{ height: 0; }
}

@media (max-width: 610px) {
  .graph-toolbar {
    gap: 6px;
  }

  .graph-toolbar .spacer {
    display: none;
  }

  .graph-toolbar .btn.small {
    padding: 7px 9px;
    font-size: 12px;
    border-radius: 10px;
  }

  .toolbar {
    gap: 6px;
  }

  .toolbar .spacer {
    display: none;
  }

  .toolbar .btn.small {
    padding: 7px 9px;
    font-size: 12px;
    border-radius: 10px;
  }
}

/* Fullscreen graph overlay (enterprise mode) */
.fs-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9999;
  display: none;
}
.fs-backdrop.show{ display: block; }

/* Fullscreen close button lives inside the graph panel header */
#graphPanel .panel-title--graph{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
#graphPanel .panel-title-text{
  flex: 1;
  min-width: 0;
}

.panel-close{
  display: none;
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  width: 40px;
  height: 34px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 22px;
  line-height: 32px;
  padding: 0;
}
.panel-close:hover{ border-color: rgba(255,255,255,0.20); background: rgba(255,255,255,0.06); }
#graphPanel.is-fullscreen .panel-close{
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Export format switch (SVG/PNG) */
.save-switch{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
}
.save-switch-label{
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.switch{
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input{
  opacity: 0;
  width: 0;
  height: 0;
}
.slider{
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 120ms ease, border-color 120ms ease;
}
.slider:before{
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 999px;
  background: rgba(229,231,235,0.92);
  transition: transform 120ms ease;
}
.switch input:checked + .slider{
  background: rgba(59,130,246,0.20);
  border-color: rgba(59,130,246,0.45);
}
.switch input:checked + .slider:before{
  transform: translateX(20px);
}



/* Compact export switch on small screens (shrink ONLY the SVG/PNG switch) */
@media (max-width: 420px){
  .save-switch{
    gap: 4px;
    padding: 1px 4px;
    border-radius: 10px;
  }
  .save-switch-label{
    font-size: 9px;
    line-height: 1;
  }
  .switch{
    width: 32px;
    height: 18px;
  }
  .slider:before{
    width: 12px;
    height: 12px;
    left: 2px;
    top: 2px;
  }
  .switch input:checked + .slider:before{
    transform: translateX(16px);
  }
}

@media (max-width: 360px){
  .save-switch{
    gap: 3px;
    padding: 1px 3px;
    border-radius: 9px;
  }
  .save-switch-label{
    font-size: 8px;
  }
  .switch{
    width: 28px;
    height: 16px;
  }
  .slider:before{
    width: 10px;
    height: 10px;
    left: 2px;
    top: 2px;
  }
  .switch input:checked + .slider:before{
    transform: translateX(14px);
  }
}
/* Graph panel moved into the backdrop while fullscreen is active */
#graphPanel.is-fullscreen{
  position: absolute;
  inset: 18px;
  z-index: 2;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
}

/* Fullscreen: show only the diagram + toolbar (hide the entities table block) */
#graphPanel.is-fullscreen .mini-title,
#graphPanel.is-fullscreen .entity-table-wrap,
#graphPanel.is-fullscreen .hint{
  display: none !important;
}

/* Fullscreen sizing: make the Cytoscape canvas consume the remaining height */
#graphPanel.is-fullscreen .panel-body{
  flex: 1;
  min-height: 0;
}
#graphPanel.is-fullscreen .graph-canvas{
  flex: 1;
  height: auto;
  min-height: 0;
}

/* -------- Tree Model (dependency tree) -------- */
.graph-toolbar--tree{ gap: 8px; }

.input{
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
}
.input:focus{
  border-color: rgba(59,130,246,0.55);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.input.small{ padding: 7px 10px; font-size: 12px; }

.select{
  -webkit-appearance: none;
  appearance: none;
  color-scheme: dark;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 34px 8px 10px;
  outline: none;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(229,231,235,0.9) 50%),
    linear-gradient(135deg, rgba(229,231,235,0.9) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 11px) 50%;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
}
.select option{
  background-color: rgba(15, 23, 42, 0.98) !important;
  color: var(--text) !important;
}
.select option:checked{
  background-color: rgba(30, 41, 59, 0.95) !important;
  color: var(--text) !important;
}
.select option:hover{
  background-color: rgba(30, 41, 59, 0.65) !important;
  color: var(--text) !important;
}
.select:focus{
  border-color: rgba(71, 85, 105, 0.75);
  box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.35);
}

/* Text selection inside native select (best-effort across browsers) */
.select::selection{ background: rgba(30, 41, 59, 0.85); color: var(--text); }
.select option::selection{ background: rgba(30, 41, 59, 0.85); color: var(--text); }
.select.small{ padding: 7px 34px 7px 10px; font-size: 12px; }

.tree-search{
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 10px;
}
.tree-search-row{
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.tree-search-row .select{ flex: 1; min-width: 180px; }
.tree-search-hint{ font-size: 12px; color: var(--muted); margin-top: 6px; }

.tree-wrap{
  flex: 1;
  min-height: 240px;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 10px;
}

.tree-view,
.tree-view ul{
  list-style: none;
  margin: 0;
  padding-left: 0;
}
.tree-view ul{ padding-left: 22px; margin-top: 6px; }

.tree-node{ margin: 4px 0; }
.tree-row{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 12px;
}
.tree-row:hover{ background: rgba(255,255,255,0.05); }

.tree-toggle{
  width: 20px;
  height: 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-weight: 800;
  user-select: none;
}
.tree-toggle[aria-expanded="true"]{ background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.35); }
.tree-toggle.is-leaf{ opacity: 0.35; cursor: default; }

.tree-label{
  font-size: 12px;
  color: var(--text);
  word-break: break-word;
}
.tree-badge{
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(255,255,255,0.04);
}
.tree-badge.cte{ border-color: rgba(59,130,246,0.45); color: rgba(147,197,253,0.95); }

.tree-node.is-collapsed > ul{ display: none; }

.tree-node.is-hit > .tree-row{
  background: rgba(59,130,246,0.14);
  border: 1px solid rgba(59,130,246,0.32);
}

.trace-wrap{
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 10px;
  font-size: 12px;
  color: var(--text);
  overflow: auto;
  max-height: 220px;
}
.trace-item{ padding: 6px 8px; border-radius: 12px; }
.trace-item:hover{ background: rgba(255,255,255,0.05); }
.trace-item .muted{ color: var(--muted); }
.trace-path{ white-space: normal; word-break: break-word; }

/* Fullscreen: keep Tree-only blocks visible */
#graphPanel.is-fullscreen .mini-title.tree-mini-title,
#graphPanel.is-fullscreen .hint.tree-hint{
  display: block !important;
}

@media (max-width: 420px){
  .tree-search-row .select{ min-width: 140px; }
  .tree-wrap{ max-height: 420px; }
}


/* ===== ER diagram editing (fullscreen only) ===== */
.er-fs-only{ display:none; }
#graphPanel.is-fullscreen .er-fs-only{ display:inline-flex; }

#erEditBar.er-editbar{ display:none; margin:10px 0 10px; padding:10px 12px; border:1px solid var(--border); background: rgba(255,255,255,0.03); border-radius:14px; align-items:center; justify-content:space-between; gap:12px; }
#graphPanel.is-fullscreen.is-editing #erEditBar{ display:flex; }
#graphPanel.is-editing .graph-canvas{ outline:1px dashed rgba(255,255,255,0.18); outline-offset:-8px; border-radius:14px; }

.er-editbar-left{ display:flex; align-items:center; gap:10px; min-width: 0; }
.er-editbadge{ font-size:11px; font-weight:800; letter-spacing:.7px; color:#111827; background:#fbbf24; padding:4px 8px; border-radius:999px; flex:0 0 auto; }
.er-edithint{ font-size:12px; color: var(--muted); opacity:.9; white-space: nowrap; overflow:hidden; text-overflow: ellipsis; }
.er-editbar-right{ display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.btn.danger{ border-color: rgba(239,68,68,0.55); color: #fecaca; }
.btn.danger:hover{ background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.7); }
#graphPanel .btn.small.active{ border-color: rgba(59,130,246,0.55); background: rgba(59,130,246,0.14); }

.er-toast-stack{ position: fixed; right: 18px; bottom: 18px; display:flex; flex-direction:column; gap:10px; z-index: 10050; pointer-events:none; }
.er-toast{ pointer-events:auto; min-width: 240px; max-width: 360px; border:1px solid var(--border); background: rgba(17,24,39,0.92); backdrop-filter: blur(8px); border-radius:16px; padding:10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
.er-toast-title{ font-weight:800; font-size:12px; letter-spacing:.2px; margin:0 0 4px; }
.er-toast-msg{ margin:0; font-size:12px; color: var(--text); opacity:.9; line-height:1.35; }
.er-toast--ok{ border-color: rgba(16,185,129,0.45); }
.er-toast--warn{ border-color: rgba(245,158,11,0.55); }
.er-toast--err{ border-color: rgba(239,68,68,0.6); }
.er-toast-actions{ margin-top:8px; display:flex; gap:8px; justify-content:flex-end; }

.er-modal-backdrop{ position: fixed; inset:0; z-index:10040; display:none; background: rgba(0,0,0,0.55); }
.er-modal-backdrop.show{ display:flex; align-items:center; justify-content:center; padding:18px; }
.er-modal{ width: min(720px, 96vw); max-height: 90vh; overflow:hidden; border:1px solid var(--border); background: rgba(17,24,39,0.95); border-radius:18px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.er-modal-head{ display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid var(--border); gap: 10px; }
.er-modal-title{ font-weight:800; font-size:13px; }
.er-modal-close{ appearance:none; border:1px solid var(--border); background: rgba(255,255,255,0.04); color: var(--text); width:40px; height:34px; border-radius:12px; cursor:pointer; font-size:22px; line-height:30px; padding:0; }
.er-modal-close:hover{ border-color: rgba(255,255,255,0.20); background: rgba(255,255,255,0.06); }
.er-modal-body{ padding:14px; overflow:auto; max-height: calc(90vh - 120px); }
.er-modal-foot{ padding:12px 14px; border-top:1px solid var(--border); display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap; }
.er-form-row{ display:grid; grid-template-columns: 170px 1fr; gap:10px; align-items:start; margin-bottom:10px; }
.er-form-row label{ font-size:12px; color: var(--muted); padding-top:8px; }
.er-input,.er-select,.er-textarea{ width:100%; border:1px solid var(--border); background: rgba(255,255,255,0.03); color: var(--text); border-radius:12px; padding:10px 12px; font-size:13px; outline:none; color-scheme: dark; }
.er-textarea{ min-height:140px; resize:vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size:12px; line-height:1.35; }

.er-select option{ background: var(--bg); color: var(--text); }
.er-input:focus,.er-select:focus,.er-textarea:focus{ border-color: rgba(59,130,246,0.55); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.er-muted{ color: var(--muted); font-size:12px; opacity:.85; line-height:1.45; margin-top:6px; }
@media (max-width: 560px){ .er-form-row{ grid-template-columns: 1fr; } .er-editbar-left{ width:100%; } .er-edithint{ white-space: normal; } #erEditBar.er-editbar{ align-items:flex-start; flex-direction:column; } .er-editbar-right{ width:100%; justify-content:flex-start; } }


/* =========================
   API Docs (business style)
   ========================= */

.api-head { margin-bottom: 10px; }

.api-kv-grid{
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}
.api-kv{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  border-radius: 16px;
  padding: 12px 12px 10px;
}
.api-kv-k{
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.api-kv-v{
  font-size: 13px;
  font-weight: 800;
  color: #e5e7eb;
}

.api-layout{
  margin-top: 14px;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  /* sidebar (toc) + content */
  gap: 16px;
  align-items: start;
}

.api-toc{
  display: block;
  padding: 0;
  margin: 0;
}
.api-toc-title{ display: none; }
.api-toc-link{
  display: block;
  text-decoration: none;
  color: #d1d5db;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
}
.api-toc-link:hover{
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}
.api-toc-link--indent{
  padding-left: 20px;
  color: #cbd5e1;
  font-size: 12.5px;
}

.api-note{
  margin-top: 12px;
  border: 1px solid var(--border);
  background: rgba(59,130,246,0.10);
  border-radius: 18px;
  padding: 12px;
}
.api-note-title{
  font-weight: 900;
  margin-bottom: 6px;
}
.api-note-body{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.api-section h2{
  margin: 18px 0 10px;
  font-size: 16px;
}
.api-lead{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 10px;
}

.api-card{
  border: 1px solid var(--border);
  background: rgba(2,6,23,0.40);
  border-radius: 18px;
  padding: 12px;
}
.api-card-title{
  font-weight: 900;
  font-size: 13px;
  color: #cbd5e1;
  margin-bottom: 8px;
}
.api-card-body{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.api-card-footnote{
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.endpoint{
  margin-top: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.26);
  border-radius: 18px;
  padding: 12px;
}
.endpoint-head{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.endpoint-path{
  font-weight: 900;
  font-size: 14px;
}
.endpoint-badge{
  border: 1px solid rgba(147,197,253,0.35);
  background: rgba(147,197,253,0.12);
  color: #dbeafe;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.endpoint-desc{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 12px;
}
.endpoint-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.http-method{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
}
.http-method--post{
  border-color: rgba(34,197,94,0.45);
  background: rgba(34,197,94,0.12);
  color: #bbf7d0;
}

.param-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.param-table th, .param-table td{
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  vertical-align: top;
}
.param-table th{
  text-align: left;
  font-weight: 900;
  color: #cbd5e1;
  background: rgba(255,255,255,0.03);
}

.api-details{
  margin-top: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  border-radius: 16px;
  padding: 10px 12px;
}
.api-details > summary{
  cursor: pointer;
  font-weight: 900;
  color: #e5e7eb;
}
.api-details-body{
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.api-list{
  margin: 8px 0 0;
  padding-left: 18px;
}
.api-list li{ margin: 6px 0; }

.api-section, .endpoint{ scroll-margin-top: 125px; }

/* =========================
   API Docs — mobile hardening
   (fix overflow / horizontal scroll)
   ========================= */

.api-layout,
.api-content,
.endpoint,
.endpoint-grid,
.endpoint-grid > *,
.api-card,
.api-kv,
.api-toc,
.api-note {
  min-width: 0;
}

.endpoint-path,
.api-kv-v,
.api-note-body,
.api-card-title,
.api-lead {
  overflow-wrap: break-word;
  word-break: normal;
}

.codeblock {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Tables: keep the table layout intact and scroll on small screens.
   Avoid display:block on <table> (it can make text look "vertical" due to ultra-narrow cells). */
.table-scroll{
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
}

.table-scroll .param-table{
  margin: 0;
  min-width: 680px;
}

.table-scroll .param-table th,
.table-scroll .param-table td{
  white-space: nowrap;
}

.table-scroll .param-table th:last-child,
.table-scroll .param-table td:last-child{
  white-space: normal;
  min-width: 280px;
}

@media (max-width: 1100px){
  .api-kv-grid{ grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .endpoint-grid{ grid-template-columns: 1fr; }
}

@media (max-width: 720px){
  .api-kv-grid{ grid-template-columns: 1fr; }
  .api-kv, .api-card, .endpoint{ padding: 10px; }
  .codeblock{ font-size: 11.5px; padding: 10px; }
}


/* =========================
   API Docs — layout + mobile polish (futuristic + readable)
   ========================= */

.api-layout{
  grid-template-columns: 320px minmax(0, 1fr);
}

.api-side{
  position: sticky;
  top: 125px; /* below topbar */
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 16px; /* единый вертикальный ритм панелей */
}

.api-hero{
  position: relative;
  overflow: hidden;
}
.api-hero::before{
  content:"";
  position: absolute;
  inset: -40% -20%;
  pointer-events: none;
  background:
    radial-gradient(600px 260px at 16% 10%, rgba(56,189,248,0.12), transparent 60%),
    radial-gradient(520px 240px at 84% 18%, rgba(99,102,241,0.11), transparent 62%);
  opacity: 0.9;
}
.api-hero > *{ position: relative; z-index: 1; }

.api-details > summary{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.api-details > summary code,
.api-details-body code,
.api-lead code{
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

.codeblock{
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

@media (max-width: 1100px){
  .api-layout{ grid-template-columns: 1fr; }
  .api-side{ position: static; }
}

@media (max-width: 720px){
  .api-toc--desktop{ display: block; }
  .api-toc--mobile{ display: none; }
  .api-tocPanelTitle{ display: block; }
}

/* =========================
   Bottom FAQ (panel-style)
   ========================= */

.faqBlock{ margin-top: 16px; }
.faqBlock-body{ gap: 0; }

.faqBlock-item{
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.faqBlock-item:last-child{ border-bottom: 0; }

.faqBlock-sum{
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 32px;
  align-items: center;
  gap: 12px;

  padding: 12px 10px;
  cursor: pointer;
  user-select: none;
  border-radius: 14px;
}
.faqBlock-sum::-webkit-details-marker{ display:none; }

.faqBlock-sum:hover{ background: rgba(255,255,255,0.03); }

.faqBlock-sum:focus-visible{
  outline: 2px solid rgba(147,197,253,0.45);
  outline-offset: 3px;
}

.faqBlock-q{
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.faqBlock-icon{
  width: 30px;
  height: 30px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 140ms ease;
}
.faqBlock-icon svg{
  width: 16px;
  height: 16px;
  fill: none;
  stroke: rgba(229,231,235,0.85);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.faqBlock-item[open] .faqBlock-icon{ transform: rotate(180deg); }

.faqBlock-ans{
  padding: 0 10px 12px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@media (max-width: 720px){
  .faqBlock-sum{ padding: 11px 10px; }
}


/* =========================
   NET
   ========================= */

.ui-pageGrid{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;

  background:
    /* fine grid */
    linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px),
    linear-gradient(0deg,  rgba(255,255,255,0.022) 1px, transparent 1px),
    /* coarse grid */
    linear-gradient(90deg, rgba(255,255,255,0.050) 1px, transparent 1px),
    linear-gradient(0deg,  rgba(255,255,255,0.040) 1px, transparent 1px);

  background-size:
    34px 34px,
    34px 34px,
    170px 170px,
    170px 170px;

  opacity: 0.42;
}
@media (max-width: 720px){
  .ui-pageGrid{ opacity: 0.30; }
}