:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b2030;
  --line: #262c3d;
  --text: #eef1f7;
  --muted: #9aa3b8;
  --low: #22c55e;
  --low-bg: rgba(34, 197, 94, 0.12);
  --high: #f43f5e;
  --high-bg: rgba(244, 63, 94, 0.12);
  --accent: #8b5cf6;
  --radius: 16px;
  --bar-bg: rgba(11, 13, 18, 0.88);
  --stage: #000;
  color-scheme: dark;
}
/* Day mode (the sun/moon button; follows the phone setting until picked). */
:root[data-theme="light"] {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #eef0f6;
  --line: #d9dde8;
  --text: #10131a;
  --muted: #5b6475;
  --low: #15803d;
  --low-bg: rgba(21, 128, 61, 0.1);
  --high: #be123c;
  --high-bg: rgba(190, 18, 60, 0.08);
  --accent: #7c3aed;
  --bar-bg: rgba(246, 247, 251, 0.9);
  --stage: #e9ebf2;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--bar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: 0.02em; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: block; flex: none; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }
.brand .tagline { display: block; max-width: 15em; font-style: italic; font-weight: 600; font-size: 12px; letter-spacing: 0; color: var(--text); opacity: 0.85; }
.bar-spacer { flex: 1; }
.bar a.who { text-decoration: none; color: var(--muted); font-size: 14px; white-space: nowrap; }

/* Feed switcher */
.tabs { display: flex; gap: 8px; padding: 12px 16px 0; max-width: 640px; margin: 0 auto; }
.tab {
  flex: 1; text-align: center; text-decoration: none;
  padding: 10px 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-weight: 700; font-size: 15px;
}
.tab.low.on { background: var(--low-bg); border-color: var(--low); color: var(--low); }
.tab.high.on { background: var(--high-bg); border-color: var(--high); color: var(--high); }

.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }
.note { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}

/* Clip card */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 18px; overflow: hidden;
}
.card-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.score {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 15px;
}
.score.low { background: var(--low-bg); color: var(--low); }
.score.high { background: var(--high-bg); color: var(--high); }
.score.mid { background: var(--panel-2); color: var(--muted); }
.card-meta { color: var(--muted); font-size: 13px; }
.card-head .open { margin-left: auto; color: var(--muted); font-size: 13px; text-decoration: none; white-space: nowrap; }
.embed { background: #000; min-height: 220px; display: grid; place-items: center; }
.embed iframe { width: 100%; border: 0; display: block; }
.embed .yt { aspect-ratio: 16 / 9; height: auto; }
.embed .tall { height: 740px; max-height: 85vh; }
.embed .x { width: 100%; background: var(--bg); padding: 0 8px; }
.embed .x .twitter-tweet { margin: 0 auto !important; }
.embed .placeholder { color: var(--muted); padding: 40px 16px; text-align: center; font-size: 14px; }
.card-foot { display: flex; align-items: center; gap: 16px; padding: 10px 14px; border-top: 1px solid var(--line); }
.card-foot a { text-decoration: none; color: var(--muted); font-size: 14px; }
.card-foot a:hover { color: var(--text); }

.more { display: block; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* Home doors */
.hero { text-align: center; padding: 36px 16px 8px; max-width: 680px; margin: 0 auto; }
.hero h1 { font-size: clamp(30px, 7vw, 46px); line-height: 1.1; margin: 0 0 12px; letter-spacing: -0.02em; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 520px; }
.hero p + p { margin-top: 12px; }
.hero p a { color: var(--text); font-weight: 700; }
.doors { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 680px; margin: 28px auto; padding: 0 16px; }
@media (max-width: 560px) { .doors { grid-template-columns: 1fr; } }
.door {
  display: block; text-decoration: none; border-radius: 20px; padding: 26px 22px;
  border: 1px solid var(--line); background: var(--panel);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.door:hover { transform: translateY(-2px); }
.door .icon { font-size: 40px; }
.door h2 { margin: 10px 0 6px; font-size: 24px; }
.door p { margin: 0; color: var(--muted); font-size: 15px; }
.door .count { margin-top: 14px; font-weight: 700; font-size: 14px; }
.door.low { border-color: rgba(34, 197, 94, 0.45); background: linear-gradient(180deg, var(--low-bg), var(--panel)); }
.door.low .count { color: var(--low); }
.door.high { border-color: rgba(244, 63, 94, 0.45); background: linear-gradient(180deg, var(--high-bg), var(--panel)); }
.door.high .count { color: var(--high); }

/* Panels and forms */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 10px; font-size: 19px; }
.panel p { color: var(--muted); margin: 0 0 12px; font-size: 15px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=url], textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
}
textarea { min-height: 80px; resize: vertical; }
.btn {
  display: inline-block; padding: 10px 16px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 700; text-decoration: none; margin-top: 12px;
}
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn:disabled { opacity: 0.6; cursor: default; }
.msg { font-size: 14px; margin-top: 10px; min-height: 1em; }
.msg.err { color: var(--high); }
.msg.ok { color: var(--low); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Comments */
.comments { margin-top: 8px; }
.comment { padding: 12px 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; }
.comment .who { font-weight: 700; font-size: 14px; }
.comment .agent { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }
.comment .agent.owner { background: rgba(250, 204, 21, 0.16); color: #fde047; }
.comment .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.comment .body { white-space: pre-wrap; word-wrap: break-word; margin-top: 4px; }
.comment .tools { margin-top: 4px; display: flex; gap: 12px; }
.comment .tools button { background: none; border: 0; color: var(--muted); font-size: 12px; cursor: pointer; padding: 0; }
.comment.hidden-c { opacity: 0.5; }

footer { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 16px 50px; }
footer a { color: var(--muted); }
.fine { color: var(--muted); font-size: 13px; }

/* Score banner on a clip page (drives extension installs) */
.banner { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; border: 1px solid var(--line); }
.banner.low { background: var(--low-bg); border-color: rgba(34, 197, 94, 0.5); }
.banner.high { background: var(--high-bg); border-color: rgba(244, 63, 94, 0.5); }
.banner strong { font-size: 18px; }
.banner.low strong { color: var(--low); }
.banner.high strong { color: var(--high); }
.banner p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.banner a { color: var(--text); font-weight: 700; }

/* Share buttons */
.share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.share-row a, .share-row button {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2); text-decoration: none; font-size: 14px; font-weight: 600; cursor: pointer;
}
.share-row a:hover, .share-row button:hover { border-color: var(--muted); }
.card-foot .share-link { margin-left: auto; }

/* Ad slots: off until an ad network is chosen (AIFV_ADS in app.js). Never inside a player. */
.ad-slot { margin: 0 0 18px; min-height: 100px; border-radius: var(--radius); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 12px; }

/* ---------- Home: picker, then one clip at a time ---------- */
.bar .who + .who { margin-left: 4px; }
.intro { margin: 18px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.intro a { color: var(--text); font-weight: 700; }
.cats { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0 0; }
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.cat.on { background: var(--text); color: var(--bg); border-color: var(--text); }
  display: flex; flex-direction: column; align-items: center; text-decoration: none;
  padding: 10px 6px; border-radius: 14px; margin-bottom: 10px; font-weight: 800; font-size: 15px; text-align: center;
}
.tile-owner { padding: 0 10px 8px; }
.tile-owner select { width: 100%; font-size: 12px; padding: 5px; border-radius: 8px; background: var(--bg); border: 1px dashed var(--accent); }
/* Wide screens: play the post right in the column. */
.search { margin: 0; }
.search input { width: 100%; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 15px; }
.tag-input { width: 100%; margin-top: 6px; font-size: 12px; padding: 5px 8px; border-radius: 8px; background: var(--bg); border: 1px dashed var(--accent); }
#owner-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
#owner-tools .tag-input { font-size: 14px; padding: 9px 10px; }
.votes { display: inline-flex; align-items: center; gap: 4px; }
.vbtn { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 700; cursor: pointer; }
.vbtn.on { color: var(--text); border-color: var(--accent); background: rgba(139, 92, 246, 0.2); }
.votes > span { min-width: 18px; text-align: center; font-weight: 800; font-size: 13px; }
.clip-votes { margin: -8px 0 16px; }
.join { max-width: 520px; margin: 24px auto 0; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.join h2 { margin: 0 0 8px; font-size: 19px; }
.join ul { margin: 0; padding-left: 20px; color: var(--muted); font-size: 15px; }
.join .fine { margin-top: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); margin-top: 12px; }
#follows-list { display: flex; flex-wrap: wrap; gap: 6px; }

.pick { max-width: 560px; margin: 0 auto; padding: 16px 16px 8px; }
.pick-title { font-size: 22px; margin: 4px 0 14px; }
.pick-label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 20px 0 8px; }
.pick-feeds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feed-choice {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  padding: 14px 8px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--panel); cursor: pointer;
}
.feed-choice .feed-sign { font-size: 34px; line-height: 1; font-weight: 900; }
.feed-choice .feed-name { font-weight: 800; font-size: 15px; }
.feed-choice small { color: var(--muted); font-size: 12px; }
.feed-choice.low .feed-sign { color: var(--low); }
.feed-choice.high .feed-sign { color: var(--high); }
.feed-choice.low.on { border-color: var(--low); background: var(--low-bg); }
.feed-choice.high.on { border-color: var(--high); background: var(--high-bg); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 14px; font-weight: 700; cursor: pointer; }
.opt.on { background: var(--text); color: var(--bg); border-color: var(--text); }
#follow:not(:empty) { margin-top: 8px; }
.btn.go { display: block; width: 100%; margin-top: 24px; padding: 14px; font-size: 17px; border-radius: 14px; }
.pick-count { text-align: center; margin: 8px 0 0; min-height: 1.4em; }

body.watching footer { display: none; }
body.watching .brand .tagline, body.watching .brand small { display: none; }
.watch { position: relative; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100vh - 53px); height: calc(100dvh - 53px); }
.watch-top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 700; cursor: pointer; text-align: left; }
.stage { background: var(--stage); flex: 1 1 0; min-height: 0; overflow: auto; display: flex; flex-direction: column; justify-content: center; }
.stage > iframe { width: 100%; border: 0; display: block; }
.stage .yt { aspect-ratio: 16 / 9; height: auto; max-height: 100%; }
.stage .tall { height: 100%; }
.stage .x { width: 100%; padding: 8px; margin: auto 0; }
.stage .x .twitter-tweet { margin: 0 auto !important; }
.stage .placeholder { color: var(--muted); padding: 40px 16px; text-align: center; font-size: 14px; margin: auto 0; }
.watch-info { flex: none; padding: 8px 14px 0; display: flex; flex-direction: column; gap: 6px; }
.watch-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.watch-line .tag { color: var(--text); font-weight: 600; }
.watch-line a { font-size: 14px; }
.watch-nav { flex: none; display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; padding: 8px 14px calc(10px + env(safe-area-inset-bottom)); }
.watch-nav .btn { margin: 0; padding: 12px; }
.watch-info .vbtn { padding: 4px 10px; }
.theme-btn { background: transparent; border: 1px solid var(--line); border-radius: 999px; width: 36px; height: 36px; display: grid; place-items: center; font-size: 17px; line-height: 1; cursor: pointer; padding: 0; flex: none; }
:root[data-theme="light"] .comment .agent { color: #6d28d9; }
:root[data-theme="light"] .comment .agent.owner { color: #a16207; }
.disc-title { font-size: 22px; margin: 4px 0 6px; }
.disc-share { margin: 0 0 14px; }
.disc-share .btn { margin-top: 0; }
.disc { display: flex; gap: 12px; align-items: center; text-decoration: none; padding: 10px; margin-bottom: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.disc.low { border-color: var(--low); }
.disc.high { border-color: var(--high); }
.disc-pic { width: 84px; height: 84px; flex: none; border-radius: 10px; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; }
.disc-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.disc-pic .ph { font-size: 12px; color: var(--muted); }
.disc-info { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.disc-line { font-size: 14px; font-weight: 600; }
.disc-line.fine { font-weight: 400; }

/* Left menu */
.menu-btn { background: transparent; border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px; font-size: 18px; line-height: 1; cursor: pointer; flex: none; color: var(--text); }
.menu { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: 260px; max-width: 82vw; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px 24px;
  transform: translateX(-105%); transition: transform 0.2s ease; }
.menu.open { transform: none; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; text-decoration: none; font-weight: 600; font-size: 15px; }
.menu a:hover, .menu a:focus-visible { background: var(--panel-2); }
.menu a .score { padding: 2px 8px; font-size: 13px; }
.menu-head { margin: 14px 12px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.menu-head:first-child { margin-top: 4px; }
.menu-head small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.menu-shade { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.45); }
@media (min-width: 1100px) {
  .menu { transform: none; top: 0; padding-top: 70px; z-index: 5; }
  .menu-btn, .menu-shade { display: none !important; }
  body.has-menu { padding-left: 260px; }
}

/* Scrolling feed: one clip per screen, snapped */
.feed { flex: 1 1 0; min-height: 0; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; }
.feed::-webkit-scrollbar { display: none; }
.slide { height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); }
.stage-wrap { position: relative; flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.slide .stage { flex: 1 1 0; min-height: 0; overflow: hidden; }
.slide.playing .stage { overflow: auto; }
.shield { position: absolute; inset: 0; z-index: 2; width: 100%; border: 0; padding: 0 0 16px; margin: 0; background: transparent; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center; touch-action: pan-y; -webkit-tap-highlight-color: transparent; }
.shield span { background: rgba(0, 0, 0, 0.62); color: #fff; font-weight: 800; font-size: 14px; padding: 8px 16px; border-radius: 999px; }
.slide.playing .shield { bottom: auto; height: 22%; min-height: 56px; padding: 0; cursor: ns-resize; background: linear-gradient(rgba(0, 0, 0, 0.28), transparent); }
.slide.playing .shield span { display: none; }
.slide .watch-info { padding-bottom: 10px; }
.slide.end { justify-content: center; align-items: center; text-align: center; }
.slide.end .placeholder { color: var(--muted); padding: 24px; }
.feed-arrows { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); z-index: 6; display: flex; flex-direction: column; gap: 10px; }
.arrow { width: 44px; height: 44px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 16px; cursor: pointer; display: grid; place-items: center; }
.missing-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.missing-btn:disabled { cursor: default; opacity: 0.85; }
