:root {
  color-scheme: dark;
  --bg: #11100d;
  --surface: #1a1813;
  --surface-raised: #242118;
  --surface-soft: #2d291f;
  --text: #f6f0e2;
  --muted: #a9a294;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #f3c653;
  --accent-strong: #ffd86d;
  --success: #78d6a3;
  --danger: #ff8d82;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 85% -10%, rgba(243, 198, 83, 0.13), transparent 36rem),
    linear-gradient(180deg, #17150f 0, var(--bg) 28rem);
}

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

button {
  font: inherit;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px max(20px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(17, 16, 13, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(243, 198, 83, 0.25);
  border-radius: 14px;
  color: #18140a;
  background: var(--accent);
  box-shadow: 0 8px 30px rgba(243, 198, 83, 0.18);
  font-size: 20px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.connection {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
}

main,
footer {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: end;
  padding: 72px 0 42px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: clamp(38px, 8vw, 76px);
  font-weight: 750;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.summary {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.55;
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 19px;
  border: 0;
  border-radius: 16px;
  color: #17130a;
  background: var(--accent);
  box-shadow: 0 12px 35px rgba(243, 198, 83, 0.16);
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.refresh-button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.refresh-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.refresh-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.refresh-button.loading svg {
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.status-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 46px;
  padding: 18px;
  border: 1px solid rgba(120, 214, 163, 0.16);
  border-radius: 18px;
  background: rgba(120, 214, 163, 0.06);
}

.status-card.error {
  border-color: rgba(255, 141, 130, 0.18);
  background: rgba(255, 141, 130, 0.07);
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(120, 214, 163, 0.1);
}

.status-card.error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(255, 141, 130, 0.1);
}

.status-card strong {
  font-size: 14px;
}

.status-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.gallery-section {
  padding: 10px 0 70px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: -0.035em;
}

.count-badge {
  min-width: max-content;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
}

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

.photo-card {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  cursor: zoom-in;
  aspect-ratio: 0.72;
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 260ms ease, filter 260ms ease;
}

.photo-card:hover img {
  transform: scale(1.018);
  filter: brightness(1.04);
}

.photo-number {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(17, 16, 13, 0.78);
  backdrop-filter: blur(12px);
  font-size: 12px;
  font-weight: 750;
}

.empty-state {
  padding: 60px 20px;
  border: 1px dashed var(--line);
  border-radius: 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.018);
}

.empty-icon {
  margin-bottom: 14px;
  font-size: 42px;
}

.empty-state h2 {
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0 38px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.viewer[hidden],
.toast[hidden] {
  display: none;
}

.viewer {
  position: fixed;
  z-index: 100;
  inset: 0;
}

.viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(16px);
}

.viewer-panel {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: auto 1fr;
}

.viewer-toolbar {
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px 18px;
  color: #fff;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent);
  font-size: 13px;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.viewer-actions a {
  color: #fff;
  font-size: 12px;
  text-decoration: none;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0 0 4px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 28px;
  cursor: pointer;
}

.viewer-stage {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  padding: 0 60px 22px;
}

.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.55);
  touch-action: pan-y pinch-zoom;
}

.viewer-nav {
  position: absolute;
  z-index: 2;
  top: 50%;
  display: grid;
  width: 44px;
  height: 54px;
  padding: 0 0 5px;
  place-items: center;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 15px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 38px;
  cursor: pointer;
}

.viewer-nav:disabled {
  opacity: 0.22;
  cursor: default;
}

.viewer-prev { left: 12px; }
.viewer-next { right: 12px; }

.toast {
  position: fixed;
  z-index: 150;
  right: 20px;
  bottom: 20px;
  max-width: min(390px, calc(100vw - 40px));
  padding: 14px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface-soft);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.error {
  border-color: rgba(255, 141, 130, 0.35);
}

@media (max-width: 760px) {
  .topbar {
    min-height: 64px;
    padding-inline: 16px;
  }

  .connection {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  main,
  footer {
    width: min(100% - 28px, 1120px);
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 52px 0 34px;
  }

  .refresh-button {
    width: 100%;
  }

  .status-card {
    margin-bottom: 32px;
  }

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

  .photo-card {
    border-radius: 15px;
  }

  footer {
    flex-direction: column;
    gap: 7px;
  }

  .viewer-stage {
    padding: 0 0 18px;
  }

  .viewer-nav {
    top: auto;
    bottom: 24px;
    background: rgba(0, 0, 0, 0.6);
  }

  .viewer-prev { left: 18px; }
  .viewer-next { right: 18px; }
}

@media (max-width: 390px) {
  .brand small {
    display: none;
  }

  .gallery {
    grid-template-columns: 1fr;
  }

  .photo-card {
    aspect-ratio: 0.78;
  }
}

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