:root {
  --bg: #f7f5f0;
  --card: #fff;
  --ink: #1c1917;
  --muted: #57534e;
  --accent: #b45309;
  --border: #e7e5e4;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.header-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

.header-qr-wrap {
  flex: 0 0 auto;
  margin-left: auto;
}

.header-qr-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.72rem;
  max-width: 100px;
  text-align: center;
  line-height: 1.2;
}

.header-qr-link:hover .header-qr-label {
  color: var(--ink);
}

.header-qr-link canvas,
.header-qr-link .header-qr-img {
  display: block;
  border: 1px solid #a8a29e;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(28, 25, 23, 0.08);
}

.header-qr-label {
  display: block;
}

.logo-link {
  display: inline-block;
  line-height: 0;
  text-decoration: none;
  color: inherit;
}

.logo-link:hover .logo,
.logo-link:focus-visible .logo {
  opacity: 0.9;
}

.logo-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.logo {
  max-width: 250px;
  width: 100%;
  height: auto;
  display: block;
}

.header-text h1 {
  margin: 0 0 0.25rem;
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-name label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.form-name input[type="text"] {
  width: 100%;
  max-width: 320px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.btn, button[type="submit"] {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.45rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

.btn.secondary {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--border);
  margin-top: 0;
  margin-right: 0.5rem;
}

.upload-row {
  margin-top: 0.5rem;
}

.welcome {
  margin: 0 0 0.75rem;
}

.error {
  color: #b91c1c;
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.status {
  margin: 0.75rem 0 0;
  min-height: 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

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

.gallery figure {
  margin: 0;
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #e7e5e4;
  border-radius: 3px;
  cursor: pointer;
}

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

.gallery figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.35rem 0.45rem;
  font-size: 0.68rem;
  background: rgba(28, 25, 23, 0.82);
  color: #fafaf9;
  line-height: 1.25;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

#gallery-empty {
  margin-top: 0.5rem;
}

[hidden] { display: none !important; }

.footer {
  text-align: center;
  padding: 2rem 1rem;
  border-top: 1px solid var(--border);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 2rem;
  line-height: 1;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
}
