@layer gallery {
  :where([data-gallery-page="customize"]) {
    width: min(100%, 96rem);
  }

  :where([data-gallery-customizer="header"]) {
    max-width: 56rem;
  }

  :where([data-gallery-customizer="header"] > [data-nk="button-group"]) {
    margin-block-start: 0.75rem;
  }

  :where([data-gallery="customizer-errors"]) {
    margin: 0;
    padding: 0.75rem 1rem;
    color: var(--nk-color-danger-content);
    background: color-mix(
      in oklab,
      var(--nk-color-danger) 10%,
      var(--nk-color-surface)
    );
    border-inline-start: 0.25rem solid var(--nk-color-danger);
    border-radius: var(--nk-radius-sm);
    line-height: var(--nk-leading-normal);
  }

  :where(
    [data-gallery="customizer-preview-section"],
    [data-gallery="customizer-controls-section"],
    [data-gallery="customizer-exports"]
  ) {
    display: grid;
    gap: 1.25rem;
    min-inline-size: 0;
  }

  :where([data-gallery="customizer-section-header"]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(14rem, 28rem);
    gap: 1rem 2rem;
    align-items: end;
  }

  :where([data-gallery="customizer-section-header"] *) {
    margin: 0;
  }

  :where([data-gallery="customizer-section-header"] > div) {
    display: grid;
    gap: 0.35rem;
  }

  :where([data-gallery="customizer-section-header"] h2) {
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    letter-spacing: -0.025em;
    line-height: 1.15;
    text-wrap: balance;
  }

  :where([data-gallery="customizer-section-header"] > p) {
    color: var(--nk-color-muted-foreground);
    font-size: 0.9rem;
    line-height: 1.55;
    text-wrap: pretty;
  }

  :where([data-gallery="theme-preview"]) {
    min-inline-size: 0;
    overflow: clip;
    color: var(--nk-color-foreground);
    font-family: var(--nk-font-sans);
    background: var(--nk-color-canvas);
    border: var(--nk-border-width) solid var(--nk-color-border);
    border-radius: var(--nk-radius-xl);
    box-shadow: var(--nk-shadow-md);
    color-scheme: light;
  }

  :where([data-gallery="theme-preview"][data-theme="dark"]) {
    color-scheme: dark;
  }

  :where(
    [data-gallery="theme-preview"] [data-gallery-customizer-shell]
  ) {
    --nk-app-shell-sidebar-width: 14rem;
    --nk-app-shell-topbar-height: 3.25rem;

    block-size: 52rem;
    min-block-size: 52rem;
    overflow: hidden;
  }

  @media (min-width: 48.0625rem) {
    :where(
      [data-gallery="theme-preview"]
        [data-gallery-customizer-shell]
        > [data-slot="app-shell-sidebar"]
    ) {
      position: relative;
      inset-block-start: auto;
      block-size: auto;
      min-block-size: 0;
    }
  }

  :where(
    [data-gallery="theme-preview"]
      [data-gallery-customizer-shell]
      > [data-slot="app-shell-main"]
  ) {
    overflow: auto;
  }

  :where([data-gallery="customizer-brand"]) {
    display: grid;
    min-inline-size: 0;
    line-height: 1.15;
  }

  :where([data-gallery="customizer-brand"] strong) {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  :where([data-gallery="customizer-brand"] small) {
    color: var(--nk-color-muted-foreground);
    font-size: var(--nk-text-xs);
  }

  :where([data-gallery="customizer-application"]) {
    min-block-size: 100%;
    padding: clamp(1rem, 3vw, 2rem);
  }

  :where([data-gallery="customizer-preview-grid"]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(var(--nk-space) * 4);
    align-items: start;
  }

  :where(
    [data-gallery="customizer-preview-grid"] [data-slot="card-body"]
  ) {
    min-inline-size: 0;
  }

  :where([data-gallery="customizer-pro"]) {
    display: grid;
    gap: calc(var(--nk-space) * 4);
  }

  :where([data-gallery="customizer-pro"] > header) {
    display: grid;
    gap: calc(var(--nk-space) * 1.5);
  }

  :where([data-gallery="customizer-pro"] > header > *) {
    margin: 0;
  }

  :where([data-gallery="customizer-pro"] > header h2) {
    font-size: var(--nk-text-lg);
    line-height: var(--nk-leading-tight);
  }

  :where([data-gallery="customizer-pro"] > header p) {
    color: var(--nk-color-muted-foreground);
    font-size: var(--nk-text-sm);
  }

  :where([data-gallery="customizer-pro-grid"]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(var(--nk-space) * 4);
    align-items: start;
  }

  :where(
    [data-gallery="customizer-pro-grid"] [data-nk="progressive-image"]
  ) {
    display: grid;
    min-block-size: 7rem;
    place-items: center;
    color: var(--nk-color-muted-foreground);
    background: var(--nk-color-muted);
  }

  :where([data-gallery="customizer-controls"]) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    min-inline-size: 0;
  }

  :where([data-gallery="customizer-control"]) {
    min-inline-size: 0;
    margin: 0;
    padding: 1rem;
    background: color-mix(
      in oklab,
      currentColor 2.5%,
      var(--nk-color-surface)
    );
    border: var(--nk-border-width) solid var(--nk-color-border);
    border-radius: var(--nk-radius-lg);
  }

  :where([data-gallery="customizer-control"] legend) {
    padding: 0;
    color: var(--nk-color-foreground);
    font-size: 0.9rem;
    font-weight: var(--nk-font-weight-semibold);
  }

  :where([data-gallery="customizer-control"] > p) {
    min-block-size: 2.5em;
    margin: 0.35rem 0 0.75rem;
    color: var(--nk-color-muted-foreground);
    font-size: 0.75rem;
    line-height: 1.35;
    text-wrap: pretty;
  }

  :where([data-gallery="customizer-options"]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  :where([data-gallery="customizer-option"]) {
    min-inline-size: 0;
    min-block-size: 2.5rem;
    padding: 0.3rem 0.45rem;
    border-radius: var(--nk-radius-md);
  }

  :where([data-gallery="customizer-option"]:has(input:checked)) {
    background: color-mix(
      in oklab,
      var(--nk-color-primary) 9%,
      transparent
    );
  }

  :where(
    [data-gallery="customizer-option"] > [data-slot="radio-button-label"]
  ) {
    min-block-size: 2.5rem;
  }

  :where(
    [data-gallery="customizer-option"] [data-slot="radio-button-label-text"]
  ) {
    display: flex;
    min-inline-size: 0;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
  }

  :where(
    [data-gallery="customizer-option"]
      [data-slot="radio-button-label-text"]
      > span:last-child
  ) {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  :where([data-gallery="customizer-swatch"]) {
    position: relative;
    display: inline-grid;
    flex: none;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    place-items: center;
    overflow: hidden;
    color: var(--nk-color-foreground);
    background: var(--nk-color-muted);
    border: var(--nk-border-width) solid
      color-mix(in oklab, currentColor 20%, transparent);
    border-radius: var(--nk-radius-sm);
    font-size: 0.65rem;
    font-weight: var(--nk-font-weight-semibold);
    line-height: 1;
  }

  :where(
    [data-gallery-swatch-kind="accent"][data-gallery-swatch="blue"]
  ) {
    background: oklch(0.546 0.245 262.881);
  }

  :where(
    [data-gallery-swatch-kind="accent"][data-gallery-swatch="indigo"]
  ) {
    background: oklch(0.511 0.262 276.966);
  }

  :where(
    [data-gallery-swatch-kind="accent"][data-gallery-swatch="violet"]
  ) {
    background: oklch(0.541 0.281 293.009);
  }

  :where(
    [data-gallery-swatch-kind="accent"][data-gallery-swatch="rose"]
  ) {
    background: oklch(0.56 0.253 17.585);
  }

  :where(
    [data-gallery-swatch-kind="accent"][data-gallery-swatch="amber"]
  ) {
    background: oklch(0.666 0.179 58.318);
  }

  :where(
    [data-gallery-swatch-kind="accent"][data-gallery-swatch="emerald"]
  ) {
    background: oklch(0.527 0.154 150.069);
  }

  :where(
    [data-gallery-swatch-kind="accent"][data-gallery-swatch="neutral"]
  ) {
    background: oklch(0.269 0 0);
  }

  :where(
    [data-gallery-swatch-kind="neutral"][data-gallery-swatch="slate"]
  ) {
    background: oklch(0.554 0.046 257.417);
  }

  :where(
    [data-gallery-swatch-kind="neutral"][data-gallery-swatch="gray"]
  ) {
    background: oklch(0.551 0.027 264.364);
  }

  :where(
    [data-gallery-swatch-kind="neutral"][data-gallery-swatch="zinc"]
  ) {
    background: oklch(0.552 0.016 285.938);
  }

  :where(
    [data-gallery-swatch-kind="neutral"][data-gallery-swatch="neutral"]
  ) {
    background: oklch(0.556 0 0);
  }

  :where(
    [data-gallery-swatch-kind="neutral"][data-gallery-swatch="stone"]
  ) {
    background: oklch(0.553 0.013 58.071);
  }

  :where([data-gallery-swatch-kind="radius"]) {
    background: color-mix(
      in oklab,
      var(--nk-color-primary) 18%,
      var(--nk-color-surface)
    );
  }

  :where([data-gallery-swatch-kind="radius"][data-gallery-swatch="none"]) {
    border-radius: 0;
  }

  :where([data-gallery-swatch-kind="radius"][data-gallery-swatch="sm"]) {
    border-radius: 0.125rem;
  }

  :where([data-gallery-swatch-kind="radius"][data-gallery-swatch="md"]) {
    border-radius: 0.375rem;
  }

  :where([data-gallery-swatch-kind="radius"][data-gallery-swatch="lg"]) {
    border-radius: 0.625rem;
  }

  :where([data-gallery-swatch-kind="density"]) {
    background-color: transparent;
    background-image: repeating-linear-gradient(
      to bottom,
      currentColor 0 1px,
      transparent 1px 4px
    );
    background-position: center;
    background-size: 0.9rem 0.75rem;
    background-repeat: no-repeat;
  }

  :where(
    [data-gallery-swatch-kind="density"][data-gallery-swatch="comfortable"]
  ) {
    background-size: 0.9rem 1rem;
    background-image: repeating-linear-gradient(
      to bottom,
      currentColor 0 1px,
      transparent 1px 6px
    );
  }

  :where([data-gallery-swatch-kind="font"]) {
    inline-size: 1.65rem;
    background: transparent;
  }

  :where([data-gallery-swatch-kind="font"][data-gallery-swatch="humanist"]) {
    font-family: Optima, Candara, "Noto Sans", source-sans-pro, sans-serif;
  }

  :where([data-gallery-swatch-kind="font"][data-gallery-swatch="serif"]) {
    font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  }

  :where([data-gallery-swatch-kind="font"][data-gallery-swatch="mono"]) {
    font-family: var(--nk-font-mono);
  }

  :where([data-gallery-swatch-kind="shell"]) {
    background-color: transparent;
    background-image:
      linear-gradient(to right, currentColor 0 28%, transparent 28%),
      linear-gradient(to bottom, currentColor 0 22%, transparent 22%);
    opacity: 0.72;
  }

  :where(
    [data-gallery-swatch-kind="shell"][data-gallery-swatch="sidebar"]
  ) {
    background-image: linear-gradient(
      to right,
      currentColor 0 32%,
      transparent 32%
    );
  }

  :where(
    [data-gallery-swatch-kind="shell"][data-gallery-swatch="topbar"]
  ) {
    background-image: linear-gradient(
      to bottom,
      currentColor 0 30%,
      transparent 30%
    );
  }

  :where([data-gallery-swatch-kind="appearance"]) {
    border-radius: var(--nk-radius-full);
  }

  :where(
    [data-gallery-swatch-kind="appearance"][data-gallery-swatch="light"]
  ) {
    background: oklch(0.985 0 0);
  }

  :where(
    [data-gallery-swatch-kind="appearance"][data-gallery-swatch="dark"]
  ) {
    background: oklch(0.205 0 0);
  }

  :where(
    [data-gallery-swatch-kind="appearance"][data-gallery-swatch="system"]
  ) {
    background: linear-gradient(
      135deg,
      oklch(0.985 0 0) 0 50%,
      oklch(0.205 0 0) 50% 100%
    );
  }

  :where([data-gallery="customizer-exports"] > [data-nk="tabs"]) {
    min-inline-size: 0;
  }

  :where([data-gallery="customizer-export"]) {
    min-inline-size: 0;
    overflow: hidden;
    background: color-mix(
      in oklab,
      currentColor 2.5%,
      var(--nk-color-surface)
    );
    border: var(--nk-border-width) solid var(--nk-color-border);
    border-radius: var(--nk-radius-lg);
  }

  :where([data-gallery="customizer-export"] > header) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.8rem;
    border-block-end: var(--nk-border-width) solid var(--nk-color-border);
  }

  :where([data-gallery="customizer-export"] > header > div) {
    display: grid;
    min-inline-size: 0;
    gap: 0.1rem;
  }

  :where([data-gallery="customizer-export"] > header strong) {
    font-size: 0.8rem;
  }

  :where([data-gallery="customizer-export"] > header small) {
    overflow: hidden;
    color: var(--nk-color-muted-foreground);
    font-family: var(--nk-font-mono);
    font-size: 0.7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  :where([data-gallery="customizer-export"] pre) {
    max-block-size: 32rem;
    margin: 0;
    overflow: auto;
    padding: 1rem;
    font-family: var(--nk-font-mono);
    font-size: 0.78rem;
    font-variant-ligatures: none;
    line-height: 1.65;
    tab-size: 2;
  }

  :where([data-gallery="customizer-export"] code) {
    display: block;
    inline-size: max-content;
    min-inline-size: 100%;
    font: inherit;
  }

  :where([data-gallery="customizer-status"]) {
    position: fixed;
    z-index: 100;
    inset-block-end: 1rem;
    inset-inline-end: 1rem;
    max-inline-size: min(24rem, calc(100vw - 2rem));
    margin: 0;
    padding: 0.65rem 0.8rem;
    color: var(--nk-color-foreground);
    background: var(--nk-color-elevated);
    border: var(--nk-border-width) solid var(--nk-color-border);
    border-radius: var(--nk-radius-md);
    box-shadow: var(--nk-shadow-md);
    font-size: 0.8rem;
    line-height: 1.4;
  }

  :where([data-gallery="customizer-status"]:empty) {
    display: none;
  }

  :where([data-gallery="customizer-status"][data-state="success"]) {
    color: var(--nk-color-success-content);
  }

  :where([data-gallery="customizer-status"][data-state="error"]) {
    color: var(--nk-color-danger-content);
  }

  @media (max-width: 64rem) {
    :where([data-gallery="customizer-controls"]) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :where([data-gallery="customizer-preview-grid"]) {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  @media (max-width: 48rem) {
    :where([data-gallery="customizer-section-header"]) {
      grid-template-columns: minmax(0, 1fr);
      align-items: start;
    }

    :where([data-gallery="theme-preview"]) {
      border-radius: var(--nk-radius-lg);
    }

    :where(
      [data-gallery="theme-preview"] [data-gallery-customizer-shell]
    ) {
      block-size: 42rem;
      min-block-size: 42rem;
    }

    :where([data-gallery="customizer-application"]) {
      padding: 1rem;
    }

    :where([data-gallery="customizer-pro-grid"]) {
      grid-template-columns: minmax(0, 1fr);
    }

    :where([data-gallery="customizer-controls"]) {
      grid-template-columns: none;
      grid-auto-flow: column;
      grid-auto-columns: minmax(13rem, 78vw);
      gap: 0.6rem;
      overflow-x: auto;
      padding-block-end: 0.5rem;
      overscroll-behavior-inline: contain;
      scroll-snap-type: inline mandatory;
      scrollbar-width: thin;
    }

    :where([data-gallery="customizer-control"]) {
      scroll-snap-align: start;
    }

    :where([data-gallery="customizer-export"] > header) {
      align-items: flex-start;
    }

    :where([data-gallery="customizer-status"]) {
      inset-block-end: 0.75rem;
      inset-inline: 0.75rem;
      max-inline-size: none;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    :where([data-gallery="customizer-controls"]) {
      scroll-behavior: auto;
    }
  }
}
