:root {
  --paper: #f5f6fb;
  --surface: #ffffff;
  --ink: #17181c;
  --muted: #777b87;
  --line: #e4e6ed;
  --blue: #1d42f5;
  --blue-soft: #dce3ff;
  --violet: #9a7cff;
  --coral: #ff806a;
  --shadow: 0 22px 60px rgba(33, 38, 59, 0.12);
  --radius: 22px;
  --sidebar: 230px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 100;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  padding: 12px 18px;
  text-decoration: none;
  transition: top 160ms ease;
}

.skip-link:focus { top: 16px; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  padding: 31px 22px 24px;
  backdrop-filter: blur(22px);
}

.brand, .mobile-brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand img { display: block; width: 166px; height: auto; }
.mobile-brand img { display: block; width: 145px; height: auto; }

.side-nav { display: grid; gap: 5px; margin-top: 57px; }

.side-link {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 13px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #686c77;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 12px;
  text-align: left;
  text-decoration: none;
  transition: 180ms ease;
}

.side-link svg { width: 18px; height: 18px; }
.side-link:first-child svg { fill: currentColor; stroke: none; }
.side-link:hover { background: #f2f3f8; color: var(--ink); }
.side-link.is-active { background: var(--ink); color: white; }

.sidebar-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: auto;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
  padding: 20px 8px 0;
}

.sidebar-note p { margin: 0; }
.sidebar-note strong { color: var(--ink); font-size: 11px; }

.live-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #22be76;
  box-shadow: 0 0 0 4px rgba(34, 190, 118, 0.12);
  margin-top: 4px;
}

.main-content { margin-left: var(--sidebar); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(228, 230, 237, 0.85);
  background: rgba(245, 246, 251, 0.88);
  padding: 0 clamp(22px, 4vw, 58px);
  backdrop-filter: blur(20px);
}

.mobile-brand { display: none; }

.search-box {
  display: flex;
  width: min(520px, 50vw);
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: white;
  box-shadow: 0 4px 16px rgba(39, 44, 70, 0.035);
  padding: 0 13px;
  transition: 180ms ease;
}

.search-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 66, 245, 0.1);
}

.search-box svg { width: 18px; height: 18px; color: #8c909b; }

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  padding: 13px 0;
}

.search-box input::placeholder { color: #a0a3ad; }

.search-box kbd {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: #9295a0;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  padding: 3px 6px;
  white-space: nowrap;
}

.top-actions, .view-switch { display: flex; align-items: center; gap: 8px; }

.view-switch {
  border-radius: 12px;
  background: white;
  padding: 4px;
}

.icon-button, .round-button {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
}

.icon-button { width: 32px; height: 32px; color: #a1a4ad; }
.icon-button svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.icon-button.is-active { background: var(--ink); color: white; }

.sync-button {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  box-shadow: 0 7px 18px rgba(29, 66, 245, 0.2);
  color: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 11px 15px;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.sync-button:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(29, 66, 245, 0.27); }
.sync-button:disabled { cursor: wait; opacity: 0.75; }
.sync-button svg { width: 16px; height: 16px; }
.sync-button.is-syncing svg { animation: spin 850ms linear infinite; }

.hero {
  position: relative;
  display: grid;
  min-height: 350px;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 48px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  padding: 56px clamp(22px, 4vw, 58px);
}

.hero::before {
  position: absolute;
  top: -155px;
  right: -80px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(29, 66, 245, 0.1), rgba(29, 66, 245, 0) 68%);
  content: "";
  pointer-events: none;
}

.hero-copy { position: relative; z-index: 1; max-width: 760px; }

.eyebrow, .section-kicker {
  color: var(--blue);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.eyebrow { margin: 0 0 19px; }

.hero h1 {
  max-width: 700px;
  margin: 0;
  font-size: clamp(54px, 6.8vw, 98px);
  font-weight: 500;
  letter-spacing: -0.065em;
  line-height: 0.88;
}

.hero h1 em {
  display: block;
  color: var(--blue);
  font-family: "Newsreader", Georgia, serif;
  font-weight: 500;
}

.hero-description {
  max-width: 510px;
  color: #656975;
  font-size: 14px;
  line-height: 1.7;
  margin: 22px 0 0;
}

.hero-stats {
  position: relative;
  z-index: 1;
  display: grid;
  width: 210px;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  border-left: 1px solid var(--line);
  padding-left: 28px;
}

.hero-stats div { display: flex; flex-direction: column; gap: 4px; }
.hero-stats strong { font-family: "Newsreader", serif; font-size: 36px; font-weight: 500; }
.hero-stats span { color: var(--muted); font-size: 9px; line-height: 1.35; text-transform: uppercase; letter-spacing: 0.07em; }
.hero-stats p { grid-column: 1 / -1; color: #8b8e98; font-size: 10px; line-height: 1.5; margin: 0; }

.collection { padding: 52px clamp(22px, 4vw, 58px) 80px; }

.collection-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 30px;
}

.section-kicker { margin: 0 0 8px; }
.collection-head h2 { margin: 0; font-size: clamp(28px, 3vw, 42px); font-weight: 500; letter-spacing: -0.045em; }

.filter-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }

.filter-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: #737782;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 13px;
  transition: 160ms ease;
}

.filter-chip:hover { border-color: #b7bac4; color: var(--ink); }
.filter-chip.is-active { border-color: var(--ink); background: var(--ink); color: white; }

.gallery { opacity: 1; transition: opacity 180ms ease; }
.gallery:empty { display: none; }

.gallery.mosaic {
  column-count: 4;
  column-gap: 14px;
}

.gallery.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.gallery-card {
  position: relative;
  display: block;
  width: 100%;
  break-inside: avoid;
  overflow: hidden;
  border: 0;
  border-radius: 15px;
  background: #e9ebf3;
  cursor: zoom-in;
  margin: 0 0 14px;
  padding: 0;
  text-align: left;
  transform: translateZ(0);
}

.grid .gallery-card { aspect-ratio: 1 / 1; margin: 0; }
.mosaic .gallery-card[data-orientation="portrait"] { aspect-ratio: 0.8 / 1; }
.mosaic .gallery-card[data-orientation="square"] { aspect-ratio: 1 / 1; }
.mosaic .gallery-card[data-orientation="landscape"] { aspect-ratio: 1.38 / 1; }
.mosaic .gallery-card[data-orientation="unknown"] { aspect-ratio: 1 / 1; }

.gallery-card::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(14, 16, 24, 0.82), rgba(14, 16, 24, 0) 55%);
  content: "";
  opacity: 0;
  transition: opacity 220ms ease;
}

.gallery-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 520ms cubic-bezier(.2,.8,.2,1), filter 220ms ease;
}

.gallery-card.is-fallback img { display: none; }
.gallery-card.is-fallback { background: linear-gradient(145deg, var(--blue-soft), #f0eaff 58%, #ffe6df); }

.fallback-art {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(29, 66, 245, 0.45);
  font-family: "Newsreader", serif;
  font-size: 52px;
}

.fallback-art::before, .fallback-art::after {
  position: absolute;
  border: 1px solid currentColor;
  border-radius: 50%;
  content: "";
}
.fallback-art::before { width: 62%; height: 62%; }
.fallback-art::after { width: 38%; height: 38%; }

.card-top {
  position: absolute;
  inset: 11px 11px auto;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 180ms ease;
}

.card-number {
  border-radius: 999px;
  background: rgba(18, 19, 25, 0.58);
  color: white;
  font-family: "DM Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
  padding: 6px 8px;
  backdrop-filter: blur(9px);
}

.favorite-button {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #4e515b;
  cursor: pointer;
  backdrop-filter: blur(9px);
}

.favorite-button svg { width: 14px; height: 14px; }
.favorite-button.is-favorite { color: var(--coral); }
.favorite-button.is-favorite svg { fill: currentColor; }

.card-copy {
  position: absolute;
  inset: auto 15px 14px;
  z-index: 3;
  color: white;
  opacity: 0;
  transform: translateY(7px);
  transition: opacity 180ms ease, transform 220ms ease;
}

.card-copy strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-copy span { display: block; color: rgba(255,255,255,.7); font-size: 9px; margin-top: 4px; }

.gallery-card:hover::after, .gallery-card:focus-visible::after,
.gallery-card:hover .card-top, .gallery-card:focus-visible .card-top,
.gallery-card:hover .card-copy, .gallery-card:focus-visible .card-copy { opacity: 1; }
.gallery-card:hover .card-copy, .gallery-card:focus-visible .card-copy { transform: translateY(0); }
.gallery-card:hover img { transform: scale(1.035); }

.gallery-card:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(29, 66, 245, 0.34);
  outline-offset: 3px;
}

.loading-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.loading-grid i {
  aspect-ratio: .82;
  border-radius: 15px;
  background: linear-gradient(100deg, #e9eaf0 20%, #f6f7fa 38%, #e9eaf0 56%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
.loading-grid i:nth-child(2), .loading-grid i:nth-child(5) { aspect-ratio: 1; }
.loading-grid[hidden] { display: none; }

.empty-state {
  border: 1px dashed #ccd0dc;
  border-radius: var(--radius);
  padding: 70px 24px;
  text-align: center;
}
.empty-state span { color: var(--blue); font-family: "Newsreader", serif; font-size: 60px; }
.empty-state h3 { margin: 7px 0 6px; font-size: 22px; }
.empty-state p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.empty-state button { border: 0; border-radius: 10px; background: var(--ink); color: white; cursor: pointer; padding: 10px 15px; }

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  color: #9a9da6;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  padding: 22px clamp(22px, 4vw, 58px);
}
.footer p { margin: 0; }
.footer span { margin-left: 5px; }

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  border: 0;
  background: rgba(12, 13, 17, 0.83);
  color: white;
  margin: 0;
  padding: 20px;
  backdrop-filter: blur(24px);
}
.lightbox::backdrop { background: rgba(12, 13, 17, 0.78); }
.lightbox[open] { display: grid; place-items: center; animation: fade-in 180ms ease; }

.lightbox-panel {
  display: grid;
  width: min(1180px, calc(100vw - 40px));
  height: min(850px, calc(100dvh - 40px));
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px;
  background: #181a20;
  box-shadow: 0 35px 100px rgba(0,0,0,.45);
}

.lightbox-head {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  padding: 14px 18px 14px 22px;
}
.lightbox-head > div:first-child { min-width: 0; }
.lightbox-head h2 { max-width: 600px; overflow: hidden; font-size: 15px; margin: 2px 0 1px; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-head p { color: #8f939e; font-size: 10px; margin: 0; }
.lightbox-index { color: #6f87ff; font-family: "DM Mono", monospace; font-size: 8px; letter-spacing: .14em; text-transform: uppercase; }

.lightbox-actions { display: flex; align-items: center; gap: 8px; }
.round-button { width: 38px; height: 38px; flex: 0 0 auto; background: rgba(255,255,255,.08); color: #dfe1e7; }
.round-button:hover { background: rgba(255,255,255,.14); }
.round-button svg { width: 17px; height: 17px; }
.open-canva { border-radius: 10px; background: white; color: var(--ink); font-size: 11px; font-weight: 700; padding: 11px 14px; text-decoration: none; }
.open-canva span { color: var(--blue); margin-left: 4px; }

.preview-stage { position: relative; display: grid; place-items: center; overflow: hidden; background: #0e0f13; }
.preview-stage::before { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 32px 32px; content: ""; }
.preview-stage iframe, .preview-stage > img { position: relative; z-index: 1; width: min(88%, 850px); height: calc(100% - 42px); border: 0; border-radius: 10px; background: #202228; object-fit: contain; }
.preview-stage > img { display: none; }
.preview-stage.is-fallback iframe { display: none; }
.preview-stage.is-fallback > img { display: block; }

.preview-loader { position: absolute; z-index: 0; display: flex; align-items: center; gap: 10px; color: #7c808b; font-size: 10px; }
.preview-loader i { width: 16px; height: 16px; border: 2px solid #333641; border-top-color: #7d91ff; border-radius: 50%; animation: spin .8s linear infinite; }
.preview-loader.is-done { display: none; }

.stage-arrow {
  position: absolute;
  z-index: 3;
  top: 50%;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  transform: translateY(-50%);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  background: rgba(22,24,29,.78);
  color: white;
  cursor: pointer;
  backdrop-filter: blur(10px);
}
.stage-arrow:hover { background: var(--blue); border-color: var(--blue); }
.stage-arrow.previous { left: 18px; }
.stage-arrow.next { right: 18px; }

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  transform: translateY(20px);
  border-radius: 12px;
  background: var(--ink);
  box-shadow: var(--shadow);
  color: white;
  font-size: 11px;
  opacity: 0;
  padding: 12px 16px;
  pointer-events: none;
  transition: 180ms ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position-x: -200%; } }
@keyframes fade-in { from { opacity: 0; } }

@media (max-width: 1180px) {
  .gallery.mosaic { column-count: 3; }
  .gallery.grid, .loading-grid { grid-template-columns: repeat(3, 1fr); }
  .hero { grid-template-columns: 1fr; gap: 30px; }
  .hero-stats { width: auto; max-width: 280px; border-left: 0; border-top: 1px solid var(--line); padding: 20px 0 0; }
}

@media (max-width: 840px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .topbar { height: auto; min-height: 74px; flex-wrap: wrap; padding-top: 13px; padding-bottom: 13px; }
  .mobile-brand { display: inline-flex; }
  .search-box { order: 3; width: 100%; }
  .hero { min-height: 360px; padding-top: 48px; padding-bottom: 48px; }
  .collection-head { align-items: flex-start; flex-direction: column; }
  .filter-row { justify-content: flex-start; }
  .lightbox-panel { width: calc(100vw - 24px); height: calc(100dvh - 24px); }
  .lightbox { padding: 12px; }
}

@media (max-width: 620px) {
  .view-switch { display: none; }
  .sync-button span { display: none; }
  .sync-button { width: 40px; height: 40px; justify-content: center; padding: 0; }
  .top-actions { margin-left: auto; }
  .hero { min-height: 330px; padding-top: 46px; padding-bottom: 46px; }
  .hero h1 { font-size: clamp(54px, 17vw, 76px); }
  .hero-description { font-size: 13px; }
  .hero-stats { display: none; }
  .collection { padding-top: 40px; }
  .gallery.mosaic { column-count: 2; column-gap: 9px; }
  .gallery.grid, .loading-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .gallery-card { border-radius: 11px; margin-bottom: 9px; }
  .card-copy { inset: auto 10px 10px; }
  .card-top { inset: 8px 8px auto; }
  .collection-head { margin-bottom: 22px; }
  .filter-row { width: calc(100vw - 44px); overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .filter-chip { white-space: nowrap; }
  .lightbox-head { min-height: 70px; padding: 12px; }
  .lightbox-head h2 { max-width: 44vw; font-size: 12px; }
  .lightbox-head p { display: none; }
  .open-canva { font-size: 0; padding: 11px 13px; }
  .open-canva span { font-size: 14px; margin: 0; }
  .lightbox-actions .round-button:first-child { display: none; }
  .preview-stage iframe, .preview-stage > img { width: calc(100% - 22px); height: calc(100% - 70px); }
  .stage-arrow { top: auto; bottom: 10px; transform: none; width: 40px; height: 40px; }
  .stage-arrow.previous { left: calc(50% - 48px); }
  .stage-arrow.next { right: calc(50% - 48px); }
  .footer { align-items: flex-start; flex-direction: column; gap: 7px; }
}

@media (hover: none) {
  .gallery-card::after { opacity: .72; background: linear-gradient(to top, rgba(14,16,24,.68), transparent 42%); }
  .gallery-card .card-copy { opacity: 1; transform: none; }
  .gallery-card .card-top { opacity: 1; }
  .gallery-card .card-number { display: none; }
}

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