:root {
  color-scheme: dark;
  --bg: #0B0D12;
  --surface: #141821;
  --raised: #1C2230;
  --border: #30384B;
  --text: #F4F5FA;
  --muted: #A6AFC2;
  --accent: #A99BFF;
  --success: #78D9AF;
  --danger: #FF969E;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
svg { width: 24px; height: 24px; flex-shrink: 0; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { font-size: 40px; line-height: 1.2; letter-spacing: -1px; margin: 8px 0; }
h2 { font-size: 20px; font-weight: 650; margin: 0 0 16px; }
h3 { font-size: 16px; font-weight: 600; margin: 16px 16px 8px; }
button, input, select { font: inherit; }
button, .button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--raised); color: var(--text); cursor: pointer; }
button, a, input, select { transition: background-color .15s, color .15s, opacity .15s; }
button:hover:not(:disabled), .button:hover { background: var(--border); }
button:disabled { color: var(--muted); background: var(--surface); border-color: var(--border); cursor: not-allowed; }
input, select { min-height: 48px; max-width: 100%; padding: 12px 16px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 12px; }
select { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input::placeholder { color: var(--muted); }
input:focus, select:focus { border-color: var(--accent); }
label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 550; }
button.primary, .primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 650; }
button.primary:hover:not(:disabled) { background: #c4baff; }
button.danger { color: var(--bg); background: var(--danger); border-color: var(--danger); font-weight: 650; }
button.danger:hover:not(:disabled) { background: #ffb9bf; }
button.primary:disabled, button.danger:disabled { color: var(--muted); background: var(--surface); border-color: var(--border); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
#library-heading:focus { outline: none; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.brand { display: inline-flex; gap: 12px; align-items: center; color: var(--text); font-size: 24px; font-weight: 700; letter-spacing: -1px; min-height: 44px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; background: var(--accent); color: var(--bg); border-radius: 12px; }
.site-header { border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 2; }
.header-inner { max-width: 1440px; margin: auto; padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.quiet-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }
.quiet-link:hover { color: var(--text); }
.page { max-width: 1440px; margin: auto; padding: 32px 32px max(48px, env(safe-area-inset-bottom)); }
.skip-link { position: fixed; top: -100px; left: 16px; padding: 12px; background: var(--accent); color: var(--bg); z-index: 10; }
.skip-link:focus { top: 12px; }
.login-page { display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 0%, #25213c 0%, var(--bg) 65%); }
.login-panel { width: 100%; max-width: 420px; padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.login-panel h1 { font-size: 32px; margin: 12px 0 16px; }
.login-panel form { margin-top: 32px; }
.login-panel input, .login-panel button { width: 100%; margin-bottom: 16px; }
.login-panel button { justify-content: space-between; }
.breadcrumbs { display: flex; align-items: center; gap: 12px; overflow-x: auto; white-space: nowrap; max-width: 100%; padding: 4px 4px 12px; color: var(--muted); font-size: 14px; }
.breadcrumbs a, .breadcrumbs [aria-current] { display: inline-flex; min-height: 44px; align-items: center; }
.breadcrumbs [aria-current] { color: var(--text); }
.page-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 24px; margin: 16px 0 32px; }
.page-heading > div:first-child { min-width: 0; flex: 1 1 240px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.toolbar { display: flex; align-items: end; gap: 16px; border-bottom: 1px solid var(--border); padding-bottom: 24px; }
.search-field { flex: 1; }
.search-field input { width: 100%; }
.toolbar select { min-width: 180px; }
#item-count { font-size: 14px; margin: 24px 0; }
.item-section { margin-bottom: 32px; }
.item-section:has(.folder-grid:empty), .item-section:has(.video-grid:empty) { display: none; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 16px; }
.item-card { min-width: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.folder-card { display: flex; align-items: center; gap: 8px; padding: 8px; }
.folder-link { flex: 1; display: flex; gap: 16px; align-items: center; padding: 12px 8px; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.folder-link svg { color: var(--accent); }
.delete-button { color: var(--muted); background: transparent; border-color: transparent; padding: 8px; font-size: 14px; min-width: 44px; flex-shrink: 0; }
.delete-button:hover:not(:disabled) { color: var(--danger); }
.video-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.video-link { color: var(--text); display: block; border-radius: 16px; }
.file-cover { aspect-ratio: 16 / 9; position: relative; display: grid; place-items: center; border-radius: 15px 15px 0 0; background: radial-gradient(ellipse at 80% 0%, #36304f, transparent 75%), linear-gradient(135deg, #202737, #151923); border-bottom: 1px solid var(--border); }
.cover-play { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--raised); color: var(--accent); border: 1px solid var(--border); }
.extension { position: absolute; left: 12px; bottom: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--muted); padding: 4px 8px; font-size: 12px; font-weight: 600; }
.card-footer { display: flex; align-items: end; justify-content: space-between; gap: 4px; padding: 0 8px 8px 16px; }
.metadata { color: var(--muted); font-size: 12px; padding-bottom: 8px; }
.metadata span, .metadata time { display: block; }
.empty-state { text-align: center; padding: 48px 16px; border: 1px dashed var(--border); border-radius: 16px; color: var(--muted); }
.empty-state > svg { width: 40px; height: 40px; color: var(--accent); margin-bottom: 16px; }
.empty-state h2 { color: var(--text); }
.empty-state .actions { justify-content: center; margin-top: 24px; }
.status-area { margin: 24px 0; }
.status-area p:empty { display: none; }
.notice, .compatibility { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--muted); }
#upload-area { margin-top: 48px; border-top: 1px solid var(--border); padding-top: 32px; }
.section-heading { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: 16px; }
.section-heading h2 { margin-bottom: 8px; }
.section-heading p { margin-top: 0; }
#drop-zone { border: 1px dashed var(--border); border-radius: 16px; padding: 24px; background: var(--surface); }
#drop-zone.dragover { border-color: var(--accent); background: var(--raised); }
#video-files { width: 100%; padding: 8px; }
input::file-selector-button { font: inherit; border: 0; border-radius: 8px; background: var(--raised); color: var(--text); min-height: 44px; margin-right: 12px; padding: 8px 12px; cursor: pointer; }
.upload-queue { list-style: none; padding: 0; }
.queue-row { margin: 16px 0; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.queue-row h3 { margin: 0 0 8px; }
.queue-row p { margin: 8px 0; }
.queue-row .destination, .queue-row .transfer { color: var(--muted); font-size: 14px; }
.queue-row[data-state="succeeded"] .queue-status { color: var(--success); }
.queue-row[data-state="failed"] .queue-status, .queue-row[data-state="unknown"] .queue-status { color: var(--danger); }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
.queue-actions { display: flex; flex-wrap: wrap; gap: 8px; }
dialog { width: calc(100% - 32px); max-width: 480px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow-y: auto; padding: 32px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: #000b; }
dialog input { width: 100%; }
.path-label { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 12px; margin-top: 24px; }
.player-page h1 { font-size: 24px; margin: 16px 0 24px; }
.player-stage { background: #000; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; display: grid; place-items: center; }
.player-stage video { display: block; width: 100%; max-height: calc(100vh - 240px); max-height: calc(100dvh - 240px); object-fit: contain; }
.player-feedback { min-height: 48px; padding: 12px 0; color: var(--muted); }
.player-feedback p { margin: 0; }
.player-error { padding: 16px; border: 1px solid var(--danger); border-radius: 12px; }
.player-error h2 { color: var(--danger); }
[hidden] { display: none !important; }
@media (min-width: 640px) and (max-width: 1023px) {
  .header-inner, .page { padding-left: 24px; padding-right: 24px; }
  .video-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
}
@media (max-width: 639px) {
  .header-inner { padding: 12px 16px; }
  .page { padding: 16px 16px max(32px, env(safe-area-inset-bottom)); }
  h1 { font-size: 32px; }
  .page-heading { gap: 16px; margin-bottom: 24px; }
  .page-heading > div:first-child { flex-basis: 100%; }
  .toolbar { flex-wrap: wrap; }
  .search-field { flex-basis: 100%; }
  .toolbar > div:last-child, .toolbar select { width: 100%; }
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .video-card h3 { margin: 12px 12px 8px; }
  .card-footer { padding-left: 12px; flex-wrap: wrap; }
  .login-panel { padding: 24px; }
  .login-page { padding: 16px; }
  dialog { width: 100%; max-width: none; max-height: calc(100dvh - 16px); margin: auto 0 0; border-radius: 16px 16px 0 0; padding: 24px 16px max(24px, env(safe-area-inset-bottom)); }
  .dialog-actions > button { flex: 1; }
  #drop-zone { padding: 16px; }
  .player-page h1 { font-size: 20px; }
}
@media (max-width: 399px) { .video-grid { grid-template-columns: minmax(0, 1fr); } }
@media (orientation: landscape) and (max-height: 540px) {
  .player-page { padding-top: 8px; }
  .player-page h1 { margin: 8px 0; font-size: 18px; }
  .player-page .player-stage video { max-height: 75vh; max-height: 75dvh; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
