:root {
  color-scheme: dark;
  --bg: #0f0f0f;
  --surface: #181818;
  --surface-2: #212121;
  --surface-3: #2b2b2b;
  --line: #303030;
  --text: #f1f1f1;
  --muted: #aaa;
  --accent: #ff0033;
  --accent-hover: #e6002e;
  --success: #2ba640;
  --danger: #ff667d;
  --header-h: 64px;
  --sidebar-w: 232px;
  --shadow: 0 18px 60px rgba(0, 0, 0, .42);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; min-height: 100vh; padding-bottom: 150px; }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.app-header { position: fixed; inset: 0 0 auto 0; z-index: 50; height: var(--header-h); display: grid; grid-template-columns: minmax(210px, 1fr) minmax(320px, 680px) minmax(210px, 1fr); align-items: center; gap: 20px; padding: 0 18px; background: rgba(15, 15, 15, .97); backdrop-filter: blur(18px); }
.header-left, .header-actions { display: flex; align-items: center; gap: 14px; min-width: 0; }
.header-actions { justify-content: flex-end; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; min-width: 0; }
.brand-icon { width: 31px; height: 22px; display: grid; place-items: center; border-radius: 7px; background: var(--accent); color: #fff; font-size: .75rem; padding-left: 2px; }
.brand-name { font-weight: 900; letter-spacing: -.04em; font-size: 1.18rem; }
.brand small { align-self: flex-start; color: var(--muted); font-size: .62rem; margin-top: 4px; }
.round-button { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; cursor: pointer; font-size: 1.25rem; }
.round-button:hover { background: var(--surface-2); }
.header-search { display: grid; grid-template-columns: 1fr 64px; min-width: 0; }
.search-field { position: relative; }
.search-field input { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 22px 0 0 22px; background: #121212; color: var(--text); padding: 0 48px 0 18px; outline: none; font-size: 1rem; }
.search-field input:focus { border-color: #1c62b9; box-shadow: inset 1px 0 0 #1c62b9; }
.clear-search { position: absolute; right: 8px; top: 3px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; font-size: 1.4rem; }
.clear-search:hover { background: var(--surface-2); }
.search-submit { height: 42px; border: 1px solid var(--line); border-left: 0; border-radius: 0 22px 22px 0; background: #222; cursor: pointer; font-size: 1.35rem; }
.search-submit:hover { background: #303030; }
.service-pill { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.service-pill > span:last-child { display: grid; min-width: 0; }
.service-pill strong { font-size: .75rem; white-space: nowrap; }
.service-pill small { color: var(--muted); font-size: .65rem; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #777; box-shadow: 0 0 0 4px rgba(255,255,255,.04); }
.status-dot.online { background: #2ba640; box-shadow: 0 0 0 4px rgba(43,166,64,.15); }

.sidebar { position: fixed; top: var(--header-h); bottom: 0; left: 0; z-index: 35; width: var(--sidebar-w); padding: 12px; background: var(--bg); overflow-y: auto; transition: transform .22s ease, width .22s ease; }
.sidebar nav { display: grid; gap: 4px; }
.nav-item { width: 100%; height: 46px; border: 0; border-radius: 11px; background: transparent; display: grid; grid-template-columns: 38px 1fr; align-items: center; text-align: left; cursor: pointer; padding: 0 12px; }
.nav-item span { font-size: 1.22rem; }
.nav-item strong { font-size: .9rem; font-weight: 650; }
.nav-item:hover, .nav-item.active { background: var(--surface-2); }
.sidebar-note { margin-top: 20px; padding: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.sidebar-note strong { color: var(--text); }
.sidebar-note p { margin: 6px 0 0; line-height: 1.5; }
body.sidebar-collapsed .sidebar { width: 76px; }
body.sidebar-collapsed .nav-item { grid-template-columns: 1fr; justify-items: center; height: 64px; padding: 6px; }
body.sidebar-collapsed .nav-item strong, body.sidebar-collapsed .sidebar-note { display: none; }
body.sidebar-collapsed .main-content { margin-left: 76px; }

.main-content { margin-left: var(--sidebar-w); padding: calc(var(--header-h) + 12px) 26px 40px; transition: margin-left .22s ease; }
.content-panel { display: none; max-width: 1760px; margin: 0 auto; }
.content-panel.active { display: block; }
.topic-chips { position: sticky; top: var(--header-h); z-index: 20; display: flex; gap: 12px; overflow-x: auto; padding: 12px 0 14px; background: linear-gradient(180deg, var(--bg) 78%, rgba(15,15,15,0)); scrollbar-width: none; }
.topic-chips::-webkit-scrollbar { display: none; }
.topic-chip { flex: 0 0 auto; border: 0; border-radius: 9px; background: var(--surface-2); padding: 8px 13px; font-size: .88rem; font-weight: 700; cursor: pointer; }
.topic-chip:hover { background: var(--surface-3); }
.topic-chip.active { background: #f1f1f1; color: #0f0f0f; }
.home-section { padding: 18px 0 28px; }
.results-section { min-height: 420px; }
.section-heading, .page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h1, .section-heading h2, .page-heading h1 { margin: 0; letter-spacing: -.025em; }
.section-heading h1, .page-heading h1 { font-size: clamp(1.55rem, 2.2vw, 2.15rem); }
.section-heading h2 { font-size: 1.35rem; }
.section-heading p, .page-heading p { margin: 6px 0 0; color: var(--muted); }
.compact-heading { align-items: center; }
.text-button { border: 0; background: transparent; color: #3ea6ff; cursor: pointer; font-weight: 700; padding: 8px; }
.text-button:hover { text-decoration: underline; }
.result-count { border-radius: 999px; background: var(--surface-2); color: var(--muted); padding: 7px 11px; font-size: .8rem; white-space: nowrap; }
.eyebrow { color: var(--muted); font-size: .69rem; letter-spacing: .13em; font-weight: 800; }

.recent-searches { display: flex; flex-wrap: wrap; gap: 9px; }
.recent-search { border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 9px 13px; cursor: pointer; color: var(--text); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-search:hover { background: var(--surface-2); }

.video-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 16px; row-gap: 34px; }
.video-card { min-width: 0; }
.thumbnail-wrap { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #222; }
.thumbnail-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .22s ease; }
.video-card:hover .thumbnail-wrap img { transform: scale(1.02); }
.thumbnail-button { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; }
.thumbnail-button:focus-visible { outline: 3px solid #3ea6ff; outline-offset: -3px; }
.duration-badge { position: absolute; right: 6px; bottom: 6px; padding: 3px 5px; border-radius: 4px; background: rgba(0,0,0,.82); font-size: .72rem; font-weight: 800; pointer-events: none; }
.play-overlay { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; background: rgba(0,0,0,.18); transition: opacity .2s; pointer-events: none; }
.play-overlay span { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.75); padding-left: 3px; }
.video-card:hover .play-overlay { opacity: 1; }
.video-details { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding-top: 11px; }
.video-copy { min-width: 0; }
.video-copy h3 { margin: 0 0 7px; font-size: .96rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-copy p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.card-menu { position: relative; }
.card-menu > summary { list-style: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; font-size: 1.25rem; }
.card-menu > summary::-webkit-details-marker { display: none; }
.card-menu > summary:hover { background: var(--surface-2); }
.card-menu[open] .card-menu-popover { display: grid; }
.card-menu-popover { display: none; position: absolute; top: 38px; right: 0; z-index: 12; min-width: 210px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #282828; box-shadow: var(--shadow); }
.card-menu-popover button, .card-menu-popover a { border: 0; background: transparent; color: var(--text); text-decoration: none; text-align: left; border-radius: 8px; padding: 10px 12px; cursor: pointer; font-size: .86rem; }
.card-menu-popover button:hover, .card-menu-popover a:hover { background: #3a3a3a; }
.welcome-state, .empty-state { min-height: 310px; display: grid; place-items: center; text-align: center; }
.welcome-card { max-width: 590px; padding: 48px 28px; }
.welcome-card h2, .empty-state h2 { margin: 14px 0 8px; }
.welcome-card p, .empty-state p { margin: 0; color: var(--muted); line-height: 1.6; }
.welcome-icon, .empty-icon { width: 70px; height: 70px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--accent); font-size: 1.7rem; }
.loading-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 16px; }
.skeleton { min-width: 0; }
.skeleton-thumb, .skeleton-line { background: linear-gradient(90deg, #1c1c1c 25%, #2a2a2a 50%, #1c1c1c 75%); background-size: 200% 100%; animation: shimmer 1.25s infinite; }
.skeleton-thumb { aspect-ratio: 16 / 9; border-radius: 12px; }
.skeleton-line { height: 12px; border-radius: 8px; margin-top: 12px; }
.skeleton-line.short { width: 62%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.notice { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; line-height: 1.5; }
.notice.neutral { background: rgba(62,166,255,.08); color: #b8dcff; border-color: rgba(62,166,255,.25); }
.notice.error { background: rgba(255,102,125,.08); color: #ffc0ca; border-color: rgba(255,102,125,.25); }
.notice.success { background: rgba(43,166,64,.08); color: #b8f1c0; border-color: rgba(43,166,64,.25); }

.page-heading { padding: 24px 0 28px; }
.button { border: 0; border-radius: 999px; padding: 11px 17px; cursor: pointer; font-weight: 800; transition: background .18s, transform .18s, opacity .18s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.button.primary { background: #fff; color: #111; }
.button.primary:hover { background: #ddd; }
.button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.button.secondary:hover { background: var(--surface-3); }
.button.danger { background: rgba(255,102,125,.09); color: #ffc0ca; border: 1px solid rgba(255,102,125,.25); }
.button.compact { padding: 8px 12px; font-size: .8rem; }
.library-list { display: grid; gap: 12px; }
.library-item { display: grid; grid-template-columns: 54px minmax(0,1fr) auto; gap: 15px; align-items: center; padding: 14px; border-bottom: 1px solid var(--line); }
.library-icon { width: 48px; height: 48px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-size: 1.25rem; }
.library-copy { min-width: 0; }
.library-copy strong, .library-copy small { display: block; }
.library-copy strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.library-copy small { color: var(--muted); margin-top: 5px; }
.library-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.library-actions a { text-decoration: none; }

.player-drawer { position: fixed; left: calc(var(--sidebar-w) + 18px); right: 18px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 60; min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 16px; background: rgba(24,24,24,.97); box-shadow: var(--shadow); backdrop-filter: blur(18px); transform: translateY(calc(100% + 35px)); opacity: 0; pointer-events: none; transition: transform .24s ease, opacity .24s ease, left .22s ease; }
.player-drawer.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
body.sidebar-collapsed .player-drawer { left: 94px; }
.player-main { display: flex; align-items: center; gap: 13px; min-width: 0; flex: 1; }
.video-frame, .native-video { width: min(300px, 30vw); min-width: 190px; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; flex: 0 0 auto; }
.video-frame iframe, .native-video { width: 100%; height: 100%; border: 0; object-fit: contain; }
.native-audio { width: min(410px, 42vw); }
.now-playing-copy { min-width: 0; }
.now-playing-copy strong, .now-playing-copy small { display: block; }
.now-playing-copy strong { margin: 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-playing-copy small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-actions { display: flex; align-items: center; gap: 8px; }

.modal { width: min(580px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 18px; padding: 0; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(5px); }
.modal form { padding: 22px; }
.small-modal { width: min(490px, calc(100% - 28px)); }
.modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.modal-head h2 { margin: 5px 0 0; }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field > span { color: var(--muted); font-size: .85rem; font-weight: 700; }
.field input, .field select { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: #121212; color: var(--text); padding: 13px; outline: none; }
.field input:focus, .field select:focus { border-color: #3ea6ff; }
.dropzone { display: grid; place-items: center; min-height: 205px; border: 1px dashed #555; border-radius: 14px; background: #121212; cursor: pointer; text-align: center; padding: 24px; }
.dropzone:hover { border-color: #3ea6ff; }
.dropzone input { display: none; }
.dropzone-icon { font-size: 2rem; color: #3ea6ff; }
.dropzone strong { margin: 8px 0 4px; }
.dropzone small { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-note { margin: -4px 0 16px; color: var(--muted); line-height: 1.55; font-size: .88rem; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px; border: 1px solid var(--line); border-radius: 12px; background: #121212; margin-bottom: 18px; }
.segment { border: 0; background: transparent; color: var(--muted); padding: 10px; border-radius: 9px; cursor: pointer; font-weight: 800; }
.segment.active { background: var(--surface-3); color: white; }
.progress-wrap { margin-top: 16px; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .25s; }
.progress-wrap small { display: block; color: var(--muted); margin-top: 7px; }
.toast-region { position: fixed; top: 76px; right: 18px; display: grid; gap: 10px; z-index: 90; }
.toast { max-width: 380px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: #282828; box-shadow: var(--shadow); animation: toastIn .25s ease; }
.toast.error { border-color: rgba(255,102,125,.42); }
.toast.success { border-color: rgba(43,166,64,.42); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 1280px) {
  .video-grid, .loading-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-header { grid-template-columns: 210px minmax(260px, 1fr) 190px; }
  .service-pill small { display: none; }
}
@media (max-width: 950px) {
  :root { --sidebar-w: 76px; }
  .sidebar { width: 76px; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; height: 64px; padding: 6px; }
  .nav-item strong, .sidebar-note { display: none; }
  .app-header { grid-template-columns: auto minmax(180px, 1fr) auto; gap: 10px; }
  .brand-name, .brand small, .service-pill { display: none; }
  .main-content { margin-left: 76px; padding-inline: 18px; }
  .player-drawer { left: 90px; }
  .video-grid, .loading-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  body { padding-bottom: 220px; }
  .app-header { height: auto; min-height: 64px; grid-template-columns: auto 1fr auto; padding: 9px 10px; }
  .header-left { gap: 5px; }
  .header-search { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .header-actions .button { display: none !important; }
  .sidebar { top: auto; bottom: 0; width: 100%; height: 64px; padding: 4px 8px max(4px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); overflow: hidden; z-index: 70; }
  .sidebar nav { grid-template-columns: repeat(4, 1fr); }
  .nav-item { height: 54px; grid-template-columns: 1fr; gap: 0; justify-items: center; font-size: .85rem; }
  .nav-item strong { display: block; font-size: .65rem; }
  .nav-item span { font-size: 1.05rem; }
  .menu-button { display: none; }
  .main-content, body.sidebar-collapsed .main-content { margin-left: 0; padding: 122px 10px 60px; }
  .topic-chips { top: 112px; padding-top: 8px; }
  .section-heading, .page-heading { align-items: stretch; flex-direction: column; }
  .video-grid, .loading-grid { grid-template-columns: 1fr; row-gap: 28px; }
  .thumbnail-wrap { border-radius: 10px; }
  .player-drawer, body.sidebar-collapsed .player-drawer { left: 8px; right: 8px; bottom: calc(72px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; max-height: 74vh; overflow-y: auto; }
  .player-main { width: 100%; flex-wrap: wrap; align-items: flex-start; }
  .video-frame, .native-video { width: 100%; min-width: 0; }
  .native-audio { width: 100%; }
  .player-actions { justify-content: flex-end; flex-wrap: wrap; }
  .now-playing-copy small { white-space: normal; }
  .library-item { grid-template-columns: 48px 1fr; }
  .library-actions { grid-column: 1 / -1; justify-content: stretch; }
  .library-actions .button, .library-actions a { flex: 1; text-align: center; }
  .toast-region { top: 122px; right: 10px; left: 10px; }
  .toast { max-width: none; }
}

.bridge-banner { display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; margin: 4px 0 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #181818; }
.bridge-banner .bridge-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #272727; font-size: 1.1rem; }
.bridge-banner strong, .bridge-banner small { display: block; }
.bridge-banner small { color: var(--muted); margin-top: 2px; }
.bridge-banner.online { border-color: rgba(53, 199, 89, .45); background: rgba(53, 199, 89, .08); }
.bridge-banner.online .bridge-icon { background: rgba(53, 199, 89, .18); }
.bridge-banner.offline { border-color: rgba(255, 82, 82, .38); }

@media (max-width: 680px) { .bridge-banner { grid-template-columns: 38px 1fr; } .bridge-banner .button { grid-column: 1 / -1; width: 100%; } }
