:root {
  --yellow: #FFFC00;
  --black: #111;
  --white: #fff;
  --grey: #8a8a8e;
  --bg: #fff;
  --card: #f3f3f5;
  --text: #111;
  --blue: #0eadff;
  --red: #ff3b5c;
  --purple: #a05dff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0f10; --card: #1d1d20; --text: #f5f5f7; }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #000; }
body { font-family: "Nunito", system-ui, sans-serif; color: var(--text); overscroll-behavior: none; }
button, input, select { font: inherit; color: inherit; border: none; background: none; outline: none; }
button { cursor: pointer; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; }

/* ---------- AUTH ---------- */
#auth { background: var(--yellow); display: flex; align-items: center; justify-content: center; padding: 24px; color: var(--black); }
.auth-box { width: 100%; max-width: 360px; text-align: center; }
.logo { font-size: 72px; filter: drop-shadow(0 6px 0 rgba(0,0,0,.15)); animation: pop .6s cubic-bezier(.3,1.6,.5,1); }
.brand { font-weight: 900; font-size: 44px; letter-spacing: -1px; margin-bottom: 18px; }
.tabs { display: flex; background: rgba(0,0,0,.08); border-radius: 99px; padding: 4px; margin-bottom: 18px; }
.tab { flex: 1; padding: 10px; border-radius: 99px; font-weight: 800; transition: .2s; }
.tab.active { background: var(--black); color: var(--yellow); }
#authForm { display: flex; flex-direction: column; gap: 12px; }
#authForm input { background: #fff; border-radius: 16px; padding: 16px 18px; font-size: 17px; font-weight: 700; box-shadow: 0 3px 0 rgba(0,0,0,.08); }
.reg-only { display: none; }
.register .reg-only { display: block; }
.hint { font-size: 13px; margin-top: 12px; opacity: .65; }

.btn-big { background: var(--black); color: var(--yellow); font-weight: 900; font-size: 18px; padding: 16px; border-radius: 99px; width: 100%; transition: transform .1s; margin-top: 6px; }
.btn-big:active { transform: scale(.96); }
.btn-small { background: var(--yellow); color: var(--black); font-weight: 800; padding: 10px 16px; border-radius: 99px; }
.btn-outline { width: 100%; margin: 28px 0 8px; padding: 14px; border-radius: 99px; border: 2px solid var(--red); color: var(--red); font-weight: 800; }

/* ---------- MAIN / TABS ---------- */
#main { background: #000; }
.tab-view { position: absolute; inset: 0; display: none; }
.tab-view.active { display: block; animation: fade .2s; }

#video, #shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#video.mirror { transform: scaleX(-1); }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .35s ease-out; }

.round { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: rgba(0,0,0,.35); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: #fff; position: relative; flex-shrink: 0; }
.round.big { width: 56px; height: 56px; font-size: 24px; }
.round.ghost { background: none; backdrop-filter: none; }
.panel .round, .sheet .round { background: var(--card); color: var(--text); }
.avatar-btn { font-size: 24px; overflow: hidden; }

.top-bar { position: absolute; top: calc(12px + var(--safe-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; z-index: 3; }
.side-bar { position: absolute; top: calc(70px + var(--safe-top)); right: 12px; display: flex; flex-direction: column; gap: 12px; z-index: 3; }
.badge { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--red); color: #fff; font-size: 12px; font-weight: 900; display: grid; place-items: center; padding: 0 5px; }

.cam-controls { position: absolute; bottom: calc(96px + var(--safe-bot)); left: 0; right: 0; display: flex; justify-content: center; z-index: 3; }
.shutter { width: 80px; height: 80px; border-radius: 50%; border: 6px solid #fff; background: rgba(255,255,255,.12); transition: transform .12s; }
.shutter:active { transform: scale(.88); background: rgba(255,255,255,.35); }
.shot-controls { position: absolute; bottom: calc(96px + var(--safe-bot)); left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; z-index: 3; }
.send-btn { background: var(--blue); color: #fff; font-weight: 900; font-size: 18px; padding: 16px 26px; border-radius: 99px; box-shadow: 0 6px 20px rgba(14,173,255,.45); }
.send-btn:active { transform: scale(.95); }
.cam-error { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #fff; font-weight: 800; font-size: 20px; padding: 30px; }

.bottom-nav { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 0 calc(8px + var(--safe-bot)); display: flex; justify-content: space-around; z-index: 5; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.bottom-nav button { display: flex; flex-direction: column; align-items: center; font-size: 26px; opacity: .55; color: #fff; transition: .2s; min-width: 70px; }
.bottom-nav button span { font-size: 12px; font-weight: 800; }
.bottom-nav button.active { opacity: 1; transform: scale(1.12); }
#main.light-nav .bottom-nav { background: var(--bg); border-top: 1px solid var(--card); }
#main.light-nav .bottom-nav button { color: var(--text); }

/* ---------- PANELS & SHEETS ---------- */
.panel { background: var(--bg); overflow-y: auto; padding-bottom: 100px; }
.panel-head, .sheet-head { display: flex; align-items: center; justify-content: space-between; padding: calc(12px + var(--safe-top)) 14px 10px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.panel-head h2, .sheet-head h2 { font-weight: 900; font-size: 22px; }

.sheet { position: fixed; inset: 0; background: var(--bg); z-index: 20; overflow-y: auto; padding: 0 16px calc(30px + var(--safe-bot)); animation: slideUp .28s cubic-bezier(.2,.9,.3,1); }
.sheet .sheet-head { margin: 0 -16px; padding-left: 14px; padding-right: 14px; }
.sheet h3 { font-weight: 900; font-size: 15px; margin: 22px 0 10px; color: var(--grey); text-transform: uppercase; letter-spacing: .5px; }
.sheet input, .sheet select { width: 100%; background: var(--card); border-radius: 14px; padding: 14px 16px; font-weight: 700; font-size: 16px; }
.search { margin-top: 6px; }

.list { display: flex; flex-direction: column; gap: 2px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-radius: 14px; animation: fade .25s; }
.row:active { background: var(--card); }
.row .meta { flex: 1; min-width: 0; }
.row .name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 13px; color: var(--grey); font-weight: 700; }
.row .acts { display: flex; gap: 6px; }
.pill { padding: 8px 14px; border-radius: 99px; font-weight: 800; font-size: 14px; background: var(--card); }
.pill.yes { background: var(--yellow); color: var(--black); }
.pill.no { color: var(--red); }
.pill.done { opacity: .5; }

.avatar { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; flex-shrink: 0; background: var(--yellow); }
.avatar.xl { width: 110px; height: 110px; font-size: 60px; margin: 0 auto; box-shadow: 0 8px 0 rgba(0,0,0,.08); }
.empty { text-align: center; color: var(--grey); font-weight: 800; font-size: 17px; padding: 60px 20px; line-height: 1.6; }
.empty big { font-size: 48px; }

.profile-top { text-align: center; margin-top: 10px; }
.prof-name { font-weight: 900; font-size: 26px; margin-top: 14px; }
.prof-user { color: var(--grey); font-weight: 800; }
.role-tag { display: inline-block; background: var(--purple); color: #fff; font-size: 12px; padding: 2px 10px; border-radius: 99px; margin-left: 6px; vertical-align: middle; }

.pick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-row button { width: 46px; height: 46px; border-radius: 50%; font-size: 24px; background: var(--card); border: 3px solid transparent; transition: .15s; }
.pick-row button.sel { border-color: var(--text); transform: scale(1.1); }

.invite-new { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.invite-new select { flex: 1; }
.code { font-family: ui-monospace, monospace; font-weight: 900; font-size: 20px; letter-spacing: 2px; }

.toast { position: fixed; left: 50%; top: calc(16px + var(--safe-top)); transform: translate(-50%, -150%); background: var(--black); color: #fff; padding: 12px 20px; border-radius: 99px; font-weight: 800; z-index: 100; transition: transform .3s cubic-bezier(.3,1.4,.5,1); max-width: 90vw; text-align: center; }
.toast.show { transform: translate(-50%, 0); }

@keyframes pop { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- ADMIN ---------- */
.btn-admin { width: 100%; margin-top: 22px; padding: 15px; border-radius: 99px; background: var(--purple); color: #fff; font-weight: 900; font-size: 17px; }
.btn-outline.warn { border-color: #ff9f0a; color: #ff9f0a; margin-top: 14px; }
.state-box { background: var(--card); border-radius: 16px; padding: 14px 16px; font-weight: 800; line-height: 1.7; margin-bottom: 12px; }
.state-box a { color: var(--purple); }
.upload-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.upload-box input[type=file] { padding: 12px; font-size: 14px; }
.tag { display: inline-block; font-size: 11px; font-weight: 900; padding: 2px 9px; border-radius: 99px; margin-left: 6px; vertical-align: middle; text-transform: uppercase; }
.tag.live { background: #30d158; color: #fff; }
.tag.beta { background: var(--purple); color: #fff; }
.tag.archived { background: var(--card); color: var(--grey); }
.switch { width: 52px; height: 30px; border-radius: 99px; background: var(--card); position: relative; transition: .2s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.25); transition: .2s; }
.switch.on { background: var(--purple); }
.switch.on::after { left: 25px; }
