/* BrainGains: full-bleed vertical feed on phones; a 9:16 column centered on desktop. */
:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #15151b;
  --panel-2: #1f1f27;
  --line: rgba(255, 255, 255, 0.12);
  --ink: #f5f5f7;
  --dim: rgba(245, 245, 247, 0.66);
  --accent: #c6ff3d;
  --like: #ff3b5c;
  --danger: #ff6b6b;
  --display: "Archivo Black", Impact, system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, sans-serif;
  --col: min(100vw, calc(100dvh * 9 / 16));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--body); -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 18px; letter-spacing: 0.01em; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); clip-path: polygon(30% 20%, 30% 80%, 82% 50%); }
.brand-lg { font-size: 30px; justify-content: center; }
.brand-lg .brand-mark { width: 34px; height: 34px; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; overflow-y: auto;
  background: radial-gradient(120% 70% at 50% 0%, #1b2a05 0%, #000 60%); }
body:has(.auth:not([hidden])) { overflow: auto; }
.auth-card { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.auth-tag { margin: -6px 0 6px; text-align: center; color: var(--dim); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel); border-radius: 12px; padding: 4px; }
.tabs button { border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--dim); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--ink); }
#auth-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--dim); }
.field input { font: 500 16px var(--body); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.field input:focus { outline: none; border-color: var(--accent); }
.form-error { margin: 0; min-height: 1.3em; color: var(--danger); font-size: 14px; }
.btn-primary { border: 0; border-radius: 12px; padding: 14px; background: var(--accent); color: #000; font-weight: 700; font-size: 16px; cursor: pointer; }
.btn-primary:disabled { opacity: 0.6; }
.btn-ghost { border: 1px solid var(--line); background: none; border-radius: 12px; padding: 12px; font-weight: 600; cursor: pointer; }

/* ---------- feed ---------- */
.app { position: fixed; inset: 0; }
.feed { position: absolute; inset: 0 auto 0 50%; transform: translateX(-50%); width: var(--col); height: 100dvh;
  overflow-y: scroll; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; outline: none; }
.feed::-webkit-scrollbar { display: none; }
@media (min-width: 700px) { .feed { border-inline: 1px solid var(--line); } }

.topbar { position: fixed; z-index: 5; top: 0; left: 50%; transform: translateX(-50%); width: var(--col);
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 24px; pointer-events: none;
  background: linear-gradient(rgba(0,0,0,.55), transparent); }
.topbar > * { pointer-events: auto; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(0,0,0,.35);
  color: var(--ink); cursor: pointer; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); background: var(--panel-2);
  font-weight: 700; font-size: 14px; cursor: pointer; text-transform: uppercase; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 42px; min-width: 200px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; display: grid; box-shadow: 0 12px 40px rgba(0,0,0,.6); }
.menu-who { padding: 8px 10px 10px; font-size: 13px; color: var(--dim); border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-wrap: anywhere; }
.menu-who strong { display: block; color: var(--ink); font-size: 15px; }
.menu-pop a, .menu-pop button { text-align: left; padding: 10px; border-radius: 8px; border: 0; background: none; color: var(--ink); text-decoration: none; font-weight: 600; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--panel-2); }

.slide { position: relative; height: 100dvh; scroll-snap-align: start; scroll-snap-stop: always; overflow: hidden; background: #000; }
.slide video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tap-zone { position: absolute; inset: 0; }
.paused-icon { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .15s; }
.paused-icon svg { width: 84px; height: 84px; fill: rgba(255,255,255,.85); filter: drop-shadow(0 4px 18px rgba(0,0,0,.5)); }
.slide.paused .paused-icon { opacity: 1; }

.meta { position: absolute; left: 16px; right: 84px; bottom: calc(env(safe-area-inset-bottom) + 26px); pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.meta::before { content: ""; position: absolute; inset: -60px -100px -40px -16px; z-index: -1; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.series { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: .04em; text-transform: uppercase; }
.title { margin: 0 0 6px; font-family: var(--display); font-weight: 400; font-size: 21px; line-height: 1.15; text-wrap: balance; }
.desc { pointer-events: auto; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  border: 0; background: none; padding: 0; text-align: left; font-size: 14px; line-height: 1.4; color: var(--dim); cursor: pointer; }

.rail { position: absolute; right: 8px; bottom: calc(env(safe-area-inset-bottom) + 28px); display: grid; gap: 18px; justify-items: center; }
.rail-btn { display: grid; justify-items: center; gap: 3px; width: 60px; border: 0; background: none; cursor: pointer;
  font-size: 12px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.rail-btn svg { width: 34px; height: 34px; fill: #fff; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); transition: transform .15s; }
.rail-btn:active svg { transform: scale(.88); }
.like[aria-pressed="true"] svg { fill: var(--like); animation: pop .35s ease; }
.mute .off { display: none; }
.app.muted .mute .on { display: none; }
.app.muted .mute .off { display: block; }
@keyframes pop { 40% { transform: scale(1.3); } }

.progress { position: absolute; left: 0; right: 0; bottom: env(safe-area-inset-bottom); height: 14px; display: flex; align-items: flex-end; cursor: pointer; touch-action: none; }
.progress::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.2); }
.progress-fill { position: relative; height: 3px; width: 0; background: #fff; }
.progress:hover::before, .progress:hover .progress-fill, .progress.scrubbing::before, .progress.scrubbing .progress-fill { height: 6px; }

.burst { position: absolute; pointer-events: none; width: 110px; height: 110px; margin: -55px 0 0 -55px; opacity: 0;
  background: var(--like); clip-path: path("M55 98S14 73 3 47C-5 29 7 8 27 8c11 0 19 6 28 16 8-10 17-16 28-16 20 0 32 21 24 39C96 73 55 98 55 98z"); }
.burst.go { animation: burst .7s ease-out; }
@keyframes burst { 0% { opacity: 0; transform: scale(.4) rotate(-12deg); } 20% { opacity: 1; transform: scale(1.15) rotate(-12deg); } 100% { opacity: 0; transform: scale(1) translateY(-60px) rotate(-12deg); } }

.empty { height: 100dvh; display: grid; place-content: center; text-align: center; padding: 24px; color: var(--dim); gap: 8px; }
.empty code { color: var(--accent); }
.end-card { scroll-snap-align: start; }
.empty .btn-ghost { justify-self: center; margin-top: 8px; padding: 10px 22px; color: var(--ink); }

.sound-hint { position: fixed; z-index: 6; left: 50%; top: calc(env(safe-area-inset-top) + 70px); transform: translateX(-50%);
  border: 0; border-radius: 999px; padding: 8px 14px; background: rgba(0,0,0,.65); font-weight: 600; cursor: pointer; backdrop-filter: blur(8px); }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 9; background: rgba(0,0,0,.5); }
.sheet { position: fixed; z-index: 10; left: 50%; bottom: 0; transform: translateX(-50%); width: var(--col); max-height: 70dvh; overflow-y: auto;
  background: var(--panel); border-radius: 18px 18px 0 0; padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px); display: grid; gap: 10px;
  animation: up .2s ease-out; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 6px; }
.sheet h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1.15; }
.sheet p { margin: 0; line-height: 1.5; color: var(--dim); }
.sheet-series { color: var(--accent) !important; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
@keyframes up { from { transform: translate(-50%, 100%); } }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 90px; transform: translate(-50%, 20px); padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: #000; font-weight: 600; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* All-videos library: slides in from the left over the feed */
.library { position: fixed; z-index: 8; top: 0; left: 50%; transform: translateX(-50%); width: var(--col); height: 100dvh;
  background: var(--bg); display: flex; flex-direction: column; animation: lib-in .22s ease-out; }
.library[hidden] { display: none; }
@keyframes lib-in { from { transform: translateX(-100%); opacity: .4; } }
.lib-head { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; border-bottom: 1px solid var(--line); }
.lib-head h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 20px; }
.lib-count { flex: 1; color: var(--dim); font-size: 13px; }
.lib-body { flex: 1; overflow-y: auto; padding: 4px 16px calc(env(safe-area-inset-bottom) + 24px); overscroll-behavior: contain; }
.lib-body h3 { margin: 18px 0 10px; color: var(--accent); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.lib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tile { position: relative; aspect-ratio: 9 / 16; border: 0; padding: 0; border-radius: 8px; overflow: hidden; background: var(--panel-2);
  cursor: pointer; color: var(--ink); text-align: left; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.seen img { opacity: .55; }
.tile-label { position: absolute; inset: auto 0 0; padding: 22px 6px 6px; font-size: 11.5px; font-weight: 600; line-height: 1.25;
  background: linear-gradient(transparent, rgba(0,0,0,.85)); }
.tile-label b { display: block; color: var(--accent); font-size: 10.5px; }
.tile-badge { position: absolute; top: 5px; right: 5px; padding: 2px 6px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  background: rgba(0,0,0,.65); color: var(--dim); }
.tile-badge.new { background: var(--accent); color: #000; }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
