:root {
  --ui-card-min: 260px;
}

main {
  width: min(1560px, 100%);
  padding: 10px clamp(10px, 2.4vw, 34px) 52px;
}

.filter-toolbar {
  top: 54px;
  gap: 8px;
  margin-bottom: 10px;
  padding: 7px;
}

#toggle-filters {
  min-height: 36px;
  padding: 7px 11px;
  border-radius: 8px;
}

.layout-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 2px;
  align-items: center;
  padding: 3px;
  border: 1px solid rgba(216, 224, 234, 0.92);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}

.layout-toggle button {
  min-height: 30px;
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #536174;
  font-size: 12px;
  font-weight: 850;
}

.layout-toggle button[aria-pressed="true"] {
  background: #172033;
  color: #ffffff;
}

.active-filter-chips {
  gap: 6px;
}

.filter-chip {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 12px;
}

button.filter-chip {
  border: 1px solid rgba(15, 118, 110, 0.28);
  background: #ddf7ef;
  color: #075f59;
  cursor: pointer;
}

.controls {
  display: none !important;
  margin-bottom: 12px;
}

.controls.is-open {
  display: block !important;
}

.source-chip-bar {
  top: 104px;
  margin-bottom: 9px;
}

.cards {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--ui-card-min)), 1fr));
  gap: 12px;
  align-items: start;
}

body[data-layout-mode="two"] .cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body[data-layout-mode="three"] .cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.video-card {
  grid-template-columns: minmax(0, 1fr);
  border-radius: 10px;
  box-shadow: 0 8px 18px rgba(26, 36, 54, 0.06);
}

.thumbnail {
  min-height: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(23, 32, 51, 0.08)),
    #e2e8f0;
}

.thumbnail img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  transition: transform 180ms ease;
}

.video-card:hover .thumbnail img {
  transform: scale(1.025);
}

.thumbnail-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.thumbnail-placeholder[hidden] {
  display: none !important;
}

.thumbnail.is-thumbnail-broken {
  background:
    linear-gradient(135deg, rgba(210, 75, 75, 0.1), rgba(15, 118, 110, 0.1)),
    #eef2f7;
}

.card-body {
  gap: 6px;
  padding: 10px;
}

.rank-line {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  min-width: 0;
  font-size: 11px;
}

.rank-line strong {
  font-size: 16px;
}

body[data-source-group="live"] .rank-line strong,
body[data-source-group="live"] .rank-line .original-rank {
  display: none;
}

.keyword-pill,
.status-pill,
.badge {
  min-height: 22px;
  padding: 2px 7px;
  font-size: 11px;
}

.video-card h3 {
  min-height: 3.75em;
  max-height: 3.75em;
  font-size: 14px;
  line-height: 1.25;
  line-break: strict;
  overflow-wrap: break-word;
  text-wrap: pretty;
  word-break: keep-all;
  -webkit-line-clamp: 3;
}

.video-card h3 a {
  line-break: strict;
  overflow-wrap: break-word;
  text-wrap: inherit;
  word-break: inherit;
}

.rank-metric {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  min-width: 0;
  max-width: 118px;
  min-height: 22px;
  margin-left: auto;
  padding: 2px 7px;
  overflow: hidden;
  border: 1px solid rgba(210, 75, 75, 0.16);
  border-radius: 999px;
  background: #fff1ed;
  color: #9f2f2f;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-metric.metric-live {
  background: #fee2e2;
  color: #b91c1c;
}

.rank-metric.metric-duration {
  border-color: rgba(15, 118, 110, 0.16);
  background: #e6f6f2;
  color: #0b5f59;
}

.rank-metric.metric-subscriber {
  border-color: rgba(62, 91, 160, 0.18);
  background: #eef4ff;
  color: #254479;
}

.rank-metric.metric-like {
  border-color: rgba(190, 118, 26, 0.18);
  background: #fff6dc;
  color: #8a5312;
}

.channel,
.id-line,
.meta-list {
  font-size: 12px;
}

.channel-metric-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.channel-metric-row.has-avatar {
  grid-template-columns: 24px minmax(0, 1fr);
}

.channel-metric-row .channel {
  margin: 0;
}

.channel-avatar {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(216, 224, 234, 0.95);
  border-radius: 999px;
  background: #edf3f7;
  color: #405164;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
}

.channel-avatar[hidden] {
  display: none !important;
}

.channel-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.status-pill.video {
  display: none !important;
}

.video-card:not(.has-rank-metric) .status-pill:not(.video) {
  margin-left: auto;
}

.status-pill.live {
  gap: 4px;
  padding-inline: 6px;
  background: #fee2e2;
  color: #b91c1c;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-pill.live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}

.meta-list {
  gap: 5px;
}

.meta-list span {
  padding: 2px 6px;
}

.meta-list span.is-promoted-metric {
  display: none !important;
}

.id-line {
  font-size: 11px;
}

@media (min-width: 761px) {
  body[data-layout-mode="auto"] .cards {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--ui-card-min)), 1fr));
  }
}

@media (max-width: 760px) {
  main {
    padding: 6px 8px 40px;
  }

  .site-header {
    padding: 7px 8px;
  }

  .filter-toolbar {
    top: 7px;
    gap: 6px;
    margin-inline: 0;
    padding: 6px;
  }

  #toggle-filters {
    min-height: 34px;
    padding-inline: 9px;
  }

  .layout-toggle button {
    min-height: 28px;
    padding-inline: 7px;
  }

  .active-filter-chips {
    min-width: 110px;
  }

  .filter-chip {
    max-width: 58vw;
    min-height: 28px;
  }

  .source-chip-bar {
    top: 58px;
    margin-inline: 0;
  }

  .cards,
  body[data-layout-mode="auto"] .cards,
  body[data-layout-mode="two"] .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body[data-layout-mode="three"] .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .card-body {
    padding: 8px;
  }

  .rank-line {
    gap: 4px;
  }

  .rank-line strong {
    font-size: 15px;
  }

  .rank-line > span:first-of-type {
    display: none;
  }

  .rank-metric {
    max-width: 78px;
    min-height: 20px;
    padding: 1px 6px;
    font-size: 10px;
  }

  .keyword-pill,
  .status-pill {
    min-height: 20px;
    padding: 1px 6px;
    font-size: 10px;
  }

  .video-card h3 {
    display: -webkit-box;
    min-height: 3.66em;
    max-height: 3.66em;
    font-size: 12px;
    line-height: 1.22;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .video-card h3 a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .channel {
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .channel-metric-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  .channel-metric-row.has-avatar {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .channel-avatar {
    width: 22px;
    height: 22px;
    font-size: 10px;
  }

  .id-line {
    display: none;
  }

  .meta-list {
    display: none;
  }

  .meta-list span {
    display: none;
    min-width: 0;
    padding: 1px 5px;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.45;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .meta-list span.metric-view,
  .meta-list span.metric-live,
  .meta-list span.metric-duration {
    display: inline-flex;
    align-items: center;
  }

  .meta-list span.metric-view,
  .meta-list span.metric-live {
    flex: 1 1 auto;
    border: 1px solid rgba(210, 75, 75, 0.16);
    background: #fff1ed;
    color: #9f2f2f;
    font-weight: 850;
  }

  .meta-list span.metric-duration {
    flex: 0 0 auto;
    border: 1px solid rgba(15, 118, 110, 0.16);
    background: #e6f6f2;
    color: #0b5f59;
    font-weight: 800;
  }

  .video-card.has-primary-metric .meta-list span.metric-duration {
    display: none;
  }

  body[data-layout-mode="three"] .card-body {
    gap: 5px;
    padding: 6px;
  }

  body[data-layout-mode="three"] .channel-metric-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  body[data-layout-mode="three"] .channel-metric-row.has-avatar {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  body[data-layout-mode="three"] .channel-avatar {
    width: 20px;
    height: 20px;
    font-size: 9px;
  }

  body[data-layout-mode="three"] .video-card h3 {
    min-height: 3.45em;
    max-height: 3.45em;
    font-size: 11px;
    line-height: 1.15;
  }

  body[data-layout-mode="three"] .channel {
    display: block;
    font-size: 10px;
    line-height: 1.2;
  }

  body[data-layout-mode="three"] .meta-list {
    display: none;
  }

  body[data-layout-mode="three"] .keyword-pill {
    display: none;
  }

  body[data-source-group="live"][data-layout-mode="three"] .keyword-pill {
    display: inline-flex;
  }
}

@media (max-width: 420px) {
  .layout-toggle button {
    padding-inline: 6px;
  }

  .filter-chip.sort {
    display: none;
  }
}
