:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.9);
  --surface-soft: rgba(255, 255, 255, 0.5);
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #86868b;
  --border: rgba(0, 0, 0, 0.07);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.06);
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --green: #34c759;
  --red: #ff3b30;
  --radius-xl: 2rem;
  --radius-lg: 1.5rem;
  --radius-md: 1.1rem;
  --content: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(0, 113, 227, 0.08), transparent 32rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 26rem;
  height: 26rem;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.17;
  pointer-events: none;
}

.ambient-one {
  top: 6rem;
  right: -12rem;
  background: #5ac8fa;
}

.ambient-two {
  top: 38rem;
  left: -14rem;
  background: #bf5af2;
}

.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  padding-top: env(safe-area-inset-top);
  background: rgba(245, 245, 247, 0.72);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}

.topbar::after {
  position: absolute;
  right: 0;
  bottom: -12px;
  left: 0;
  height: 12px;
  content: "";
  background: linear-gradient(to bottom, rgba(245, 245, 247, 0.14), transparent);
  pointer-events: none;
}

.topbar-inner {
  width: min(calc(100% - 2rem), var(--content));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: inherit;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-icon {
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  border-radius: 0.65rem;
  background: var(--text);
  color: var(--bg);
}

.brand-icon svg {
  width: 1.2rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.icon-button,
.primary-button,
.download-button,
.category-chip {
  border: 0;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.icon-button,
.primary-button,
.download-button {
  min-height: 44px;
  transition: transform 100ms ease-out, background-color 160ms ease, opacity 160ms ease;
}

.icon-button:active,
.primary-button:active,
.download-button:active,
.category-chip:active {
  transform: scale(0.97);
}

.icon-button {
  width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-strong);
  box-shadow: inset 0 0 0 1px var(--border);
}

.icon-button svg {
  width: 1.2rem;
}

.primary-button {
  padding: 0.68rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.primary-button:hover:not(:disabled) {
  background: var(--blue-hover);
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.primary-button svg {
  width: 1.1rem;
}

main {
  width: min(calc(100% - 2rem), var(--content));
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 0.6rem;
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 680;
  letter-spacing: 0.01em;
}

.hero h1 {
  max-width: 950px;
  margin: 0;
  font-size: clamp(3rem, 8vw, 6.5rem);
  font-weight: 720;
  letter-spacing: -0.055em;
  line-height: 0.96;
  text-wrap: balance;
}

.hero h1 span {
  color: var(--secondary);
}

.hero-copy {
  max-width: 760px;
  margin: 1.8rem 0 0;
  color: var(--secondary);
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  letter-spacing: -0.018em;
  line-height: 1.5;
}

code {
  padding: 0.15em 0.4em;
  border-radius: 0.45em;
  background: rgba(127, 127, 127, 0.12);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
}

.status-row {
  min-height: 36px;
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.status-pill,
.muted-pill {
  min-height: 32px;
  padding: 0.38rem 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 999px;
  background: var(--surface-strong);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--secondary);
  font-size: 0.82rem;
  font-weight: 560;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 14%, transparent);
}

.status-pill.loading .status-dot {
  background: var(--tertiary);
  box-shadow: none;
  animation: pulse 1.2s ease-in-out infinite;
}

.status-pill.error .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 12%, transparent);
}

.controls {
  position: sticky;
  z-index: 30;
  top: calc(64px + env(safe-area-inset-top));
  margin: 0 -0.75rem 1.4rem;
  padding: 0.75rem;
  display: grid;
  gap: 0.7rem;
  border-radius: 1.6rem;
  background: rgba(245, 245, 247, 0.7);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}

.search-field {
  min-height: 48px;
  padding: 0 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-radius: 0.95rem;
  background: var(--surface-strong);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-soft);
  color: var(--secondary);
}

.search-field:focus-within {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--blue) 75%, transparent), var(--shadow-soft);
}

.search-field svg {
  width: 1.15rem;
  flex: 0 0 auto;
}

.search-field input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
}

.search-field input::placeholder {
  color: var(--tertiary);
}

.category-nav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline proximity;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.category-chip {
  min-height: 38px;
  padding: 0.5rem 0.8rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--secondary);
  font-size: 0.86rem;
  font-weight: 580;
  scroll-snap-align: start;
  transition: transform 100ms ease-out, background-color 160ms ease, color 160ms ease;
}

.category-chip:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.channel-sections {
  display: grid;
  gap: 3.4rem;
  padding-bottom: 4rem;
}

.channel-section {
  scroll-margin-top: 10.5rem;
}

.section-heading {
  margin: 0 0 1.1rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 680;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.section-count {
  margin: 0 0 0.2rem;
  color: var(--tertiary);
  font-size: 0.86rem;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.channel-card {
  min-height: 218px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px) saturate(155%);
  -webkit-backdrop-filter: blur(20px) saturate(155%);
  transform: translateZ(0);
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.channel-card:hover {
  transform: translateY(-2px);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.logo-area {
  height: 88px;
  padding: 0.65rem;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 1rem;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.045);
  background: lightgray;
}

.channel-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
}

.logo-fallback {
  max-width: 100%;
  color: #1d1d1f;
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  text-align: center;
  text-wrap: balance;
}

.card-content {
  padding: 0.9rem 0.15rem 0.15rem;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.channel-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.018em;
  line-height: 1.25;
}

.channel-meta {
  margin: 0.3rem 0 0;
  color: var(--tertiary);
  font-size: 0.76rem;
}

.download-button {
  width: 100%;
  margin-top: auto;
  padding: 0.68rem 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 0.85rem;
  background: rgba(0, 113, 227, 0.1);
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 630;
}

.download-button:hover {
  background: rgba(0, 113, 227, 0.15);
}

.download-button svg {
  width: 1rem;
}

.message-card,
.info-card {
  padding: clamp(1.2rem, 4vw, 2rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px) saturate(155%);
  -webkit-backdrop-filter: blur(20px) saturate(155%);
}

.message-card {
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.message-card h2,
.info-card h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.message-card p,
.info-card p {
  margin: 0.35rem 0 0;
  color: var(--secondary);
}

.message-icon {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 113, 227, 0.1);
  color: var(--blue);
  font-weight: 700;
}

.error-card .message-icon {
  background: rgba(255, 59, 48, 0.1);
  color: var(--red);
}

.info-card {
  margin: 1rem 0 5rem;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 2rem;
}

.info-card .eyebrow {
  margin-bottom: 0.45rem;
}

.info-card > p {
  margin: 0;
  font-size: 1.03rem;
  line-height: 1.6;
}

footer {
  width: min(calc(100% - 2rem), var(--content));
  margin: 0 auto;
  padding: 0 0 calc(2.2rem + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--tertiary);
  font-size: 0.78rem;
}

footer p {
  margin: 0;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 50%;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  max-width: min(calc(100% - 2rem), 420px);
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(28, 28, 30, 0.88);
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 560;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 18px) scale(0.98);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast.visible {
  opacity: 1;
  transform: translate(50%, 0) scale(1);
}

[hidden] {
  display: none !important;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

@media (max-width: 980px) {
  .channel-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  :root {
    --radius-xl: 1.65rem;
    --radius-lg: 1.25rem;
  }

  .topbar-inner,
  main,
  footer {
    width: min(calc(100% - 1.25rem), var(--content));
  }

  .topbar-inner {
    min-height: 58px;
  }

  .primary-button span {
    display: none;
  }

  .primary-button {
    width: 44px;
    padding: 0;
    border-radius: 50%;
  }

  .controls {
    top: calc(58px + env(safe-area-inset-top));
    margin-inline: -0.3rem;
    padding-inline: 0.3rem;
  }

  .hero {
    padding-top: 3.8rem;
  }

  .hero h1 {
    font-size: clamp(3rem, 15vw, 4.8rem);
  }

  .channel-section {
    scroll-margin-top: 10rem;
  }

  .channel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .channel-card {
    min-height: 208px;
    padding: 0.75rem;
  }

  .logo-area {
    height: 80px;
    background: lightgray;
  }

  .info-card {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  footer {
    flex-direction: column;
    gap: 0.25rem;
  }
}

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

  .channel-card {
    min-height: 0;
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 0.85rem;
  }

  .logo-area {
    width: 104px;
    height: 104px;
    align-self: center;
    background: lightgray;
  }

  .card-content {
    min-width: 0;
    padding-top: 0.2rem;
  }

  .download-button {
    margin-top: 0.9rem;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --surface: rgba(28, 28, 30, 0.72);
    --surface-strong: rgba(44, 44, 46, 0.92);
    --surface-soft: rgba(44, 44, 46, 0.62);
    --text: #f5f5f7;
    --secondary: #a1a1a6;
    --tertiary: #8e8e93;
    --border: rgba(255, 255, 255, 0.09);
    --shadow: 0 18px 54px rgba(0, 0, 0, 0.42);
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.25);
    --blue: #0a84ff;
    --blue-hover: #409cff;
  }

  body {
    background:
      radial-gradient(circle at 50% -10%, rgba(10, 132, 255, 0.16), transparent 32rem),
      var(--bg);
  }

  .topbar,
  .controls {
    background: rgba(0, 0, 0, 0.68);
  }

  .topbar::after {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), transparent);
  }

  .logo-area {
    background: lightgray;
  }

  .download-button {
    background: rgba(10, 132, 255, 0.16);
  }

  .download-button:hover {
    background: rgba(10, 132, 255, 0.23);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .channel-card:hover {
    transform: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .controls,
  .channel-card,
  .message-card,
  .info-card,
  .toast {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--surface-strong);
  }
}

@media (prefers-contrast: more) {
  :root {
    --border: currentColor;
  }

  .channel-card,
  .message-card,
  .info-card,
  .search-field,
  .status-pill,
  .muted-pill {
    border: 1px solid currentColor;
  }
}
