:root {
  --bg: #f7f2ea;
  --paper: #fffdf9;
  --ink: #2c2622;
  --muted: #7b7067;
  --line: #e6dccf;
  --accent: #a8835a;
  --accent-ink: #fff;
  --accent-soft: #f1e6d7;
  --ok: #5f7d5a;
  --err: #b4483c;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 8px 24px rgba(60, 40, 20, .06);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 1100px; margin: 0 auto; padding: 0 16px 120px; }
.page-subir main, .page-admin main { max-width: 620px; }
a { color: var(--accent); }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Encabezado */
.hero { text-align: center; padding: 34px 16px 10px; }
.rings { width: 54px; height: 34px; stroke: var(--accent); stroke-width: 2.4; }
.hero h1 { font: 600 clamp(34px, 9vw, 52px)/1.05 var(--serif); margin: 6px 0 4px; letter-spacing: .5px; }
.hero .date { margin: 0; color: var(--muted); letter-spacing: .18em; text-transform: uppercase; font-size: 12px; }

.tabs {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 6px; justify-content: center;
  padding: 10px 16px; margin-bottom: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tabs a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 22px; border-radius: 999px;
  text-decoration: none; color: var(--ink); font-weight: 500;
  border: 1px solid var(--line); background: var(--paper);
}
.tabs a svg { font-size: 18px; }
.tabs a.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.lead { text-align: center; color: var(--muted); font: italic 500 21px/1.35 var(--serif); margin: 6px 8px 22px; }
.tip { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 8px; }
.foot { text-align: center; color: var(--muted); font: italic 15px var(--serif); padding: 30px 16px 40px; }

/* ---------- Botón gigante de subir */
.picker {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 34px 20px; border-radius: 24px;
  background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow); cursor: pointer; text-align: center;
  transition: transform .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.picker:active { transform: scale(.98); }
.picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.picker-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); margin-bottom: 6px; }
.picker-icon svg { font-size: 32px; color: #fff; }
.picker-title { font: 600 28px/1.1 var(--serif); }
.picker-sub { font-size: 14px; opacity: .75; }
.picker:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---------- Formularios */
.field { margin: 18px 2px; }
.field label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.opt { color: var(--muted); font-weight: 400; }
input[type=text], input[type=password] {
  width: 100%; font: inherit; font-size: 16px; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.small { padding: 8px 14px; font-size: 14px; white-space: nowrap; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); font-size: 14px; white-space: nowrap;
}
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 14px 0; box-shadow: var(--shadow); }
.card h2 { font: 600 28px/1.15 var(--serif); margin: 0 0 8px; }
.card h3 { font: 600 22px/1.2 var(--serif); margin: 0 0 12px; }
.card.closed { text-align: center; padding: 36px 20px; }
.card.narrow { max-width: 380px; margin: 30px auto; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 12.5px; }
.error { color: var(--err); font-size: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
code { font-size: 12px; background: var(--accent-soft); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

/* ---------- Cola de subida */
.lote { margin-top: 10px; }
.lote-head { display: flex; justify-content: space-between; align-items: center; margin: 8px 2px; }
.lote-head h2 { font: 600 24px var(--serif); margin: 0; }
.cola { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 10px;
}
.item .th {
  width: 64px; height: 64px; border-radius: 10px; background: var(--accent-soft) center/cover no-repeat;
  display: grid; place-items: center; color: var(--accent); position: relative; overflow: hidden;
}
.item .th svg { font-size: 26px; }
.item .name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12.5px; color: var(--muted); }
.item .meta.err { color: var(--err); }
.item .meta.ok { color: var(--ok); }
.bar { height: 5px; border-radius: 9px; background: var(--accent-soft); overflow: hidden; margin: 6px 0 2px; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
.item.done .bar span { background: var(--ok); }
.item .tags-line { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: #6d5233; font-size: 12px; border: 0; }
.tag.add { background: transparent; border: 1px dashed var(--accent); color: var(--accent); }
.item .act { align-self: start; }
.ico-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; color: var(--muted); }
.ico-btn svg { font-size: 18px; }
.ok-badge { color: var(--ok); }

.resumen {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 596px; margin: 0 auto;
  background: var(--ink); color: var(--bg); border-radius: 16px; padding: 12px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.resumen-bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.18); overflow: hidden; margin-bottom: 9px; }
.resumen-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.resumen.done .resumen-bar span { background: #9bb894; }
.resumen-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }

/* ---------- Hoja de etiquetas (bottom sheet) */
.sheet-bg { position: fixed; inset: 0; background: rgba(30, 20, 10, .45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; background: var(--paper); border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 85vh; overflow: auto;
  animation: up .2s ease;
}
@media (min-width: 600px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet h3 { font: 600 24px var(--serif); margin: 0 0 4px; }
.sheet .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.sheet .chips button { padding: 9px 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: 15px; }
.sheet .chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.sheet .sheet-foot { display: flex; justify-content: flex-end; margin-top: 16px; }

/* ---------- Galería */
.banner { background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; font-size: 14px; margin: 6px 0 10px; text-align: center; }
.stats { text-align: center; color: var(--muted); margin: 4px 0 12px; font-size: 14px; }
.filtros { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.seg { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font-size: 14px; }
.seg button.on { background: var(--ink); color: var(--bg); }
.tag-scroll { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.tag-scroll::-webkit-scrollbar { display: none; }
.tag-scroll button { flex: none; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: 13.5px; }
.tag-scroll button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tag-scroll button small { opacity: .65; margin-left: 4px; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; } }
.tile {
  position: relative; aspect-ratio: 1; border: 0; padding: 0; overflow: hidden;
  background: var(--accent-soft); border-radius: 6px; display: block; width: 100%;
}
@media (min-width: 640px) { .tile { border-radius: 10px; } }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease, opacity .3s; opacity: 0; }
.tile img.ld { opacity: 1; }
.tile:hover img { transform: scale(1.03); }
.tile .badge {
  position: absolute; right: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 3px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 11.5px; padding: 2px 7px 2px 5px; border-radius: 999px;
}
.tile .badge svg { font-size: 12px; fill: #fff; stroke: none; }
.tile .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.sentinel { display: flex; justify-content: center; padding: 26px; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.nuevos {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 25;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 9px 18px; font-weight: 600; box-shadow: var(--shadow);
}

/* ---------- Visor */
.visor { position: fixed; inset: 0; z-index: 50; background: #0c0a09; color: #f3ede6; display: flex; flex-direction: column; }
.visor-top { display: flex; justify-content: space-between; align-items: center; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; font-size: 14px; }
.visor .ico { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: rgba(255,255,255,.08); border: 0; }
.visor .ico svg { font-size: 22px; }
.visor-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.visor-stage img, .visor-stage video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.visor-stage .note { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.6); padding: 6px 12px; border-radius: 999px; font-size: 12.5px; }
.visor .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; display: none; place-items: center; }
.visor .nav svg { font-size: 24px; }
.visor .prev { left: 14px; } .visor .next { right: 14px; }
@media (hover: hover) and (min-width: 700px) { .visor .nav { display: grid; } }
.visor-info { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); font-size: 14px; display: grid; gap: 6px; }
.visor-info .when { font-weight: 500; }
.visor-info .who { opacity: .7; font-size: 13px; }
.visor-info .tags-line { display: flex; flex-wrap: wrap; gap: 6px; }
.visor-info .tag { background: rgba(255,255,255,.12); color: #f3ede6; cursor: pointer; }
.visor-info .admin-row { display: flex; gap: 8px; flex-wrap: wrap; }
.visor-info .admin-row button { background: rgba(255,255,255,.1); border: 0; color: #fff; padding: 7px 13px; border-radius: 999px; font-size: 13px; }

/* ---------- Admin */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.kpis div { background: var(--bg); border-radius: 12px; padding: 12px; }
.kpis b { display: block; font: 600 26px var(--serif); }
.kpis span { color: var(--muted); font-size: 13px; }
.switch { display: flex; gap: 14px; align-items: flex-start; padding: 10px 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { flex: none; width: 46px; height: 28px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; margin-top: 2px; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch small { display: block; color: var(--muted); font-size: 13px; }
.copy { display: flex; gap: 8px; }
.copy input { flex: 1; }
.qr-wrap { display: flex; gap: 16px; align-items: center; margin-top: 14px; }
.qr { width: 132px; height: 132px; flex: none; background: #fff; border-radius: 10px; padding: 8px; }
.qr canvas, .qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 80; }

/* ---------- Gestionar (admin) */
.page-gestionar main { max-width: 1200px; }
@media (max-width: 440px) { .tabs { gap: 4px; padding: 10px 8px; } .tabs a { padding: 9px 13px; font-size: 14px; gap: 6px; } }
.g-toolbar { display: grid; gap: 10px; margin: 6px 0 12px; }
.g-toolbar input[type=search] {
  width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--paper); color: var(--ink);
}
.g-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.g-filters select {
  font: inherit; font-size: 14px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink);
}
.chip-btn.on { background: var(--err); border-color: var(--err); color: #fff; }
.chip-btn svg { font-size: 16px; }
.g-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 0 10px; flex-wrap: wrap; }
.g-head-actions { display: flex; align-items: center; gap: 14px; }
.g-grid { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 640px) { .g-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }
.g-tile { cursor: pointer; }
.g-tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.g-tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: 11.5px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.6)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.g-tile .badge { bottom: auto; top: 6px; right: 6px; }
.g-tile .check {
  position: absolute; top: 6px; left: 6px; width: 28px; height: 28px; border-radius: 50%; padding: 0;
  border: 2px solid #fff; background: rgba(0,0,0,.25); color: transparent; display: grid; place-items: center;
  opacity: .85; transition: opacity .15s;
}
.g-tile .check svg { font-size: 16px; stroke-width: 3; }
@media (hover: hover) { .g-tile .check { opacity: 0; } .g-tile:hover .check, .g-grid.selecting .check { opacity: 1; } }
.g-tile.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.g-tile.sel img { transform: scale(.92); }
.g-tile.sel .check { opacity: 1; background: var(--accent); border-color: var(--accent); color: #fff; }

body.modo-papelera .no-trash, body:not(.modo-papelera) .only-trash { display: none; }
.bulk {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40;
  max-width: 900px; margin: 0 auto; background: var(--ink); color: var(--bg); border-radius: 16px;
  padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.bulk > span { font-weight: 600; font-size: 14px; padding-left: 4px; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bulk-actions button { border: 0; border-radius: 999px; padding: 8px 13px; font-size: 13.5px; background: rgba(255,255,255,.12); color: #fff; }
.bulk-actions button.danger, .btn.danger { background: var(--err); color: #fff; }
.bulk-actions button.danger-soft { background: rgba(180,72,60,.35); }
.bulk-actions button.ghost { background: transparent; text-decoration: underline; }
.btn.danger-soft { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line)); }

.modal-bg { position: fixed; inset: 0; z-index: 55; background: rgba(20, 14, 8, .6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.editor {
  width: 100%; max-width: 1040px; max-height: calc(100vh - 32px); background: var(--paper); border-radius: 20px; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr);
}
.ed-media { background: #0c0a09; display: flex; flex-direction: column; min-height: 0; }
.ed-media img, .ed-media video { flex: 1; min-height: 0; width: 100%; height: 100%; object-fit: contain; max-height: calc(100vh - 90px); }
.ed-nav { display: flex; align-items: center; justify-content: center; gap: 14px; color: #ddd; font-size: 13px; padding: 6px; }
.ed-nav .ico-btn { color: #fff; }
.ed-nav .ico-btn:disabled { opacity: .3; }
.ed-form { padding: 18px 20px 22px; overflow: auto; display: grid; gap: 14px; align-content: start; }
.ed-form h3 { font: 600 24px var(--serif); margin: 0; }
.ed-field { display: grid; gap: 6px; }
.ed-field > span { font-size: 13.5px; font-weight: 500; }
.ed-field input {
  width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
.ed-field .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-field .chips button { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: 14px; }
.ed-field .chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ed-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-actions .btn { padding: 10px 16px; font-size: 14px; }
.ed-info { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 4px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.ed-info dt { color: var(--muted); }
.ed-info dd { margin: 0; word-break: break-all; }
@media (max-width: 760px) {
  .modal-bg { padding: 0; align-items: stretch; }
  .editor { display: block; max-height: none; height: 100%; border-radius: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .ed-media { display: block; }
  .ed-media img, .ed-media video { display: block; width: 100%; height: 42vh; max-height: none; }
  .ed-form { overflow: visible; }
}

/* ---------- Estado del servidor */
.pill { display: inline-block; vertical-align: middle; font: 600 12px var(--sans); padding: 3px 10px; border-radius: 999px; margin-left: 6px; }
.pill.ok { background: #e3ecdf; color: var(--ok); }
.pill.bad { background: #f6dfdb; color: var(--err); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.checks li { display: flex; gap: 10px; align-items: flex-start; }
.checks li > span { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.checks li.ok > span { background: #e3ecdf; color: var(--ok); }
.checks li.bad > span { background: #f6dfdb; color: var(--err); }
.checks small { display: block; color: var(--muted); font-size: 12.5px; }

/* ---------- Nombre obligatorio */
.req { color: var(--accent); font-weight: 500; }
.field-err { color: var(--err); font-size: 13.5px; margin: 6px 2px 0; }
.field.invalid input { border-color: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 18%, transparent); }
.nombre-field { margin: 0 2px 16px; }
.picker.locked { opacity: .55; }
.picker.locked .picker-sub::after { content: " · primero escribe tu nombre"; }
