:root {
  --bg: #100d0b;
  --surface: #191512;
  --surface-2: #221d19;
  --surface-3: #2c2520;
  --line: #3a312a;
  --text: #f2ebe3;
  --muted: #a99b8e;
  --faint: #7a6d62;
  --accent: #c9956b;
  --accent-2: #e3b68e;
  --accent-ink: #1a120c;
  --ok: #74c493;
  --ok-bg: rgba(116, 196, 147, .14);
  --bad: #e5806f;
  --bad-bg: rgba(229, 128, 111, .14);
  --warn: #e3b75f;
  --warn-bg: rgba(227, 183, 95, .14);
  --radius: 14px;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 120px; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); }
button, input, textarea, select { font: inherit; color: inherit; }
img, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.boot { min-height: 100vh; display: grid; place-items: center; font: 500 42px var(--serif); letter-spacing: 6px; color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Cabecera ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  padding: 12px max(16px, env(safe-area-inset-left)); background: rgba(16, 13, 11, .88);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand .logo { font: 500 26px/1 var(--serif); letter-spacing: 4px; color: var(--accent); }
.brand .sub { font-size: 10.5px; letter-spacing: 2.4px; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.menu { position: relative; }
.menu > button { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px 6px 6px; cursor: pointer; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 600; font-size: 12px; }
.menu .dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 18px 40px rgba(0,0,0,.45); }
.menu .dropdown a, .menu .dropdown button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; border: 0; background: none; color: var(--text); text-decoration: none; cursor: pointer; }
.menu .dropdown a:hover, .menu .dropdown button:hover { background: var(--surface-3); }
.menu .dropdown .who { padding: 8px 12px 10px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* ---------- Layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 16px 120px; }
.narrow { max-width: 440px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: .2px; margin: 0; }
h1 { font-size: clamp(30px, 6vw, 44px); line-height: 1.08; }
h2 { font-size: 28px; line-height: 1.15; }
h3 { font-size: 21px; }
.eyebrow { font-size: 11px; letter-spacing: 2.4px; text-transform: uppercase; color: var(--accent); font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }
.divider { height: 1px; background: var(--line); margin: 22px 0; border: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }

/* ---------- Formularios ---------- */
label.field { display: block; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { resize: vertical; min-height: 96px; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 149, 107, .18); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 76px; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font-size: 12.5px; padding: 6px 8px; cursor: pointer; }
.code-input { font-size: 28px; letter-spacing: 12px; text-align: center; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
  font-weight: 500; font-size: 14px; text-decoration: none; color: var(--text); transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; padding: 13px 16px; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.linkbtn { background: none; border: 0; color: var(--accent-2); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; font-size: 13.5px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.tabs button { border: 0; background: none; padding: 9px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button.on { background: var(--surface-3); color: var(--text); }

.alert { padding: 11px 14px; border-radius: 10px; font-size: 13.5px; background: var(--surface-2); border: 1px solid var(--line); }
.alert.err { background: var(--bad-bg); border-color: rgba(229,128,111,.35); color: #f4b3a7; }
.alert.ok { background: var(--ok-bg); border-color: rgba(116,196,147,.35); color: #b7e4c7; }
.alert.info { background: rgba(201,149,107,.1); border-color: rgba(201,149,107,.3); color: var(--accent-2); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 30px 26px; }
.auth .logo-big { font: 500 54px/1 var(--serif); letter-spacing: 8px; color: var(--accent); text-align: center; }
.auth .tag { text-align: center; font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); margin: 8px 0 26px; }

/* ---------- Lista de campañas ---------- */
.grid-campaigns { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 22px; }
.camp { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: border-color .15s, transform .15s; }
.camp:hover { border-color: var(--accent); transform: translateY(-2px); }
.camp .thumb { aspect-ratio: 16/9; background: var(--surface-2) center/cover no-repeat; }
.camp .body { padding: 16px 18px 18px; }
.camp h3 { font-size: 24px; margin: 6px 0 8px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 500; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.badge.accent { color: var(--accent-2); background: rgba(201,149,107,.12); border-color: transparent; }

.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width .4s; }

/* ---------- Campaña ---------- */
.camp-head { display: grid; gap: 14px; }
.camp-head .desc { color: var(--muted); max-width: 680px; white-space: pre-wrap; }
.howto { margin-top: 18px; }
.howto ol { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
.howto li { margin: 4px 0; }
.howto li b { color: var(--text); font-weight: 500; }

.admin-bar { margin-top: 18px; padding: 14px; border: 1px dashed rgba(201,149,107,.45); border-radius: var(--radius); background: rgba(201,149,107,.05); }
.admin-bar .row { gap: 8px; }

.pnav { position: sticky; top: 55px; z-index: 20; margin: 22px -16px 0; padding: 10px 16px; background: rgba(16,13,11,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.pnav::-webkit-scrollbar { display: none; }
.pnav a { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 13px; white-space: nowrap; }
.pnav a .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.pnav a.s-ready .dot { background: var(--ok); }
.pnav a.s-no .dot { background: var(--bad); }
.pnav a.s-progress .dot { background: var(--warn); }

.piece { margin-top: 34px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.piece > header { padding: 20px 22px 0; display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.piece .num { font: 500 40px/0.9 var(--serif); color: var(--accent); min-width: 44px; }
.piece .titles { flex: 1; min-width: 200px; }
.piece .titles h2 { margin-top: 2px; }
.piece .titles .row { margin-top: 8px; gap: 8px; }
.piece .pdesc { padding: 10px 22px 0; color: var(--muted); white-space: pre-wrap; }
.psec { padding: 20px 22px; border-top: 1px solid var(--line); margin-top: 20px; }
.psec + .psec { margin-top: 0; }
.psec > .sec-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.psec > .sec-title h3 { font-size: 22px; }

/* Archivos */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; padding: 18px 22px 0; }
.media-grid.has-video { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tile { background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s; }
.tile.st-aprobado { border-color: var(--ok); }
.tile.st-rechazado { border-color: var(--bad); }
.tile .frame { position: relative; background: #000; aspect-ratio: 4/5; display: grid; place-items: center; overflow: hidden; }
.tile.is-video .frame, .tile.r-portada .frame, .tile.r-historia .frame { aspect-ratio: 9/16; }
.tile .frame img, .tile .frame video { width: 100%; height: 100%; object-fit: contain; }
.tile .frame img { cursor: zoom-in; }
.tile .frame .stamp { position: absolute; top: 10px; left: 10px; pointer-events: none; }
.tile .meta { padding: 10px 12px 4px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tile .meta .fname { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 10px 10px; }
.vote { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 6px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-3); cursor: pointer; font-size: 13.5px; font-weight: 500; }
.vote:disabled { cursor: default; opacity: .7; }
.vote.yes.on { background: var(--ok); border-color: var(--ok); color: #0d1f14; }
.vote.no.on { background: var(--bad); border-color: var(--bad); color: #2a0f0a; }
.tile .note-link { padding: 0 12px 12px; }
.tile .adm { display: flex; gap: 6px; padding: 0 10px 10px; flex-wrap: wrap; }
.tile .adm select { flex: 1; min-width: 90px; padding: 5px 8px; font-size: 12.5px; border-radius: 8px; }
.empty-media { margin: 18px 22px 0; padding: 26px; text-align: center; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); }

/* Copies */
.copies { display: grid; gap: 12px; }
.copt { position: relative; display: block; background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; padding: 14px 16px 12px 48px; cursor: pointer; transition: border-color .15s, background .15s; }
.copt:hover { border-color: #57493e; }
.copt.on { border-color: var(--accent); background: rgba(201,149,107,.07); }
.copt .radio { position: absolute; left: 16px; top: 16px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--faint); display: grid; place-items: center; }
.copt.on .radio { border-color: var(--accent); }
.copt.on .radio::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.copt .clabel { font-size: 11.5px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: 6px; }
.copt .cbody { white-space: pre-wrap; word-wrap: break-word; }
.copt .cfoot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--faint); flex-wrap: wrap; }
.copt textarea { margin-top: 4px; min-height: 120px; cursor: text; }
.copt.disabled { cursor: default; }

/* Decisión */
.decide { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dbtn { padding: 15px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.dbtn:disabled { cursor: default; }
.dbtn.yes.on { background: var(--ok); border-color: var(--ok); color: #0d1f14; }
.dbtn.no.on { background: var(--bad); border-color: var(--bad); color: #2a0f0a; }
.hint { margin-top: 10px; font-size: 13px; color: var(--warn); }

/* Notas */
.notes-list { display: grid; gap: 10px; margin-bottom: 14px; }
.note { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; }
.note.mine { border-color: rgba(201,149,107,.35); }
.note .nhead { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.note .nhead b { color: var(--text); font-weight: 600; }
.note .nbody { margin-top: 4px; white-space: pre-wrap; word-wrap: break-word; }
.note .about { font-size: 12px; color: var(--accent-2); }
.note-form .about-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; background: rgba(201,149,107,.12); color: var(--accent-2); padding: 4px 6px 4px 10px; border-radius: 99px; margin-bottom: 8px; }
.note-form .about-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; }

/* Edición admin dentro de la pieza */
.adm-box { margin: 18px 22px 0; padding: 14px; border: 1px dashed rgba(201,149,107,.45); border-radius: 12px; background: rgba(201,149,107,.04); }
.adm-box .row { gap: 8px; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: rgba(201,149,107,.08); }
.uploads { display: grid; gap: 8px; margin-top: 10px; }
.upl { font-size: 13px; }
.upl .progress { margin-top: 4px; }

/* Final */
.finish { margin-top: 40px; text-align: center; }
.finish .card { padding: 28px 22px; }
.summary-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; text-align: left; }
.summary-table th, .summary-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.summary-table th { font-weight: 500; color: var(--muted); font-size: 12.5px; }

/* Usuarios */
.users { display: grid; gap: 10px; margin-top: 18px; }
.user-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.user-row .info { flex: 1; min-width: 200px; }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 8px 8px 12px; font-size: 13px; word-break: break-all; }
.linkbox code { flex: 1; color: var(--accent-2); }

/* Toast y lightbox */
#toast { position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--surface-3); border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; box-shadow: 0 12px 30px rgba(0,0,0,.5); max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--bad); color: #f4b3a7; }
#lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(8,6,5,.95); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
#lightbox img { max-width: 100%; max-height: calc(100vh - 80px); object-fit: contain; border-radius: 6px; }
#lightbox .lb-cap { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 13px; }
#lightbox .lb-close { position: absolute; top: 14px; right: 14px; }

.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(8,6,5,.75); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; }

@media (max-width: 640px) {
  .wrap { padding-top: 20px; }
  .piece > header, .piece .pdesc, .psec { padding-left: 16px; padding-right: 16px; }
  .media-grid { padding: 16px 16px 0; grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .media-grid.has-video { grid-template-columns: 1fr 1fr; }
  .tile.is-video { grid-column: 1 / -1; }
  .tile.is-video .frame { max-height: 78vh; aspect-ratio: 9/16; }
  .tile .acts { grid-template-columns: 1fr 1fr; padding: 6px; gap: 5px; }
  .vote { font-size: 12.5px; padding: 8px 4px; }
  .vote .lbl { display: none; }
  .tile .meta { padding: 8px 8px 2px; }
  .adm-box, .empty-media { margin-left: 16px; margin-right: 16px; }
  .brand .sub { display: none; }
  .piece .num { font-size: 34px; min-width: 36px; }
  h2 { font-size: 25px; }
  .copt { padding-left: 44px; }
  .copt .radio { left: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
