@layer pages {
  .themes-page {
    padding: 24px 16px 80px;
    max-width: 720px;
    margin: 0 auto;
    color: var(--color-text);
  }

  .themes-page__back {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: var(--weight-semibold);
    color: var(--color-accent);
    text-decoration: none;
    padding: 8px 14px;
  }

  .themes-page__title {
    font-family: var(--font-title);
    font-size: 24px;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin: 0 0 8px;
  }

  .themes-page__intro {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0 0 24px;
  }

  .themes-page__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  @media (width >= 600px) {
    .themes-page__grid {
      grid-template-columns: repeat(3, 1fr);
    }
  }

  .themes-page__card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition:
      transform var(--duration-fast) var(--easing-default),
      border-color var(--duration-fast) var(--easing-default);
  }

  .themes-page__card:active {
    transform: scale(0.98);
  }

  .themes-page__card:hover {
    border-color: var(--color-accent);
  }

  /* Mini-preview using each palette's actual hex values directly so the
   * preview shows the target theme regardless of the active root theme. */
  .themes-page__preview {
    position: relative;
    aspect-ratio: 16 / 10;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--preview-bg, #0a0a0b);
    border: 1px solid var(--color-border-subtle);
  }

  .themes-page__preview-bg {
    position: absolute;
    inset: 0;
    background: var(--preview-bg, #0a0a0b);
  }

  .themes-page__preview-card {
    position: absolute;
    left: 12%;
    right: 12%;
    top: 22%;
    height: 18%;
    background: var(--preview-surface, #111113);
    border-radius: 4px;
  }

  .themes-page__preview-card--alt {
    top: 50%;
    height: 18%;
    opacity: 0.85;
  }

  .themes-page__preview-accent {
    position: absolute;
    left: 12%;
    bottom: 14%;
    width: 26%;
    height: 12%;
    background: var(--color-accent);
    border-radius: 999px;
  }

  .themes-page__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .themes-page__name {
    font-family: var(--font-title);
    font-size: 13px;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    color: var(--color-text);
  }

  .themes-page__desc {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.4;
  }

  /* Per-card preview palettes — hex literals on purpose: the preview must
   * show the target theme regardless of which palette is active globally. */
  .themes-page__card--dark-classic {
    --preview-bg: #0a0a0b;
    --preview-surface: #1a1a1d;
  }

  .themes-page__card--dark-oled {
    --preview-bg: #000;
    --preview-surface: #18150f;
  }

  .themes-page__card--light-pure {
    --preview-bg: #fff;
    --preview-surface: #ebebef;
  }

  /* System: split-diagonal preview showing both halves */
  .themes-page__card--system .themes-page__preview-bg {
    background: linear-gradient(135deg, #0a0a0b 0%, #0a0a0b 49%, #fff 51%, #fff 100%);
  }

  .themes-page__card--system .themes-page__preview-card {
    background: linear-gradient(135deg, #1a1a1d 0%, #1a1a1d 49%, #ebebef 51%, #ebebef 100%);
  }
}
