:root {
  color-scheme: light;
  --bg: #f7f5f0;
  --panel: #ffffff;
  --panel-soft: #fff9ec;
  --ink: #191714;
  --muted: #6d675e;
  --line: #ded7ca;
  --accent: #d71920;
  --accent-dark: #a70d14;
  --teal: #0f766e;
  --amber: #b7791f;
  --shadow: 0 18px 40px rgba(31, 25, 15, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(215, 25, 32, 0.08), transparent 240px),
    var(--bg);
}

button,
select {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 48px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid rgba(222, 215, 202, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.region-form {
  display: grid;
  grid-template-columns: minmax(190px, 320px) 44px;
  align-items: end;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.field select {
  width: 100%;
  height: 44px;
  padding: 0 42px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  background: var(--panel);
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(215, 25, 32, 0.45);
  color: var(--accent-dark);
}

.icon-button:disabled,
.field select:disabled {
  cursor: wait;
  opacity: 0.62;
}

.summary {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 42px 0 24px;
}

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

h1 {
  max-width: 820px;
  margin: 0;
  font-size: 4.3rem;
  line-height: 0.95;
  letter-spacing: 0;
}

.summary-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 220px;
}

.summary-stats span {
  min-height: 32px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.86rem;
  white-space: nowrap;
}

.status-panel {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid rgba(183, 121, 31, 0.28);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  background: var(--panel-soft);
}

.status-panel strong {
  display: block;
  margin-bottom: 4px;
}

.status-panel p {
  margin: 0;
  color: var(--muted);
}

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

.video-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(222, 215, 202, 0.95);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(31, 25, 15, 0.07);
}

.video-card:hover {
  transform: translateY(-2px);
  transition: transform 160ms ease;
}

.rank {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  min-width: 38px;
  height: 32px;
  padding: 4px 8px;
  border-radius: 8px;
  color: #fff;
  background: rgba(25, 23, 20, 0.86);
  font-weight: 900;
  text-align: center;
}

.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #191714;
}

.thumb-button {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  color: #fff;
  background: #191714;
  cursor: pointer;
}

.thumb-button img,
.thumb-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
}

.play-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 999px;
  color: #fff;
  background: rgba(215, 25, 32, 0.9);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  transform: translate(-50%, -50%);
}

.thumb-button:hover .play-mark {
  background: var(--accent-dark);
}

.video-copy {
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 14px;
}

.video-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.3;
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

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

.channel {
  overflow: hidden;
  color: var(--teal);
  font-size: 0.92rem;
  font-weight: 700;
  text-overflow: ellipsis;
  text-decoration: none;
  white-space: nowrap;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.metrics span {
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f2eee6;
}

.skeleton {
  min-height: 308px;
  border: 1px solid rgba(222, 215, 202, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent),
    #ece5d8;
  background-size: 220px 100%, 100% 100%;
  animation: shimmer 1.1s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: 420px 0, 0 0;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar,
  .summary {
    align-items: stretch;
    flex-direction: column;
  }

  .region-form {
    grid-template-columns: 1fr 44px;
  }

  .summary {
    padding-top: 30px;
  }

  h1 {
    font-size: 2.35rem;
    line-height: 1;
  }

  .summary-stats {
    justify-content: flex-start;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
