:root {
  --paper: #F4EFEA;
  --ink: #321536;
  --accent: #6E3A78;
  --accent-06: rgba(110, 58, 120, 0.08);
  --accent-12: rgba(110, 58, 120, 0.16);
  --accent-45: rgba(110, 58, 120, 0.55);
  --plum: #4A2151;
  --pen: #8B768D;
  --pen-12: rgba(139, 118, 141, 0.18);
  --pen-30: rgba(139, 118, 141, 0.35);
  --lilac: #BFB3C3;
  --ink-18: rgba(50, 21, 54, 0.18);
  --ink-60: rgba(50, 21, 54, 0.65);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, .frn {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.page {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px clamp(20px, 4vw, 48px) 32px;
  overflow: hidden;
}

.content { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; }

/* Brand header */
.brandtext { display: flex; flex-direction: column; gap: 2px; }
.bt1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--plum);
}
.bt2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--pen);
}
.logomark { width: min(230px, 62vw); height: auto; margin-bottom: 26px; }
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: clamp(24px, 5vh, 56px);
}
.brand .loc {
  margin-left: auto;
  font-size: 16px;
  font-weight: 500;
  color: var(--pen);
  background: #fff;
  border: 1px solid var(--pen-30);
  padding: 6px 14px;
  border-radius: 999px;
}
button.locbtn {
  appearance: none;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
}
button.locbtn:hover { border-color: var(--accent-45); color: var(--accent); }
.locbtn .chev { font-size: 12px; }

a.pbtn { text-decoration: none; }
.pbtn.current {
  background: var(--accent-06);
  border-color: var(--accent-45);
  cursor: default;
}

/* Screens */
.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; }

.screen h1 { font-size: clamp(30px, 4.6vw, 44px); margin-bottom: 10px; }
.screen .sub { color: var(--ink-60); font-size: clamp(16px, 2vw, 19px); margin-bottom: clamp(22px, 4vh, 40px); }

/* Provider grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.pbtn {
  appearance: none;
  border: 1.5px solid var(--ink-18);
  background: #fff;
  border-radius: 16px;
  padding: 14px 20px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.pbtn:hover { background: var(--accent-06); border-color: var(--accent-45); }
.pbtn:active { transform: scale(0.985); background: var(--accent-12); }
.pbtn .nm { font-family: 'Playfair Display', Georgia, serif; font-size: 21px; font-weight: 500; display: block; color: var(--plum); }
.pbtn .rl { font-size: 16px; color: var(--ink-60); margin-top: 3px; display: block; }

/* Other-building section */
.altwrap { margin-top: clamp(28px, 5vh, 48px); }
.altrule {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.altrule::before, .altrule::after { content: ''; flex: 1; height: 1px; background: var(--pen-30); }
.altrule span { font-size: 16px; font-weight: 500; letter-spacing: 0.04em; color: var(--pen); }
.altnote { color: var(--ink-60); font-size: 16px; margin-bottom: 16px; text-align: center; }

/* Name screen */
.namebox { max-width: 560px; }
.namebox input[type="text"] {
  width: 100%;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--ink-18);
  border-radius: 16px;
  padding: 18px 22px;
  outline: none;
}
.namebox input[type="text"]:focus { border-color: var(--accent); }
.hp { position: absolute; left: -9999px; top: -9999px; height: 1px; width: 1px; overflow: hidden; }

.actions { display: flex; gap: 14px; margin-top: 22px; align-items: center; }
.cta {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 19px;
  font-weight: 600;
  border-radius: 999px;
  padding: 18px 40px;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.cta:disabled { opacity: 0.35; cursor: default; }
.cta:not(:disabled):active { transform: scale(0.98); }
.ghost {
  appearance: none;
  background: none;
  border: none;
  color: var(--ink-60);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  padding: 14px 18px;
}
.ghost:hover { color: var(--ink); }

.buildingnote {
  margin-top: 18px;
  font-size: 16px;
  color: var(--pen);
  background: #fff;
  border: 1px solid var(--pen-30);
  border-radius: 12px;
  padding: 12px 16px;
  max-width: 560px;
}
.buildingnote:empty { display: none; }

/* Done / fail screens */
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
#screen-done .center {
  background: var(--lilac);
  border-radius: 24px;
  margin: 0 calc(-1 * clamp(8px, 2vw, 24px));
  padding: clamp(32px, 8vh, 72px) 24px;
}

.center h1 { font-size: clamp(34px, 5vw, 52px); }
.center .sub { max-width: 640px; margin-bottom: 0; }

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.logomark.anim { animation: breathe 1.8s ease-in-out 2; }

/* Footer */
.foot {
  position: relative;
  z-index: 1;
  margin-top: 28px;
  font-size: 16px;
  color: var(--ink-60);
  text-align: center;
}

/* Settings page */
.settings { max-width: 640px; }
.settings h1 { font-size: clamp(28px, 4vw, 38px); margin-bottom: 8px; }
.settings .sub { margin-bottom: 28px; }
.prefrow {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1.5px solid var(--ink-18);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 14px;
}
.prefrow .lbl { flex: 1; }
.prefrow .lbl b { font-family: 'Playfair Display', Georgia, serif; font-size: 20px; font-weight: 500; display: block; color: var(--plum); }
.prefrow .lbl small { color: var(--ink-60); font-size: 16px; }

.switch { position: relative; width: 56px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--ink-18);
  border-radius: 999px;
  transition: background 0.15s ease;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(25, 22, 33, 0.25);
  transition: transform 0.15s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(24px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.destbox { margin: 4px 0 14px 8px; padding-left: 12px; border-left: 2px solid var(--pen-30); }
.destbox.hidden { display: none; }
.destopt { display: flex; gap: 12px; align-items: flex-start; padding: 10px 8px; border-radius: 10px; cursor: pointer; }
.destopt:hover { background: var(--accent-06); }
.destopt input { margin-top: 5px; accent-color: var(--accent); width: 18px; height: 18px; }
.destopt .lbl b { font-size: 16px; font-weight: 600; font-family: 'Poppins', sans-serif; display: block; }
.destopt .lbl small { color: var(--ink-60); font-size: 16px; }
.destopt input:disabled ~ .lbl { opacity: 0.45; }

.status { min-height: 26px; font-size: 16px; color: var(--accent); font-weight: 500; margin-top: 6px; }

/* Home page */
.locgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.locgrid a {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--ink-18);
  border-radius: 16px;
  padding: 22px;
}
.locgrid a:hover { background: var(--accent-06); border-color: var(--accent-45); }
.locgrid a b { font-family: 'Playfair Display', Georgia, serif; font-size: 22px; font-weight: 500; display: block; }
.locgrid a small { color: var(--ink-60); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
