:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #dde1e8;
  --text: #1b2230;
  --muted: #5d6779;
  --code-bg: #0f1623;
  --code-text: #e6edf7;
  --code-muted: #6f7d95;
  --ph: #ffc66d;
  --warn-bg: #fff4e0;
  --warn-border: #f0b45a;
  --warn-text: #7a4a00;
  --accent: #2496ed;
  --accent-ink: #ffffff;
  --radius: 12px;
  --header-h: 60px;
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1219; --surface: #151c27; --surface-2: #1c2533; --border: #263043;
    --text: #e7ecf4; --muted: #93a0b6; --code-bg: #090d14;
    --warn-bg: #2b2210; --warn-border: #8a6420; --warn-text: #f3d08a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1219; --surface: #151c27; --surface-2: #1c2533; --border: #263043;
  --text: #e7ecf4; --muted: #93a0b6; --code-bg: #090d14;
  --warn-bg: #2b2210; --warn-border: #8a6420; --warn-text: #f3d08a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.logo svg { width: 100%; height: 100%; display: block; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--sans); }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.brand small { color: var(--muted); font-weight: 500; }
.brand .logo { width: 30px; height: 30px; color: var(--accent); flex: none; }
.crumb-sep { color: var(--border); }
.crumb-logo { width: 20px; height: 20px; color: var(--accent); flex: none; }
.spacer { flex: 1; }
.search {
  position: relative; flex: 1; max-width: 460px;
}
.search input {
  width: 100%; height: 40px; padding: 0 44px 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
.search input::placeholder { color: var(--muted); }
.search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font: 12px var(--mono); color: var(--muted); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; background: var(--surface-2); pointer-events: none;
}
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; flex: none;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
#toc-toggle { display: none; }

/* ---------- index (página padre) ---------- */
.hero { max-width: 1040px; margin: 0 auto; padding: 56px 20px 12px; }
.hero h1 { font-size: clamp(2rem, 4vw + 1rem, 3.2rem); line-height: 1.05; margin: 0 0 12px; letter-spacing: -.03em; }
.hero p { margin: 0; color: var(--muted); max-width: 56ch; font-size: 1.05rem; }
.hero .search { max-width: 520px; margin-top: 26px; }
.grid {
  max-width: 1040px; margin: 0 auto; padding: 24px 20px 64px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.card {
  --accent: #2496ed;
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  text-decoration: none; overflow: hidden; transition: transform .18s, border-color .18s, box-shadow .18s;
}
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--accent); }
a.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 10px 28px -14px var(--accent); }
.card .logo { width: 56px; height: 56px; color: var(--accent); }
.card h2 { margin: 6px 0 0; font-size: 1.35rem; letter-spacing: -.01em; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }
.card .meta { margin-top: auto; padding-top: 8px; font-size: .85rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.pill { font-size: .75rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.card .pill { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

/* página de una guía que aún no está lista */
.construction { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 88px 0 96px; }
.construction .logo { width: 88px; height: 88px; color: var(--accent); }
.construction h1 { margin: 6px 0 0; font-size: clamp(2rem, 4vw + 1rem, 3rem); letter-spacing: -.03em; color: var(--accent); }
.construction p { margin: 0; color: var(--muted); max-width: 46ch; }
.construction .hint { margin-bottom: 10px; }
.pill.big { font-size: .9rem; padding: 5px 16px; color: var(--accent); border-color: var(--accent); }
.construction .navbtn { text-decoration: none; max-width: none; }
.results { max-width: 1040px; margin: 0 auto; padding: 0 20px 64px; }
.results h2 { font-size: 1rem; color: var(--muted); font-weight: 600; margin: 8px 0 12px; }
.hit {
  display: block; padding: 12px 14px; margin-bottom: 8px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.hit:hover { border-color: var(--accent); }
.hit code { font: 13.5px var(--mono); word-break: break-all; }
.hit small { display: block; color: var(--muted); margin-top: 2px; }
.hit .tag { color: var(--accent); font-weight: 600; }

/* ---------- perfil privado ---------- */
.dlg { width: min(380px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); }
.dlg::backdrop { background: rgb(0 0 0 / .5); }
.dlg h2 { margin: 0 0 6px; font-size: 1.25rem; }
.dlg p { margin: 0 0 14px; color: var(--muted); font-size: .95rem; }
.dlg input, .dlg select, .dlg textarea { width: 100%; margin-bottom: 8px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; }
.dlg input, .dlg select { height: 40px; }
.dlg textarea { padding: 10px 12px; font-family: var(--mono); font-size: .9rem; resize: vertical; }
.dlg-list { margin: 0 0 8px; padding-left: 18px; max-height: 180px; overflow: auto; font-size: .88rem; }
.topbtn { flex: none; height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-weight: 600; }
.topbtn:hover { background: var(--surface-2); }
#priv-export { color: var(--accent); border-color: var(--accent); }
.pill.local { color: var(--accent); border-color: var(--accent); }
.local-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.dlg .dlg-err { min-height: 1.4em; margin: 8px 0 0; color: #d64545; font-size: .88rem; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
#lock.on { color: var(--accent); border-color: var(--accent); }

/* ---------- favoritos ---------- */
.hero-row { display: flex; align-items: center; gap: 12px; margin-top: 26px; }
.hero-row .search { flex: 1; max-width: 520px; margin-top: 0; }
.favbtn {
  flex: none; height: 40px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); text-decoration: none; font-weight: 600;
}
.favbtn svg { width: 16px; height: 16px; color: #e8a33d; }
.favbtn:hover { border-color: #e8a33d; }
.badge { font: 600 .78rem var(--mono); color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }

/* página de favoritos */
.favpage { max-width: 1040px; margin: 0 auto; padding: 28px 20px 80px; }
.favpage .tool-head .logo { color: #e8a33d; }
.fav-group { margin-top: 32px; }
.fav-group h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 1.25rem; letter-spacing: -.01em; }
.fav-group h2 .logo { width: 26px; height: 26px; color: var(--accent); flex: none; }
.fav-list { display: grid; gap: 8px; }
.fav-row { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.fav-row:hover { border-color: var(--accent); }
.fav-link { flex: 1; min-width: 0; text-decoration: none; }
.fav-link code { font: 13.5px var(--mono); word-break: break-all; }
.fav-link small { display: block; color: var(--muted); }
.fav-link .tag { font-weight: 600; }
.fav-copy, .favs-btn {
  flex: none; height: 30px; padding: 0 12px; font-size: .82rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.fav-copy:hover, .favs-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.favs-btn:disabled { opacity: .45; cursor: not-allowed; }
.favs-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.favs-btn.primary:hover { color: var(--accent-ink); opacity: .9; }
.favs-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.favs-note { color: var(--muted); font-size: .82rem; }
.favs-empty { margin: 4px 0 0; color: var(--muted); font-size: .93rem; }
.favs-importbox { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 10px; }
.favs-import {
  width: 100%; padding: 10px 12px; font: 12.5px/1.5 var(--mono); resize: vertical; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.favs-msg { margin: 8px 0 0; min-height: 1.3em; font-size: .88rem; color: var(--muted); }

/* vista de favoritos dentro de una guía */
.toc a.favlink .star { display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; color: #e8a33d; }
.toc a.favlink .star svg { width: 100%; height: 100%; display: block; }
.fav-link:hover code { color: var(--accent); }

/* estrella dentro de cada comando */
.fav {
  flex: none; margin: 6px 0 0; width: 30px; height: 30px; display: grid; place-items: center; padding: 0;
  border-radius: 7px; border: 1px solid #2a364b; background: #182131; color: #8fa0bb;
}
.fav svg { width: 15px; height: 15px; }
.fav:hover { background: #22304a; color: #ffc66d; }
.fav.on { color: #ffc66d; border-color: #6b5220; }
.fav-row .fav { margin: 0; }
.code.small .fav { margin-top: 3px; height: 26px; }

/* ---------- página de herramienta ---------- */
.layout { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 36px; padding: 0 20px; }
.toc { position: sticky; top: var(--header-h); align-self: start; max-height: calc(100vh - var(--header-h)); overflow: auto; padding: 24px 0 32px; }
.toc h2 { font-size: .75rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px 12px; }
.toc a {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .93rem;
  border-left: 3px solid transparent;
}
.toc a:hover { background: var(--surface-2); color: var(--text); }
.toc a.active { color: var(--text); background: var(--surface); border-left-color: var(--accent); font-weight: 600; }
.toc a.dim { opacity: .35; }
.toc .n { font: 12px var(--mono); color: var(--muted); }

main { padding: 28px 0 80px; min-width: 0; }
.tool-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.tool-head .logo { width: 54px; height: 54px; color: var(--accent); }
.tool-head h1 { margin: 0; font-size: clamp(1.7rem, 3vw + .6rem, 2.4rem); letter-spacing: -.03em; line-height: 1.1; color: var(--accent); }
.tool-head p { margin: 2px 0 0; color: var(--muted); }
.status { margin: 14px 0 0; color: var(--muted); font-size: .9rem; min-height: 1.4em; }

/* navegación anterior / siguiente: se oculta al buscar */
.secnav { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }
body.searching .secnav { display: none; }
.navbtn {
  max-width: 48%; padding: 12px 16px; text-align: left; border-radius: 10px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.navbtn.next { margin-left: auto; text-align: right; }
.navbtn:hover { border-color: var(--accent); color: var(--accent); }
section.sec.off { display: none; }

.note {
  margin: 16px 0 0; padding: 12px 14px; border-radius: 10px; font-size: .93rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
}
.note.warn, .warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.note.warn { border-left-color: var(--warn-border); }

section.sec { padding-top: 56px; scroll-margin-top: calc(var(--header-h) + 8px); }
section.sec > h2 {
  display: flex; align-items: baseline; gap: 14px; margin: 0 0 6px; padding-bottom: 12px;
  font-size: clamp(1.6rem, 1.6vw + 1rem, 2.15rem); line-height: 1.15; letter-spacing: -.025em; font-weight: 800;
  color: var(--accent); border-bottom: 2px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}
section.sec > h2 .num {
  font: 700 1rem var(--mono); color: var(--accent-ink); background: var(--accent);
  padding: 3px 9px; border-radius: 7px; align-self: center; letter-spacing: 0;
}
section.sec > h2 .count { margin-left: auto; font: 500 .8rem var(--sans); color: var(--muted); }

.item { margin-top: 14px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.item .desc { margin: 10px 2px 0; color: var(--text); font-size: .95rem; }
.item .alias { margin-top: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.item .alias .lbl { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.item .warn { margin-top: 10px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--warn-border); font-size: .9rem; }
.item .warn::before { content: "⚠ "; }
.item.hidden, section.sec.hidden { display: none; }

/* comando ubicado desde un favorito o una búsqueda: se ilumina y se apaga solo a los 5 s */
.item.flash { animation: flash 5s ease-out; }
@keyframes flash {
  0%, 65% {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 40%, transparent);
    background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  }
  100% { border-color: var(--border); box-shadow: 0 0 0 0 transparent; background: var(--surface); }
}
@media (prefers-reduced-motion: reduce) {
  .item.flash {
    animation: none; border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 40%, transparent);
  }
}

.code {
  position: relative; display: flex; align-items: flex-start; gap: 8px;
  background: var(--code-bg); color: var(--code-text); border-radius: 9px; padding: 0 0 0 14px;
}
.code pre { margin: 0; flex: 1; min-width: 0; overflow-x: auto; padding: 12px 0; font: 13.5px/1.55 var(--mono); tab-size: 2; }
.code code { font: inherit; }
.code:not(.plain) pre code::before { content: "$ "; color: var(--code-muted); user-select: none; }
.code.plain pre code::before { content: none; }
.code .ph { color: var(--ph); cursor: text; border-bottom: 1px dashed currentColor; border-radius: 3px; outline: none; }
.code .ph:hover { background: #ffc66d22; }
.code .ph:focus { background: #ffc66d33; border-bottom-style: solid; }
.code .ph.filled { color: #7ee2a8; border-bottom-style: solid; }

/* contenido enriquecido: intro, pasos, salida de ejemplo y consejos */
.intro { margin: 10px 0 0; color: var(--muted); max-width: 70ch; }
.items.pasos { counter-reset: paso; }
.pasos .item { counter-increment: paso; position: relative; padding-left: 62px; }
.pasos .item::before {
  content: counter(paso); position: absolute; left: 14px; top: 14px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 700 .95rem var(--mono);
}
.ej { margin-top: 10px; }
.ej .lbl { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ej pre {
  margin: 4px 0 0; padding: 10px 14px; overflow-x: auto; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; font: 12.5px/1.5 var(--mono); color: var(--muted);
}
.tip {
  margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: .9rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}
.tip::before { content: "💡 "; }
.copy {
  flex: none; margin: 6px 6px 0 0; height: 30px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; border-radius: 7px; border: 1px solid #2a364b; background: #182131; color: #b8c4d8;
}
.copy:hover { background: #22304a; color: #fff; }
.copy svg { width: 14px; height: 14px; }
.copy.ok { background: #14532d; border-color: #1f7a45; color: #d5f7e1; }
.code.small pre { padding: 8px 0; font-size: 12.5px; }
.code.small { display: inline-flex; max-width: 100%; }
.code.small .copy { margin-top: 3px; height: 26px; }

.glosario { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-top: 14px; }
.glosario .item { margin: 0; }
.glosario dt { font-weight: 700; margin-bottom: 4px; }
.glosario dd { margin: 0; color: var(--muted); font-size: .93rem; }

.empty { margin-top: 48px; padding: 32px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.hl { background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 3px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  #toc-toggle { display: grid; }
  .toc {
    position: fixed; z-index: 40; top: var(--header-h); left: 0; bottom: 0; width: min(310px, 86vw);
    max-height: none; padding: 16px 12px; background: var(--bg); border-right: 1px solid var(--border);
    transform: translateX(-102%); transition: transform .2s;
  }
  body.toc-open .toc { transform: none; }
  body.toc-open::after { content: ""; position: fixed; inset: var(--header-h) 0 0 0; background: #0006; z-index: 35; }
  .search kbd { display: none; }
  .crumb-hide { display: none; }
}
@media (max-width: 560px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .layout, .hero, .grid, .results, .favpage { padding-left: 16px; padding-right: 16px; }
  .hero-row { flex-wrap: wrap; }
  .hero-row .search { flex-basis: 100%; max-width: none; }
  .brand small { display: none; }
  .copy span { display: none; }
}
