/* What the style — estilos base */

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #efefec;
  --text: #17171a;
  --text-2: #5d5d63;
  --text-3: #8b8b92;
  --line: #e2e2de;
  --line-strong: #cfcfca;
  --accent: #2f4cdd;
  --accent-text: #ffffff;
  --accent-soft: #e6eafc;
  --mark: #ffe58a;
  --avoid: #b4382b;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .05);
  --radius: 10px;
  --radius-sm: 6px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --topbar-base: 60px; /* alto fijo de la barra en escritorio */
  --topbar-h: 60px;    /* alto real medido por JS (móvil cambia): solo para lo que va debajo */
  --sidebar-w: 248px;
  --sheet-head-h: 52px;
  --detail-pad: 24px;
  --brand-yellow: #ffd60a;
    /* Barra superior: blanca en tema claro, negra en tema oscuro */
  --bar-bg: #ffffff;
  --bar-text: #17171a;
  --bar-text-2: #5d5d63;
  --bar-line: #e2e2de;
  --bar-field: #f6f6f4;
  --bar-field-line: #dcdcd7;
  --bar-hover: #efefec;
  --bar-focus: #17171a;
  --logo-q: var(--bar-text);
  --sidebar-bg: #ffffff;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214;
    --surface: #1b1b1e;
    --surface-2: #242428;
    --text: #ececef;
    --text-2: #a3a3ab;
    --text-3: #75757d;
    --line: #2b2b30;
    --line-strong: #3a3a40;
    --accent: #8197ff;
    --accent-text: #0e1124;
    --accent-soft: #232a4d;
    --mark: #6b5a12;
    --avoid: #f08a7e;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .3);
    --bar-bg: #0c0c0e;
    --bar-text: #f2f2ef;
    --bar-text-2: #a6a6ad;
    --bar-line: #26262b;
    --bar-field: #1b1b1e;
    --bar-field-line: #33333a;
    --bar-hover: #222226;
    --bar-focus: var(--brand-yellow);
    --logo-q: var(--brand-yellow);
    --sidebar-bg: #0c0c0e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121214;
  --surface: #1b1b1e;
  --surface-2: #242428;
  --text: #ececef;
  --text-2: #a3a3ab;
  --text-3: #75757d;
  --line: #2b2b30;
  --line-strong: #3a3a40;
  --accent: #8197ff;
  --accent-text: #0e1124;
  --accent-soft: #232a4d;
  --mark: #6b5a12;
  --avoid: #f08a7e;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .3);
  --bar-bg: #0c0c0e;
  --bar-text: #f2f2ef;
  --bar-text-2: #a6a6ad;
  --bar-line: #26262b;
  --bar-field: #1b1b1e;
  --bar-field-line: #33333a;
  --bar-hover: #222226;
  --bar-focus: var(--brand-yellow);
  --logo-q: var(--brand-yellow);
  --sidebar-bg: #0c0c0e;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.has-sheet { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.num { font-family: var(--mono); font-size: .78em; color: var(--text-3); font-weight: 500; letter-spacing: .02em; }
.h-small {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2);
}

/* ---------- controles ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-weight: 500;
}
.btn:hover { border-color: var(--text-3); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }

.link-btn {
  border: 0; background: none; padding: 2px 4px; margin: -2px -4px;
  color: var(--text-2); font-size: 12px; cursor: pointer; border-radius: 4px;
}
.link-btn:hover { color: var(--accent); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: none; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 13px; white-space: nowrap;
}
.chip:hover:not(:disabled) { border-color: var(--text-3); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip:disabled { opacity: .4; cursor: default; }
.chip-n { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.chip[aria-pressed="true"] .chip-n { color: inherit; opacity: .75; }
.chip-x { background: var(--accent-soft); border-color: transparent; padding-right: 7px; }
.chip-x::after { content: "×"; font-size: 15px; line-height: 1; color: var(--text-2); }

.tag {
  border: 0; background: var(--surface-2); color: var(--text-2);
  font-size: 12px; padding: 2px 8px; border-radius: 4px; cursor: pointer;
}
.tag:hover { background: var(--accent-soft); color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- barra superior ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  height: var(--topbar-base); padding: 0 16px;
  background: var(--bar-bg); color: var(--bar-text);
  border-bottom: 1px solid var(--bar-line);
}
.topbar .icon-btn { color: var(--bar-text-2); }
.topbar .icon-btn:hover { background: var(--bar-hover); color: var(--bar-text); }
.topbar :focus-visible { outline-color: var(--bar-focus); }

/* Logo: collage de recortes tipográficos */
.brand { display: inline-flex; color: inherit; text-decoration: none; padding: 4px 2px; flex: none; }
/* Escritorio: la marca ocupa el ancho del sidebar para que el menú arranque en la misma
   vertical que la barra de resultados y las cards (sidebar + padding del main) */
@media (min-width: 761px) {
  .brand { width: calc(var(--sidebar-w) + 20px - 16px - 20px); } /* + padding main − padding topbar − gap */
  .sections { margin-left: -10px; }                              /* el texto del enlace, no su caja */
}
.logo { display: inline-flex; align-items: center; line-height: 1; white-space: nowrap; }
.logo-what {
  font: italic 400 27px/1 "Instrument Serif", Georgia, serif;
  letter-spacing: -.01em; padding-right: 3px; transform: translateY(1px);
}
.logo-the {
  font: 700 10px/1 "Space Mono", var(--mono);
  background: var(--bar-text); color: var(--bar-bg);
  padding: 3px 4px 2px; margin: 0 2px 0 1px;
  transform: rotate(-7deg) translateY(-6px);
}
.logo-style {
  font: 400 19px/1 Anton, "Arial Narrow", Impact, sans-serif;
  text-transform: uppercase; letter-spacing: .02em;
  background: var(--brand-yellow); color: #111;
  padding: 4px 7px 3px 6px;
  transform: rotate(-2.5deg);
  clip-path: polygon(0 6%, 9% 0, 34% 4%, 62% 0, 100% 3%, 98% 52%, 100% 96%, 70% 100%, 41% 95%, 12% 100%, 2% 94%, 0 48%);
}
.logo-q {
  font: italic 400 30px/1 "Instrument Serif", Georgia, serif;
  color: var(--logo-q); margin-left: 1px;
  transform: rotate(10deg) translateY(-2px);
}
.brand:hover .logo-style { transform: rotate(-1deg); }
.brand:hover .logo-the { transform: rotate(-3deg) translateY(-6px); }
.logo-style, .logo-the { transition: transform .2s; }

.sections { display: flex; gap: 6px; }
.section-link {
  position: relative; display: inline-flex; align-items: center; height: 36px; padding: 0 10px;
  color: var(--bar-text-2); text-decoration: none; font-weight: 500; border-radius: var(--radius-sm);
  transition: color .15s;
}
.section-link::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 4px; height: 2px; border-radius: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .25s cubic-bezier(.2, .7, .2, 1);
}
.section-link:hover { color: var(--bar-text); }
.section-link:hover::after, .section-link:focus-visible::after { transform: scaleX(1); }
.section-link:active { opacity: .7; }
.section-link[aria-current="page"] { color: var(--bar-text); }
.section-link[aria-current="page"]::after { transform: scaleX(1); background: var(--brand-yellow); height: 3px; bottom: 3px; }

.search { position: relative; flex: 1; max-width: 380px; margin-left: auto; }
.search input {
  width: 100%; height: 34px; font-size: 13.5px; padding: 0 34px 0 34px;
  border: 1px solid var(--bar-field-line); border-radius: 8px;
  background: var(--bar-field); color: var(--bar-text);
}
.search input::placeholder { color: var(--bar-text-2); }
.search input:focus { outline: none; border-color: var(--bar-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bar-focus) 18%, transparent); }
.search input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--bar-text-2); pointer-events: none; }
.search-kbd {
  position: absolute; right: 8px; top: 8px;
  font: 11px/16px var(--mono); padding: 0 6px; border: 1px solid var(--bar-field-line); border-radius: 4px; color: var(--bar-text-2);
}
.search input:focus ~ .search-kbd, .search input:not(:placeholder-shown) ~ .search-kbd { display: none; }
.search input:disabled { opacity: .55; cursor: not-allowed; }
/* Botón para borrar: solo visible cuando hay texto (sin depender del JS) */
.search-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 6px; background: none; color: var(--bar-text-2); cursor: pointer;
}
.search-clear svg { width: 16px; height: 16px; }
.search-clear:hover { color: var(--bar-text); background: var(--bar-hover); }
.search input:placeholder-shown ~ .search-clear, .search input:disabled ~ .search-clear { display: none; }

.search input:disabled ~ .search-kbd { display: none; }

/* ---------- layout ---------- */

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

.layout { transition: grid-template-columns .25s cubic-bezier(.2, .7, .2, 1); }
.filters {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); overflow: hidden auto;
  background: var(--sidebar-bg);
}
.filters-scroll { width: var(--sidebar-w); padding: 16px 20px 40px 16px; }
.sidebar-collapsed .layout { grid-template-columns: 0 minmax(0, 1fr); }
.sidebar-collapsed .filters { visibility: hidden; transition: visibility 0s .25s; }

/* Borde reactivo: botón a lo alto del borde del sidebar */
.rail {
  position: fixed; z-index: 15; top: var(--topbar-h); bottom: 0; left: calc(var(--sidebar-w) - 7px);
  width: 14px; padding: 0; border: 0; background: none;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='13' fill='%2317171a' stroke='%23fff' stroke-width='2'/%3E%3Cpath d='m18 10.5-5.5 5.5 5.5 5.5' fill='none' stroke='%23ffd60a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 16 16, w-resize;
  transition: left .25s cubic-bezier(.2, .7, .2, 1);
}
.sidebar-collapsed .rail {
  left: 0;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='13' fill='%2317171a' stroke='%23fff' stroke-width='2'/%3E%3Cpath d='m14 10.5 5.5 5.5-5.5 5.5' fill='none' stroke='%23ffd60a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 16 16, e-resize;
}
.rail-line {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; margin-left: -.5px;
  background: var(--line); transition: background .15s, width .15s, margin .15s;
}
.sidebar-collapsed .rail-line { left: 0; margin-left: 0; }
.rail:hover .rail-line, .rail:focus-visible .rail-line { width: 3px; margin-left: -1.5px; background: var(--accent); }
.sidebar-collapsed .rail:hover .rail-line, .sidebar-collapsed .rail:focus-visible .rail-line { margin-left: 0; }
.rail:focus-visible { outline: none; }
/* Con teclado no hay cursor: se muestra una pestaña visible con la flecha */
.rail-tip {
  position: absolute; top: 50%; left: 50%; width: 24px; height: 40px; margin: -20px 0 0 -12px;
  border-radius: 12px; background: var(--accent); opacity: 0; transform: scale(.8); transition: opacity .15s, transform .15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m14 7-5 5 5 5' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 18px; background-position: center; background-repeat: no-repeat;
}
.sidebar-collapsed .rail-tip { left: 12px; transform: scale(.8) scaleX(-1); }
.rail:focus-visible .rail-tip { opacity: 1; transform: none; }
.sidebar-collapsed .rail:focus-visible .rail-tip { transform: scaleX(-1); }
@media (hover: none) { .rail-tip { opacity: 1; transform: none; } }
.sidebar-collapsed .filters-toggle { display: inline-flex; }
.about { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); color: var(--text-2); font-size: 13px; }
.about p + p { margin-top: 8px; }
.about-lead { font-size: 17px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; color: var(--text); }
.section-tag {
  display: inline-block; margin-bottom: 10px; padding: 2px 6px 1px;
  background: var(--brand-yellow); color: #111; border-radius: 3px;
  font: 700 10px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .08em;
}
.about-mobile { display: none; }

.filters-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; min-height: 24px; }
.filters-title { font-size: 14px; font-weight: 600; }
.filters-actions { display: flex; align-items: center; gap: 14px; }
.toggle-all { display: inline-flex; align-items: center; gap: 4px; }
.toggle-all svg { width: 12px; height: 12px; }

.facet { border-top: 1px solid var(--line); }
.facet:last-child { border-bottom: 1px solid var(--line); }
.facet-head { display: flex; align-items: center; gap: 8px; }
.facet-toggle {
  flex: 1; display: flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left;
}
.facet-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.facet-toggle:hover .facet-label { color: var(--text); }
.chevron { width: 12px; height: 12px; color: var(--text-3); transform: rotate(-90deg); transition: transform .15s; flex: none; }
.facet.is-open .chevron { transform: none; }
.facet-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text);
  font: 600 11px/18px var(--mono); text-align: center;
}
.facet-values { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 0 14px; }
.facet-values[hidden] { display: none; }

.drawer-head, .drawer-foot, .drawer-backdrop { display: none; }
.btn-block { width: 100%; justify-content: center; height: 42px; }

.main { padding: 16px 20px 16px; min-width: 0; }
.main:focus { outline: none; }

.toolbar {
  position: sticky; top: var(--topbar-h); z-index: 10;
  display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap;
  margin: -16px -20px 16px; padding: 10px 20px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.toolbar-start, .toolbar-end, .toolbar-actions { display: flex; align-items: center; gap: 8px; }
.toolbar-start { flex: none; }
/* Lado derecho fluido: el select se encoge (sin mínimo) antes de partir la línea */
.toolbar-end { margin-left: auto; flex: 1 1 0; min-width: 0; justify-content: flex-end; }
.toolbar-end .count { flex: none; }
.sort { display: flex; flex: 0 1 auto; min-width: 0; }
.toolbar .sort select { min-width: 0; max-width: min(100%, 11rem); width: auto; text-overflow: ellipsis; }
.show-sm { display: none; }
.toolbar .btn, .toolbar .sort select { height: 32px; }
.toolbar .btn { text-decoration: none; color: var(--text); }
.count { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.active { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; }
.sort select {
  height: 32px; padding: 0 26px 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 9px center / 9px;
  appearance: none; font-size: 13px; cursor: pointer;
}
.filters-toggle { display: none; }
.filters-toggle svg { width: 18px; height: 18px; }
.filters-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); font: 600 11px/18px var(--mono); text-align: center;
}
.filters-badge[hidden] { display: none; }

/* ---------- secciones tipo página ---------- */

.page { padding: 8px 0 40px; min-height: calc(100vh - var(--topbar-h) - 140px); }
.page-note { color: var(--text-3); }
.view-page .layout { grid-template-columns: minmax(0, 1fr); }
.view-page .filters, .view-page .rail, .view-page .toolbar, .view-page .about-mobile,
.view-page #grid, .view-page .empty, .view-page #intro { display: none !important; }
.view-page .main { padding-top: 32px; }

/* ---------- menú móvil ---------- */

.menu-btn, .mobile-menu { display: none; }
.menu-lines { position: relative; display: block; width: 18px; height: 8px; }
.menu-lines span {
  position: absolute; left: 0; width: 100%; height: 1.6px; border-radius: 1px; background: currentColor;
  transition: transform .2s, top .2s;
}
.menu-lines span:first-child { top: 0; }
.menu-lines span:last-child { top: calc(100% - 1.6px); }
.menu-btn[aria-expanded="true"] .menu-lines span:first-child { top: calc(50% - .8px); transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] .menu-lines span:last-child { top: calc(50% - .8px); transform: rotate(-45deg); }

/* ---------- footer ---------- */

.footer { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; justify-content: center; text-align: center; }
.labs {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-2); text-decoration: none; font-size: 13px;
}
.labs:hover { color: var(--text); }
.labs-x { width: 15px; height: 15px; color: var(--text); }
.labs-bar { width: 1px; height: 16px; background: currentColor; opacity: .5; }
.labs-name { font-weight: 600; color: var(--text); letter-spacing: .01em; }

/* ---------- tarjetas ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }

.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.card:focus-visible { outline-offset: 0; }
.card-media { display: block; aspect-ratio: 3 / 2; background: var(--surface-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; object-position: top left; transition: transform .3s; }
.card:hover .card-media img { transform: scale(1.02); }
.card-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px; flex: 1; }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
.card-summary {
  color: var(--text-2); font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-hit { font-size: 12.5px; color: var(--text-2); border-left: 2px solid var(--accent); padding-left: 8px; }
.card-hit-label { display: block; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-dl { width: 30px; height: 30px; margin: -6px -8px -6px 0; color: var(--text-3); }
.card-dl:hover { color: var(--text); }
.card-tags { margin-top: auto; padding-top: 4px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn .muted { font-weight: 400; font-size: 12px; }
.detail-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.detail-titlebar .btn { text-decoration: none; color: var(--text); }
.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn-sm svg { width: 17px; height: 17px; }

.empty { padding: 60px 0; text-align: center; color: var(--text-2); display: grid; gap: 12px; justify-items: center; }
.empty[hidden] { display: none; }

/* ---------- ficha de detalle ---------- */

.sheet {
  width: min(1180px, calc(100vw - 32px)); height: calc(100vh - 32px); max-height: none; max-width: none;
  margin: auto; padding: 0;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / .25);
  overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .18s ease-out; }
.sheet::backdrop { background: rgb(10 10 12 / .5); backdrop-filter: blur(2px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px) scale(.995); } }

.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  height: var(--sheet-head-h); padding: 0 10px; border-bottom: 1px solid var(--line); flex: none;
}
.sheet-nav { display: flex; align-items: center; gap: 2px; }
.sheet-pos { font: 12px var(--mono); color: var(--text-3); min-width: 44px; text-align: center; }
.sheet-body { overflow-y: auto; flex: 1; overscroll-behavior: contain; }

.detail { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 32px; padding: var(--detail-pad); }
/* Columna fija: arranca y se queda en el mismo sitio (top = padding) y nunca supera el alto visible,
   para que el sticky no se suelte; si no cabe, hace scroll por dentro. */
.detail-aside {
  display: flex; flex-direction: column; gap: 24px; align-self: start;
  position: sticky; top: var(--detail-pad);
  max-height: calc(100vh - 32px - 2px - var(--sheet-head-h) - 2 * var(--detail-pad));
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
}
.detail-image { display: block; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); cursor: zoom-in; }
.detail-tags { display: grid; gap: 8px; margin: 0; }
.detail-tags > div { display: grid; grid-template-columns: 92px 1fr; gap: 8px; align-items: baseline; }
.detail-tags dt { font-size: 12px; color: var(--text-3); }
.detail-tags dd { margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }

.related { display: grid; gap: 6px; }
.related .h-small { margin-bottom: 2px; }
.related { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.related .h-small { grid-column: 1 / -1; }
.mini {
  display: flex; align-items: center; gap: 8px; text-align: left;
  padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  cursor: pointer; font-size: 13px; font-weight: 500; min-width: 0;
}
.mini:hover { border-color: var(--line-strong); background: var(--surface-2); }
.mini img { width: 48px; height: 34px; object-fit: cover; object-position: top left; border-radius: 4px; flex: none; }
.mini > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.detail-title { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.detail-title .num { font-size: 15px; vertical-align: 6px; margin-right: 2px; }

.detail-sections { display: grid; gap: 0; border-top: 1px solid var(--line); }
.block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.block p { max-width: 70ch; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.block .link-btn { opacity: 0; transition: opacity .15s; }
.block:hover .link-btn, .block .link-btn:focus-visible { opacity: 1; }
.block-avoid .h-small { color: var(--avoid); }

.prompt {
  display: grid; gap: 12px; padding: 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
}
.prompt .block-head { margin: 0; }
.prompt-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--text-2); }
.field input {
  height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 13px; color: var(--text);
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input::placeholder { color: var(--text-3); }
.prompt-include { display: flex; flex-wrap: wrap; gap: 4px 14px; border: 0; margin: 0; padding: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--accent); margin: 0; }
.prompt-preview {
  margin: 0; padding: 12px; max-height: 220px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: 12px/1.55 var(--mono); color: var(--text-2); white-space: pre-wrap; word-break: break-word;
}
.prompt-actions { display: flex; align-items: center; gap: 16px; }
.prompt-actions .btn { min-width: 150px; justify-content: center; transition: background .15s, border-color .15s; }
.btn-primary.is-done, .btn-primary.is-done:hover { background: #1f8a4c; border-color: #1f8a4c; color: #fff; filter: none; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 1000;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  transition: opacity .15s, transform .15s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */

/* En columna única se intercalan los bloques de ambas columnas */
@media (max-width: 960px) {
  .detail { display: flex; flex-direction: column; gap: 20px; }
  .detail-aside, .detail-main { display: contents; }
  .detail-title { order: 1; }
  .detail-image { order: 3; }
  .detail-tags { order: 4; }
  .detail-sections { order: 5; }
  .prompt { order: 6; }
  .related { order: 7; }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px 10px 16px; gap: 10px 4px; }
  .brand { order: 1; margin-right: auto; width: auto; }
  .topbar .sections { display: none; }
  #theme-toggle { order: 2; }
  .menu-btn { display: inline-grid; order: 3; color: var(--bar-text) !important; }
  .search { order: 4; flex-basis: 100%; max-width: none; margin-right: 4px; }
  body.menu-open { overflow: hidden; }
  body.menu-open .search { display: none; }
  .mobile-menu {
    display: block; position: fixed; z-index: 19; inset: var(--topbar-h) 0 0 0;
    background: var(--bar-bg); color: var(--bar-text); padding: 24px 16px; overflow-y: auto;
    animation: menu-in .2s ease-out;
  }
  .mobile-menu[hidden] { display: none; }
  .mobile-menu nav { display: flex; flex-direction: column; gap: 4px; }
  .mobile-menu .section-link { height: auto; padding: 10px 0; font-size: 30px; font-weight: 700; letter-spacing: -.02em; align-self: flex-start; }
  .mobile-menu .section-link::after { left: 0; right: 0; bottom: 6px; }
  @keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } }
  .toolbar { margin: 0 -16px 16px; padding: 10px 16px; }
  .toolbar { gap: 8px; }
  .toolbar .active { order: 3; flex-basis: 100%; }
  .toolbar .active:empty { display: none; }
  .hide-sm { display: none; }
  .filters-toggle { width: 32px; padding: 0; justify-content: center; position: relative; }
  .filters-toggle .filters-badge { position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; font-size: 10px; line-height: 16px; padding: 0 4px; }
  .show-sm { display: inline; }
  .search-kbd { display: none; }
  .layout { display: block; }
  .about-mobile { display: block; }
  .filters .about { display: none; }
  .filters {
    position: fixed; z-index: 60; top: 0; left: 0; bottom: 0;
    width: min(360px, 88vw); height: 100dvh; padding: 0;
    display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--line);
    box-shadow: 0 0 40px rgb(0 0 0 / .25);
    transform: translateX(-100%); visibility: hidden;
    transition: transform .22s ease, visibility 0s .22s;
  }
  body.filters-open { overflow: hidden; }
  body.filters-open .filters { transform: none; visibility: visible; transition: transform .22s ease; }
  .drawer-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); flex: none;
  }
  .drawer-title { font-weight: 600; font-size: 15px; }
  .filters-scroll { flex: 1; overflow-y: auto; padding: 12px 16px 16px; overscroll-behavior: contain; width: auto; }
  .rail, .sidebar-hide { display: none; }
  .sidebar-collapsed .filters { visibility: hidden; }
  body.filters-open.sidebar-collapsed .filters { visibility: visible; }
  .filters-scroll .filters-title { visibility: hidden; }
  .drawer-foot { display: block; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex: none; }
  .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgb(10 10 12 / .45); }
  .drawer-backdrop[hidden] { display: none; }
  .facet-toggle { min-height: 44px; }
  .chip { height: 32px; }
  .filters-toggle { display: inline-flex; }
  .main { padding: 16px 16px 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; }
  .sheet { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .detail { padding: 16px; }
  .prompt-fields { grid-template-columns: 1fr; }
  .block .link-btn { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- tiles de icono (secciones sin imagen) ---------- */

.card-media-tile, .detail-tile, .tile {
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--tile, var(--accent)) 16%, var(--surface));
  color: color-mix(in srgb, var(--tile, var(--accent)) 75%, var(--text));
}
.card-media-tile svg { width: 26%; height: auto; transition: transform .3s; }
.card:hover .card-media-tile svg { transform: scale(1.06) rotate(-2deg); }
.detail-tile { aspect-ratio: 3 / 2; cursor: default; }
.detail-tile svg { width: 24%; height: auto; }
.detail-tile img { width: 100%; height: 100%; object-fit: cover; }
.mini-media { width: 48px; height: 34px; flex: none; border-radius: 4px; overflow: hidden; }
.mini-media img, .mini .tile { width: 100%; height: 100%; object-fit: cover; }
.tile-sm svg { width: 18px; height: 18px; }
.mini .tile { border-radius: 0; }

.mono { font-family: var(--mono); font-weight: 600; letter-spacing: -.01em; }
.card-title .mono { font-size: 14px; }
.detail-title .mono { font-size: .9em; }
.example { font-family: var(--mono); font-size: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.prompt-hint { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.prompt-hint svg { width: 18px; height: 18px; flex: none; color: var(--accent); }
.field select {
  height: 34px; padding: 0 28px 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 10px center / 9px;
  appearance: none; font-size: 13px; color: var(--text);
}
.field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card-dl svg { width: 18px; height: 18px; }

/* Al final del archivo para prevalecer. En pantallas táctiles, campos a 16px: por debajo, iOS amplía la página al enfocarlos.
   (No se bloquea el zoom con maximum-scale: lo necesita quien amplía para leer.) */
@media (pointer: coarse) {
  input, select, textarea, .search input, .field input, .field select, .sort select { font-size: 16px; }
}
