:root {
  color-scheme: dark;
  --bg: #080b12;
  --panel: #111823;
  --panel-2: #162131;
  --ink: #f4f7fb;
  --muted: #a6b3c4;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --teal: #36d4c6;
  --cyan: #72b8ff;
  --hot: #ff5a66;
  --gold: #f6c65b;
  --green: #5ee1a2;
  --shadow: rgba(0, 0, 0, 0.36);
}

:root[data-display-mode="contrast"] {
  --bg: #000;
  --panel: #050505;
  --panel-2: #101010;
  --ink: #fff;
  --muted: #e6e6e6;
  --line: rgba(255, 255, 255, 0.4);
  --line-strong: rgba(255, 255, 255, 0.68);
  --teal: #00ffff;
  --cyan: #8ecbff;
  --hot: #ffdd00;
  --gold: #fff;
  --green: #00ffff;
  --shadow: rgba(0, 0, 0, 0.72);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(8, 11, 18, 1) 430px),
    var(--bg);
  color: var(--ink);
  font-family: "Meiryo", sans-serif;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  width: min(1540px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 18px;
}

.header-side {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.brand-block {
  display: grid;
  gap: 8px;
}

.eyebrow {
  width: fit-content;
  margin: 0;
  padding: 7px 10px;
  border: 1px solid rgba(54, 212, 198, 0.28);
  border-radius: 999px;
  background: rgba(54, 212, 198, 0.1);
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(1.75rem, 2.7vw, 2.7rem);
  line-height: 1.16;
  font-weight: 800;
}

.lead {
  max-width: 760px;
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.6;
}

.disclaimer {
  max-width: 640px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.7;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 8px;
  margin: 0;
}

.display-label {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr);
  gap: 8px;
  align-items: center;
  width: min(380px, 100%);
}

.display-label select {
  min-height: 34px;
}

.stats div,
.view-tabs,
.control-panel,
.category-tabs,
.summary,
.clip-card {
  border: 1px solid var(--line);
  background: rgba(17, 24, 35, 0.86);
  box-shadow: 0 18px 40px var(--shadow);
  backdrop-filter: blur(18px);
}

.stats div {
  padding: 11px 13px;
  border-radius: 8px;
}

dt {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
}

dd {
  margin: 0;
}

.stats dd {
  margin-top: 4px;
  color: #fff;
  font-size: 1.02rem;
  font-weight: 900;
}

main {
  width: min(1540px, calc(100% - 36px));
  margin: 0 auto 48px;
}

.view-tabs,
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 8px;
}

.tab-button,
.category-tab {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0 12px;
  cursor: pointer;
}

.tab-button.is-active,
.category-tab.is-active {
  border-color: rgba(54, 212, 198, 0.54);
  background: rgba(54, 212, 198, 0.12);
  color: var(--teal);
}

.control-panel {
  position: sticky;
  z-index: 4;
  top: 0;
  display: grid;
  grid-template-columns: 1.15fr 0.75fr 0.75fr 1.1fr auto;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

select,
input[type="search"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #0c111b;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 0 12px;
  outline: none;
}

input[type="search"]::placeholder {
  color: rgba(166, 179, 196, 0.62);
}

select:focus,
input[type="search"]:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(54, 212, 198, 0.16);
}

.toggle-label {
  align-self: end;
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #0c111b;
  cursor: pointer;
}

.toggle-label input {
  accent-color: var(--teal);
}

.summary {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.94rem;
}

.clip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.clip-card {
  overflow: hidden;
  border-radius: 8px;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.clip-card:hover {
  transform: translateY(-3px);
  border-color: rgba(114, 184, 255, 0.38);
  box-shadow: 0 24px 58px rgba(0, 0, 0, 0.48);
}

.clip-card.is-surging {
  border-color: rgba(255, 90, 102, 0.48);
}

.media-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #05070b;
}

.thumb-button,
.player-slot,
.player-slot iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.thumb-button {
  display: block;
  padding: 0;
  border: 0;
  background: #05070b;
  cursor: pointer;
}

.thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 220ms ease;
}

.thumb-button:hover .thumb {
  transform: scale(1.04);
}

.player-slot iframe {
  border: 0;
  background: #05070b;
}

.clip-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.clip-meta,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category {
  min-width: 0;
  overflow: hidden;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.created,
.broadcaster {
  color: var(--muted);
  font-size: 0.82rem;
}

.title {
  display: -webkit-box;
  min-height: 2.9em;
  margin: 0;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.status-badge {
  width: fit-content;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.status-surge {
  border-color: rgba(255, 90, 102, 0.46);
  background: rgba(255, 90, 102, 0.12);
  color: #ffbdc3;
}

.status-new {
  border-color: rgba(114, 184, 255, 0.42);
  background: rgba(114, 184, 255, 0.12);
  color: #cae4ff;
}

.status-growth {
  border-color: rgba(94, 225, 162, 0.42);
  background: rgba(94, 225, 162, 0.1);
  color: #b6f5d4;
}

.status-normal {
  background: rgba(255, 255, 255, 0.04);
}

:root[data-display-mode="contrast"] body {
  background: #000;
}

:root[data-display-mode="contrast"] .stats div,
:root[data-display-mode="contrast"] .view-tabs,
:root[data-display-mode="contrast"] .control-panel,
:root[data-display-mode="contrast"] .category-tabs,
:root[data-display-mode="contrast"] .summary,
:root[data-display-mode="contrast"] .clip-card {
  border-color: #ffdd00;
  background: #050505;
  box-shadow: none;
  backdrop-filter: none;
}

:root[data-display-mode="contrast"] select,
:root[data-display-mode="contrast"] input[type="search"],
:root[data-display-mode="contrast"] .toggle-label {
  border-color: #fff;
  background: #000;
  color: #fff;
}

:root[data-display-mode="contrast"] input[type="search"]::placeholder {
  color: #cfcfcf;
  opacity: 1;
}

:root[data-display-mode="contrast"] select:focus,
:root[data-display-mode="contrast"] input[type="search"]:focus {
  border-color: #ffdd00;
  box-shadow: 0 0 0 3px rgba(255, 221, 0, 0.42);
}

:root[data-display-mode="contrast"] .tab-button,
:root[data-display-mode="contrast"] .category-tab {
  border-color: #fff;
  background: #000;
  color: #fff;
}

:root[data-display-mode="contrast"] .tab-button.is-active,
:root[data-display-mode="contrast"] .category-tab.is-active {
  border-color: #fff;
  background: #00ffff;
  color: #000;
}

:root[data-display-mode="contrast"] .clip-card.is-surging {
  border-color: #ffdd00;
}

:root[data-display-mode="contrast"] .clip-card:hover {
  border-color: #fff;
  box-shadow: 0 0 0 2px #ffdd00;
}

:root[data-display-mode="contrast"] .status-badge {
  border-width: 2px;
}

:root[data-display-mode="contrast"] .status-surge {
  border-color: #fff;
  background: #ffdd00;
  color: #000;
}

:root[data-display-mode="contrast"] .status-new {
  border-color: #fff;
  background: #00ffff;
  color: #000;
}

:root[data-display-mode="contrast"] .status-growth {
  border-color: #ffdd00;
  background: #000;
  color: #ffdd00;
}

:root[data-display-mode="contrast"] .status-normal {
  border-color: #fff;
  background: #000;
  color: #fff;
}

:root[data-display-mode="contrast"] .delta,
:root[data-display-mode="contrast"] .score,
:root[data-display-mode="contrast"] .category {
  color: #ffdd00;
}

:root[data-display-mode="contrast"] .metrics div {
  border-color: #fff;
  background: #101010;
}

:root[data-display-mode="contrast"] .metrics dt,
:root[data-display-mode="contrast"] .created,
:root[data-display-mode="contrast"] .broadcaster,
:root[data-display-mode="contrast"] .summary,
:root[data-display-mode="contrast"] .disclaimer,
:root[data-display-mode="contrast"] .site-footer {
  color: #e6e6e6;
}

:root[data-display-mode="contrast"] .clip-link,
:root[data-display-mode="contrast"] .load-more {
  border-color: #fff;
  background: #000;
  color: #fff;
}

:root[data-display-mode="contrast"] .clip-link:hover,
:root[data-display-mode="contrast"] .load-more:hover {
  background: #ffdd00;
  color: #000;
}

.broadcaster {
  min-height: 1.2em;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 0;
}

.metrics div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
}

.metrics dd {
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 0.96rem;
  font-weight: 950;
}

.delta {
  color: var(--hot);
}

.ratio {
  color: var(--gold);
}

.score {
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 900;
}

.clip-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid rgba(114, 184, 255, 0.42);
  border-radius: 7px;
  color: #d9ecff;
  font-size: 0.84rem;
  font-weight: 900;
  padding: 0 11px;
  text-decoration: none;
}

.clip-link:hover {
  background: rgba(114, 184, 255, 0.12);
}

.empty {
  padding: 42px;
  text-align: center;
  color: var(--muted);
}

.load-more {
  display: block;
  width: min(320px, 100%);
  min-height: 44px;
  margin: 18px auto 0;
  border: 1px solid rgba(54, 212, 198, 0.42);
  border-radius: 8px;
  background: rgba(54, 212, 198, 0.12);
  color: var(--teal);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.load-more:hover {
  background: rgba(54, 212, 198, 0.18);
}

.site-footer {
  display: grid;
  gap: 4px;
  width: min(1540px, calc(100% - 36px));
  margin: -24px auto 36px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.6;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 1280px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .header-side {
    justify-items: stretch;
  }

  .display-label {
    justify-self: end;
  }
}

@media (max-width: 980px) {
  .display-label {
    justify-self: stretch;
  }

  .clip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1280px) and (min-width: 981px) {
  .control-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .clip-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  main,
  .site-footer {
    width: min(100% - 24px, 1540px);
  }

  .topbar {
    padding-top: 18px;
  }

  .stats,
  .control-panel {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

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

  .clip-meta,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }
}
