:root {
  color-scheme: dark;
  --bg: #07090c;
  --surface: #11151b;
  --surface-2: #171d25;
  --text: #f4f6f8;
  --muted: #9aa6b2;
  --accent: #39e6b4;
  --accent-2: #28a9ff;
  --danger: #ff667a;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 78% -20%, #123b42 0, transparent 38rem), var(--bg); }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
button, .button, input { min-height: 48px; border-radius: 12px; }
button, .button { border: 0; padding: .8rem 1.15rem; background: var(--accent); color: #03241c; font-weight: 750; cursor: pointer; }
button:hover, button:focus-visible, .button:hover, .button:focus-visible { filter: brightness(1.1); outline: 3px solid #fff; outline-offset: 3px; }
button:disabled { opacity: .55; cursor: wait; }
input { width: 100%; border: 1px solid #34404d; background: #0d1116; color: var(--text); padding: .8rem 1rem; }
input:focus { outline: 3px solid var(--accent-2); border-color: transparent; }
.topbar { min-height: 76px; display: flex; align-items: center; gap: 1.5rem; padding: 0 clamp(1.25rem, 4vw, 4.5rem); background: rgba(7, 9, 12, .84); border-bottom: 1px solid #222a34; position: sticky; top: 0; z-index: 10; backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: .72rem; font-weight: 820; letter-spacing: -.02em; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: #041215; font-weight: 900; box-shadow: 0 0 24px #39e6b455; }
.topbar nav { display: flex; align-items: center; gap: .4rem; margin-left: auto; }
.nav-link, .text-button { color: var(--muted); background: transparent; padding: .7rem .9rem; font-weight: 650; }
.nav-link[aria-current="page"], .nav-link:hover { color: var(--text); }
.page { width: min(1600px, 100%); margin: 0 auto; padding: clamp(1.5rem, 4vw, 4.5rem); }
.catalog-head { display: flex; justify-content: space-between; align-items: end; gap: 1.5rem; margin: 1rem 0 2rem; }
.eyebrow { color: var(--accent); font-size: .8rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: .25rem 0; font-size: clamp(2rem, 5vw, 4.25rem); line-height: 1; letter-spacing: -.05em; }
.catalog-head p, .muted { color: var(--muted); }
.search-wrap { width: min(28rem, 100%); }
.media-groups { display: grid; gap: clamp(2rem, 4vw, 3.5rem); }
.media-group { min-width: 0; }
.folder-heading { margin: 0 0 1rem; font-size: clamp(1.15rem, 2vw, 1.55rem); letter-spacing: -.02em; }
.folder-heading::before { content: ""; display: inline-block; width: .55rem; height: .55rem; margin-right: .65rem; border-radius: 2px; background: var(--accent); box-shadow: 0 0 12px #39e6b466; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: clamp(1rem, 2vw, 1.8rem); }
.media-card { min-width: 0; cursor: pointer; border-radius: var(--radius); transition: transform .18s ease; }
.media-card:hover, .media-card:focus-visible { transform: translateY(-6px) scale(1.01); outline: none; }
.media-card:focus-visible .poster { box-shadow: 0 0 0 4px #fff, 0 18px 50px #000; }
.poster { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius); background: linear-gradient(155deg, #1c3340, #10151a 55%, #112a27); box-shadow: 0 12px 32px #0008; }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster-mark { position: absolute; inset: 0; display: grid; place-items: center; color: #ffffff12; font-size: 8rem; font-weight: 900; }
.play-badge { position: absolute; left: 1rem; bottom: 1rem; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; padding-left: 3px; background: #f8fffd; color: #08110f; opacity: 0; transform: translateY(8px); transition: .18s ease; }
.media-card:hover .play-badge, .media-card:focus-visible .play-badge { opacity: 1; transform: none; }
.card-progress { position: absolute; height: 5px; left: .8rem; right: .8rem; bottom: .55rem; background: #ffffff30; border-radius: 9px; overflow: hidden; }
.card-progress span { height: 100%; display: block; background: var(--accent); }
.media-card h2 { margin: .85rem 0 .3rem; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card p { margin: 0; color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 5rem 1rem; border: 1px dashed #34404d; border-radius: var(--radius); }
.empty[hidden] { display: none; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(450px, 100%); padding: clamp(1.5rem, 5vw, 3rem); border: 1px solid #26313c; border-radius: 24px; background: #0d1116e8; box-shadow: 0 30px 80px #000b; }
.auth-card .brand { display: flex; margin-bottom: 2.5rem; }
.auth-card h1 { font-size: 2.4rem; }
.auth-card label { display: block; margin: 1.1rem 0 .4rem; color: #d7dde3; font-weight: 650; }
.auth-card button { width: 100%; margin-top: 1.4rem; }
.form-error { min-height: 1.4rem; color: var(--danger); margin-top: .8rem; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 1.25rem; }
.panel { padding: clamp(1.25rem, 3vw, 2rem); background: var(--surface); border: 1px solid #252f3a; border-radius: var(--radius); }
.panel h2 { margin-top: 0; }
.status-line { display: flex; align-items: center; gap: .7rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.server-url { display: block; overflow-wrap: anywhere; color: var(--accent); font-size: clamp(1.1rem, 2vw, 1.5rem); margin: 1rem 0; }
.path-form { display: grid; grid-template-columns: 1fr auto; gap: .7rem; }
.path-list { list-style: none; padding: 0; margin: 1rem 0; }
.path-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-top: 1px solid #28313b; overflow-wrap: anywhere; }
.danger-note { color: #ffcad1; font-size: .9rem; }
.upload-panel { margin-top: 1.25rem; }
.upload-panel label { display: block; margin: 1rem 0 .4rem; font-weight: 650; }
.upload-panel select { width: 100%; min-height: 48px; padding: .7rem 1rem; border: 1px solid #34404d; border-radius: 12px; background: #0d1116; color: var(--text); }
.upload-panel select:focus-visible { outline: 3px solid var(--accent-2); }
.upload-panel form { margin-top: 1rem; }
.upload-panel input[type="file"] { padding: .7rem; }
.upload-panel #upload-submit { margin-top: .8rem; }
.upload-panel progress { width: 100%; height: 1rem; accent-color: var(--accent); }
.upload-panel code { overflow-wrap: anywhere; }
.player-page { min-height: 100vh; background: #000; display: flex; flex-direction: column; }
.player-head { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem; background: #090b0e; position: relative; z-index: 3; }
.back { width: 48px; height: 48px; display: grid; place-items: center; font-size: 1.5rem; border-radius: 50%; }
.player-title { min-width: 0; }
.player-title h1 { font-size: 1.25rem; margin: 0 0 .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-title p { margin: 0; color: var(--muted); font-size: .82rem; }
.player-settings-button { margin-left: auto; background: var(--surface-2); color: var(--text); border: 1px solid #35414e; }
.video-wrap { flex: 1; display: grid; place-items: center; min-height: 0; }
.video-stage { width: 100%; position: relative; display: grid; place-items: center; }
video { display: block; width: 100%; max-height: calc(100vh - 80px); background: #000; }
.tracks-menu { position: absolute; z-index: 5; top: 1rem; right: clamp(1rem, 3vw, 3rem); width: min(440px, calc(100% - 2rem)); max-height: calc(100vh - 120px); overflow-y: auto; padding: 1.25rem; border: 1px solid #3b4856; border-radius: 18px; background: #10151bed; box-shadow: 0 24px 70px #000d; backdrop-filter: blur(20px); }
.tracks-menu[hidden] { display: none; }
.tracks-menu-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.tracks-menu h2 { margin: 0; font-size: 1.35rem; }
.tracks-menu h3 { margin: 1.2rem 0 .55rem; color: var(--muted); font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; }
.icon-button { width: 48px; min-height: 48px; padding: 0; border-radius: 50%; background: #252e38; color: var(--text); font-size: 1.7rem; }
.track-options { display: grid; gap: .45rem; }
.track-option { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; padding: .7rem .9rem; text-align: left; background: #1a222b; color: var(--text); border: 2px solid transparent; }
.track-option small { color: var(--muted); text-align: right; }
.track-option.selected { border-color: var(--accent); background: #17352f; }
.track-option.selected::before { content: "✓"; color: var(--accent); font-weight: 900; }
.track-option.selected span { margin-right: auto; }
.track-option:disabled { opacity: .45; cursor: not-allowed; }
.track-note { margin: 1rem 0 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.toast { position: fixed; z-index: 100; right: 1.5rem; bottom: 1.5rem; max-width: min(420px, calc(100vw - 3rem)); padding: 1rem 1.2rem; border-radius: 12px; background: #202832; box-shadow: 0 15px 40px #000a; transform: translateY(20px); opacity: 0; transition: .2s; }
.toast.show { transform: none; opacity: 1; }
.toast.success { border-left: 4px solid var(--accent); }
.toast.error { border-left: 4px solid var(--danger); }
@media (max-width: 760px) {
  .topbar { padding: 0 1rem; gap: .5rem; }
  .brand span:last-child { display: none; }
  .nav-link, .topbar .text-button { padding: .5rem .35rem; font-size: .8rem; }
  .catalog-head { align-items: stretch; flex-direction: column; }
  .admin-grid { grid-template-columns: 1fr; }
  .path-form { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-head { padding: .7rem; }
  .player-settings-button { font-size: 0; width: 48px; padding: 0; }
  .player-settings-button span { font-size: 1.3rem; }
  .tracks-menu { inset: .5rem; width: auto; max-height: calc(100vh - 1rem); }
}
@media (min-width: 1900px) {
  :root { font-size: 20px; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
