:root {
  color-scheme: dark;
  --header-space: calc(3.25rem + env(safe-area-inset-top));
  --footer-space: calc(3.75rem + env(safe-area-inset-bottom));
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic",
    sans-serif;
  background: #111;
  color: #f5f5f5;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: #111;
  touch-action: manipulation;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

button {
  font: inherit;
}

.site-header {
  position: fixed;
  z-index: 10;
  top: 0;
  right: 0;
  left: 0;
  padding: calc(0.7rem + env(safe-area-inset-top)) 1rem 0.7rem;
  background: linear-gradient(#111 70%, transparent);
  pointer-events: none;
}

.site-header h1 {
  max-width: 72rem;
  margin: 0 auto;
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-align: center;
}

.gallery {
  display: flex;
  min-height: 100dvh;
  padding: var(--header-space) 1rem var(--footer-space);
  align-items: center;
  justify-content: center;
}

.gallery-shell {
  position: relative;
  display: grid;
  width: min(100%, 72rem);
  height: calc(100dvh - var(--header-space) - var(--footer-space) - 1rem);
  min-height: 0;
  margin: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
}

.gallery-meta {
  position: relative;
  z-index: 4;
  display: flex;
  width: min(100%, 60rem);
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  margin-bottom: 0.35rem;
  padding: 0 0.5rem;
}

.image-counter,
.nav-hint {
  margin: 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: clamp(0.68rem, 1.5vw, 0.78rem);
  line-height: 1.35;
}

.image-counter {
  min-width: 0;
  color: rgba(255, 255, 255, 0.86);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.nav-hint {
  text-align: center;
}

.image-stage {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.25rem 0;
  place-items: center;
}

.food-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 0.2rem;
  object-fit: contain;
  opacity: 1;
  transition: opacity 120ms ease-out;
}

.food-image.is-loading {
  opacity: 0.45;
}

.navigation-zone {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 5.8rem;
  width: 50%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.navigation-zone--previous {
  left: 0;
}

.navigation-zone--next {
  right: 0;
}

.prompt-panel {
  position: relative;
  z-index: 4;
  width: min(100%, 60rem);
  flex: 0 0 auto;
  margin-top: 0.55rem;
  padding: 0 0.5rem;
}

.prompt-copy {
  display: block;
  width: 100%;
  min-height: 3.55rem;
  padding: 0.65rem 0.8rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  font-size: clamp(0.72rem, 1.5vw, 0.85rem);
  line-height: 1.45;
  text-align: left;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.prompt-copy span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.prompt-copy:disabled {
  cursor: wait;
  opacity: 0.55;
}

.prompt-copy:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.13);
}

.prompt-copy:focus-visible,
.navigation-zone:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

.site-footer {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, #111 30%);
  color: rgba(255, 255, 255, 0.65);
  font-size: clamp(0.68rem, 1.8vw, 0.78rem);
  letter-spacing: 0.02em;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}

.copy-status {
  position: fixed;
  z-index: 20;
  bottom: calc(var(--footer-space) + 0.5rem);
  left: 50%;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(245, 245, 245, 0.94);
  color: #111;
  font-size: 0.78rem;
  transform: translateX(-50%);
}

.error-message {
  position: fixed;
  top: 50%;
  left: 50%;
  max-width: min(32rem, calc(100% - 2rem));
  margin: 0;
  color: #ffb4b4;
  font-size: 0.9rem;
  text-align: center;
  transform: translate(-50%, -50%);
}

@media (max-width: 40rem) {
  :root {
    --header-space: calc(2.9rem + env(safe-area-inset-top));
    --footer-space: calc(3.4rem + env(safe-area-inset-bottom));
  }

  .gallery {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
  }

  .gallery-shell {
    height: calc(100dvh - var(--header-space) - var(--footer-space) - 0.5rem);
    grid-template-rows: auto auto auto;
    align-content: center;
  }

  .image-stage {
    width: 100%;
    height: auto;
    max-height: 60dvh;
    aspect-ratio: 3 / 2;
  }

  .prompt-panel {
    padding: 0 0.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .food-image {
    transition: none;
  }
}
