:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --text: #24211d;
  --muted: #6d675f;
  --line: #ddd7cd;
  --accent: #24211d;
  --on-accent: #ffffff;
  --viewer: #e9e4db;
  --warn: #9a3412;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18;
    --surface: #282623;
    --text: #f2eee7;
    --muted: #a8a196;
    --line: #3d3a35;
    --accent: #f2eee7;
    --on-accent: #1b1a18;
    --viewer: #111110;
    --warn: #fdba74;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button, input, label { font: inherit; color: inherit; }
button { touch-action: manipulation; }

/* Start screen */
#start {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}
.start-inner { width: 100%; max-width: 420px; text-align: center; }
h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 12px; letter-spacing: -0.02em; }
.start-inner > p:first-of-type { color: var(--muted); margin: 0 0 28px; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 14px 0 0; }

.primary {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 1.0625rem;
  text-align: center;
  cursor: pointer;
}
.primary:disabled, .primary.disabled { opacity: 0.45; pointer-events: none; }

.secondary {
  display: block;
  width: 100%;
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.9375rem;
  cursor: pointer;
}
.secondary:disabled { opacity: 0.6; }

/* Review screen: fills the phone, photo takes the spare height */
#review {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
}
#count { font-weight: 600; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.9375rem;
  cursor: pointer;
}

.viewer { position: relative; flex: 1 1 0; min-height: 180px; background: var(--viewer); }
.strip {
  position: absolute;
  inset: 0;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: grid;
  place-items: center;
}
.slide { position: relative; }
.slide img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.slide-wait, .slide-error { color: var(--muted); margin: 0; padding: 16px; text-align: center; }
.slide-error { color: var(--warn); }

.nav {
  position: absolute;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.nav:disabled { display: none; }
.prev { left: 8px; }
.next { right: 8px; }
@media (pointer: coarse) { .nav { display: none; } }

.note, .warn { margin: 0; padding: 6px 16px 0; font-size: 0.8125rem; color: var(--muted); text-align: center; min-height: 1.6em; }
.warn { color: var(--warn); }

.controls {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 16px;
  padding: 6px 16px 10px;
}
.label { display: block; font-size: 0.8125rem; color: var(--muted); margin-bottom: 4px; }
.label output { color: var(--text); font-variant-numeric: tabular-nums; }

.spots, .segments {
  display: grid;
  gap: 4px;
}
.spots { grid-template-columns: repeat(3, 1fr); }
.segments { grid-template-columns: repeat(3, 1fr); }
.spots button, .segments button {
  min-height: 44px;
  padding: 0 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  font-size: 0.875rem;
  cursor: pointer;
}
.spots .auto { font-size: 0.75rem; }
[aria-pressed="true"] {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: var(--on-accent);
}

.size { display: block; margin-top: 10px; }
.size input { width: 100%; height: 32px; margin: 0; accent-color: var(--accent); }

.savebar { padding: 0 16px calc(12px + env(safe-area-inset-bottom)); }
.busy { margin: 0 0 6px; font-size: 0.8125rem; color: var(--muted); text-align: center; }
