:root {
  --cream: #FBF3EE; --card: #ffffff; --brown: #594C40; --brown-2: #6d5e50;
  --gold: #BFA06A; --gold-2: #D4AF37; --ink: #33291F; --muted: #8a7c6d;
  --line: #ece0d5; --ok: #2e7d32; --warn: #b26a00; --err: #b3261e;
  --shadow: 0 1px 3px rgba(89,76,64,.08), 0 8px 24px rgba(89,76,64,.06);
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; } /* no accidental horizontal scroll/zoom */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink);
  font-family: "Lora", Georgia, serif;
  background: linear-gradient(180deg, #fff8f3 0%, var(--cream) 100%);
  min-height: 100vh;
}
h1, h2, h3, .brand { font-family: "Cormorant Garamond", Georgia, serif; letter-spacing: .2px; }

/* Header */
#topbar {
  padding: 10px clamp(14px, 4vw, 32px); padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brown); color: var(--cream);
  position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 12px rgba(0,0,0,.12);
}
.bar-top { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--cream); text-decoration: none;
  font-size: 22px; font-weight: 700; white-space: nowrap; flex: 0 0 auto; }
.brand span { color: var(--gold-2); }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; }
/* Truncate the email so it can never push the header past the viewport */
#who { margin-left: auto; font-size: 12.5px; opacity: .9; min-width: 0;
  max-width: 56vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
#who a { color: var(--gold-2); }
/* Nav: one horizontal row; scrolls sideways if it can't fit rather than wrapping/overflowing */
#nav { display: flex; gap: 6px; margin-top: 8px; flex-wrap: nowrap;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
#nav::-webkit-scrollbar { display: none; }
#nav a { color: var(--cream); text-decoration: none; opacity: .85; font-family: "Lora", serif;
  font-size: 14.5px; padding: 6px 14px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto;
  transition: background .15s, opacity .15s; }
#nav a:hover { opacity: 1; background: rgba(255,255,255,.1); }
#nav a.active { opacity: 1; background: var(--gold); color: var(--brown); font-weight: 600; }

main { max-width: 860px; margin: 0 auto; padding: clamp(16px, 3vw, 28px); }
h1 { font-size: 30px; font-weight: 600; margin: 6px 0 18px; }
h3 { font-size: 20px; margin: 0 0 10px; }
.muted { color: var(--muted); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; margin: 16px 0; box-shadow: var(--shadow); }

/* Forms */
label { display: block; margin: 14px 0 5px; font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px; color: var(--brown-2); }
input, select {
  font-family: "Lora", serif; font-size: 16px; padding: 12px 14px;
  border: 1px solid #dccfc2; border-radius: 10px; width: 100%; background: #fffdfb; color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(191,160,106,.2); }

/* Buttons */
button {
  font-family: "Lora", serif; background: var(--brown); color: var(--cream); border: 0;
  border-radius: 12px; padding: 13px 22px; font-size: 16px; cursor: pointer;
  transition: transform .05s, box-shadow .15s, background .15s; box-shadow: var(--shadow);
}
button:hover { background: #4c4136; }
button:active { transform: translateY(1px); }
button.secondary { background: var(--gold); color: var(--brown); font-weight: 600; }
button.ghost { background: transparent; color: var(--brown); box-shadow: none; border: 1px solid #dccfc2; padding: 9px 16px; font-size: 14px; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* Scanner */
#video { width: 100%; border-radius: 16px; background: #000; aspect-ratio: 3/4; object-fit: cover;
  transition: box-shadow .15s ease; box-shadow: var(--shadow); }
#video.flash-ok  { box-shadow: 0 0 0 6px var(--ok); }
#video.flash-dup { box-shadow: 0 0 0 6px var(--warn); }
#video.flash-err { box-shadow: 0 0 0 6px var(--err); }
.result { padding: 14px 16px; border-radius: 12px; margin-top: 14px; font-weight: 600; background: #f4ece4; }
.result.ok  { background: #e6f4ea; color: var(--ok); }
.result.dup { background: #fff3e0; color: var(--warn); }
.result.err { background: #fdecea; color: var(--err); }

/* Stats + tables */
.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat { flex: 1 1 130px; background: #fffdfb; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-family: "Cormorant Garamond", serif; font-size: 34px; font-weight: 700; color: var(--brown); line-height: 1; }
.stat span { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 8px; border-bottom: 2px solid var(--line);
  font-family: "Lora", serif; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
a.maplink, a.place { color: var(--brown); }
.center { text-align: center; }
.pill { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: #f0e7dd; color: var(--brown-2); }
/* Big, legible code to copy onto a flier by hand */
.fieldcode { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: clamp(38px, 12vw, 60px);
  font-weight: 700; letter-spacing: 6px; color: var(--brown); margin: 12px 0 6px; word-break: break-all; }
