:root {
  --bg: #070708;
  --surface: #111114;
  --card: #17171c;
  --line: #2a2a32;
  --text: #f4f1ea;
  --muted: #9b978f;
  --accent: #a259ff;
  --accent-dim: #4b2a85;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "Segoe UI", "Helvetica Neue", sans-serif; }
a, button { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img, video { max-width: 100%; display: block; }
.shell { width: min(860px, 100%); margin: 0 auto; padding: 76px 16px 108px; }
.shell.shorts-mode { width: 100%; max-width: 520px; padding: 0 0 74px; }
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; gap: 12px; align-items: center;
  padding: 10px 14px; background: rgba(7,7,8,.92); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; letter-spacing: .02em; font-size: 18px; cursor: pointer; }
.brand img { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
.search { flex: 1; }
.search input, label input, label select, label textarea, .gate-card input, .gate-card select, .gate-card textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
}
.dock {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #0c0c0f; border-top: 1px solid var(--line); padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
}
.dock a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 11px; cursor: pointer; }
.dock svg { width: 22px; height: 22px; fill: currentColor; }
.dock a.on { color: var(--text); }
.dock .create svg { background: var(--text); color: #111; border-radius: 8px; width: 34px; height: 26px; padding: 2px; }
.dock-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.page-title { margin: 6px 0 12px; font-size: 22px; }
.lede, .fine, .dim, .handle { color: var(--muted); }
.flashes p { background: #1d1330; border: 1px solid var(--accent-dim); padding: 10px 12px; border-radius: 10px; }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(600px 280px at 50% 0%, rgba(162,89,255,.18), transparent 60%), var(--bg); }
.gate-card { width: min(440px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 22px; display: grid; gap: 12px; }
.gate-card.wide { width: min(560px, 100%); }
.gate-logo { width: 72px; height: 72px; border-radius: 16px; object-fit: cover; }
h1, h2 { margin: 10px 0 4px; letter-spacing: .04em; }
.mode { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode button, .btn, button[type="submit"] { border: 0; border-radius: 999px; padding: 11px 16px; background: var(--accent); color: white; cursor: pointer; }
.mode button { background: var(--surface); color: var(--muted); }
.mode button.on { background: var(--text); color: #111; }
.stack, .feed { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.card { display: grid; gap: 10px; }
.thumb { position: relative; display: block; aspect-ratio: 16/9; background: #000; border-radius: 14px; overflow: hidden; cursor: pointer; }
.thumb img, .thumb video, .short-card img, .short-card video { width: 100%; height: 100%; object-fit: cover; }
.thumb em { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.72); padding: 2px 6px; border-radius: 6px; font-style: normal; font-size: 12px; }
.meta, .watch-row, .who { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.avatar, .who img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #222; }
.avatar.xl { width: 96px; height: 96px; }
.title { font-weight: 680; cursor: pointer; }
.meta p { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.row-head, .actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.short-row, .chip-row, .library { display: flex; gap: 10px; overflow: auto; padding-bottom: 8px; }
.short-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.short-wrap { position: relative; width: 140px; flex: 0 0 140px; }
.short-grid .short-wrap { width: auto; }
.short-card { display: block; position: relative; cursor: pointer; }
.short-card img, .short-card video { aspect-ratio: 9/16; border-radius: 12px; background: #000; }
.short-card span, .lib span, .who span { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }
.chip { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 84px; color: var(--muted); font-size: 12px; cursor: pointer; }
.chip img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; }
.empty { border: 1px dashed var(--line); border-radius: 16px; padding: 28px 16px; text-align: center; }
.empty.tall { margin-top: 20vh; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.account, .channel-head { display: grid; justify-items: start; gap: 6px; margin-bottom: 16px; }
.facts { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.facts div, .lib, .desc, .panel { background: var(--surface); border-radius: 12px; padding: 12px; }
.facts .full { grid-column: 1 / -1; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 4px 0 0; }
.panel { border: 1px solid var(--line); margin: 12px 0; }
.panel summary { cursor: pointer; }
.lib { min-width: 180px; border: 1px solid var(--line); cursor: pointer; }
.tabs { display: flex; gap: 14px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow: auto; }
.tabs a { padding: 10px 2px; color: var(--muted); cursor: pointer; }
.tabs a.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.player { background: #000; border-radius: 14px; overflow: hidden; }
.player video { width: 100%; max-height: 70vh; background: #000; }
.player.portrait { max-width: 420px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--surface); }
.pick:has(input:checked) { border-color: var(--accent); }
dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 16px; width: min(420px, calc(100% - 24px)); }
.save-item { width: 100%; display: flex; justify-content: space-between; background: var(--surface); margin: 8px 0; }
.reel { height: calc(100vh - 74px); overflow-y: auto; scroll-snap-type: y mandatory; }
.reel-item { position: relative; height: calc(100vh - 74px); scroll-snap-align: start; background: #000; }
.reel-item video { width: 100%; height: 100%; object-fit: cover; }
.reel-shade { position: absolute; left: 12px; right: 72px; bottom: 18px; }
.reel-actions { position: absolute; right: 10px; bottom: 24px; display: grid; gap: 10px; }
.reel-actions button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 52px; padding: 10px 8px; font-size: 12px; background: rgba(0,0,0,.45); border: 0; color: white; border-radius: 999px; cursor: pointer; }
.reel-actions svg { width: 28px; height: 28px; fill: none; stroke: white; }
.like[data-on="1"] { color: var(--accent); }
.like[data-on="1"] svg { fill: var(--accent); stroke: var(--accent); }
.dislike[data-on="1"] { color: var(--text); }
.dislike[data-on="1"] svg { fill: var(--text); stroke: var(--text); }
.admin { width: min(760px, calc(100% - 32px)); margin: 32px auto; }
.admin pre { white-space: pre-wrap; background: var(--surface); padding: 16px; border-radius: 12px; }
@media (min-width: 900px) { .feed { grid-template-columns: 1fr 1fr; } .watch, .watch + .feed { grid-column: 1 / -1; } }

.actions { flex-wrap: wrap; justify-content: flex-start; }
.actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.actions .btn svg { width: 18px; height: 18px; }
.mini { margin-left: auto; padding: 6px 12px; font-size: 12px; flex: none; }
.short-wrap .mini { margin: 6px 0 0; }
.ai-tag { position: absolute; left: 8px; top: 8px; z-index: 1; background: rgba(0,0,0,.72); border: 1px solid var(--accent-dim); padding: 2px 6px; border-radius: 6px; font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.ai-pill { display: inline-block; background: #1d1330; border: 1px solid var(--accent-dim); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.ai-field { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0; display: grid; gap: 10px; }
.ai-field legend { padding: 0 6px; color: var(--text); font-size: 13px; }
.ai-field .req { color: var(--accent); font-size: 11px; margin-left: 4px; }
.ai-field p { margin: 0; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
label.check input { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); }
#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); opacity: 0; pointer-events: none; z-index: 40; background: var(--text); color: #111; padding: 10px 16px; border-radius: 999px; font-size: 14px; text-align: center; max-width: calc(100% - 32px); transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
