:root {
  --bg: #0d0e17;
  --panel: #14151f;
  --panel-2: #1a1c2a;
  --panel-3: #20223a;
  --text: #e8e8f0;
  --muted: #8b92b8;
  --accent: #7f77dd;
  --accent-dim: rgba(127,119,221,.15);
  --border: rgba(255,255,255,.07);
  --border-2: rgba(255,255,255,.12);
  --shadow: 0 16px 48px rgba(0,0,0,.45);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar: 260px;

  --model: #4a90d9;
  --conditioning: #f0a500;
  --latent: #9b59b6;
  --image: #e74c3c;
  --vae: #27ae60;
  --clip: #f1c40f;
  --controlnet: #1abc9c;
  --upscale: #7f77dd;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

/* ─── Layout ─────────────────────────────────────── */
.app-shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────── */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; background: rgba(10,10,18,.97);
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  display: flex; flex-direction: column; gap: 28px;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand__logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #7f77dd, #4f4be8);
  display: grid; place-items: center;
  font-weight: 800; font-size: 1rem; color: #fff; flex-shrink: 0;
}
.brand__title { font-weight: 700; font-size: 1.05rem; }
.brand__sub { color: var(--muted); font-size: .82rem; }

.nav-links { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: .9rem; color: var(--muted);
  transition: background .18s, color .18s;
}
.nav-link svg { flex-shrink: 0; opacity: .7; }
.nav-link:hover { background: var(--accent-dim); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--border); }
.footer-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }
.wire-badge { font-size: .7rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; color: #111; }
.wire-badge.model { background: var(--model); color: #fff; }
.wire-badge.conditioning { background: var(--conditioning); }
.wire-badge.latent { background: var(--latent); color: #fff; }
.wire-badge.image { background: var(--image); color: #fff; }
.wire-badge.vae { background: var(--vae); }
.wire-badge.clip { background: var(--clip); }
.wire-badge.controlnet { background: var(--controlnet); }

/* ─── Main content ───────────────────────────────── */
.content { padding: 48px 52px; max-width: 1100px; }

.menu-toggle {
  display: none; position: fixed; top: 16px; left: 16px; z-index: 100;
  background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text);
  width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  align-items: center; justify-content: center;
}

/* ─── Section ────────────────────────────────────── */
.section { margin-bottom: 72px; }
.section-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 32px; }
.section-num {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent-dim); color: var(--accent);
  font-weight: 700; font-size: 1rem; display: grid; place-items: center;
  flex-shrink: 0; margin-top: 2px;
}
.section-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.section-desc { color: var(--muted); font-size: .95rem; }

/* ─── Cards grid ─────────────────────────────────── */
.cards-grid { display: grid; gap: 12px; }

/* ─── Expandable card ────────────────────────────── */
.exp-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; transition: border-color .2s;
}
.exp-card:hover { border-color: var(--border-2); }
.exp-card.open { border-color: rgba(127,119,221,.3); }

.exp-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; cursor: pointer; user-select: none;
}
.exp-header:hover .exp-title { color: var(--accent); }
.exp-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent-dim); color: var(--accent);
  display: grid; place-items: center; font-size: 1rem; flex-shrink: 0;
}
.exp-meta { flex: 1; min-width: 0; }
.exp-title { font-weight: 600; font-size: .98rem; }
.exp-sub { color: var(--muted); font-size: .83rem; margin-top: 2px; }
.exp-badges { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.exp-chevron { color: var(--muted); transition: transform .2s; flex-shrink: 0; }
.exp-card.open .exp-chevron { transform: rotate(180deg); }

.exp-body { padding: 0 20px 20px; display: none; border-top: 1px solid var(--border); }
.exp-card.open .exp-body { display: block; }
.exp-desc { color: var(--muted); font-size: .9rem; margin: 16px 0; line-height: 1.65; }

.ports-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.ports-group { display: flex; flex-direction: column; gap: 6px; }
.ports-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 2px; }
.port-badges { display: flex; flex-wrap: wrap; gap: 6px; }

.type-badge { font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; color: #111; }
.type-badge.model { background: var(--model); color: #fff; }
.type-badge.conditioning { background: var(--conditioning); }
.type-badge.latent { background: var(--latent); color: #fff; }
.type-badge.image { background: var(--image); color: #fff; }
.type-badge.vae { background: var(--vae); }
.type-badge.clip { background: var(--clip); }
.type-badge.controlnet { background: var(--controlnet); }
.type-badge.upscale { background: var(--upscale); color: #fff; }
.type-badge.mask { background: #888; color: #fff; }
.type-badge.default { background: var(--panel-3); color: var(--text); }

/* ─── Params list ────────────────────────────────── */
.params-list { display: grid; gap: 12px; margin-top: 4px; }

.param-card {
  background: var(--panel-2); border-radius: var(--radius-sm); padding: 16px;
  border: 1px solid var(--border);
}

.param-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.param-label {
  font-weight: 600; font-size: .88rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace; color: var(--accent);
}
.param-cur-value {
  font-size: 1.15rem; font-weight: 800; color: var(--accent);
  font-variant-numeric: tabular-nums; min-width: 52px; text-align: right;
}
.param-desc { color: var(--muted); font-size: .855rem; margin-bottom: 12px; line-height: 1.55; }

/* Zone bar */
.param-zones { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.param-zone { height: 100%; }

/* Slider */
input[type=range] {
  -webkit-appearance: none; width: 100%; height: 6px;
  border-radius: 3px; background: var(--panel-3); outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
  border: 3px solid var(--bg); box-shadow: 0 0 0 2px var(--accent);
  transition: transform .15s;
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.2); }
input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 3px solid var(--bg);
}

.param-zone-desc {
  font-size: .84rem; padding: 8px 12px; border-radius: 8px;
  margin-top: 8px; font-weight: 500; line-height: 1.4;
}

/* Rich select */
.param-select {
  background: var(--panel-3); border: 1px solid var(--border-2); color: var(--text);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; width: 100%; margin-bottom: 8px;
}
.param-select:focus { outline: 2px solid var(--accent); }
.param-select-desc {
  background: var(--panel-3); border-radius: 10px;
  padding: 10px 12px; font-size: .855rem; color: var(--muted); min-height: 40px;
  border: 1px solid var(--border);
}

/* Simple select options list */
.param-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.param-option-pill {
  background: var(--panel-3); border-radius: 999px;
  padding: 3px 10px; font-size: .78rem; color: var(--muted);
  border: 1px solid var(--border);
}

/* Seed */
.param-seed-row { display: flex; gap: 10px; }
.param-seed-input {
  flex: 1; background: var(--panel-3); border: 1px solid var(--border-2);
  color: var(--text); border-radius: 10px; padding: 10px 12px;
}
.param-seed-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.param-rand-btn {
  background: var(--accent-dim); border: 1px solid rgba(127,119,221,.3);
  color: var(--accent); font-weight: 600; border-radius: 10px;
  padding: 10px 14px; cursor: pointer; transition: background .18s; white-space: nowrap;
}
.param-rand-btn:hover { background: rgba(127,119,221,.25); }

.param-extra {
  background: var(--accent-dim); border: 1px solid rgba(127,119,221,.3);
  border-radius: 8px; padding: 8px 12px; font-size: .83rem;
  color: var(--accent); margin-top: 8px; line-height: 1.5;
}

/* ─── Category Gallery ───────────────────────────── */
.cat-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.cat-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 20px;
  cursor: pointer; transition: border-color .2s, background .2s, transform .15s;
  text-align: center;
}
.cat-card:hover {
  border-color: var(--accent); background: var(--accent-dim);
  transform: translateY(-2px);
}
.cat-card-icon { font-size: 2rem; margin-bottom: 10px; line-height: 1; }
.cat-card-title { font-weight: 700; font-size: .95rem; margin-bottom: 4px; }
.cat-card-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-3); border-radius: 999px;
  padding: 2px 10px; font-size: .76rem; color: var(--muted);
  margin-bottom: 8px;
}
.cat-card-desc { color: var(--muted); font-size: .8rem; line-height: 1.4; }

/* ─── Category node view ─────────────────────────── */
.node-view-header {
  display: flex; align-items: center; gap: 14px; margin-bottom: 24px;
}
.back-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--panel-2);
  border: 1px solid var(--border-2); color: var(--muted);
  border-radius: 10px; cursor: pointer; font-size: .875rem;
  transition: background .18s, color .18s;
  white-space: nowrap;
}
.back-btn:hover { background: var(--accent-dim); color: var(--accent); border-color: rgba(127,119,221,.3); }
.node-view-cat { font-weight: 700; font-size: 1.1rem; }
.node-view-cnt { color: var(--muted); font-size: .85rem; }

/* ─── Workflow ────────────────────────────────────── */
.workflow-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
}
.workflow-head { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.workflow-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 4px; }
.workflow-sub { color: var(--muted); font-size: .87rem; }
.workflow-svg-wrap {
  overflow-x: auto; padding: 20px; background: #0a0b13;
  scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}
.workflow-svg-wrap::-webkit-scrollbar { height: 6px; }
.workflow-svg-wrap::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
.workflow-tip {
  padding: 14px 24px; background: var(--accent-dim);
  font-size: .875rem; color: var(--accent); border-top: 1px solid var(--border);
}
.workflow-tip strong { color: var(--text); }

/* ─── Reference ──────────────────────────────────── */
.ref-section { margin-bottom: 32px; }
.ref-title { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }
.ref-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.ref-table th {
  text-align: left; padding: 10px 14px; background: var(--panel-2);
  color: var(--muted); font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .08em;
}
.ref-table th:first-child { border-radius: 10px 0 0 0; }
.ref-table th:last-child { border-radius: 0 10px 0 0; }
.ref-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.ref-table tr:last-child td { border-bottom: none; }
.ref-table tr:nth-child(even) td { background: rgba(255,255,255,.015); }
.ref-table code {
  font-family: monospace; font-size: .85em;
  background: var(--panel-3); padding: 2px 6px; border-radius: 4px; color: var(--accent);
}

/* ─── Mobile ─────────────────────────────────────── */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 50;
    transform: translateX(-100%); transition: transform .25s ease; width: var(--sidebar);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 40px rgba(0,0,0,.6); }
  .menu-toggle { display: flex; }
  .content { padding: 72px 20px 40px; }
  .cat-gallery { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .content { padding: 72px 16px 40px; }
  .section-title { font-size: 1.25rem; }
  .ports-row { flex-direction: column; gap: 12px; }
  .cat-gallery { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .cat-gallery { grid-template-columns: 1fr; }
}

/* ─── Sidebar overlay ────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 40;
}
.sidebar-overlay.open { display: block; }
