:root {
  color-scheme: light;
  --ink: #15201d;
  --muted: #5f6f68;
  --line: #d7ded9;
  --panel: #f7f8f5;
  --paper: #ffffff;
  --accent: #d8422f;
  --accent-dark: #a92e21;
  --focus: #167267;
  --shadow: 0 18px 55px rgba(21, 32, 29, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef2ed;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 0 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.summary {
  min-width: 210px;
  display: grid;
  justify-items: end;
  gap: 2px;
  color: var(--muted);
}

.summary strong {
  color: var(--ink);
  font-size: clamp(1.6rem, 4vw, 3rem);
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 18px;
  align-items: start;
}

.panel,
.table-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  gap: 10px;
  padding: 18px;
  position: sticky;
  top: 18px;
}

label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
  min-height: 150px;
}

input:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(22, 114, 103, 0.18);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compact {
  margin-top: 2px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  color: var(--ink);
  cursor: pointer;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.secondary,
.icon-button {
  background: #fff;
  color: var(--accent-dark);
}

.secondary:hover,
.icon-button:hover {
  background: #fff4f1;
}

.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.quiet:hover {
  background: #f0f3ef;
  border-color: #f0f3ef;
  color: var(--ink);
}

.wide {
  width: 100%;
}

.status {
  min-height: 21px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status.error {
  color: #9d2419;
}

.table-wrap {
  overflow: hidden;
}

.table-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.tool-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  padding: 8px 34px 8px 10px;
}

.channel-groups {
  display: grid;
}

.channel-group {
  border-bottom: 1px solid var(--line);
}

.channel-toggle {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 12px 16px;
  text-align: left;
}

.channel-toggle:hover {
  background: #f8faf7;
  color: var(--ink);
}

.chevron {
  color: var(--accent-dark);
  font-size: 1.05rem;
  transform: rotate(-90deg);
  transition: transform 0.16s ease;
}

.channel-group.open .chevron {
  transform: rotate(0deg);
}

.channel-name {
  min-width: 0;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-count,
.channel-total {
  color: var(--muted);
  font-weight: 750;
  white-space: nowrap;
}

.channel-total {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.channel-videos {
  display: none;
  background: #fbfcfa;
}

.channel-group.open .channel-videos {
  display: grid;
}

.channel-video-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px 12px 50px;
  border-top: 1px solid var(--line);
}

.channel-video-row a {
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.channel-video-row a:hover {
  color: var(--accent-dark);
}

.channel-video-row span {
  color: var(--muted);
  font-size: 0.84rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

td:nth-child(3),
th:nth-child(3) {
  text-align: right;
}

tr:last-child td {
  border-bottom: 0;
}

.video-title {
  display: grid;
  gap: 4px;
}

.video-title a {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.video-title a:hover {
  color: var(--accent-dark);
}

.video-title span {
  color: var(--muted);
  font-size: 0.86rem;
}

.views {
  font-variant-numeric: tabular-nums;
  font-weight: 850;
}

.delete-button {
  width: 36px;
  min-height: 36px;
  border-color: #e5e9e5;
  background: #fff;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
}

.delete-button:hover {
  background: #fff4f1;
  border-color: #ffc8bd;
  color: var(--accent-dark);
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 70px 16px;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 22px, 680px);
    padding: 18px 0;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .summary {
    justify-items: start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .table-tools {
    justify-content: flex-start;
  }

  .channel-toggle {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .channel-count,
  .channel-total {
    grid-column: 2;
  }

  table {
    min-width: 820px;
  }
}
