:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --good:           #006300;
  --bad:            #d03b3b;

  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green */
  --series-7: #4a3aa7; /* violet */
  --series-8: #e34948; /* red */
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
    --good:           #0ca30c;
    --bad:            #e66767;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page:           #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);
  --good:           #0ca30c;
  --bad:            #e66767;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.app-header {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 16px 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.app-header h1 { margin: 0 0 4px; font-size: 22px; }
.muted { color: var(--text-secondary); margin: 4px 0; }
.small { font-size: 13px; }
.hidden { display: none !important; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.card h2 { margin: 0 0 6px; font-size: 16px; }
.card h3 { margin: 16px 0 6px; font-size: 14px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-head h2 { margin: 0; }

.card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 700px) {
  .card-row { grid-template-columns: 1fr; }
}

details.card > summary {
  cursor: pointer;
  list-style: none;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { display: inline-flex; align-items: center; gap: 8px; }
details.card > summary h2::before {
  content: "▸";
  display: inline-block;
  font-size: 12px;
  color: var(--text-muted);
  transition: transform .15s;
}
details.card[open] > summary h2::before { transform: rotate(90deg); }
details.card > summary + * { margin-top: 6px; }

.notice { border-color: var(--series-4); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat-tile .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stat-tile .stat-value {
  font-size: 26px;
  font-weight: 600;
  margin-top: 4px;
  font-variant-numeric: proportional-nums;
}
.stat-tile .stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--series-1);
  color: #fff;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--text-primary); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: var(--bad); }
.btn.active { outline: 2px solid var(--series-1); outline-offset: 1px; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.drop-zone {
  border: 2px dashed var(--baseline);
  border-radius: 10px;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-secondary);
  cursor: pointer;
  margin-top: 8px;
}
.drop-zone:focus, .drop-zone.drag {
  outline: none;
  border-color: var(--series-1);
  color: var(--text-primary);
}

.progress { margin-top: 12px; }
.progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--gridline);
  overflow: hidden;
}
.progress-fill { height: 100%; width: 0%; background: var(--series-1); transition: width .2s; }

input[type="text"] {
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 14px;
  flex: 1;
  min-width: 160px;
}
.search-input { max-width: 220px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field span { font-size: 13px; color: var(--text-secondary); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-scroll { overflow-x: auto; margin-top: 8px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--gridline); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.video-title { white-space: normal; max-width: 320px; }
td.needs-review { box-shadow: inset 3px 0 0 var(--series-4); }

select.lang-select {
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 13px;
}

.channel-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.channel-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--gridline); }
.channel-row:last-child { border-bottom: none; }
.channel-name { font-size: 13.5px; }
.channel-count { color: var(--text-muted); font-size: 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 13px; }
.legend-item {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 2px 0; margin: 0;
  color: var(--text-primary); font: inherit; cursor: pointer;
}
.legend-item--off { color: var(--text-muted); text-decoration: line-through; }
.legend-item--off .legend-swatch { opacity: .35; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 10;
}
.modal-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; width: 100%; max-width: 480px;
}
hr { border: none; border-top: 1px solid var(--gridline); margin: 14px 0; }

@media (max-width: 480px) {
  .app-header { flex-direction: column; }
}
