:root {
  --bg: #FAFAF9;
  --surface: #FFFFFF;
  --surface-2: #F0EFED;
  --text: #1C1917;
  --muted: #57534E;
  --border: #E7E5E4;
  --accent: #C2410C;
  --on-accent: #FFFFFF;
  --scrim: rgb(12 10 9 / .45);
  --radius: 14px;
  --t-fast: 120ms;
  --t-med: 220ms;
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0C0A09;
    --surface: #1C1917;
    --surface-2: #292524;
    --text: #F5F5F4;
    --muted: #A8A29E;
    --border: #292524;
    --accent: #FB923C;
    --on-accent: #1C1917;
    --scrim: rgb(0 0 0 / .6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --- cabecera fija: buscador + micro + categorias --- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto; gap: 10px;
  padding: calc(var(--safe-t) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--border);
}
.search {
  position: relative; display: flex; align-items: center;
  background: var(--surface-2); border-radius: 999px; min-height: 48px;
}
.search-ico { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search input {
  flex: 1; min-width: 0; height: 48px; padding: 0 44px 0 44px;
  border: 0; background: transparent; color: var(--text);
  font-size: 17px; /* >=16 para que iOS no haga zoom */
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { outline: none; }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.clear {
  position: absolute; right: 2px; width: 44px; height: 44px;
  display: grid; place-items: center; border: 0; background: none; color: var(--muted);
}
.clear svg { width: 18px; height: 18px; }
.mic {
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  transition: transform var(--t-fast) ease-out;
}
.mic:active { transform: scale(.92); }
.mic.on { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 25%, transparent); } }

.chips {
  grid-column: 1 / -1;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px;
  scroll-padding-inline: 16px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: 14px; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }
.chip.hint { border-color: var(--accent); }

/* --- rejilla de carpetas --- */
main { padding: 8px 16px calc(var(--safe-b) + 24px); max-width: 1100px; margin: 0 auto; }
.status { margin: 6px 2px 12px; color: var(--muted); font-size: 14px; }
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 12px;
}
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.card {
  display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left;
  transition: transform var(--t-fast) ease-out;
}
.card:active { transform: scale(.97); }
.cover {
  position: relative; aspect-ratio: 9 / 16; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .ph {
  position: absolute; inset: 0; padding: 14px;
  display: flex; align-items: flex-end;
  color: #fff; font-weight: 600; font-size: 15px; line-height: 1.3;
  background: linear-gradient(160deg, var(--c1), var(--c2));
}
.badge {
  position: absolute; left: 8px; bottom: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px 3px 6px; border-radius: 999px;
  background: rgb(0 0 0 / .62); color: #fff; font-size: 12px; font-weight: 500;
}
.badge svg { width: 14px; height: 14px; }
.card h3 {
  margin: 8px 2px 0; font-size: 14px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .who { margin: 2px 2px 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { grid-column: 1 / -1; padding: 40px 8px; text-align: center; color: var(--muted); }

.foot { margin-top: 32px; text-align: center; color: var(--muted); font-size: 13px; }
.link { border: 0; background: none; color: var(--accent); font-size: 14px; min-height: 44px; padding: 0 8px; text-decoration: underline; }

/* --- muestra e importar --- */
.intro {
  margin: 4px 0 16px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  display: grid; gap: 12px;
}
.intro[hidden] { display: none; }
.intro p { margin: 0; font-size: 15px; }
@media (min-width: 700px) { .intro { grid-template-columns: 1fr auto; align-items: center; } .intro .btn { padding: 0 20px; } }
.btn { border: 0; font: inherit; font-weight: 600; cursor: pointer; width: 100%; }
.intro .btn { width: auto; }
.muted { color: var(--muted); font-size: 14px; }
.privacy { margin: 8px 0 0; }
.imp h2 { margin: 4px 56px 4px 0; font-size: 22px; }
.imp > .muted { margin: 0 0 8px; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 18px; }
.steps li { counter-increment: s; position: relative; padding-left: 40px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px;
}
.steps h3 { margin: 2px 0 8px; font-size: 17px; }
.steps p { margin: 8px 0 0; }
.btn.bm { display: inline-flex; width: auto; padding: 0 22px; cursor: grab; }
.file { position: relative; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.imp-status { min-height: 1.5em; margin: 16px 0 8px; font-weight: 600; }
.imp details { margin-top: 8px; }
.imp summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.only-mouse { display: none; }
@media (hover: hover) and (pointer: fine) { .only-mouse { display: block; } .only-touch { display: none; } }

/* --- ficha de una publicacion (hoja inferior) --- */
.sheet {
  border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%;
  max-height: 92dvh; background: var(--surface); color: var(--text);
  border-radius: 20px 20px 0 0; overflow: auto; overscroll-behavior: contain;
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] { animation: up var(--t-med) cubic-bezier(.2, .8, .2, 1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 700px) {
  .sheet { margin: auto; max-width: 640px; border-radius: 20px; }
}
.sheet-body { position: relative; padding: 16px 16px calc(var(--safe-b) + 20px); }
.close {
  position: absolute; top: 12px; right: 12px; z-index: 1;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: rgb(0 0 0 / .55); color: #fff;
}
.d-cover { width: min(58%, 240px); margin: 0 auto; }
.d-cover .cover { border-radius: 16px; }
.d-info { max-width: 60ch; margin: 16px auto 0; }
.d-info h2 { margin: 0; font-size: 20px; line-height: 1.3; }
.d-meta { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.d-cats { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; }
.d-cats .chip { min-height: 32px; font-size: 13px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; border-radius: 12px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 600; text-decoration: none;
}
.d-cap { margin: 16px 0 0; white-space: pre-line; overflow-wrap: anywhere; font-size: 15px; color: var(--text); }
.d-cap:empty { display: none; }

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