:root {
  --bg: #070b14; --panel: #111827; --panel2: #0d1422; --line: rgba(255,255,255,.08);
  --text: #f1f5f9; --muted: #8b98ad; --accent: #2dd4bf; --accent2: #14b8a6;
  --ring: #f59e0b; --danger: #fb7185; --ok: #34d399;
  --safe-t: env(safe-area-inset-top); --safe-b: env(safe-area-inset-bottom);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(900px 500px at 0% -10%, rgba(45,212,191,.12), transparent 60%),
              radial-gradient(700px 500px at 110% 110%, rgba(129,140,248,.12), transparent 60%), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center-text { text-align: center; }

/* full-screen onboarding screens */
.screen { min-height: 100%; padding: calc(32px + var(--safe-t)) 24px calc(32px + var(--safe-b)); }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; max-width: 440px; margin: 0 auto; }
.screen h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.logo { width: 76px; height: 76px; border-radius: 20px; box-shadow: 0 12px 40px rgba(45,212,191,.25); }
.card { width: 100%; background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); border: 1px solid var(--line); border-radius: 20px; padding: 20px; }
.form { display: flex; flex-direction: column; gap: 14px; text-align: left; margin-top: 8px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form input { font: inherit; font-size: 17px; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; outline: none; }
.form input:focus { border-color: var(--accent); }
.error { color: var(--danger); font-size: 14px; }
.steps { list-style: none; display: flex; flex-direction: column; gap: 16px; text-align: left; }
.steps li { display: flex; align-items: center; gap: 14px; }
.step-n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: rgba(45,212,191,.15); color: var(--accent); }
svg.inline { width: 18px; height: 18px; vertical-align: -3px; color: #60a5fa; }
.bell-hero { width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 6px;
  background: radial-gradient(circle, rgba(245,158,11,.25), rgba(245,158,11,.05) 70%); color: var(--ring); animation: swing 2.4s ease-in-out infinite; }
.bell-hero svg { width: 54px; height: 54px; }
.bell-hero.off { color: var(--muted); background: rgba(255,255,255,.05); animation: none; }
@keyframes swing { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(12deg); } 80% { transform: rotate(-10deg); } 90% { transform: rotate(6deg); } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 14px; padding: 14px 20px; font-weight: 600; text-decoration: none; color: var(--text); width: 100%; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #04221f; box-shadow: 0 10px 30px rgba(45,212,191,.25); }
.btn.big { padding: 18px; font-size: 18px; margin-top: 10px; }
.btn.ghost { background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; }
.btn.danger { color: var(--danger); }
.btn:active { transform: scale(.98); }

/* app chrome */
#app { min-height: 100%; padding: calc(var(--safe-t)) 0 calc(78px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 8px; }
.title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.title img { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.06); }
.view { padding: 0 16px; }

/* live stage */
.stage { position: relative; border-radius: 22px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; border: 1px solid var(--line); box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.stage.small { margin-top: 14px; }
door-player, door-player video, .stage > video { display: block; width: 100%; height: 100%; object-fit: cover; background: #000; }
.badge { position: absolute; top: 12px; right: 12px; display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 6px 11px; border-radius: 999px; background: rgba(0,0,0,.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.on i { background: #f43f5e; animation: pulse 1.6s infinite; }
.icon-btn.over { position: absolute; background: rgba(0,0,0,.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.tl { top: 10px; left: 10px; } .br { bottom: 10px; right: 10px; }
.talking { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; font-weight: 600;
  padding: 8px 16px; border-radius: 999px; background: rgba(244,63,94,.85); }
.talking i { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.bl { bottom: 10px; left: 10px; } .br2 { bottom: 10px; right: 58px; }

/* incoming ring: the live view plus answer / dismiss, like a phone call */
.call { margin-top: 16px; padding: 18px 16px 20px; border-radius: 22px; text-align: center; animation: up .25s ease;
  background: rgba(245,158,11,.14); border: 1px solid rgba(245,158,11,.5); }
.call-text { display: flex; flex-direction: column; gap: 4px; }
.call-text b { font-size: 20px; }
.call-text span { color: var(--muted); font-size: 14px; }
.call-actions { display: flex; justify-content: space-around; margin-top: 18px; }
.call-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--text); }
.call-btn svg { width: 72px; height: 72px; padding: 20px; border-radius: 50%; color: #fff; }
.call-btn.decline svg { background: #ef4444; box-shadow: 0 10px 28px rgba(239,68,68,.4); }
.call-btn.answer svg { background: #22c55e; box-shadow: 0 10px 28px rgba(34,197,94,.45); animation: ringpulse 1.2s infinite; }
.call-btn:active svg { transform: scale(.94); }
@keyframes ringpulse { 50% { box-shadow: 0 0 0 14px rgba(34,197,94,.15), 0 10px 28px rgba(34,197,94,.45); } }
/* while a ring is on screen, the call card replaces push-to-talk and the event list */
#app.call-ringing .talk-wrap, #app.call-on .section-title, #app.call-on #latest { display: none; }
#app.call-talking .talk { display: none; }

.talk-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 22px 0 8px; }
.talk { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; color: #04221f;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 12px 34px rgba(45,212,191,.35);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: transform .12s, box-shadow .12s; }
.talk svg { width: 34px; height: 34px; }
.talk.active { transform: scale(1.12); background: linear-gradient(135deg, #fb7185, #f43f5e); color: #fff; box-shadow: 0 0 0 12px rgba(244,63,94,.18), 0 12px 34px rgba(244,63,94,.4); }
.talk.busy { opacity: .6; }

.section-title { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 18px 2px 10px; }

/* events */
.event-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.event { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 18px; background: rgba(255,255,255,.04); border: 1px solid var(--line); text-align: left; width: 100%; }
.event img { width: 96px; height: 72px; object-fit: cover; border-radius: 12px; background: #000; flex: none; }
.event .meta { flex: 1; min-width: 0; }
.event .what { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.event .what i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.event.ring .what i { background: var(--ring); }
.event .when { color: var(--muted); font-size: 14px; }
.event .play { color: var(--muted); }
.day-head { font-size: 13px; font-weight: 700; color: var(--muted); margin: 10px 2px 0; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

.chips { display: flex; gap: 8px; margin: 4px 0 14px; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 15px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid var(--line); font-size: 14px; font-weight: 500; }
.chip.on { background: rgba(45,212,191,.16); border-color: rgba(45,212,191,.5); color: var(--accent); }

/* playback */
.hours { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.hour { position: relative; padding: 10px 0 8px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); font-size: 14px; font-variant-numeric: tabular-nums; }
.hour[disabled] { opacity: .3; }
.hour.on { border-color: var(--accent); color: var(--accent); }
.hour b { display: block; font-weight: 600; }
.hour small { display: block; font-size: 11px; color: var(--muted); }
.hour.has-ring::after { content: ""; position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--ring); }
.pb-actions, .sheet-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.segments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }

/* bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; padding: 8px 8px calc(8px + var(--safe-b));
  background: rgba(7,11,20,.82); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); z-index: 5; }
.tabs button { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 500; color: var(--muted); padding: 4px 0; }
.tabs button.on { color: var(--accent); }

/* sheets */
.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet-card { width: 100%; max-width: 760px; background: var(--panel); border-radius: 24px 24px 0 0; padding: 16px 16px calc(20px + var(--safe-b)); border-top: 1px solid var(--line); animation: up .25s ease; display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet video { width: 100%; border-radius: 16px; background: #000; aspect-ratio: 4 / 3; }
.setting { display: flex; justify-content: space-between; padding: 12px 4px; border-bottom: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* landscape phones / fullscreen: video takes the screen */
.stage:fullscreen, .stage:-webkit-full-screen { border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }
.stage:fullscreen door-player video { object-fit: contain; }
@media (min-width: 720px) { .view { padding: 0 24px; } }
