:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1d1a17;
  --muted: #6b645c;
  --line: #e7e1d8;
  --accent: #d6453d;
  --accent-ink: #ffffff;
  --accent-soft: #fdeceb;
  --danger: #b3261e;
  --ok: #2f7d4f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 26, 23, .05), 0 8px 24px -12px rgba(29, 26, 23, .18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130f; --surface: #1f1c17; --ink: #f3eee6; --muted: #a59c90; --line: #332e27;
    --accent-soft: #3a1f1d; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.danger-text { color: var(--danger); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
.narrow { max-width: 420px; margin: 40px auto; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.brand { text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-size: .95rem; }
.top nav { display: flex; align-items: center; gap: 16px; }
.top nav a { text-decoration: none; font-weight: 500; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px; border-top: 1px solid var(--line); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .08s ease, box-shadow .15s ease; }
.button:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.button.small { padding: 7px 13px; font-size: .875rem; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.link.danger { color: var(--danger); }
.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.actions.center { justify-content: center; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.flash.error { background: var(--accent-soft); color: var(--danger); border: 1px solid var(--danger); }
.flash.notice { background: #e8f5ec; color: var(--ok); border: 1px solid var(--ok); }
.empty { text-align: center; padding: 48px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.sticky { position: sticky; top: 80px; align-self: start; }

.hero { padding: 48px 0 32px; max-width: 760px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; color: var(--accent); font-weight: 700; }
.lead { font-size: 1.125rem; color: var(--muted); }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.demo { display: grid; grid-template-columns: 1fr 1.4fr; gap: 32px; align-items: center; margin: 48px 0; }
@media (max-width: 720px) { .demo { grid-template-columns: 1fr; } }
.phone { border: 8px solid #222; border-radius: 32px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); max-width: 300px; margin: 0 auto; }
.phone-banner { background: var(--danger); color: #fff; font-weight: 700; padding: 14px; font-size: 1.05rem; }
.phone-body { padding: 16px; font-size: .95rem; line-height: 1.7; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface); margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .95rem; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font-size: .9rem; font-weight: 500; width: auto; cursor: pointer; }
.chip input { width: auto; margin: 0; accent-color: var(--accent); }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.chips.static .chip { cursor: default; }
.rows { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.row { display: grid; grid-template-columns: 1.2fr 1fr 1.4fr 1.4fr auto; gap: 8px; align-items: center; }
@media (max-width: 720px) { .row { grid-template-columns: 1fr 1fr; } .row .remove { grid-column: span 2; justify-self: end; } }
.danger-zone { margin-top: 32px; text-align: right; }
.add-row { margin-top: 4px; }

.person-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: .8rem; font-weight: 600; }
.pill.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.plain { list-style: none; padding: 0; margin: 0 0 8px; }
.plain li { padding: 4px 0; }
.qr { border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 8px; }
.share-url { margin: 12px 0 4px; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.table.compact td { padding: 8px 6px; font-size: .95rem; }

.styles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.style-option { align-items: center; text-align: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-size: .85rem; }
.style-option input { position: absolute; opacity: 0; }
.style-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.swatch { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 16px; }
.swatch img { width: 56px; height: 56px; border-radius: 6px; }
.swatch-matte_black { background: #1e1e1e; }
.swatch-brushed_steel { background: linear-gradient(135deg, #cfd2d6, #8f959b); }
.swatch-medical_red { background: #c8102e; }
.swatch-clear_acrylic { background: linear-gradient(135deg, #e9f3ff, #c8dcf0); }
.swatch-bamboo { background: #d9b382; }
.swatch-silicone_bright { background: linear-gradient(135deg, #ffb703, #fb8500); }
.tag-preview { display: inline-grid; gap: 6px; place-items: center; background: #1e1e1e; color: #ddd; padding: 18px 18px 12px; border-radius: 22px; }
.tag-preview img { width: 160px; height: 160px; border-radius: 10px; }
.tag-mark { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; }

/* Public card — the page a stranger sees after scanning */
body.public { background: var(--bg); }
.pub { max-width: 560px; margin: 0 auto; }
.pub-brand { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.pub-head { padding: 8px 0 16px; display: flex; flex-direction: column; gap: 4px; }
.pub-head h1 { font-size: 2rem; margin: 0; }
.pub-head .pill { align-self: flex-start; }
.pub-danger { background: var(--danger); color: #fff; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; font-size: 1.05rem; }
.pub-danger h2 { color: #fff; margin-bottom: 8px; }
.pub-danger .pill { background: #fff; color: var(--danger); border-color: #fff; }
.pub-allergy { padding: 8px 0; border-top: 1px solid rgba(255,255,255,.3); }
.pub-allergy strong { font-size: 1.2rem; }
.pub-treat { font-weight: 700; }
.pub-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.pub-section h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 10px; }
.pub-contact { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 8px; border-radius: 12px; background: var(--bg); text-decoration: none; }
.pub-phone { font-weight: 700; color: var(--accent); white-space: nowrap; }
.pub-lock { text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.inline-form { display: flex; gap: 8px; max-width: 320px; margin: 12px auto; }
.pub-foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px 0; }

/* Printable wallet card */
.print-sheet { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.wallet-card { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.wallet-front, .wallet-back { width: 85.6mm; height: 54mm; border-radius: 3mm; border: 1px solid var(--line); background: #fff; color: #111; padding: 5mm; display: flex; flex-direction: column; gap: 1.5mm; overflow: hidden; }
.wallet-title { font-size: 8pt; letter-spacing: .12em; text-transform: uppercase; color: #d6453d; font-weight: 700; }
.wallet-name { font-size: 15pt; font-weight: 700; }
.wallet-alert { background: #b3261e; color: #fff; padding: 1.5mm 2.5mm; border-radius: 1.5mm; font-weight: 700; font-size: 9pt; }
.wallet-line { font-size: 8pt; }
.wallet-back { align-items: center; justify-content: center; }
.wallet-back img { width: 34mm; height: 34mm; }
.wallet-url { font-size: 6.5pt; font-family: ui-monospace, monospace; }
@media print {
  .top, .foot, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; }
  .wallet-front, .wallet-back { box-shadow: none; }
}
