:root {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #141417;
  --surface-2: #1d1d21;
  --surface-3: #29292f;
  --text: #f8f8f8;
  --muted: #a5a5ad;
  --line: rgba(255,255,255,.09);
  --accent: #e50914;
  --accent-2: #ff3b43;
  --success: #31c46c;
  --shadow: 0 20px 60px rgba(0,0,0,.28);
  --radius: 24px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f3f5;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --surface-3: #ececf0;
  --text: #111115;
  --muted: #696971;
  --line: rgba(0,0,0,.09);
  --shadow: 0 20px 55px rgba(0,0,0,.1);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.noscript { padding: 20px; background: #fff; color: #111; }

.onboarding { position: fixed; inset: 0; z-index: 100; min-height: 100dvh; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: calc(var(--safe-top) + 56px) 28px calc(var(--safe-bottom) + 28px); text-align: center; color: #fff; background: linear-gradient(150deg,#f60000 0%,#d80009 52%,#b8000b 100%); }
.onboarding__glow { position: absolute; border-radius: 50%; filter: blur(6px); opacity: .25; pointer-events: none; }
.onboarding__glow--one { width: 420px; height: 420px; top: -170px; right: -220px; background: #ff8585; }
.onboarding__glow--two { width: 340px; height: 340px; bottom: 120px; left: -230px; background: #ff6464; }
.onboarding__content, .onboarding__actions { position: relative; z-index: 1; }
.onboarding__content { margin: auto 0; }
.onboarding h1 { margin: 34px 0 6px; font-size: clamp(52px,16vw,76px); letter-spacing: -3px; line-height: .96; }
.onboarding__subtitle { margin: 0; font-size: 24px; font-weight: 750; }
.onboarding__description { max-width: 460px; margin: 28px auto 0; color: rgba(255,255,255,.84); font-size: 17px; line-height: 1.45; }
.onboarding__actions { width: 100%; max-width: 560px; margin: 0 auto; }
.onboarding__legal { margin: 28px 0 10px; color: rgba(255,255,255,.7); font-size: 13px; line-height: 1.4; }
.legal-links { display: flex; justify-content: center; gap: 8px; color: rgba(255,255,255,.8); font-size: 13px; }
.legal-links button { padding: 0; border: 0; color: inherit; background: none; text-decoration: underline; }

.app { min-height: 100dvh; padding-bottom: calc(82px + var(--safe-bottom)); }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; min-height: calc(68px + var(--safe-top)); padding: calc(10px + var(--safe-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(24px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; text-align: left; }
.brand > span:last-child { display: grid; }
.brand strong { font-size: 18px; line-height: 1; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 13px; background: #fff; box-shadow: 0 10px 30px rgba(229,9,20,.2); }
.brand-mark--large { width: 126px; height: 88px; margin: 0 auto; border-radius: 28px; }
.brand-mark__ring { width: 25px; height: 25px; border: 4px solid var(--accent); border-right-color: transparent; border-radius: 50%; transform: rotate(-20deg); }
.brand-mark--large .brand-mark__ring { width: 58px; height: 58px; border-width: 7px; }
.brand-mark__play { position: absolute; left: 52%; width: 0; height: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-left: 12px solid var(--accent); transform: translate(-30%,-1%); }
.brand-mark--large .brand-mark__play { border-top-width: 14px; border-bottom-width: 14px; border-left-width: 23px; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.icon-button { display: inline-grid; place-items: center; min-width: 42px; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 22px; }
.icon-button:disabled { opacity: .35; }
.safety-pill { display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 12px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff4a4a; box-shadow: 0 0 0 4px rgba(255,74,74,.12); }
.safety-pill.safe .status-dot { background: var(--success); box-shadow: 0 0 0 4px rgba(49,196,108,.12); }

.ios-install-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 12px 16px 0; padding: 14px 16px; border: 1px solid rgba(229,9,20,.28); border-radius: 18px; background: rgba(229,9,20,.1); }
.ios-install-banner div { display: grid; gap: 3px; }
.ios-install-banner span { color: var(--muted); font-size: 12px; }
.ios-install-banner button { border: 0; background: none; font-size: 24px; }

.main-content { width: min(860px,100%); margin: 0 auto; padding: 18px 16px 28px; }
.tab-panel { display: none; animation: fade .18s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: .4; transform: translateY(4px); } }
.hero-card, .player-card, .settings-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.hero-card { position: relative; overflow: hidden; padding: 24px; background: radial-gradient(circle at 110% -20%,rgba(229,9,20,.33),transparent 44%),var(--surface); }
.hero-card__text h1, .page-heading h1 { margin: 5px 0 8px; font-size: clamp(31px,8vw,46px); letter-spacing: -1.4px; line-height: 1.02; }
.hero-card__text p { margin: 0; color: var(--muted); line-height: 1.45; }
.eyebrow { color: var(--accent-2); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.url-form { display: grid; gap: 10px; margin-top: 24px; }
input[type="url"], input[type="search"] { width: 100%; height: 52px; padding: 0 16px; border: 1px solid var(--line); border-radius: 16px; outline: none; color: var(--text); background: var(--surface-2); }
input:focus, select:focus { border-color: rgba(229,9,20,.7); box-shadow: 0 0 0 4px rgba(229,9,20,.12); }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 18px; border-radius: 16px; font-weight: 750; cursor: pointer; }
.primary-button { border: 0; color: #fff; background: linear-gradient(135deg,var(--accent-2),var(--accent)); box-shadow: 0 12px 30px rgba(229,9,20,.24); }
.primary-button--light { width: 100%; color: var(--accent); background: #fff; }
.secondary-button { border: 1px solid var(--line); color: var(--text); background: var(--surface-2); }
.secondary-button--compact { min-height: 42px; border-radius: 14px; font-size: 13px; }
.secondary-button:disabled { opacity: .38; }
.quick-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; margin-top: 10px; }
.file-button { position: relative; overflow: hidden; }
.file-button input, .file-action input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.form-message { min-height: 18px; margin: 12px 2px 0; color: var(--muted); font-size: 13px; }
.form-message.error { color: #ff666d; }

.player-card { margin-top: 18px; overflow: hidden; }
.player-shell { position: relative; aspect-ratio: 16/9; overflow: hidden; background: #000; }
.video-mount, .video-mount iframe, .video-mount video { width: 100%; height: 100%; }
.video-mount iframe, .video-mount video { display: block; border: 0; background: #000; }
.player-placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 24px; color: #fff; text-align: center; background: radial-gradient(circle at center,#27272b 0,#0b0b0d 70%); }
.player-placeholder h2 { margin: 12px 0 6px; font-size: 20px; }
.player-placeholder p { margin: 0; color: #a8a8af; font-size: 13px; }
.placeholder-play { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent); box-shadow: 0 14px 40px rgba(229,9,20,.32); }
.now-playing { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 18px 8px; }
.now-playing > div { min-width: 0; display: grid; gap: 3px; }
.now-playing span, .now-playing small { color: var(--muted); font-size: 11px; }
.now-playing strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.player-controls { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; padding: 8px 18px; }
.player-links { display: flex; justify-content: space-between; padding: 8px 20px 18px; }
.text-button { padding: 0; border: 0; color: var(--accent-2); background: none; font-weight: 700; font-size: 13px; }
.text-button.disabled { pointer-events: none; opacity: .35; }

.queue-section { margin-top: 28px; }
.section-heading, .page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.section-heading { margin: 0 4px 12px; }
.section-heading h2 { margin: 3px 0 0; font-size: 22px; }
.page-heading { margin: 10px 4px 20px; }
.compact-list, .media-list { display: grid; gap: 10px; }
.queue-item, .media-item { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.media-thumb { position: relative; display: grid; place-items: center; width: 70px; aspect-ratio: 16/10; overflow: hidden; border-radius: 12px; color: #fff; background: linear-gradient(145deg,#313137,#121214); font-size: 18px; }
.media-thumb.youtube { background: linear-gradient(145deg,#ff313a,#a30008); }
.media-thumb.vimeo { background: linear-gradient(145deg,#39b7ff,#0068a1); }
.media-thumb.direct { background: linear-gradient(145deg,#9b5cff,#4b168e); }
.media-thumb.local { background: linear-gradient(145deg,#38c98d,#0b754e); }
.media-meta { min-width: 0; display: grid; gap: 4px; }
.media-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.media-actions { display: flex; align-items: center; gap: 5px; }
.mini-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.empty-state { margin: 20px 4px; color: var(--muted); text-align: center; font-size: 14px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-bar input { flex: 1 0 100%; }
.chip { height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.chip.active { border-color: var(--accent); color: #fff; background: var(--accent); }

.settings-card { margin-bottom: 14px; overflow: hidden; box-shadow: none; }
.setting-row, .setting-action { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 72px; padding: 15px 17px; border: 0; border-bottom: 1px solid var(--line); color: var(--text); background: transparent; text-align: left; }
.setting-row:last-child, .setting-action:last-child { border-bottom: 0; }
.setting-row > span, .setting-action > span:first-child { display: grid; gap: 4px; }
.setting-row small, .setting-action small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.setting-row select { max-width: 145px; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--surface-2); }
input[role="switch"] { appearance: none; width: 48px; height: 28px; padding: 3px; border-radius: 999px; background: var(--surface-3); transition: .2s; }
input[role="switch"]::before { content: ""; display: block; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.25); transition: .2s; }
input[role="switch"]:checked { background: var(--accent); }
input[role="switch"]:checked::before { transform: translateX(20px); }
.danger-card { border-color: rgba(255,80,80,.18); }
.setting-action.danger strong { color: #ff5c64; }
.about-text { margin: 20px 6px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(4,1fr); min-height: calc(70px + var(--safe-bottom)); padding: 8px 8px var(--safe-bottom); border-top: 1px solid var(--line); background: color-mix(in srgb,var(--surface) 90%,transparent); backdrop-filter: blur(24px); }
.nav-item { display: grid; place-items: center; align-content: center; gap: 4px; padding: 5px; border: 0; border-radius: 14px; color: var(--muted); background: none; }
.nav-item span { font-size: 20px; }
.nav-item small { font-size: 10px; font-weight: 700; }
.nav-item.active { color: var(--accent-2); background: rgba(229,9,20,.09); }

.modal-backdrop { position: fixed; inset: 0; z-index: 120; display: grid; place-items: end center; padding: 18px 16px calc(18px + var(--safe-bottom)); background: rgba(0,0,0,.68); backdrop-filter: blur(8px); }
.modal-card { position: relative; width: min(520px,100%); padding: 25px; border: 1px solid var(--line); border-radius: 28px; color: var(--text); background: var(--surface); box-shadow: 0 28px 80px rgba(0,0,0,.45); }
.modal-card h2 { margin: 7px 0 10px; font-size: 27px; line-height: 1.05; }
.modal-card p { color: var(--muted); line-height: 1.5; }
.modal-icon { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 16px; border-radius: 16px; color: #fff; background: var(--accent); font-size: 24px; font-weight: 900; }
.confirm-row { display: flex; align-items: flex-start; gap: 12px; margin: 22px 0; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); line-height: 1.4; }
.confirm-row input { width: 22px; height: 22px; accent-color: var(--accent); }
.modal-card .primary-button { width: 100%; }
.modal-card--info { max-height: 82dvh; overflow: auto; }
.modal-card--info h3 { margin-top: 22px; }
.modal-card--info li { margin-bottom: 8px; color: var(--muted); line-height: 1.45; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--surface-2); font-size: 24px; }
.toast { position: fixed; left: 50%; bottom: calc(88px + var(--safe-bottom)); z-index: 200; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; color: #fff; background: rgba(20,20,23,.95); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%,16px); transition: .2s; text-align: center; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (min-width: 700px) {
  .main-content { padding-top: 28px; }
  .url-form { grid-template-columns: minmax(0,1fr) auto; }
  .quick-actions { width: 420px; }
  .modal-backdrop { place-items: center; }
}

@media (display-mode: standalone) {
  .topbar { min-height: calc(62px + var(--safe-top)); }
}
