:root {
  --bg: #0d0b12;
  --panel: #1a1622;
  --panel-2: #241e30;
  --text: #fbf7ff;
  --muted: #a99fbb;
  --accent: #ff3d7f;
  --accent-2: #ffc23d;
  --ok: #2fd47a;
  --radius: 18px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, select, input { font: inherit; }
a { color: var(--accent-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .9em; }

/* ---------- Cabina ---------- */
body.booth { overflow: hidden; user-select: none; -webkit-user-select: none; }
#stage { position: fixed; inset: 0; display: grid; place-items: center; background: #000; }
#preview { display: block; background: #000; }
#video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 16px 14px; background: linear-gradient(#000a, #0000); z-index: 5; }
.topbar-right { display: flex; gap: 8px; }
.chip { background: #0008; color: var(--text); border: 1px solid #fff3; border-radius: 999px; padding: 10px 16px;
  font-size: clamp(14px, 2.2vh, 22px); font-weight: 600; cursor: pointer; backdrop-filter: blur(8px); white-space: nowrap; }
.chip.on { background: var(--accent); border-color: transparent; }
.chip.icon { padding: 10px 13px; }
.chip-theme { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; }

.bottombar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 2.2vh;
  padding: 16px 16px max(3.5vh, env(safe-area-inset-bottom)); background: linear-gradient(#0000, #000b); z-index: 5; }
.status { background: #000a; padding: 10px 22px; border-radius: 999px; font-size: clamp(16px, 2.6vh, 30px); font-weight: 600; text-align: center; }
.shutter { width: clamp(84px, 11vh, 150px); aspect-ratio: 1; border-radius: 50%; border: 6px solid #fff; background: transparent; padding: 7px; cursor: pointer; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--accent); transition: transform .1s; }
.shutter:active span { transform: scale(.9); }

.countdown { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 6; }
.countdown { grid-template-rows: 1fr auto; }
.count-hint { align-self: end; margin-bottom: 26vh; background: #000a; padding: 10px 22px; border-radius: 999px; font-size: clamp(16px, 2.4vh, 28px); font-weight: 600; }
.orient-h .count-hint { margin-bottom: 18vh; }
.countdown span { align-self: center; font-size: 38vh; font-weight: 900; color: #fff; text-shadow: 0 0 40px #000, 0 0 12px var(--accent);
  animation: pop 1s ease-out; }
@keyframes pop { 0% { transform: scale(1.6); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(.9); opacity: .85; } }

.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 7; }
.flash.go { animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

.overlay { position: fixed; inset: 0; background: #000c; z-index: 10; display: grid; place-items: center; padding: 16px; overflow: auto; }
.modal { background: var(--panel); border-radius: var(--radius); padding: 24px; width: min(640px, 100%); display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin: 0 0 4px; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.modal label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.modal .row { display: flex; flex-wrap: wrap; gap: 8px; }
select, input[type=text], input[type=number] { background: var(--panel-2); color: var(--text); border: 1px solid #fff2; border-radius: 10px; padding: 10px 12px; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.btn { background: var(--panel-2); color: var(--text); border: 1px solid #fff2; border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: var(--accent); border-color: transparent; }
.btn.danger { background: #5a1a26; }
.btn.small { padding: 6px 10px; font-size: .9em; }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.theme-card { background: var(--panel-2); border: 2px solid transparent; border-radius: 14px; padding: 10px; color: var(--text); cursor: pointer; text-align: left; }
.theme-card.active { border-color: var(--accent); }
.orient-h .theme-card .thumb { aspect-ratio: 3/2; }
.theme-card .thumb { aspect-ratio: 2/3; border-radius: 8px; background: repeating-conic-gradient(#333 0 25%, #222 0 50%) 0 0/20px 20px; overflow: hidden; }
.theme-card .thumb img { width: 100%; height: 100%; object-fit: fill; }
.theme-card .name { font-weight: 700; margin-top: 8px; }

.result { background: #000e; cursor: pointer; }
.result-card { display: flex; flex-direction: column; align-items: center; gap: 2vh; max-height: 100%; }
.result-card > img { max-height: 58vh; max-width: 90vw; border-radius: 10px; box-shadow: 0 10px 40px #000; animation: drop .5s ease-out; }
@keyframes drop { from { transform: translateY(-30px) scale(.95); opacity: 0; } }
.result-info { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1vh; }
.result-label { font-size: clamp(18px, 2.6vh, 34px); color: var(--muted); }
.result-num { font-size: clamp(64px, 11vh, 180px); font-weight: 900; letter-spacing: .08em; line-height: 1; color: var(--accent-2); }
.result-code { font-size: clamp(18px, 3vh, 36px); letter-spacing: .12em; }
.result-code strong { color: var(--text); font-weight: 900; }
.result-qr { display: flex; align-items: center; gap: 14px; }
.result-qr img { width: clamp(90px, 12vh, 180px); border-radius: 8px; background: #fff; }
.result-qr img[src=""] { display: none; }
.result-url { font-size: clamp(14px, 1.8vh, 22px); color: var(--muted); }
.result-hint { font-size: clamp(14px, 2vh, 24px); }
.progress { width: 60vw; height: 6px; background: #fff2; border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; width: 100%; background: var(--accent); }

/* Cabina en horizontal: foto y número lado a lado */
.orient-h .result-card { flex-direction: row; gap: 4vw; }
.orient-h .result-card > img { max-height: 78vh; max-width: 62vw; }
.orient-h .result-num { font-size: clamp(64px, 14vh, 200px); }
.orient-h .progress { width: 26vw; }
.orient-h .countdown span { font-size: 45vh; }
.orient-h .shutter { position: fixed; right: max(3vw, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); }

/* ---------- Páginas normales (admin / galería) ---------- */
body.page { min-height: 100%; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; background: var(--panel); position: sticky; top: 0; z-index: 3; flex-wrap: wrap; }
.page-header h1 { margin: 0; font-size: 1.4rem; }
.page-header nav { display: flex; gap: 8px; flex-wrap: wrap; }
main.wrap { padding: 20px; max-width: 1400px; margin: 0 auto; }
.card { background: var(--panel); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card h2 { margin-top: 0; font-size: 1.15rem; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.grid-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .95em; }
.grid-form label.check { flex-direction: row; align-items: center; gap: 10px; }

.admin-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .admin-layout { grid-template-columns: 1fr; } }
.preview-box { position: sticky; top: 80px; }
.preview-box canvas { width: 100%; border-radius: 12px; background: #000; display: block; }

.theme-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.theme-tabs .btn.active { background: var(--accent); }

.props { display: flex; flex-direction: column; gap: 10px; }
.prop { display: grid; grid-template-columns: 72px 1fr; gap: 12px; background: var(--panel-2); border-radius: 12px; padding: 10px; border: 2px solid transparent; }
.prop.selected { border-color: var(--accent-2); }
.prop .pthumb { width: 72px; height: 72px; border-radius: 8px; background: repeating-conic-gradient(#444 0 25%, #333 0 50%) 0 0/14px 14px; display: grid; place-items: center; cursor: pointer; }
.prop .pthumb img { max-width: 100%; max-height: 100%; }
.prop .pfields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-items: end; }
.prop .pfields label { display: flex; flex-direction: column; gap: 4px; font-size: .85em; font-weight: 600; }
.prop .pfields label.check { flex-direction: row; align-items: center; gap: 6px; }
.prop input[type=range] { width: 100%; accent-color: var(--accent); }
.frame-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.frame-thumb { width: 90px; aspect-ratio: 2/3; border-radius: 8px; background: repeating-conic-gradient(#444 0 25%, #333 0 50%) 0 0/14px 14px; overflow: hidden; }
.frame-thumb.h { width: 135px; aspect-ratio: 3/2; }
.frame-slot { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.frame-row { align-items: flex-end; }
.frame-thumb img { width: 100%; height: 100%; object-fit: fill; }
.dropzone { border: 2px dashed #fff3; border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.drag { border-color: var(--accent); color: var(--text); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ok); color: #000; padding: 12px 20px; border-radius: 999px; font-weight: 700; z-index: 50; }
.toast.err { background: var(--accent); color: #fff; }

/* Galería */
.search { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.search { align-items: flex-end; }
.search input { font-size: 2rem; width: 200px; text-align: center; letter-spacing: .1em; font-weight: 800; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.gallery a { position: relative; display: block; border-radius: 10px; overflow: hidden; background: #000; }
.gallery img { width: 100%; display: block; aspect-ratio: 1; object-fit: contain; }
.gallery .num { position: absolute; left: 8px; bottom: 8px; background: #000b; padding: 4px 10px; border-radius: 999px; font-weight: 800; color: var(--accent-2); }
.photo-view { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 20px; }
.photo-view img { max-width: min(100%, 700px); max-height: 75vh; border-radius: 12px; box-shadow: 0 10px 40px #000; }
.photo-view .big { font-size: 3rem; font-weight: 900; color: var(--accent-2); letter-spacing: .08em; }

@media print {
  body * { visibility: hidden; }
  #printable, #printable * { visibility: visible; }
  #printable { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: contain; box-shadow: none; border-radius: 0; max-height: none; max-width: none; }
}

/* Sesiones */
.table-wrap { overflow-x: auto; }
.ses-table { width: 100%; border-collapse: collapse; font-size: .95em; }
.ses-table th, .ses-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #fff1; white-space: nowrap; }
.ses-table tr.active td { background: #ff3d7f1f; }
.ses-table .actions { display: flex; gap: 6px; }
.chip.session { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; opacity: .85; cursor: default; }

/* Visor de galería */
.viewer { position: fixed; inset: 0; z-index: 40; background: #000f; display: flex; flex-direction: column; }
.viewer-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; flex-wrap: wrap; }
.viewer-top strong { font-size: 1.4rem; color: var(--accent-2); letter-spacing: .06em; }
.viewer-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.viewer-stage { flex: 1; position: relative; display: grid; place-items: center; min-height: 0; padding: 0 64px 16px; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; user-select: none; -webkit-user-drag: none; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; border: 1px solid #fff3;
  background: #0009; color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
.viewer-nav.prev { left: 8px; } .viewer-nav.next { right: 8px; }
@media (max-width: 600px) { .viewer-stage { padding: 0 8px 12px; } .viewer-nav { top: auto; bottom: 18px; transform: none; } }
