:root {
  --bg: #0b1020;
  --panel: #151b2e;
  --panel-2: #1d2540;
  --text: #eef2ff;
  --muted: #9aa6c7;
  --brand: #ff5a1f;
  --brand-2: #ffd21f;
  --ok: #37d67a;
  --warn: #ffb020;
  --danger: #ff4d4f;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); }

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  font-size: 1rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 0.45rem 0.7rem; font-size: 0.9rem; }
.btn.big { width: 100%; padding: 1rem; font-size: 1.1rem; font-weight: 600; margin-top: 0.5rem; }
.btn.room { min-width: 2.6rem; font-weight: 700; }
.btn.room.active { background: var(--ok); color: #05210f; }

input, select {
  width: 100%;
  padding: 0.7rem;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid #2a3350;
  background: #0e1426;
  color: var(--text);
  margin-top: 0.25rem;
}
label { display: block; margin: 0.6rem 0; color: var(--muted); font-size: 0.9rem; }
label input, label select { color: var(--text); }

/* ---------- layout ---------- */
.view { min-height: 100%; }
.center { display: flex; align-items: center; justify-content: center; padding: 1rem; }
.card {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.bar, .tray-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.bar { padding: 1rem; }
.bar h1 { font-size: 1.2rem; margin: 0; }
.panel {
  background: var(--panel);
  margin: 0 1rem 1rem;
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
}
.panel h2 { margin: 0 0 0.5rem; font-size: 1rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; padding: 0.7rem 0; border-top: 1px solid #263055;
}
.list-item:first-child { border-top: 0; }

.pill {
  background: rgba(0,0,0,0.45);
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
.badge { font-weight: 600; }
.badge.warn { background: var(--warn); color: #241a00; }

/* ---------- capture ---------- */
.capture-app { background: #000; }
#capture-view { display: flex; flex-direction: column; height: 100%; }
.cam-wrap { position: relative; background: #000; flex: 0 0 58vh; overflow: hidden; }
#cam { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.6rem; padding-top: max(0.6rem, env(safe-area-inset-top));
}
.cam-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: center;
  padding: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom));
}
.shutter {
  width: 76px; height: 76px; border-radius: 50%;
  background: #fff; border: 5px solid rgba(255,255,255,0.5);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.3);
  cursor: pointer;
}
.shutter:active, .shutter.flash { background: var(--brand-2); transform: scale(0.94); }
.cam-error {
  position: absolute; left: 1rem; right: 1rem; bottom: 6rem;
  background: rgba(0,0,0,0.8); padding: 0.75rem; border-radius: 10px; color: #fff;
}

.tray { flex: 1; overflow-y: auto; background: var(--bg); padding: 0.8rem; }
.slideshow-ctl { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; margin-top: 0.8rem; }
.cell { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #222; }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell .del {
  position: absolute; top: 2px; right: 2px;
  width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,0.6); color: #fff; cursor: pointer; font-size: 0.8rem;
}
.cell .star {
  position: absolute; top: 2px; left: 2px;
  width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,0.6); color: var(--brand-2); cursor: pointer; font-size: 0.9rem; line-height: 1;
}
.cell.starred { outline: 3px solid var(--brand-2); outline-offset: -3px; }

/* ---------- slideshow (TV) ---------- */
body.tv { background: #000; overflow: hidden; }
.tv-stage { position: fixed; inset: 0; background: #000; }
.tv-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; opacity: 0; transition: opacity 0.8s ease;
}
.tv-img.on { opacity: 1; }
.tv-qr {
  position: fixed; right: 3vh; bottom: 3vh;
  height: 15vh; width: 15vh; background: #fff; padding: 1vh; border-radius: 1vh;
  box-shadow: 0 0 20px rgba(0,0,0,0.6);
}
.tv-qr svg, .tv-qr img { width: 100%; height: 100%; display: block; }
.tv-caption {
  position: fixed; left: 3vh; bottom: 3vh; right: 22vh;
  color: #fff; font-size: 2.4vh; text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.tv-idle {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; color: #fff;
  background: radial-gradient(circle at 50% 35%, #1d2540, #000);
}
.tv-idle h1 { font-size: 6vh; margin: 0 0 1vh; color: var(--brand-2); }
.tv-idle p { font-size: 3vh; color: #cdd6f4; }

/* ---------- gallery ---------- */
body.gallery { background: #f6f7fb; color: #141821; }
.g-header { padding: 1.1rem 1rem; text-align: center; }
.g-header h1 { margin: 0 0 0.25rem; font-size: 1.3rem; }
.g-notice { color: #5b647b; font-size: 0.9rem; margin: 0; }
.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; padding: 0 0.6rem 2rem; }
.g-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: #e6e9f2; cursor: pointer; }
.g-empty { text-align: center; color: #5b647b; padding: 3rem 1rem; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50;
}
.lightbox img { max-width: 94vw; max-height: 78vh; object-fit: contain; border-radius: 8px; }
.lightbox .lb-actions { margin-top: 1rem; display: flex; gap: 0.75rem; }
.lightbox .lb-close { position: fixed; top: 1rem; right: 1rem; }

/* gate + referral + toast */
.gate {
  position: fixed; inset: 0; z-index: 60; padding: 1rem;
  background: rgba(10, 14, 30, 0.96);
  display: flex; align-items: center; justify-content: center;
}
.gate-card {
  background: #fff; color: #141821; border-radius: 16px;
  padding: 1.5rem; max-width: 460px; width: 100%;
}
.gate-card h1 { margin-top: 0; font-size: 1.3rem; }
.gate-card .muted { color: #5b647b; }
.g-header .btn { margin-top: 0.7rem; }
.toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%);
  background: #141821; color: #fff; padding: 0.7rem 1.1rem; border-radius: 999px;
  z-index: 70; box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

/* admin */
body.admin { background: #f6f7fb; color: #141821; }
.admin-wrap { max-width: 920px; margin: 0 auto; padding: 1rem; }
.admin-wrap h1 { font-size: 1.4rem; }
.admin-card { background: #fff; border: 1px solid #e6e9f2; border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1rem; }
.admin-card h2 { margin: 0 0 0.6rem; font-size: 1.1rem; }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid #eef0f6; flex-wrap: wrap; }
.admin-row:first-of-type { border-top: 0; }
.admin-row .meta { color: #5b647b; font-size: 0.85rem; }
.admin-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.admin .btn { background: #eef0f6; color: #141821; }
.admin .btn.primary { background: var(--brand); color: #fff; }
.admin .btn.danger { background: #ffe3e3; color: #b42318; }
.rm-thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; background: #e6e9f2; }
.date-head { font-weight: 700; margin: 0.8rem 0 0.2rem; color: #334; }
.pill.alert { background: #ffe3e3; color: #b42318; }
