/* Layout: IDE de tres paneles (archivos · editor · bordado) con una barra
   de problemas abajo; en pantallas angostas, editor y bordado apilados. */
:root {
  --bg: #12151f;
  --panel: #171b27;
  --ed-bg: #141824;
  --ed-fg: #dfe3ee;
  --line: #262c3c;
  --muted: #8a92a8;
  --fg: #e6e9f2;
  --accent: #8fa6ff;
  --warm: #ff9e7a;
  --err: #ff6b6b;
  --warn: #f2c879;
  --ok: #7fd8a3;
  --btn-bg: #222839;
  --btn-border: #2f3648;
  --btn-hover: #2a3146;
  --menu-bg: #1d2231;
  --menu-border: #343b50;
  --active-bg: #2a3352;
  --hover-bg: #ffffff08;
  --input-bg: #0f121b;
  --badge-bg: #12151fd9;
  --term-bg: #0d1018;
  --accent-fg: #12151f;
  --syn-kw: #8fb2ff;
  --syn-prim: #ff9e7a;
  --syn-fn: #e6a3f0;
  --syn-type: #7fd8d0;
  --syn-atom: #f2c879;
  --syn-prop: #c9d1e6;
  --syn-enum: #f2c879;
  --syn-num: #9be2b8;
  --syn-str: #f2c879;
  --syn-color: #ffffff;
  --syn-comment: #6f778c;
  --syn-op: #9aa3b8;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f4f0;
  --panel: #ffffff;
  --ed-bg: #faf9f6;
  --ed-fg: #1d2230;
  --line: #ddd9d0;
  --muted: #5e667a;
  --fg: #181c28;
  --accent: #254edb;
  --warm: #d4552b;
  --err: #c92a2a;
  --warn: #b36b00;
  --ok: #1b7f4b;
  --btn-bg: #efede7;
  --btn-border: #d2cec4;
  --btn-hover: #e5e2da;
  --menu-bg: #ffffff;
  --menu-border: #cbc7bd;
  --active-bg: #dfe6ff;
  --hover-bg: #00000008;
  --input-bg: #ffffff;
  --badge-bg: #ffffffeb;
  --term-bg: #161924;
  --accent-fg: #ffffff;
  --syn-kw: #1d4ed8;
  --syn-prim: #c2410c;
  --syn-fn: #7e22ce;
  --syn-type: #0f766e;
  --syn-atom: #9a5b00;
  --syn-prop: #334155;
  --syn-enum: #9a5b00;
  --syn-num: #15803d;
  --syn-str: #a16207;
  --syn-color: #111827;
  --syn-comment: #64748b;
  --syn-op: #475569;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f4f0;
    --panel: #ffffff;
    --ed-bg: #faf9f6;
    --ed-fg: #1d2230;
    --line: #ddd9d0;
    --muted: #5e667a;
    --fg: #181c28;
    --accent: #254edb;
    --warm: #d4552b;
    --err: #c92a2a;
    --warn: #b36b00;
    --ok: #1b7f4b;
    --btn-bg: #efede7;
    --btn-border: #d2cec4;
    --btn-hover: #e5e2da;
    --menu-bg: #ffffff;
    --menu-border: #cbc7bd;
    --active-bg: #dfe6ff;
    --hover-bg: #00000008;
    --input-bg: #ffffff;
    --badge-bg: #ffffffeb;
    --term-bg: #161924;
    --syn-kw: #1d4ed8;
    --syn-prim: #c2410c;
    --syn-fn: #7e22ce;
    --syn-type: #0f766e;
    --syn-atom: #9a5b00;
    --syn-prop: #334155;
    --syn-enum: #9a5b00;
    --syn-num: #15803d;
    --syn-str: #a16207;
    --syn-color: #111827;
    --syn-comment: #64748b;
    --syn-op: #475569;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 14px;
  display: flex; flex-direction: column; overflow: hidden;
}
button, .btn-link {
  font: inherit; color: var(--fg); background: var(--btn-bg); border: 1px solid var(--btn-border);
  border-radius: 5px; padding: 5px 10px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn-link:hover { background: var(--btn-hover); }
button:focus-visible, .btn-link:focus-visible, summary:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.small, .btn-link.small { padding: 3px 8px; font-size: 12px; }
button.icon { width: 24px; height: 24px; padding: 0; font-size: 16px; line-height: 1; justify-content: center; }

.top {
  display: flex; align-items: center; gap: 16px; padding: 8px 14px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-family: var(--f-display); font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--fg); text-decoration: none; }
.brand em { font-style: normal; color: var(--muted); font-weight: 600; }
.mark { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--accent); position: relative; flex-shrink: 0; }
.mark::after { content: ""; position: absolute; inset: 4px; border-top: 2px solid var(--warm); transform: rotate(-20deg); }
.target { font-family: var(--f-mono); font-size: 12px; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target b { color: var(--fg); font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: center; }
.menu { position: relative; }
.menu summary { white-space: nowrap; list-style: none; cursor: pointer; padding: 5px 10px; border: 1px solid var(--btn-border); border-radius: 5px; background: var(--btn-bg); }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; color: var(--muted); }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; display: flex; flex-direction: column;
  min-width: 220px; background: var(--menu-bg); border: 1px solid var(--menu-border); border-radius: 6px; padding: 4px; gap: 2px;
  box-shadow: 0 8px 24px #00000033;
}
.menu-list button { text-align: left; border: 0; background: transparent; width: 100%; }
.menu-list button:hover { background: var(--btn-hover); }
.menu-list button:disabled { color: var(--muted); opacity: 0.55; cursor: default; background: transparent; }

.ide { flex: 1; display: grid; grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1fr); min-height: 0; }
.pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); min-height: 34px;
}
.pane-ops { display: flex; align-items: center; gap: 4px; }
.files { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tree { overflow: auto; padding: 6px 0 12px; font-size: 13px; }
.tree .dir { padding: 6px 10px 2px; color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; user-select: none; }
.tree .dir::before { content: "▾ "; }
.tree .dir.closed::before { content: "▸ "; }
.tree .file { display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px 20px; cursor: pointer; }
.tree .file:hover { background: var(--hover-bg); }
.tree .file.active { background: var(--active-bg); }
.tree .file .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-mono); font-size: 12.5px; }
.tree .file .lib { color: var(--muted); font-size: 10px; }
.tree .file .ops { display: none; gap: 2px; }
.tree .file:hover .ops { display: flex; }
.tree .file .ops button { padding: 0 5px; font-size: 11px; background: transparent; border: 0; color: var(--muted); }
.tree .file .ops button:hover { color: var(--fg); }
.tree input { width: 100%; font: 12.5px var(--f-mono); background: var(--input-bg); color: var(--fg); border: 1px solid var(--accent); border-radius: 3px; padding: 1px 4px; }
.new-form { padding: 6px 10px; }
.new-form input { width: 100%; font: 12.5px var(--f-mono); background: var(--input-bg); color: var(--fg); border: 1px solid var(--accent); border-radius: 4px; padding: 4px 6px; }

.editor { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); background: var(--ed-bg); }
.drop-overlay {
  position: absolute; inset: 8px; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: var(--badge-bg); border: 2px dashed var(--accent); border-radius: 8px;
  font-family: var(--f-display); font-weight: 700; font-size: 16px; color: var(--accent);
  pointer-events: none; text-align: center; padding: 16px; gap: 6px;
}
.drop-overlay[hidden] { display: none !important; }
.drop-overlay code { font-family: var(--f-mono); background: var(--panel); padding: 2px 6px; border-radius: 4px; }
.tabs { display: flex; overflow-x: auto; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 34px; }
.tab {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 0; border-right: 1px solid var(--line);
  border-radius: 0; background: transparent; color: var(--muted); font: 12.5px var(--f-mono); white-space: nowrap;
}
.tab.active { background: var(--ed-bg); color: var(--fg); box-shadow: inset 0 2px 0 var(--accent); }
.tab .x { color: var(--muted); padding: 0 2px; border-radius: 3px; }
.tab .x:hover { background: var(--hover-bg); color: var(--fg); }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; }
.tab .dot.err { background: var(--err); }
.tab .dot.warn { background: var(--warn); }
.cm-host { flex: 1; min-height: 0; overflow: hidden; }
.cm-host .cm-editor { height: 100%; }

.preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toggles { display: flex; gap: 10px; align-items: center; text-transform: none; letter-spacing: 0; font-size: 12px; flex-wrap: wrap; justify-content: flex-end; }
.toggles label { display: flex; gap: 4px; align-items: center; cursor: pointer; color: var(--fg); }
.stage { position: relative; flex: 1; min-height: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.stats {
  position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none;
}
.stats span {
  font: 600 11.5px var(--f-mono); background: var(--badge-bg); color: var(--fg); padding: 3px 8px; border-radius: 4px;
  font-variant-numeric: tabular-nums; border: 1px solid var(--line);
}
.stats span i { font-style: normal; color: var(--muted); font-weight: 400; margin-right: 4px; }
.busy { position: absolute; right: 10px; top: 10px; font: 12px var(--f-mono); background: var(--badge-bg); padding: 3px 8px; border-radius: 4px; color: var(--accent); border: 1px solid var(--line); }
.measure-readout {
  position: absolute; right: 10px; bottom: 10px; pointer-events: none;
  font: 600 11.5px var(--f-mono); font-variant-numeric: tabular-nums;
  background: var(--badge-bg); color: var(--fg); padding: 3px 8px; border-radius: 4px;
  border: 1px solid var(--line); display: flex; align-items: center; gap: 8px;
}
.measure-readout[hidden] { display: none !important; }
.measure-readout .box-dim { color: var(--accent); }
.guide-inline-editor {
  position: absolute; top: 30px; left: 30px; z-index: 40;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px; border-radius: 5px;
  background: var(--panel); border: 1px solid var(--accent);
  box-shadow: 0 6px 18px #00000055;
  font: 600 12px var(--f-mono); color: var(--fg);
}
.guide-inline-input {
  width: 68px; font: inherit; padding: 2px 5px; border-radius: 3px;
  border: 1px solid var(--btn-border); background: var(--input-bg); color: var(--fg);
}

.bottom { border-top: 1px solid var(--line); background: var(--panel); }
.problems { max-height: 132px; overflow: auto; font: 12.5px var(--f-mono); }
.problem { display: flex; gap: 10px; padding: 4px 14px; cursor: pointer; align-items: baseline; }
.problem:hover { background: var(--hover-bg); }
.problem .sev { font-weight: 600; min-width: 64px; }
.problem .sev a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.problem .sev a:hover { color: var(--accent); }
.problem.Error .sev { color: var(--err); }
.problem.Warning .sev { color: var(--warn); }
.problem.Info .sev { color: var(--accent); }
.problem .where { color: var(--muted); white-space: nowrap; }
.problem .msg { flex: 1; min-width: 0; }
.status { display: flex; justify-content: space-between; gap: 12px; padding: 4px 14px; font: 11.5px var(--f-mono); color: var(--muted); border-top: 1px solid var(--line); }
.status .ok { color: var(--ok); }

/* ---------- Banner de proyecto compartido ---------- */
.shared-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 14px; background: var(--active-bg); border-bottom: 1px solid var(--accent);
  font-size: 13px; color: var(--fg); flex-wrap: wrap;
}
.shared-banner[hidden] { display: none !important; }
.shared-banner-text { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.shared-banner-text strong { font-family: var(--f-display); color: var(--accent); font-size: 13.5px; }
.shared-banner-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Modales (Galería y Compartir) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: #0000007a;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  background: var(--panel); border: 1px solid var(--menu-border); border-radius: 10px;
  box-shadow: 0 20px 48px #00000066; display: flex; flex-direction: column;
  max-height: 88vh; width: 100%; overflow: hidden;
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  margin: 0 0 4px; font-family: var(--f-display); font-size: 20px; color: var(--fg);
}
.modal-sub { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }

.gallery-box { max-width: 980px; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  grid-auto-rows: max-content; align-items: start;
  gap: 14px; padding: 18px 20px 22px; overflow-y: auto; flex: 1; min-height: 0;
}
.gallery-card {
  display: flex; flex-direction: column; align-items: stretch; text-align: left;
  padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--ed-bg);
  overflow: hidden; cursor: pointer; transition: border-color 0.15s, transform 0.12s;
  height: auto; flex-shrink: 0;
}
.gallery-card:hover { border-color: var(--accent); background: var(--ed-bg); transform: translateY(-1px); }
.gallery-thumb {
  position: relative; width: 100%; height: 156px; flex-shrink: 0; background: #f7f3ea;
  border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  padding: 10px; overflow: hidden;
}
.gallery-thumb img {
  max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block;
}
.gallery-kind {
  position: absolute; top: 8px; right: 8px; font: 600 10px var(--f-mono);
  text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 6px; border-radius: 4px;
  background: var(--badge-bg); color: var(--accent); border: 1px solid var(--line);
}
.gallery-body {
  display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; flex: 1; width: 100%;
}
.gallery-card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.gallery-card-title { font-family: var(--f-display); font-weight: 700; font-size: 15.5px; color: var(--fg); }
.gallery-card-file { font: 11.5px var(--f-mono); color: var(--muted); }
.gallery-card-desc {
  margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.4; flex: 1;
}
.gallery-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px;
  font: 600 11px var(--f-mono); color: var(--fg);
}
.gallery-meta > span {
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px;
}
.gallery-meta i { font-style: normal; font-weight: 400; color: var(--muted); }
.gallery-swatches {
  display: inline-flex; align-items: center; gap: 3px; padding: 3px 6px !important;
}
.gallery-swatches .swatch {
  width: 10px; height: 10px; border-radius: 50%; border: 1px solid #00000040; display: inline-block;
}

.share-box { max-width: 620px; }
.share-warn {
  margin: 14px 20px 0; padding: 10px 12px; border-radius: 6px;
  background: #f2c87922; border: 1px solid var(--warn); color: var(--fg); font-size: 13px; line-height: 1.45;
}
.share-warn[hidden] { display: none !important; }
.share-warn strong { color: var(--warn); }
.share-row {
  display: flex; gap: 8px; padding: 16px 20px 12px; align-items: stretch;
}
.share-input {
  flex: 1; min-width: 0; font: 12.5px var(--f-mono); background: var(--input-bg); color: var(--fg);
  border: 1px solid var(--btn-border); border-radius: 5px; padding: 7px 10px;
}
.share-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 20px 16px; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.share-meta { font: 11.5px var(--f-mono); color: var(--muted); }

.confirm-box { max-width: 480px; }
.confirm-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px 16px; flex-wrap: wrap;
}

@media (max-width: 900px) {
  body { overflow-x: hidden; overflow-y: auto; height: auto; }
  .ide { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
  .files { max-height: 180px; border-right: 0; border-bottom: 1px solid var(--line); }
  .editor { height: 60vh; border-right: 0; }
  .preview { height: 70vh; border-top: 1px solid var(--line); }
  .target { display: none; }
  .top { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .brand em { display: none; }
  .actions { flex-wrap: wrap; gap: 6px; width: 100%; }
  .actions button, .actions .btn-link, .menu summary { padding: 4px 8px; font-size: 13px; }
  .menu summary { white-space: nowrap; }
  .menu-list { right: auto; left: 0; max-width: calc(100vw - 24px); }
  .toggles { gap: 8px; }
  .modal-backdrop { padding: 10px; }
  .modal { max-height: 92vh; }
  .modal-head { padding: 12px 14px 10px; }
  .gallery-grid { grid-template-columns: minmax(0, 1fr); padding: 12px 14px 16px; gap: 12px; }
  .gallery-thumb { height: 148px; }
  .share-row { flex-direction: column; padding: 12px 14px; }
  .share-foot { padding: 10px 14px 14px; }
  .measure-readout { bottom: 68px; right: 8px; }
}
/* ---------- Sitio de documentación (/docs/) ---------- */
body.docs-body {
  display: grid; grid-template-rows: auto 1fr; overflow: hidden; height: 100%;
  font-size: 15px; line-height: 1.65;
}
.docs-top {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); z-index: 30;
}
.docs-top-left { display: flex; align-items: center; gap: 12px; }
.docs-menu-btn { display: none; }
.docs-search-wrap { position: relative; flex: 1; max-width: 440px; min-width: 180px; }
.docs-search-input {
  width: 100%; font: 13.5px var(--f-body); background: var(--input-bg); color: var(--fg);
  border: 1px solid var(--btn-border); border-radius: 6px; padding: 6px 36px 6px 30px;
}
.docs-search-input::placeholder { color: var(--muted); }
.docs-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 13px; pointer-events: none;
}
.docs-search-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font: 11px var(--f-mono); color: var(--muted); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; pointer-events: none; background: var(--panel);
}
.docs-search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50;
  max-height: 70vh; overflow-y: auto; background: var(--menu-bg);
  border: 1px solid var(--menu-border); border-radius: 8px; padding: 6px;
  box-shadow: 0 12px 32px #00000044; display: flex; flex-direction: column; gap: 2px;
}
.docs-search-results[hidden] { display: none !important; }
.search-item {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px;
  border-radius: 6px; text-decoration: none; color: var(--fg);
}
.search-item:hover, .search-item.active { background: var(--active-bg); }
.search-item-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; }
.search-item-badge {
  font: 600 10px var(--f-mono); text-transform: uppercase; letter-spacing: 0.05em;
  padding: 1px 6px; border-radius: 4px; background: var(--btn-bg); color: var(--accent);
  border: 1px solid var(--btn-border); flex-shrink: 0;
}
.search-item-sec { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.search-item-snip { font-size: 12.5px; color: var(--muted); line-height: 1.45; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-item mark { background: #f2c87944; color: var(--fg); border-radius: 2px; padding: 0 2px; }
.search-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

.docs-layout {
  display: grid; grid-template-columns: 268px minmax(0, 1fr) 230px; min-height: 0; overflow: hidden;
}
.docs-sidebar {
  background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto;
  padding: 14px 10px 32px; font-size: 13.5px; display: flex; flex-direction: column; gap: 18px;
}
.docs-nav-group { display: flex; flex-direction: column; gap: 2px; }
.docs-nav-title {
  padding: 4px 10px 6px; font: 700 11px var(--f-mono); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.docs-nav-link {
  display: flex; align-items: baseline; gap: 8px; padding: 5px 10px; border-radius: 5px;
  color: var(--fg); text-decoration: none; line-height: 1.35;
}
.docs-nav-link:hover { background: var(--hover-bg); }
.docs-nav-link.active {
  background: var(--active-bg); color: var(--accent); font-weight: 700;
}
.docs-nav-num { font: 600 11.5px var(--f-mono); color: var(--muted); min-width: 20px; }
.docs-nav-link.active .docs-nav-num { color: var(--accent); }

.docs-main {
  overflow-y: auto; min-width: 0; padding: 32px 40px 64px; scroll-behavior: smooth;
}
.docs-article {
  max-width: 780px; margin: 0 auto; min-width: 0;
}
.docs-breadcrumb {
  font: 600 11.5px var(--f-mono); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent); margin-bottom: 6px;
}
.docs-article h1 {
  font-family: var(--f-display); font-size: 30px; line-height: 1.2; margin: 0 0 18px;
  letter-spacing: -0.01em;
}
.docs-article h2 {
  font-family: var(--f-display); font-size: 21px; line-height: 1.3; margin: 36px 0 12px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line); scroll-margin-top: 18px;
}
.docs-article h3 {
  font-family: var(--f-display); font-size: 16.5px; line-height: 1.35; margin: 26px 0 8px;
  scroll-margin-top: 18px;
}
.docs-article h4 {
  font-family: var(--f-display); font-size: 14.5px; margin: 20px 0 6px; scroll-margin-top: 18px;
}
.heading-anchor {
  color: var(--muted); text-decoration: none; margin-left: 6px; opacity: 0;
  font-family: var(--f-mono); font-weight: 400; font-size: 0.85em; transition: opacity 0.15s;
}
.docs-article h2:hover .heading-anchor,
.docs-article h3:hover .heading-anchor,
.docs-article h4:hover .heading-anchor,
.heading-anchor:focus-visible { opacity: 1; }
.heading-anchor:hover { color: var(--accent); }

.docs-article p { margin: 0 0 14px; }
.docs-article ul, .docs-article ol { margin: 0 0 16px; padding-left: 22px; }
.docs-article li { margin-bottom: 5px; }
.docs-article li > p { margin-bottom: 6px; }
.docs-article a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.docs-article a:hover { color: var(--warm); }
.docs-article hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

.docs-article code {
  font-family: var(--f-mono); font-size: 0.88em; background: var(--ed-bg);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; overflow-wrap: break-word;
}
.docs-article td code {
  white-space: nowrap; word-break: normal; overflow-wrap: normal;
}
.docs-article pre code {
  background: none; border: 0; padding: 0; font-size: inherit; word-break: normal; overflow-wrap: normal;
}

.code-block {
  margin: 14px 0 18px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--ed-bg); overflow: hidden;
}
.code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 10px; background: var(--panel); border-bottom: 1px solid var(--line);
  font: 600 11px var(--f-mono); color: var(--muted);
}
.code-lang { text-transform: uppercase; letter-spacing: 0.06em; }
.code-actions { display: flex; gap: 6px; align-items: center; }
.code-btn {
  padding: 2px 8px; font: 600 11.5px var(--f-body); border-radius: 4px;
  background: var(--btn-bg); border: 1px solid var(--btn-border); color: var(--fg);
  cursor: pointer; text-decoration: none;
}
.code-btn:hover { background: var(--btn-hover); border-color: var(--accent); }
.code-btn.play { color: var(--accent); }
.code-block pre {
  margin: 0; padding: 12px 14px; overflow-x: auto; font: 13px/1.55 var(--f-mono);
  color: var(--ed-fg);
}
.code-block.term {
  background: var(--term-bg); border-color: #2a3042;
}
.code-block.term .code-head {
  background: #121622; border-bottom-color: #23293a; color: #8a92a8;
}
.code-block.term pre { color: #d6deeb; }
.term-err { color: #ff7b7b; font-weight: 600; }
.term-warn { color: #f2c879; font-weight: 600; }
.term-ok { color: #7fd8a3; font-weight: 600; }
.term-prompt { color: #8fa6ff; user-select: none; }

/* Colores de sintaxis HoopLang en bloques estáticos */
.hl-kw { color: var(--syn-kw); font-weight: 600; }
.hl-prim { color: var(--syn-prim); font-weight: 600; }
.hl-fn { color: var(--syn-fn); }
.hl-type { color: var(--syn-type); }
.hl-atom { color: var(--syn-atom); }
.hl-prop { color: var(--syn-prop); }
.hl-enum { color: var(--syn-enum); }
.hl-num { color: var(--syn-num); }
.hl-str { color: var(--syn-str); }
.hl-color { color: var(--syn-color); font-weight: 600; }
.hl-swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  vertical-align: middle; margin-right: 3px; border: 1px solid #ffffff44;
}
.hl-comment { color: var(--syn-comment); font-style: italic; }
.hl-op { color: var(--syn-op); }

.table-wrap {
  width: 100%; overflow-x: auto; margin: 14px 0 20px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--panel); -webkit-overflow-scrolling: touch;
}
.docs-article table {
  width: 100%; border-collapse: collapse; font-size: 13.5px; line-height: 1.45;
}
.docs-article th, .docs-article td {
  text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top;
}
.docs-article td:last-child { min-width: 220px; }
.docs-article tr:last-child td { border-bottom: 0; }
.docs-article th {
  background: var(--ed-bg); font-weight: 700; color: var(--fg); white-space: nowrap;
}

.docs-toc {
  border-left: 1px solid var(--line); padding: 24px 14px 32px; overflow-y: auto;
  font-size: 12.5px; background: var(--bg);
}
.docs-toc-title {
  font: 700 11px var(--f-mono); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 8px;
}
.docs-toc-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.docs-toc-list a {
  display: block; color: var(--muted); text-decoration: none; padding: 3px 6px;
  border-radius: 4px; line-height: 1.35;
}
.docs-toc-list a:hover { color: var(--fg); background: var(--hover-bg); }
.docs-toc-list a.active { color: var(--accent); font-weight: 700; background: var(--active-bg); }
.docs-toc-list .toc-h3 { padding-left: 16px; font-size: 12px; }

.docs-pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 44px;
  padding-top: 20px; border-top: 1px solid var(--line);
}
.docs-pager a {
  display: flex; flex-direction: column; gap: 3px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--panel);
  text-decoration: none; color: var(--fg);
}
.docs-pager a:hover { border-color: var(--accent); background: var(--hover-bg); }
.docs-pager .next { text-align: right; grid-column: 2; }
.docs-pager-dir { font: 600 11px var(--f-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.docs-pager-title { font-family: var(--f-display); font-weight: 700; font-size: 15px; color: var(--accent); }

/* Portada de la documentación */
.docs-hero {
  padding: 20px 22px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); margin-bottom: 26px;
}
.docs-hero h1 { margin-bottom: 8px; }
.docs-hero p { color: var(--muted); font-size: 15.5px; margin-bottom: 14px; }
.docs-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.docs-hero-actions a.btn-link { color: var(--fg); text-decoration: none; }
.docs-hero-actions a.btn-link:hover { color: var(--fg); }
.docs-article a.btn-primary, .btn-primary {
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 700; text-decoration: none;
}
.docs-article a.btn-primary:hover, .btn-primary:hover { opacity: 0.92; background: var(--accent); color: var(--accent-fg); }
.docs-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px; margin: 12px 0 28px;
}
.docs-card {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--panel);
  text-decoration: none !important; color: var(--fg) !important; transition: border-color 0.15s;
}
.docs-card:hover { border-color: var(--accent); background: var(--hover-bg); }
.docs-card-num { font: 600 11px var(--f-mono); color: var(--accent); }
.docs-card-title { font-family: var(--f-display); font-weight: 700; font-size: 15px; }
.docs-card-desc { font-size: 12.5px; color: var(--muted); line-height: 1.4; }

.docs-backdrop { display: none; }

@media (max-width: 1120px) {
  .docs-layout { grid-template-columns: 250px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 900px) {
  body.docs-body { display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto; height: auto; min-height: 100%; }
  .docs-top { position: sticky; top: 0; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .docs-menu-btn { display: inline-flex; }
  .docs-search-wrap { order: 3; flex: 1 1 100%; max-width: none; }
  .docs-layout { display: block; overflow: visible; flex: 1; }
  .docs-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 84vw); z-index: 60;
    transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: 0 0 32px #00000066;
  }
  body.nav-open .docs-sidebar { transform: translateX(0); }
  body.nav-open .docs-backdrop {
    display: block; position: fixed; inset: 0; background: #00000066; z-index: 55;
  }
  .docs-main { padding: 20px 14px 48px; overflow: visible; }
  .docs-article h1 { font-size: 24px; }
  .docs-article h2 { font-size: 18.5px; }
  .docs-article h2, .docs-article h3, .docs-article h4 { scroll-margin-top: 96px; }
  .docs-pager { grid-template-columns: 1fr; }
  .docs-pager .next { grid-column: 1; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
