:root {
  --paper: #f4efe6;
  --card: #fffdf8;
  --ink: #241c16;
  --muted: #6d6258;
  --line: #e4d9c8;
  --accent: #6e2f2a;
  --accent-dark: #542421;
  --note: #f6ead3;
  --danger: #8d2f2f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Segoe UI", system-ui, sans-serif;
  --shadow: 0 18px 40px rgba(36, 28, 22, 0.06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 50% -180px, rgba(110, 47, 42, 0.08), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

button, input, a { font: inherit; }

button, .ghost, .primary, .camera-btn {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.wrap {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 0 max(48px, env(safe-area-inset-bottom));
}

.host-wrap { width: min(880px, calc(100% - 32px)); }

.top { text-align: center; margin-bottom: 28px; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1, h2 { font-family: var(--serif); font-weight: 500; }

h1 {
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 4.2rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
}

h2 { margin: 0 0 14px; font-size: 1.7rem; }

.lede, .hint, .print-hint, .note {
  color: var(--muted);
}

.lede {
  margin: 14px auto 0;
  max-width: 28rem;
  font-size: 1.05rem;
}

.panel, .qr-sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.panel { padding: 22px 20px 20px; margin-bottom: 28px; }

.field {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

input[type="text"], input:not([type]), input[type="url"], #guest-name, #album-title, #album-subtitle, #public-url {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

.drop, .camera-btn {
  position: relative;
  display: flex;
  overflow: hidden;
}

.drop {
  margin-top: 16px;
  min-height: 148px;
  padding: 28px 18px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1.5px dashed #c9b8a2;
  border-radius: 16px;
  background: #fbf7f1;
  cursor: pointer;
}

.drop.hot {
  border-color: var(--accent);
  background: #f8efe9;
}

.drop input, .camera-btn input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-title {
  font-family: var(--serif);
  font-size: 1.45rem;
}

.drop-hint { margin-top: 6px; color: var(--muted); font-size: 0.92rem; }

.camera-btn {
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  color: var(--accent);
  font-weight: 600;
}

.picks {
  display: flex;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
}

.pick {
  position: relative;
  flex: 0 0 auto;
}

.pick img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--line);
}

.pick-x {
  position: absolute;
  top: 4px;
  right: 4px;
  border: 0;
  border-radius: 999px;
  padding: 2px 6px;
  background: rgba(36, 28, 22, 0.78);
  color: white;
  font-size: 0.68rem;
}

.primary, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  width: 100%;
  margin-top: 14px;
  border: 0;
  background: var(--accent);
  color: #fffdf8;
  font-weight: 600;
}

.primary:hover { background: var(--accent-dark); }
.primary:disabled { opacity: 0.45; cursor: default; }

.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.button-row .primary { width: auto; margin-top: 0; flex: 1 1 200px; }
.button-row .ghost { flex: 1 1 140px; }

.bar {
  height: 6px;
  margin-top: 14px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.status { min-height: 1.3em; margin: 10px 0 0; font-size: 0.95rem; }
.status.error { color: var(--danger); }
.status.ok { color: #2f6b4f; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-head p { margin: 0; color: var(--muted); }

.hint { margin: 0 0 14px; font-size: 0.92rem; }

.note {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--note);
  color: var(--ink);
}

.path {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.86em;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  cursor: pointer;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.tile-wrap { position: relative; }

.tile {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--line);
  cursor: pointer;
  aspect-ratio: 1;
}

.tile img, .unpreview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.unpreview {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.trash {
  position: absolute;
  top: 6px;
  right: 6px;
  border: 0;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(36, 28, 22, 0.78);
  color: white;
  font-size: 0.72rem;
}

.empty {
  margin: 8px 0 0;
  color: var(--muted);
}

.qr-sheet {
  margin-bottom: 22px;
  padding: 36px 22px 28px;
  text-align: center;
}

.qr-sheet img {
  width: min(100%, 360px);
  height: auto;
  margin-top: 8px;
}

.print-hint { margin: 8px 0 0; }

.url {
  margin: 10px 0 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92rem;
  word-break: break-all;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  background: rgba(20, 15, 12, 0.92);
  color: #fffdf8;
}

.lightbox[hidden] { display: none; }

.lightbox figure {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.lightbox img {
  max-width: min(92vw, 1100px);
  max-height: 78vh;
  object-fit: contain;
}

.lightbox figcaption {
  margin-top: 10px;
  color: rgba(255, 253, 248, 0.8);
  font-size: 0.92rem;
}

.lightbox-btn {
  z-index: 1;
  border: 0;
  background: transparent;
  color: #fffdf8;
  cursor: pointer;
  min-width: 64px;
  min-height: 48px;
}

.close { grid-column: 3; grid-row: 1; justify-self: end; margin: 8px 12px 0 0; }
.prev { grid-column: 1; grid-row: 2; }
.next { grid-column: 3; grid-row: 2; }
.remove { grid-column: 2; grid-row: 3; justify-self: center; color: #ffd2d2; }

@media (max-width: 640px) {
  .prev, .next { display: none; }
}

@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .wrap { width: auto; padding: 0; }
  .qr-sheet {
    box-shadow: none;
    border: 0;
  }
  .qr-sheet img { width: 320px; }
}
