/* Every display rule below would otherwise beat the hidden attribute, which
   has hidden buttons twice already; one rule for all of them. */
[hidden] { display: none !important; }

:root {
  /* Purple and yellow: deep purple surfaces, a sunny yellow accent, and a
     lilac second accent. Text on yellow is always dark (--on-accent). */
  --bg: #140a24;
  --surface: #23123d;
  --surface-2: #331b57;
  --fg: #fff;
  --muted: rgb(236 226 255 / 0.72);
  --accent: #ffd23f;
  --on-accent: #22113d;
  --accent-2: #a97cff;
  --glass: rgb(20 10 36 / 0.45);
  --line: rgb(236 226 255 / 0.14);
  --sheet: #fbf8ff;
  --sheet-fg: #22113d;
  --sheet-muted: #7c6d96;
  --sheet-line: #ebe3f7;
  --sheet-field: #f1ebfa;
  --accent-ink: #7a4fe0; /* purple text on the light sheets, where yellow can't be read */
  --tint: rgb(169 124 255 / 0.2); /* lilac wash for fields and quiet buttons */
  --tint-line: rgb(169 124 255 / 0.4);
  --arrived: #fff4c7; /* a new comment flashes pale yellow */
  --nav-h: 56px;
  --column: min(100vw, calc(100dvh * 9 / 16), 480px);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body.app { background: var(--bg); color: var(--fg); overflow: hidden; }
a { color: inherit; }
button, input, select { font: inherit; }

/* top bar */
.top-bar {
  position: fixed; inset: 0 0 auto; z-index: 5;
  display: flex; justify-content: center; align-items: center; gap: 1rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.75rem;
  background: linear-gradient(var(--glass), transparent);
  pointer-events: none;
}
.top-bar > * { pointer-events: auto; }
.tab { font-weight: 700; font-size: 1.05rem; color: var(--muted); }
.tab.active { color: var(--fg); border-bottom: 2px solid var(--accent); padding-bottom: 0.2rem; }

.here {
  position: absolute; right: 1rem; top: max(0.6rem, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 0.35rem;
  background: var(--glass); border-radius: 999px; padding: 0.25rem 0.6rem 0.25rem 0.35rem;
  font-size: 0.8rem; backdrop-filter: blur(6px);
}
.here:empty { display: none; }
.here .faces { display: flex; }
.here .faces span {
  display: grid; place-items: center; width: 1.6rem; height: 1.6rem; margin-left: -0.45rem;
  border-radius: 50%; background: var(--surface-2); border: 2px solid var(--bg); font-size: 0.95rem;
}
.here .faces span:first-child { margin-left: 0; }
.here .faces span.me { border-color: var(--accent-2); }
.here .live-dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* feed */
.feed {
  height: calc(100dvh - var(--nav-h));
  overflow-y: scroll; scroll-snap-type: y mandatory; overscroll-behavior: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }
.clip {
  position: relative; height: calc(100dvh - var(--nav-h));
  width: var(--column); margin: 0 auto;
  scroll-snap-align: start; scroll-snap-stop: always;
  background: var(--surface); overflow: hidden;
}
.clip video { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--bg); }
.clip.paused::after {
  content: "▶"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 4rem; color: rgb(255 255 255 / 0.6); pointer-events: none;
}
.clip.arrived { animation: arrive 1s ease-out; }
@keyframes arrive { from { filter: brightness(1.8); } }

.rail {
  position: absolute; right: 0.6rem; bottom: 6.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 1.1rem;
}
.rail .creator {
  display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%;
  background: var(--sheet); font-size: 1.7rem; border: 2px solid var(--accent); margin-bottom: 0.4rem;
}
.rail button {
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  background: none; border: 0; color: var(--fg); cursor: pointer; padding: 0;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.6);
}
.rail .icon { font-size: 1.9rem; line-height: 1; }
.rail .count { font-size: 0.78rem; font-weight: 600; }
.rail .like[aria-pressed="true"] .icon { color: var(--accent); }
.rail .like.pop .icon { animation: pop 0.35s ease-out; }
.rail .count.bump { animation: pop 0.35s ease-out; }
@keyframes pop { 50% { transform: scale(1.35); } }

.info {
  position: absolute; left: 0.9rem; right: 4.5rem; bottom: 1.2rem;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.7);
}
.info p { margin: 0.3rem 0; line-height: 1.35; overflow-wrap: anywhere; }
.info .meta { font-size: 0.8rem; color: var(--muted); }

.empty-feed { display: grid; place-items: center; text-align: center; }
.empty-feed .big { font-size: 4rem; margin: 0; }
.pill {
  display: inline-block; background: var(--accent); color: var(--on-accent); border: 0; border-radius: 6px;
  padding: 0.7rem 1.4rem; font-weight: 700; text-decoration: none; cursor: pointer;
}
.pill.ghost { background: var(--tint); color: var(--fg); }

.sound {
  position: fixed; left: 50%; top: 3.6rem; transform: translateX(-50%); z-index: 4;
  background: var(--glass); color: var(--fg); border: 0; border-radius: 999px;
  padding: 0.35rem 0.8rem; font-size: 0.8rem; cursor: pointer;
}
.sound[aria-pressed="true"] { display: none; }

/* bottom nav */
.bottom-nav {
  position: fixed; inset: auto 0 0; z-index: 5; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; justify-content: space-around; align-items: center;
  background: var(--bg); border-top: 1px solid var(--line);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; font-size: 0.7rem; color: var(--muted); text-decoration: none; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav .icon { font-size: 1.4rem; line-height: 1; }
.bottom-nav .create span {
  display: grid; place-items: center; width: 3rem; height: 2rem; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 1.3rem;
  box-shadow: 0 0 0 3px var(--accent-2);
}

/* comments sheet */
.sheet {
  margin: auto auto 0; width: var(--column); max-width: 100vw; max-height: 70dvh;
  border: 0; border-radius: 14px 14px 0 0; padding: 0;
  background: var(--sheet); color: var(--sheet-fg);
  display: none; flex-direction: column;
}
.sheet[open] { display: flex; animation: slide-up 0.2s ease-out; }
.sheet::backdrop { background: rgb(20 10 36 / 0.5); }
@keyframes slide-up { from { transform: translateY(100%); } }
.sheet header { position: relative; text-align: center; padding: 0.9rem; font-size: 0.85rem; }
.sheet .close { position: absolute; right: 0.8rem; top: 0.6rem; background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: inherit; }
.sheet ul { list-style: none; margin: 0; padding: 0 1rem; overflow-y: auto; flex: 1; min-height: 8rem; }
.sheet li { display: flex; gap: 0.7rem; padding: 0.6rem 0; }
.sheet li .who { font-size: 1.6rem; }
.sheet li .remove { margin-left: auto; background: none; border: 0; color: var(--sheet-muted); font-size: 1rem; cursor: pointer; padding: 0.25rem 0.5rem; }
.sheet li .name { font-size: 0.8rem; color: var(--sheet-muted); }
.sheet li p { margin: 0.1rem 0 0; overflow-wrap: anywhere; }
.sheet li.arrived { animation: arrive-light 1.2s ease-out; }
@keyframes arrive-light { from { background: var(--arrived); } }
.sheet .empty { color: var(--sheet-muted); text-align: center; padding: 2rem 0; display: block; }
.sheet form { display: flex; gap: 0.5rem; padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--sheet-line); }
.sheet form input { flex: 1; border: 0; background: var(--sheet-field); border-radius: 999px; padding: 0.55rem 0.9rem; color: inherit; }
.sheet form button { border: 0; background: none; color: var(--accent-ink); font-weight: 700; cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 1.5rem); transform: translateX(-50%);
  background: rgb(35 18 61 / 0.92); color: var(--fg); padding: 0.5rem 0.9rem; border-radius: 8px; font-size: 0.85rem;
  opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; }

/* studio */
.studio-bar { justify-content: space-between; }
.studio-bar .close { text-decoration: none; font-size: 1.3rem; width: 2rem; }
.modes { display: flex; gap: 0.3rem; background: var(--glass); border-radius: 999px; padding: 0.2rem; margin-right: 2rem; margin-left: auto; margin-right: auto; }
.modes button { background: none; border: 0; color: var(--muted); padding: 0.35rem 0.9rem; border-radius: 999px; font-weight: 600; cursor: pointer; }
.modes button[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }

.studio { height: 100dvh; display: flex; flex-direction: column; align-items: center; }
.stage { position: relative; width: var(--column); height: min(calc(var(--column) * 16 / 9), 100dvh); background: var(--surface); overflow: hidden; }
.stage canvas, .stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage-message { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 2rem; color: var(--muted); pointer-events: none; }
.stage-message:empty { display: none; }
.timer { position: absolute; top: 4rem; left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--on-accent); padding: 0.2rem 0.6rem; border-radius: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }

.controls, .post {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: var(--column);
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 0.8rem;
  background: linear-gradient(transparent, rgb(20 10 36 / 0.82) 35%);
}
.controls[hidden], .post[hidden] { display: none; }
.pickers { display: flex; gap: 0.6rem; }
.avatar-upload { display: flex; gap: 0.5rem; justify-content: center; }
.pill.small { font-size: 0.75rem; padding: 0.35rem 0.8rem; }
.pill input[type="file"] { display: none; }
.pickers label { font-size: 0.75rem; color: var(--muted); display: flex; align-items: center; gap: 0.3rem; }
.pickers select, .post select, .post input {
  background: var(--tint); color: var(--fg); border: 1px solid var(--tint-line); border-radius: 8px; padding: 0.45rem 0.6rem;
}
.pickers select option, .post select option { color: var(--sheet-fg); }
.record {
  width: 4.6rem; height: 4.6rem; border-radius: 50%; border: 5px solid var(--accent-2);
  background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.record span { width: 3.4rem; height: 3.4rem; border-radius: 50%; background: var(--accent); transition: all 0.2s; }
.record.recording span { width: 1.7rem; height: 1.7rem; border-radius: 6px; }
.record:disabled { opacity: 0.4; cursor: default; }
.hint { margin: 0; font-size: 0.75rem; color: var(--muted); text-align: center; }
.post input[name="caption"] { width: 100%; }
.post .row { display: flex; gap: 0.6rem; width: 100%; }
.post .row > * { flex: 1; }
.post .row select { flex: 0 0 4rem; }
.file input { display: none; }

/* about page */
body.doc { background: var(--sheet); color: var(--sheet-fg); }
.readme { max-width: 42rem; margin: 0 auto; padding: 1.5rem 1rem calc(var(--nav-h) + 2rem); line-height: 1.55; }
body.doc .bottom-nav { background: var(--sheet); border-top-color: var(--sheet-line); }
body.doc .bottom-nav a { color: var(--sheet-muted); }
body.doc .bottom-nav a.active { color: var(--accent-ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.room { width: 100%; max-width: 30rem; font-size: 0.8rem; color: var(--muted); }
.room summary { cursor: pointer; text-align: center; color: var(--fg); }
.room .row { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; align-items: center; margin: 0.4rem 0; }
.room select { background: var(--tint); color: var(--fg); border: 0; border-radius: 0.5rem; padding: 0.25rem; }
.room select option { color: var(--sheet-fg); }
.room .tag { font-size: 0.65rem; padding: 0.05rem 0.4rem; border-radius: 0.5rem; background: var(--accent-2); color: var(--on-accent); }
.room .consent { background: var(--tint); border: 1px solid var(--accent); border-radius: 0.7rem; padding: 0.6rem; margin: 0.4rem 0; color: var(--fg); }
.room .consent p { margin: 0 0 0.4rem; }

/* Devices: link another browser */
.link section { margin: 1.5rem 0; }
.link .code { font: 700 2rem/1.2 ui-monospace, monospace; letter-spacing: 0.15em; margin: 0.8rem 0 0.2rem; }
.link form { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.link input { flex: 1 1 10rem; font: 600 1.1rem ui-monospace, monospace; text-transform: uppercase; padding: 0.5rem 0.7rem; border-radius: 0.6rem; border: 1px solid var(--sheet-line); }
.link .hint { color: var(--sheet-muted); }

/* body tracking switch, in the studio */
.switch { display: flex; align-items: center; justify-content: center; gap: 0.45rem; font-size: 0.8rem; color: var(--fg); cursor: pointer; }
.switch input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.switch .tag { font-size: 0.65rem; padding: 0.05rem 0.4rem; border-radius: 0.5rem; background: var(--accent-2); color: var(--on-accent); }

/* README media on /readme/ */
.readme img { max-width: 100%; height: auto; border-radius: 0.6rem; }
.readme table { width: 100%; border-collapse: collapse; }
.readme th, .readme td { padding: 0.25rem; vertical-align: top; }
