:root {
  --bg: #121212;
  --panel: #1a1a1a;
  --card: #1f1f1f;
  --line: #333;
  --text: #e5e5e5;
  --muted: #9a9a9a;
  --gold: #eba845;
  --red: #e0234e;
  --orange: #e67e22;
  --top: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--gold); }
button, input, select { font: inherit; }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 8px; padding: 12px 16px; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn-gold { background: var(--gold); color: #1a1a1a; }
.btn-red { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-small { padding: 7px 11px; font-size: 13px; }

/* Age gate */
.gate { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.94); display: flex; align-items: center; justify-content: center; padding: 16px; }
.gate-box { max-width: 380px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px 20px; display: grid; gap: 12px; }
.gate-box img { margin: 0 auto; }
.gate-box h1 { margin: 4px 0 0; font-size: 20px; color: var(--gold); }
.gate-box p { margin: 0; color: var(--muted); font-size: 14px; }

/* Header + tabs */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(8px + var(--top)) 16px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand img { display: block; }
.top-actions { display: flex; gap: 8px; }
.tabs { display: flex; overflow-x: auto; scrollbar-width: none; background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 8px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 0 0 auto; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 11px 12px; font-weight: 600; cursor: pointer; }
.tabs button.active { color: var(--gold); border-bottom-color: var(--gold); }

/* Filters */
.filters { padding: 12px 16px 4px; display: grid; gap: 10px; }
#q { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
#q:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
.filter-row { display: flex; gap: 8px; align-items: center; }
.toggle { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; font-size: 14px; }
.toggle input { accent-color: var(--gold); }
#sort { margin-left: auto; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 5px 10px; border: 1px solid var(--gold); border-radius: 999px; color: var(--gold); background: none; font-size: 13px; cursor: pointer; }
.chip.active { background: var(--gold); color: #1a1a1a; }

.hint { margin: 8px 16px 0; padding: 10px 36px 10px 12px; position: relative; background: #262626; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.hint-close { position: absolute; right: 6px; top: 4px; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }

/* Install sheet */
.sheet { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.75); display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 10px; text-align: center; margin-bottom: 0; }
.sheet-box img { margin: 0 auto; border-radius: 14px; }
.sheet-box h2 { margin: 0; font-size: 19px; color: #fff; }
.sheet-sub { margin: 0; color: var(--muted); font-size: 13px; }
.steps { text-align: left; margin: 4px 0; padding-left: 22px; display: grid; gap: 8px; font-size: 15px; }
.steps b { color: var(--gold); }
.share-ico { display: inline-block; width: 18px; height: 20px; vertical-align: -4px; border: 2px solid var(--gold); border-top: 0; border-radius: 0 0 3px 3px; position: relative; margin: 0 2px; }
.share-ico::before { content: "\2191"; position: absolute; left: 50%; top: -11px; transform: translateX(-50%); color: var(--gold); font-weight: 700; font-size: 15px; }
.sheet.ios { align-items: center; }
.sheet.ios .sheet-box { border-radius: 16px; margin: 16px; }
.sheet-arrow { position: fixed; left: 50%; bottom: 6px; transform: translateX(-50%); color: var(--gold); font-size: 42px; line-height: 1; animation: bob 1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, 8px); } }

/* Alerts panel (Favorites tab) */
.alerts { margin: 8px 0 12px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; display: flex; gap: 12px; align-items: center; }
.alerts p { margin: 0; flex: 1; font-size: 14px; }
.alerts p small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.alerts.on { border-color: #16a34a; }

/* Grid */
main { padding: 8px 16px 16px; }
.status { color: var(--muted); font-size: 13px; margin: 4px 0 10px; min-height: 1em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; }
.card.off { opacity: .45; }
.thumb { position: relative; aspect-ratio: 4 / 3; background: #262626; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badges { position: absolute; left: 6px; top: 6px; display: flex; gap: 4px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: rgba(0,0,0,.65); color: #fff; }
.badge.live { background: var(--red); }
.badge.hd { background: #2563eb; }
.badge.nw { background: #16a34a; }
.badge.show { background: var(--orange); }
.card .star { position: absolute; right: 4px; top: 2px; }
.star { background: none; border: 0; color: #fff; font-size: 24px; line-height: 1; padding: 4px; cursor: pointer; text-shadow: 0 1px 3px #000; }
.star.on { color: var(--gold); }
.card-body { padding: 7px 9px 9px; }
.card-name { display: flex; justify-content: space-between; gap: 6px; font-weight: 700; color: #fff; font-size: 14px; }
.card-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-name small { color: var(--muted); font-weight: 400; flex: 0 0 auto; }
.card-sub { margin-top: 2px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { height: 48px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 32px 8px; }

.foot { padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px)); color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

/* Room view */
.room { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; }
.room-bar { position: sticky; top: 0; display: flex; align-items: center; gap: 8px; padding: calc(6px + var(--top)) 8px 6px; background: var(--panel); border-bottom: 1px solid var(--line); }
.room-bar strong { flex: 1; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-back { background: none; border: 0; color: var(--text); font-size: 24px; padding: 4px 10px; cursor: pointer; }
.room-video { position: relative; width: 100%; aspect-ratio: 850 / 528; background: #000; }
.room-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.room-info { padding: 12px 16px 24px; max-width: 900px; }
.room-meta { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.room-subject { margin: 0 0 14px; }
.room-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.room-note { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .room-video { max-height: 70vh; }
}
