*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text-1);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

img, canvas {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

input, textarea {
  font: inherit;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

:root {
  /* Colors — dark theme */
  --color-primary: #007AFF;
  --color-primary-dark: #0056CC;
  --color-bg: #000000;
  --color-surface: #1C1C1E;
  --color-surface-2: #2C2C2E;
  --color-text-1: #FFFFFF;
  --color-text-2: #8E8E93;
  --color-text-3: #636366;
  --color-premium: #FFD60A;
  --color-success: #30D158;
  --color-destructive: #FF453A;
  --color-tag-bg: #3A3A3C;
  --color-tag-active-bg: rgba(0, 122, 255, 0.2);
  --color-card-border: #3A3A3C;

  /* Gradients */
  --gradient-install: linear-gradient(135deg, #30D158, #007AFF);
  --gradient-premium: linear-gradient(135deg, #FFD60A, #FF9500);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-xxl: 24px;
  --space-xxxl: 32px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-watch: 24px;

  /* Card sizes */
  --card-width: 160px;
  --card-image-h: 195px; /* 160 * 484/396 */
  --detail-width: 260px;
  --detail-image-h: 318px; /* 260 * 484/396 */

  /* Font */
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Main app wrapper */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
}

/* Face grid */
.face-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

@media (min-width: 640px) {
  .face-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .face-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-xl);
  }
}

@media (min-width: 1440px) {
  .face-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Category section */
.category-section {
  margin-bottom: var(--space-xxxl);
}

.category-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.category-section__title {
  font-size: 20px;
  font-weight: 700;
}

.category-section__see-all {
  font-size: 14px;
  color: var(--color-primary);
  cursor: pointer;
}

.category-section__see-all:hover {
  color: var(--color-primary-dark);
}

/* Horizontal scroll row */
.scroll-row {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: var(--space-sm);
}

.scroll-row::-webkit-scrollbar {
  display: none;
}

.scroll-row > * {
  scroll-snap-align: start;
  flex-shrink: 0;
}

/* Hero section */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-xxxl) 0;
  gap: var(--space-xxl);
}

.hero__title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.hero__subtitle {
  font-size: 16px;
  color: var(--color-text-2);
  max-width: 480px;
}

@media (min-width: 640px) {
  .hero__title {
    font-size: 40px;
  }

  .hero__subtitle {
    font-size: 18px;
  }
}

.hero__cta {
  max-width: 320px;
  width: auto;
  padding: var(--space-md) var(--space-xxl);
  font-size: 15px;
}

/* Category pills */
.category-pills {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--space-md) 0;
  margin-bottom: var(--space-xxl);
}

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

.category-pill {
  flex-shrink: 0;
  padding: var(--space-sm) var(--space-lg);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  background: var(--color-surface);
  color: var(--color-text-2);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.category-pill:hover {
  background: var(--color-surface-2);
}

.category-pill--active {
  background: var(--color-primary);
  color: var(--color-text-1);
}

/* Detail layout */
.detail {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-xxl) var(--space-lg);
}

.detail__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 14px;
  color: var(--color-primary);
  margin-bottom: var(--space-xxl);
  cursor: pointer;
}

.detail__preview-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-xxl);
}

.detail__info {
  text-align: center;
  margin-bottom: var(--space-xxl);
}

.detail__name {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.detail__meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-size: 14px;
  color: var(--color-text-2);
}

.detail__rating-star {
  color: var(--color-premium);
}

.detail__section {
  margin-bottom: var(--space-xxl);
}

.detail__section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-md);
}

.detail__description {
  font-size: 15px;
  color: var(--color-text-2);
  line-height: 1.6;
}

.detail__divider {
  height: 1px;
  background: var(--color-surface-2);
  margin: var(--space-xxl) 0;
}

/* Search */
.search-bar {
  position: relative;
}

.search-bar__input {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  padding-left: 40px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--color-text-1);
}

.search-bar__input::placeholder {
  color: var(--color-text-3);
}

.search-bar__icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-3);
  font-size: 14px;
}

/* Header */
.site-header {
  padding: var(--space-lg) 0;
  border-bottom: 1px solid var(--color-surface);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header__logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.site-header__search {
  width: 240px;
}

@media (max-width: 639px) {
  .site-header__search {
    display: none;
  }

  .site-header__search--mobile {
    display: block;
    width: 100%;
    padding: var(--space-md) 0;
  }
}

/* Footer */
.site-footer {
  padding: var(--space-xxxl) 0;
  border-top: 1px solid var(--color-surface);
  text-align: center;
}

.site-footer__contact {
  margin-bottom: var(--space-xxl);
}

.site-footer__contact-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-lg);
}

.site-footer__social {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
}

.site-footer__social-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-2);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.25s, color 0.25s, box-shadow 0.25s;
}

.site-footer__social-link:hover {
  background: var(--color-surface-2);
  color: var(--color-text-1);
  box-shadow: 0 0 16px rgba(0, 122, 255, 0.15);
}

.site-footer__social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  transition: color 0.25s;
}

.site-footer__social-link:hover .site-footer__social-icon {
  color: #1877F2;
}

.site-footer__social-label {
  line-height: 1;
}

.site-footer__divider {
  height: 1px;
  background: var(--color-surface);
  max-width: 200px;
  margin: 0 auto var(--space-xxl);
}

.site-footer__links {
  display: flex;
  justify-content: center;
  gap: var(--space-xxl);
  margin-bottom: var(--space-lg);
}

.site-footer__link {
  font-size: 14px;
  color: var(--color-text-2);
}

.site-footer__link:hover {
  color: var(--color-text-1);
}

.site-footer__copy {
  font-size: 12px;
  color: var(--color-text-3);
}

/* Face Card */
.face-card {
  cursor: pointer;
  transition: transform 0.2s;
}

.face-card:hover {
  transform: translateY(-4px);
}

.face-card__preview {
  position: relative;
  aspect-ratio: 396 / 484;
  border-radius: var(--radius-watch);
  overflow: hidden;
  border: 1px solid var(--color-card-border);
  margin-bottom: var(--space-sm);
}

.face-card__preview canvas {
  width: 100%;
  height: 100%;
}

.face-card__badge {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  background: var(--color-premium);
  color: #000;
}

.face-card__name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.face-card__label {
  font-size: 11px;
  margin-top: 2px;
}

.face-card__label--free {
  color: var(--color-success);
}

.face-card__label--premium {
  color: var(--color-premium);
}

/* Variant picker */
.variant-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

.variant-picker__arrow {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 16px;
  color: var(--color-text-1);
  transition: opacity 0.2s;
}

.variant-picker__arrow:disabled {
  opacity: 0.2;
  cursor: default;
}

.variant-picker__dots {
  display: flex;
  gap: var(--space-sm);
}

.variant-picker__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-3);
  cursor: pointer;
  transition: background 0.2s;
}

.variant-picker__dot--active {
  background: var(--color-primary);
}

.variant-picker__name {
  text-align: center;
  font-size: 14px;
  color: var(--color-text-2);
  margin-bottom: var(--space-md);
}

/* Tags */
.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.tag {
  font-size: 12px;
  padding: var(--space-xs) var(--space-md);
  border-radius: 20px;
  background: var(--color-tag-bg);
  color: var(--color-text-2);
}

/* Features badges */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.feature-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.feature-badge__icon {
  font-size: 20px;
  color: var(--color-primary);
}

.feature-badge__label {
  font-size: 11px;
  color: var(--color-text-2);
}

/* CTA Button */
.cta-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  background: var(--gradient-install);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  transition: opacity 0.2s;
  margin-bottom: var(--space-xxl);
}

.cta-button:hover {
  opacity: 0.9;
}

.cta-button--app-store {
  background: #000;
  border: 1px solid var(--color-text-3);
}

/* Watch preview container */
.watch-preview {
  aspect-ratio: 396 / 484;
  border-radius: var(--radius-watch);
  overflow: hidden;
  border: 1px solid var(--color-card-border);
}

.watch-preview canvas {
  width: 100%;
  height: 100%;
}

/* Similar faces section */
.similar-section {
  margin-top: var(--space-xxxl);
}