  :root {
    color-scheme: light dark;
    --bg: #f7f8fa;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #667085;
    --line: #dde3ea;
    --accent: #1677c7;
    --accent-soft: #e8f3fc;
    --header: #fbfcfd;
    --danger: #b42318;
    --danger-soft: #fcebea;
    --control: #f1f4f8;
    --shadow: 0 18px 48px rgba(28, 39, 49, .10);
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #111418;
      --panel: #191e24;
      --text: #eef2f6;
      --muted: #a8b2bf;
      --line: #2c3440;
      --accent: #67b7f7;
      --accent-soft: #183447;
      --header: #20262e;
      --danger: #ffb4ab;
      --danger-soft: #3a2426;
      --control: #222a33;
      --shadow: 0 18px 48px rgba(0, 0, 0, .30);
    }
  }

  * { box-sizing: border-box; }
  body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }
  a { color: inherit; text-decoration: none; }
  button, input, select { font: inherit; }
  .shell {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 30px 0 42px;
  }
  .topbar {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    align-items: end;
    gap: 18px;
    margin-bottom: 14px;
  }
  .title { min-width: 0; }
  .topline { min-width: 0; }
  h1 {
    margin: 0;
    font-size: clamp(24px, 4vw, 36px);
    line-height: 1.1;
    font-weight: 750;
  }
  .subtitle { margin: 7px 0 0; color: var(--muted); }
  .actions {
    display: grid;
    grid-template-columns: 132px 118px minmax(170px, 240px) auto auto;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    box-shadow: var(--shadow);
  }
  .menu-toggle {
    display: none !important;
  }
.field, .search, .button, select {
  width: auto;
  min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--control);
    color: var(--text);
    padding: 10px 13px;
  outline: none;
}
.search {
  width: 100%;
}
.field:focus, .search:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
  }
  .button:hover {
    transform: translateY(-1px);
  }
  .logout-form {
    display: flex;
    margin: 0;
  }
  .logout-form .button {
    width: 100%;
    height: 44px;
    line-height: 1;
    white-space: nowrap;
  }
  .button.icon {
    min-width: 44px;
    padding-inline: 12px;
  }
  .button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
  }
  .button.danger {
    border-color: var(--danger-soft);
    color: var(--danger);
  }
  .add-menu {
    position: relative;
  }
  .add-options {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 10;
    display: none;
    min-width: 156px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
  }
  .add-options.open {
    display: grid;
    gap: 4px;
  }
  .menu-item {
    min-height: 38px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    padding: 8px 10px;
    text-align: left;
  }
  .menu-item:hover {
    background: var(--control);
  }
  .toolbar-label {
    display: none;
  }
  .login-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
      linear-gradient(180deg, transparent 0, var(--bg) 72%),
      radial-gradient(circle at 50% 0, var(--accent-soft), transparent 42%);
  }
  .login-panel {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: var(--shadow);
  }
  .login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
  }
  .login-icon {
    display: grid;
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .login-title h1 {
    font-size: 26px;
  }
  .login-title .subtitle {
    margin-top: 5px;
  }
  .login-panel .field {
    width: 100%;
    margin: 0 0 12px;
    background: var(--control);
  }
  .login-panel .button {
    width: 100%;
    margin-top: 4px;
  }
  .login-footnote {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
  }
  .crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 14px;
  }
.crumbs button {
  padding: 4px 8px;
  border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
  color: inherit;
  cursor: pointer;
}
.crumbs a {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: inherit;
}
  .panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: var(--shadow);
  }
  .dropzone {
    display: grid;
    place-items: center;
    min-height: 72px;
    margin-bottom: 14px;
    border: 1px dashed var(--line);
    border-radius: 18px;
    background: var(--control);
    color: var(--muted);
    text-align: center;
    transition: border-color .15s ease, background .15s ease;
  }
.dropzone.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.upload-progress {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.upload-progress.hidden {
  display: none;
}
.upload-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 650;
}
.upload-progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--control);
}
.upload-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .18s ease;
}
.upload-progress-bar.indeterminate {
  animation: upload-pulse 1.2s ease-in-out infinite;
}
.upload-progress-detail {
  color: var(--muted);
  font-size: 13px;
}
@keyframes upload-pulse {
  0% { opacity: .35; }
  50% { opacity: 1; }
  100% { opacity: .35; }
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
}
.pagination.hidden {
  display: none;
}
.page-status {
  color: var(--muted);
  font-size: 14px;
}
.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}
.page-input {
  width: 76px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control);
  color: var(--text);
  padding: 8px 10px;
  text-align: center;
  outline: none;
}
.page-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.page-button:disabled {
  cursor: not-allowed;
  opacity: .48;
  transform: none;
}
.pagination select {
  min-width: 86px;
}
.row {
  display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 180px 148px;
    gap: 18px;
    align-items: center;
    min-height: 58px;
    padding: 10px 16px;
    border-top: 1px solid var(--line);
    width: 100%;
    color: inherit;
    background: transparent;
    text-align: left;
    transition: background .12s ease;
  }
  .row:hover { background: var(--header); }
  .row:first-child { border-top: 0; }
  .row.header {
    min-height: 44px;
    background: var(--header);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  button.row { border-left: 0; border-right: 0; border-bottom: 0; cursor: pointer; }
  .row.file { border-left: 0; border-right: 0; border-bottom: 0; }
  .row-action {
    display: inline-grid;
    justify-self: end;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    place-items: center;
    border-radius: 7px;
    font-size: 18px;
    line-height: 1;
    text-decoration: none;
  }
  .row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
  }
  .name {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
    font-weight: 650;
  }
  .icon {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
  }
  .filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .meta {
    color: var(--muted);
    font-size: 14px;
    text-align: right;
    white-space: nowrap;
  }
  .empty, .error {
    padding: 38px 16px;
    color: var(--muted);
    text-align: center;
  }
.error { color: var(--danger); }
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 14px;
}
.footer a {
  color: var(--accent);
  font-weight: 700;
}
.footer a:hover {
  text-decoration: underline;
}
  .player-modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(6, 10, 15, .72);
  }
  .player-modal.open {
    display: flex;
  }
  .player-modal.headless .player-head,
  .player-modal.headless .player-status,
  .player-modal.headless .player-controls {
    display: none;
  }
  .player-panel {
    width: min(980px, 100%);
    max-height: min(720px, calc(100vh - 36px));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
  }
  .player-modal.headless .player-panel {
    border-color: transparent;
    background: #05070a;
    box-shadow: none;
  }
  .player-close-overlay {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    z-index: 31;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 999px;
    background: rgba(5, 7, 10, .78);
    color: #fff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
    font-size: 24px;
    line-height: 1;
  }
  .player-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
  }
  .player-title {
    overflow: hidden;
    color: var(--text);
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .player-tools {
    display: flex;
    gap: 8px;
  }
  .player-stage {
    display: grid;
    min-height: 280px;
    place-items: center;
    background: #05070a;
  }
  .player-modal.headless .player-stage {
    min-height: 0;
  }
  .player-canvas {
    width: 100%;
    min-height: min(56vw, 540px);
    background: #05070a;
  }
  .native-video {
    display: block;
    width: 100%;
    max-height: min(58vh, 540px);
    background: #05070a;
  }
  .native-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 36px);
    object-fit: contain;
    background: #05070a;
  }
  .player-modal.headless .native-video {
    max-height: calc(100vh - 36px);
  }
  .player-status {
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
  }
  .player-controls {
    display: grid;
    grid-template-columns: 38px 72px minmax(0, 1fr) 72px 92px;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 13px;
  }
  .player-controls.hidden {
    display: none;
  }
  .player-seek {
    width: 100%;
    accent-color: var(--accent);
  }
.player-time-end {
  text-align: right;
}
.player-toggle {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  place-items: center;
  font-size: 14px;
}
.public-shell .topbar {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 340px);
}
.public-shell .actions {
  grid-template-columns: 132px minmax(170px, 1fr);
  justify-content: stretch;
}
.public-shell .row {
  grid-template-columns: minmax(0, 1fr) 120px 180px;
}
.public-shell .icon {
  font-size: 18px;
}
  @media (max-width: 720px) {
    .player-controls {
      grid-template-columns: 38px 58px minmax(0, 1fr) 58px;
    }
    .player-controls #playerVolume {
      grid-column: 1 / -1;
    }
    .shell {
      width: min(100% - 24px, 1080px);
      padding-top: 18px;
      padding-bottom: 26px;
    }
    .topbar {
      display: grid;
      grid-template-columns: 1fr;
      align-items: stretch;
      gap: 14px;
    }
    .topline {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }
    .menu-toggle {
      display: inline-flex !important;
      width: 44px;
      height: 44px;
      flex: 0 0 auto;
      padding: 0;
    }
      .actions {
        display: none;
        grid-template-columns: 1fr 1fr;
      justify-content: stretch;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 18px;
      background: var(--panel);
      box-shadow: var(--shadow);
    }
      .actions.open {
        display: grid;
      }
      .public-shell .actions {
        grid-template-columns: 1fr;
      }
    .actions .field,
    .actions select,
    .actions .button,
    .actions .add-menu,
    .actions .logout-form {
      width: 100%;
      min-width: 0;
    }
    .actions .search-wrap {
      grid-column: 1 / -1;
    }
    .actions .upload-button {
      grid-column: span 1;
    }
    .add-options {
      left: 0;
      right: auto;
      width: 100%;
    }
    .dropzone {
      display: none;
    }
    .pagination {
      justify-content: stretch;
    }
    .pagination .button,
    .pagination select {
      flex: 1 1 auto;
    }
    .page-jump {
      flex: 1 0 100%;
      justify-content: center;
    }
    .page-status {
      flex: 1 0 100%;
      text-align: center;
    }
      .row { grid-template-columns: minmax(0, 1fr) 82px 74px; gap: 10px; padding: 10px 12px; }
      .public-shell .row { grid-template-columns: minmax(0, 1fr) 82px; }
      .row.header .meta:nth-child(3), .row .meta:nth-child(3) { display: none; }
      .public-shell .row.header .meta:last-child,
      .public-shell .row .meta:last-child { display: none; }
    .icon { width: 32px; height: 32px; font-size: 12px; }
    .filename { direction: rtl; font-size: 13px; text-align: left; }
    .player-modal { padding: 10px; }
    .player-panel { max-height: calc(100vh - 20px); }
    .player-canvas { min-height: 56vw; }
  }
  @media (max-width: 420px) {
    body { font-size: 14px; }
    .shell { width: min(100% - 16px, 1080px); }
    .subtitle { font-size: 13px; }
    .crumbs { gap: 5px; font-size: 13px; }
      .crumbs button {
        max-width: 160px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .crumbs a {
        max-width: 160px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .row { grid-template-columns: minmax(0, 1fr) 74px; min-height: 56px; }
      .public-shell .row { grid-template-columns: minmax(0, 1fr) 64px; }
    .row.header, .row .meta { display: none; }
    .filename { font-size: 12px; }
    .row-action { width: 32px; height: 32px; min-height: 32px; font-size: 17px; }
    .actions { grid-template-columns: 1fr; }
    .actions .upload-button {
      grid-column: auto;
    }
  }
