:root {
  color-scheme: dark;
  --bg: #090b0d;
  --panel: #14181c;
  --panel2: #1d2329;
  --text: #f3f7fa;
  --muted: #9fb0bd;
  --line: #2b343c;
  --accent: #4db6ac;
  --warn: #ffcc66;
  --bad: #ff7a7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 18px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 10px 18px;
  background: #0f1316;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 22px;
  font-weight: 750;
}

nav {
  display: flex;
  gap: 8px;
}

nav a,
.button,
button,
select,
input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel2);
  color: var(--text);
  font: inherit;
}

nav a,
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  cursor: pointer;
}

button:active,
.button:active,
nav a:active {
  transform: translateY(1px);
}

input,
select {
  padding: 0 14px;
}

input {
  width: 100%;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.narrow {
  width: min(850px, 100%);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 150px 160px 150px 140px;
  gap: 10px;
  margin: 0 0 18px;
}

.folder-tools {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 10px;
  margin: 0 0 18px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 48px;
}

.breadcrumb button {
  min-height: 40px;
  padding: 0 12px;
}

.breadcrumb span {
  color: var(--muted);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 14px 0;
  font-size: 30px;
}

h2 {
  margin: 28px 0 12px;
  font-size: 22px;
}

.video-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 12px;
}

.folder-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.folder-tile {
  display: grid;
  justify-items: start;
  gap: 4px;
  min-height: 78px;
  padding: 12px 14px;
  text-align: left;
  background: #162027;
}

.folder-tile strong {
  overflow-wrap: anywhere;
}

.folder-tile span {
  color: var(--muted);
  font-size: 14px;
}

.folder-tile small {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.folder-tile.missing {
  border-color: var(--bad);
}

.video-list.compact {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.video-item {
  display: grid;
  gap: 10px;
  min-height: 148px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.video-item strong {
  display: block;
  font-size: 19px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.video-item .path {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #22303a;
  color: var(--muted);
  font-size: 14px;
}

.badge.ok {
  color: #c8fff8;
  background: #123d39;
}

.badge.warn {
  color: #ffe4a3;
  background: #3b3217;
}

.muted,
#scanState {
  color: var(--muted);
}

.scan-progress {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scan-progress[hidden] {
  display: none;
}

.progress-bar {
  height: 14px;
  overflow: hidden;
  background: #070909;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.scan-details {
  display: grid;
  gap: 4px;
}

.scan-details span {
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.wide {
  width: 100%;
  margin-top: 14px;
}

.player-body {
  min-height: 100vh;
}

.player-page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.player-page h1 {
  font-size: 26px;
  margin: 10px 0 12px;
  overflow-wrap: anywhere;
}

.player-wrap {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
}

video {
  display: block;
  width: 100%;
  max-height: calc(100vh - 210px);
  aspect-ratio: 16 / 9;
  background: #000;
}

.big-play {
  position: absolute;
  left: 50%;
  top: 50%;
  min-width: 150px;
  min-height: 72px;
  transform: translate(-50%, -50%);
  background: rgba(20, 28, 32, 0.92);
  border-color: var(--accent);
  font-size: 26px;
}

.big-play[hidden] {
  display: none;
}

.player-controls {
  display: grid;
  grid-template-columns: 1fr 120px 170px 190px 160px;
  gap: 10px;
  margin-top: 10px;
}

.player-controls label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 14px;
}

.status {
  min-height: 28px;
  color: var(--warn);
}

.status-grid {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 10px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-grid dt {
  color: var(--muted);
}

.status-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.folder-list,
.job-list {
  padding: 0;
  list-style: none;
}

.folder-list li,
.job {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.job span {
  color: var(--muted);
  font-size: 14px;
}

.job button {
  justify-self: start;
  min-height: 42px;
}

@media (max-width: 720px) {
  body {
    font-size: 17px;
  }

  .topbar {
    min-height: 58px;
    padding: 8px 10px;
  }

  .brand {
    font-size: 19px;
  }

  nav a,
  .button,
  button,
  select,
  input {
    min-height: 52px;
  }

  .page,
  .player-page {
    padding: 10px;
  }

  .controls,
  .folder-tools,
  .player-controls {
    grid-template-columns: 1fr;
  }

  .video-list {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }

  video {
    max-height: 58vh;
  }
}
