@font-face { font-family: "Nunito"; src: url("/fonts/nunito-latin-wght.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces-latin-wght.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #0d1126;
  --bg-2: #151a3a;
  --surface: rgba(30, 32, 78, 0.52);
  --surface-2: rgba(42, 40, 98, 0.62);
  --surface-solid: #1a1c44;
  --line: rgba(246, 232, 201, 0.10);
  --line-2: rgba(246, 232, 201, 0.18);
  --text: #f4ecdc;
  --muted: #aaa6cc;
  --faint: #7b78a3;
  --amber: #f5b867;
  --amber-2: #ffd59a;
  --amber-glow: rgba(245, 184, 103, 0.32);
  --rose: #ea9fa7;
  --live: #8fdcb2;
  --danger: #f08f8f;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 18px 50px rgba(3, 4, 18, 0.55);
  --font: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }

.sky {
  position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(13, 17, 38, 0.15) 0%, rgba(13, 17, 38, 0.55) 70%, rgba(13, 17, 38, 0.9) 100%),
    url("/img/sky-portrait.jpg") center top / cover no-repeat,
    var(--bg);
}
@media (min-aspect-ratio: 1/1) {
  .sky {
    background:
      radial-gradient(120% 90% at 20% 30%, rgba(13, 17, 38, 0.82), rgba(13, 17, 38, 0.45) 70%),
      url("/img/sky-landscape.jpg") center / cover no-repeat,
      var(--bg);
  }
}

.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- views ---------- */
#app { min-height: 100dvh; }
.view { min-height: 100dvh; padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); }
.view-center { display: grid; place-items: center; }

.moon-loader { width: 64px; height: 64px; color: var(--amber-2); filter: drop-shadow(0 0 18px var(--amber-glow)); animation: breathe 2.4s ease-in-out infinite; }
.moon-loader svg { width: 100%; height: 100%; fill: currentColor; stroke: none; }
.moon-loader.small { width: 40px; height: 40px; }
@keyframes breathe { 0%, 100% { transform: scale(0.92) rotate(-6deg); opacity: 0.7; } 50% { transform: scale(1.04) rotate(4deg); opacity: 1; } }

/* ---------- cards / auth ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.card-auth { width: min(420px, 100%); padding: 28px 24px 24px; text-align: center; display: grid; gap: 14px; }
.auth-art { margin: -8px auto 0; width: 148px; height: 148px; border-radius: 50%; -webkit-mask-image: radial-gradient(circle, #000 52%, transparent 71%); mask-image: radial-gradient(circle, #000 52%, transparent 71%); }
.display { font-family: var(--display); font-weight: 500; font-size: 40px; letter-spacing: -0.01em; margin: 0; }
.lede { margin: -4px 0 6px; color: var(--muted); }
.fineprint { font-size: 13px; color: var(--faint); margin: 0; }
.hint { font-size: 14px; color: var(--muted); margin: 0; }

.field { display: grid; gap: 8px; text-align: left; }
.field > span { font-size: 14px; color: var(--muted); font-weight: 600; }
.field input, .invite-form input, .copy-row input {
  width: 100%; padding: 13px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: rgba(10, 12, 32, 0.55); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .invite-form input:focus { border-color: var(--amber); box-shadow: 0 0 0 4px var(--amber-glow); }

.install-tip { display: flex; gap: 12px; text-align: left; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(245, 184, 103, 0.08); border: 1px solid rgba(245, 184, 103, 0.22); }
.install-tip p { margin: 0; font-size: 14px; color: var(--muted); }
.install-tip .i { color: var(--amber); margin-top: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; letter-spacing: 0.01em; transition: transform .15s, background .2s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn .i { width: 18px; height: 18px; }
.btn-primary { background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: #2a1a07; box-shadow: 0 8px 26px var(--amber-glow); }
.btn-ghost { background: rgba(246, 232, 201, 0.07); border-color: var(--line-2); }
.btn-ghost:hover { background: rgba(246, 232, 201, 0.12); }
.btn-small { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--danger); }

.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: rgba(246, 232, 201, 0.06); }
.icon-btn:hover { background: rgba(246, 232, 201, 0.12); }

/* ---------- monitor ---------- */
.view-monitor { padding-top: calc(10px + var(--safe-top)); max-width: 1240px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 4px 2px 14px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand img { border-radius: 9px; box-shadow: 0 0 18px var(--amber-glow); }
.wordmark { font-family: var(--display); font-size: 26px; font-weight: 500; letter-spacing: -0.01em; }

.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px; font-size: 14px; font-weight: 700; background: rgba(10, 12, 32, 0.55); border: 1px solid var(--line); white-space: nowrap; }
.status-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.status-pill[data-state="live"] .dot { background: var(--live); box-shadow: 0 0 0 0 rgba(143, 220, 178, 0.6); animation: pulse 2s infinite; }
.status-pill[data-state="live"] { color: var(--live); }
.status-pill[data-state="paused"] .dot { background: var(--amber); }
.status-pill[data-state="offline"] .dot, .status-pill[data-state="error"] .dot { background: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(143, 220, 178, 0.55); } 70% { box-shadow: 0 0 0 9px rgba(143, 220, 178, 0); } 100% { box-shadow: 0 0 0 0 rgba(143, 220, 178, 0); } }

.layout { display: grid; gap: 16px; }
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .col-side { position: sticky; top: 16px; }
}
.col-main, .col-side { display: grid; gap: 14px; min-width: 0; }

.stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 26px; overflow: hidden;
  background: radial-gradient(120% 120% at 50% 0%, #1b1f4a, #090b1c 70%);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow), 0 0 0 6px rgba(246, 232, 201, 0.03);
}
.stage[data-rotate="90"], .stage[data-rotate="270"] { aspect-ratio: 3 / 4; max-height: 78dvh; margin: 0 auto; width: auto; height: min(78dvh, 133vw); }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #05060f; transition: filter .3s; }
.stage[data-rotate="90"] video, .stage[data-rotate="270"] video { inset: auto; top: 50%; left: 50%; width: var(--rot-w, 100%); height: var(--rot-h, 100%); }
.stage[data-bright="1"] video { filter: brightness(1.55) contrast(1.08) saturate(0.85); }
.stage[data-bright="2"] video { filter: brightness(2.2) contrast(1.15) saturate(0.6); }

.overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 24px; background: radial-gradient(90% 80% at 50% 40%, rgba(26, 28, 68, 0.85), rgba(8, 9, 24, 0.94)); }
.overlay h2 { font-family: var(--display); font-weight: 500; font-size: 26px; margin: 4px 0 0; }
.overlay p { margin: 0; color: var(--muted); max-width: 30ch; }
.overlay img { width: 132px; height: 132px; -webkit-mask-image: radial-gradient(circle, #000 50%, transparent 70%); mask-image: radial-gradient(circle, #000 50%, transparent 70%); animation: float 6s ease-in-out infinite; }
.overlay img.dim { filter: grayscale(0.6) brightness(0.75); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.stage-badges { position: absolute; left: 12px; top: 12px; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: rgba(8, 9, 24, 0.62); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.badge .i { width: 15px; height: 15px; color: var(--amber-2); }

.listen-hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: inline-flex; gap: 8px; align-items: center; padding: 10px 18px; border-radius: 999px; border: 1px solid rgba(245, 184, 103, 0.4); background: rgba(8, 9, 24, 0.7); color: var(--amber-2); font-weight: 800; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: nudge 2.6s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-3px); } }

.flash { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; box-shadow: inset 0 0 0 0 rgba(234, 159, 167, 0); transition: box-shadow .4s; }
.flash.on { box-shadow: inset 0 0 0 3px rgba(234, 159, 167, 0.85), inset 0 0 60px rgba(234, 159, 167, 0.35); }

.meter-row { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.meter { flex: 1; display: grid; grid-template-columns: repeat(16, 1fr); gap: 5px; height: 22px; align-items: end; }
.meter span { display: block; border-radius: 4px; background: rgba(246, 232, 201, 0.10); height: 40%; transition: background .18s, height .18s, box-shadow .18s; }
.meter span:nth-child(n) { height: calc(35% + var(--h, 0) * 1%); }
.meter span.on { background: var(--amber-2); box-shadow: 0 0 10px var(--amber-glow); }
.meter span.on.hot { background: var(--rose); box-shadow: 0 0 12px rgba(234, 159, 167, 0.45); }
.meter-label { width: 96px; text-align: right; font-size: 14px; color: var(--muted); font-weight: 700; }

.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ctl { display: grid; justify-items: center; gap: 6px; padding: 12px 6px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 700; color: var(--muted); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: background .2s, color .2s, border-color .2s; }
.ctl .i { width: 24px; height: 24px; }
.ctl[aria-pressed="true"] { color: #2a1a07; background: linear-gradient(180deg, var(--amber-2), var(--amber)); border-color: transparent; box-shadow: 0 8px 22px var(--amber-glow); }
.ctl:active { transform: scale(0.97); }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 21px; }
.card-meta { font-size: 13px; color: var(--muted); font-weight: 700; text-align: right; }
.card-meta.on { color: var(--amber-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(246, 232, 201, 0.05); font-weight: 700; font-size: 14px; color: var(--muted); transition: all .18s; }
.chip[aria-checked="true"] { background: rgba(245, 184, 103, 0.16); border-color: rgba(245, 184, 103, 0.6); color: var(--amber-2); }
.chips-small .chip { font-size: 13px; padding: 6px 12px; }

.slider { display: grid; grid-template-columns: auto 1fr 44px; align-items: center; gap: 12px; margin: 16px 0 12px; font-size: 14px; color: var(--muted); font-weight: 700; }
.slider output { text-align: right; color: var(--text); }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--amber) var(--fill, 40%), rgba(246, 232, 201, 0.14) var(--fill, 40%)); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--amber-2); box-shadow: 0 0 0 5px var(--amber-glow); border: none; }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--amber-2); box-shadow: 0 0 0 5px var(--amber-glow); border: none; }

.row { display: flex; gap: 10px; margin-top: 14px; }
.row .btn { flex: 1; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; font-weight: 700; }
.toggle-row > span { display: inline-flex; gap: 10px; align-items: center; }
.toggle-row .i { color: var(--amber-2); }
.switch { -webkit-appearance: none; appearance: none; width: 52px; height: 30px; border-radius: 99px; background: rgba(246, 232, 201, 0.16); position: relative; transition: background .2s; flex: none; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #f4ecdc; transition: transform .2s; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.switch:checked { background: var(--amber); }
.switch:checked::after { transform: translateX(22px); }
#card-alerts .hint { margin: 8px 0 12px; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 4px 6px; font-size: 13px; color: var(--faint); font-weight: 600; }

/* ---------- sheets ---------- */
.sheet { border: none; padding: 0; background: transparent; color: var(--text); max-width: 560px; width: calc(100% - 24px); max-height: calc(100dvh - 24px); margin: auto auto 12px; }
@media (min-width: 640px) { .sheet { margin: auto; } }
.sheet::backdrop { background: rgba(4, 5, 16, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.sheet[open] { animation: rise .28s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-inner { background: var(--surface-solid); border: 1px solid var(--line-2); border-radius: 26px; padding: 20px 20px calc(20px + var(--safe-bottom)); box-shadow: var(--shadow); display: grid; gap: 14px; max-height: calc(100dvh - 24px); overflow: auto; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 24px; }

.menu-list { display: grid; gap: 6px; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(246, 232, 201, 0.04); text-align: left; font-weight: 700; }
.menu-item .i { color: var(--amber-2); }
.menu-item:hover { background: rgba(246, 232, 201, 0.09); }
.menu-item.danger, .menu-item.danger .i { color: var(--danger); }
body:not(.is-admin) .admin-only { display: none; }

.section-label { margin: 8px 0 -4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint); }
.invite-form { display: flex; gap: 8px; }
.invite-form input { flex: 1; min-width: 0; }
.invite-result { display: grid; gap: 8px; padding: 14px; border-radius: 16px; background: rgba(245, 184, 103, 0.08); border: 1px solid rgba(245, 184, 103, 0.22); }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: 13px; padding: 9px 12px; }

.people-list { display: grid; gap: 8px; }
.person { padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(246, 232, 201, 0.04); display: grid; gap: 8px; }
.person-head { display: flex; align-items: center; gap: 10px; }
.person-head strong { font-size: 16px; }
.role { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: rgba(245, 184, 103, 0.16); color: var(--amber-2); }
.person-head .spacer { flex: 1; }
.linkish { background: none; border: none; color: var(--muted); font-size: 13px; font-weight: 700; padding: 4px 6px; border-radius: 8px; }
.linkish:hover { color: var(--text); background: rgba(246, 232, 201, 0.06); }
.linkish.danger { color: var(--danger); }
.session { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.session .what { flex: 1; min-width: 0; }
.session .tag { color: var(--live); font-weight: 700; }

.pair-code { display: grid; justify-items: center; gap: 4px; padding: 16px; border-radius: 16px; background: rgba(245, 184, 103, 0.08); border: 1px dashed rgba(245, 184, 103, 0.45); }
.pair-code strong { font-family: var(--display); font-size: 44px; letter-spacing: 0.18em; color: var(--amber-2); font-weight: 600; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(10, 12, 32, 0.55); border: 1px solid var(--line); }
.segmented button { border: none; background: transparent; padding: 9px 4px; border-radius: 10px; font-weight: 700; color: var(--muted); font-size: 14px; }
.segmented button[aria-pressed="true"] { background: rgba(245, 184, 103, 0.18); color: var(--amber-2); }
.install-steps p { margin: 0 0 10px; color: var(--muted); }
.install-steps strong { color: var(--text); }

.toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 999px; background: var(--surface-solid); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-weight: 700; font-size: 14px; transition: all .25s; max-width: calc(100% - 32px); text-align: center; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(240, 143, 143, 0.5); color: #ffd2d2; }

/* Full-screen stage */
.stage:fullscreen { border-radius: 0; border: none; aspect-ratio: auto; width: 100vw; height: 100vh; max-height: none; }
.stage:-webkit-full-screen { border-radius: 0; border: none; width: 100vw; height: 100vh; }

@media (max-width: 420px) {
  .wordmark { font-size: 22px; }
  .ctl { font-size: 12px; padding: 10px 4px; }
  .meter-label { width: 84px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
