:root {
  --bg: #f3efe7;
  --bg-accent: #e4dccf;
  --surface: rgba(255, 252, 246, 0.82);
  --surface-strong: #fffaf2;
  --text: #201913;
  --muted: #6b5c4f;
  --line: rgba(32, 25, 19, 0.08);
  --shadow: 0 18px 50px rgba(68, 50, 29, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 999px;
  --chip: #ebe2d1;
  --chip-active: #201913;
  --chip-active-text: #fff8ee;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

html,
body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at top left, rgba(216, 188, 137, 0.35), transparent 26%),
    radial-gradient(circle at bottom right, rgba(112, 152, 182, 0.22), transparent 26%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(22px + env(safe-area-inset-bottom));
}

.hero {
  padding: 22px 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(255, 250, 242, 0.92), rgba(238, 229, 213, 0.78));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.hero h1 {
  margin: 10px 0 0;
  font-size: 34px;
  line-height: 1.05;
}

.hero-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.hero-stats {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.stat-card strong {
  font-size: 20px;
}

.toolbar,
.category-section,
.summary {
  margin-top: 14px;
}

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

.source-toggle,
.view-toggle,
.sort-box,
.summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}

.source-toggle,
.view-toggle {
  display: inline-flex;
  align-items: stretch;
  width: 100%;
  padding: 4px;
  gap: 4px;
}

.toggle-button {
  flex: 1 1 0;
  border: 0;
  min-width: 0;
  padding: 0 14px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.toggle-button.active {
  background: var(--chip-active);
  color: var(--chip-active-text);
}

.sort-box {
  padding: 8px 12px;
}

.sort-box label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.sort-box select {
  width: 100%;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.sort-box select:disabled {
  color: var(--muted);
  opacity: 1;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 0;
  background: var(--chip);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1;
}

.chip.active {
  background: var(--chip-active);
  color: var(--chip-active-text);
}

.summary {
  padding: 14px 16px;
  color: var(--muted);
  font-size: 13px;
}

.gallery-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.gallery-grid.double-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gallery-card {
  border: 0;
  text-align: left;
  background: var(--surface-strong);
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 250, 244, 0.85);
  box-shadow: 0 16px 38px rgba(56, 40, 23, 0.11);
  padding: 0;
}

.gallery-thumb {
  width: 100%;
  aspect-ratio: 1 / 1.08;
  object-fit: cover;
  display: block;
  background: #e9dfd0;
  opacity: 0;
  transition: opacity 0.24s ease;
}

.gallery-grid:not(.double-column) .gallery-thumb {
  aspect-ratio: auto;
  height: auto;
  max-height: none;
  object-fit: contain;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.14), transparent 40%),
    #101114;
}

.gallery-grid:not(.double-column) .gallery-thumb:not(.loaded) {
  aspect-ratio: 4 / 3;
}

.gallery-thumb.loaded {
  opacity: 1;
}

.hidden {
  display: none !important;
}

.empty-state {
  margin-top: 24px;
  padding: 40px 16px;
  text-align: center;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--muted);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(14, 10, 8, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
}

.lightbox-figure {
  width: 100%;
  max-width: 820px;
  margin: 0;
}

.lightbox-figure img {
  width: 100%;
  max-height: 74vh;
  object-fit: contain;
  display: block;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.08);
}

.lightbox figcaption {
  margin-top: 12px;
  color: #f5ede2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.lightbox figcaption strong {
  font-size: 18px;
  font-weight: 700;
}

.lightbox-number-group {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.copy-number-button {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 0;
  border-radius: 50%;
  color: #f5ede2;
  background: rgba(255, 255, 255, 0.14);
}

.copy-number-button::before,
.copy-number-button::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 2px;
}

.copy-number-button::before { left: 9px; top: 7px; }
.copy-number-button::after { left: 13px; top: 11px; background: #332a24; }
.copy-number-button.copied::after { content: "✓"; width: auto; height: auto; border: 0; left: 10px; top: 5px; background: transparent; font-size: 20px; }
.copy-number-button.copied::before { display: none; }

.lightbox-order-button {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #17110d;
  background: #f4c85a;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.lightbox-order-button:active {
  transform: translateY(1px);
  background: #e9b93f;
}

.icon-button {
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: white;
  font-size: 28px;
}

.close-button {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 14px;
}

.nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.prev-button {
  left: 10px;
}

.next-button {
  right: 10px;
}

@media (max-width: 620px) {
  .toolbar {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .toggle-button {
    min-width: auto;
    padding: 0 12px;
  }

  .lightbox figcaption strong {
    font-size: 18px;
  }
}

@media (min-width: 620px) {
  .page-shell {
    padding-left: 20px;
    padding-right: 20px;
  }
}
