:root {
  color-scheme: light;
  --ink: #101218;
  --muted: #687080;
  --line: rgba(16, 18, 24, 0.09);
  --blue: #064bd8;
  --blue-dark: #073aa2;
  --yellow: #fff200;
  --bg: #eaf1ff;
  --top-bg: #dce8fc;
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--top-bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(to bottom, var(--top-bg) 0, var(--bg) 38rem) no-repeat, var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  filter: blur(85px);
  opacity: 0.18;
  pointer-events: none;
}
.ambient-one { top: -8rem; right: -10rem; background: #2e6eea; }
.ambient-two { bottom: -10rem; left: -12rem; background: #fff200; opacity: 0.12; }

.app-shell {
  width: min(100%, 68rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(1.15rem, env(safe-area-inset-top)) 1.15rem max(1.8rem, env(safe-area-inset-bottom));
}

.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  cursor: pointer;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  color: white;
  background: var(--blue);
  border-radius: 0.82rem;
  box-shadow: 0 8px 22px rgba(0, 66, 206, 0.18);
}
.brand-mark svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }

.screen { animation: screen-in 280ms cubic-bezier(.2,.8,.2,1); }
@keyframes screen-in { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: translateY(0); } }

.picker-screen { max-width: 42rem; margin: 0 auto; padding-top: 4.2rem; }
.picker-intro { margin-bottom: 2rem; }
.eyebrow, .template-kicker {
  margin: 0 0 0.6rem;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.picker-intro h1, .template-intro h1 {
  margin: 0;
  font-size: clamp(2.4rem, 11vw, 4.7rem);
  line-height: 1;
  letter-spacing: -0.06em;
}
.picker-intro > p:last-child, .template-intro > p {
  max-width: 28rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.role-list { display: grid; gap: 0.7rem; }
.role-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  min-height: 5.1rem;
  padding: 0.8rem;
  text-align: left;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: 0 12px 36px rgba(30, 43, 69, 0.055);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  backdrop-filter: blur(18px);
}
.role-row:hover { border-color: rgba(0, 66, 206, 0.24); box-shadow: 0 15px 38px rgba(30, 43, 69, 0.085); }
.role-row:active { transform: scale(0.985); }
.role-row:focus-visible, .brand:focus-visible, .back-button:focus-visible { outline: 3px solid rgba(0, 66, 206, 0.24); outline-offset: 3px; }

.role-icon {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  color: var(--blue);
  background: var(--yellow);
  border-radius: 1rem;
}
.role-icon-yellow { background: var(--yellow); }
.role-icon-orange { color: #17191f; background: #ff6b2c; }
.role-icon-black { color: var(--yellow); background: #111318; }
.role-icon svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.role-copy { display: flex; flex-direction: column; min-width: 0; }
.role-copy strong { font-size: 1rem; letter-spacing: -0.025em; }
.role-copy small { margin-top: 0.18rem; overflow: hidden; color: #7a8290; font-size: 0.78rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.role-arrow { display: grid; place-items: center; width: 2rem; height: 2rem; color: var(--blue); background: rgba(0, 66, 206, 0.07); border-radius: 50%; font-size: 1.6rem; font-weight: 400; line-height: 1; }

.setup-screen, .template-screen { max-width: 47rem; margin: 0 auto; padding-top: 2.2rem; }
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 2.2rem;
  padding: 0.6rem 0.72rem 0.6rem 0.5rem;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}
.back-button svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.setup-intro { margin-bottom: 1.5rem; }
.setup-intro h1 {
  margin: 0;
  font-size: clamp(2.25rem, 10vw, 4.2rem);
  line-height: 1;
  letter-spacing: -0.06em;
}
.setup-intro p { max-width: 31rem; margin: 0.9rem 0 0; color: var(--muted); line-height: 1.55; }
.setup-card {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 1.45rem;
  box-shadow: 0 18px 48px rgba(30, 43, 69, 0.08);
  backdrop-filter: blur(18px);
}
.inline-back {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  margin: 0 0 0.85rem;
  padding: 0.35rem 0;
  color: var(--blue);
  background: transparent;
  border: 0;
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
}
.inline-back svg { width: 0.9rem; height: 0.9rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.choice-grid { display: grid; gap: 0.58rem; }
.cadence-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.area-grid, .precinct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-button {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 3.35rem;
  padding: 0.72rem 0.5rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid rgba(16, 18, 24, 0.12);
  border-radius: 0.95rem;
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.choice-button:hover { border-color: rgba(0, 66, 206, 0.28); }
.choice-button:active { transform: scale(0.975); }
.choice-button[aria-pressed="true"] {
  background: rgba(255, 242, 0, 0.2);
  border-color: #d6c900;
  box-shadow: inset 0 0 0 1px #d6c900, 0 7px 20px rgba(112, 105, 0, 0.08);
}
.choice-button:focus-visible, .inline-back:focus-visible { outline: 3px solid rgba(0, 66, 206, 0.24); outline-offset: 2px; }
.choice-card { align-content: center; gap: 0.15rem; min-height: 4.8rem; }
.choice-card strong { font-size: 1.05rem; }
.choice-card small { color: var(--muted); font-size: 0.68rem; font-weight: 650; }
.template-intro { margin-bottom: 1.6rem; }
.role-chip { display: inline-flex; margin-bottom: 0.75rem; padding: 0.4rem 0.6rem; color: var(--blue); background: rgba(0, 66, 206, 0.08); border-radius: 999px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.1em; }
.template-intro h1 { font-size: clamp(2.25rem, 10vw, 4.2rem); }

.template-card {
  position: relative;
  overflow: hidden;
  padding: 1.15rem;
  color: white;
  background: #131720;
  border-radius: 1.55rem;
  box-shadow: 0 22px 65px rgba(19, 23, 32, 0.22);
}
.template-card::before { content: ""; position: absolute; top: -7rem; right: -6rem; width: 14rem; height: 14rem; border-radius: 50%; background: rgba(0, 66, 206, 0.34); filter: blur(25px); pointer-events: none; }
.template-topline { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.template-kicker { color: #8590a2; }
.template-topline h2 { margin: 0; font-size: 1.2rem; letter-spacing: -0.035em; }
.template-sections {
  position: relative;
  display: grid;
  gap: 0.85rem;
  margin: 1rem 0;
}
.template-section {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 1.15rem;
}
.template-section-heading {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}
.template-section-number {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.8rem;
  height: 1.8rem;
  color: #111318;
  background: var(--yellow);
  border-radius: 0.56rem;
  font-size: 0.78rem;
  font-weight: 900;
}
.template-section h3 {
  margin: 0.12rem 0 0;
  color: white;
  font-size: 0.9rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.template-section-text {
  margin: 0 0 0.85rem;
  white-space: pre-wrap;
  color: #dce2eb;
  font: 400 0.74rem/1.65 "DM Mono", monospace;
}
.section-copy-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 2.85rem;
  color: white;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.85rem;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}
.section-copy-button:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 242, 0, 0.3); }
.section-copy-button:active { transform: scale(0.985); }
.section-copy-button:focus-visible { outline: 3px solid rgba(255, 242, 0, 0.42); outline-offset: 2px; }
.section-copy-button svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: calc(100% - 2rem);
  max-width: 22rem;
  padding: 0.8rem 1rem;
  color: white;
  background: rgba(19, 23, 32, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 1rem;
  box-shadow: 0 16px 45px rgba(19, 23, 32, 0.3);
  opacity: 0;
  transform: translate(-50%, 1.5rem) scale(0.96);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
  backdrop-filter: blur(18px);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast-check { display: grid; place-items: center; width: 2rem; height: 2rem; color: #111318; background: var(--yellow); border-radius: 50%; font-weight: 900; }
.toast div { display: flex; flex-direction: column; }
.toast strong { font-size: 0.82rem; }
.toast small { margin-top: 0.08rem; color: #aeb6c3; font-size: 0.68rem; }

@media (min-width: 720px) {
  .app-shell { padding-inline: 2rem; }
  .picker-screen { padding-top: 6.2rem; }
  .picker-intro { text-align: center; }
  .picker-intro > p:last-child { margin-inline: auto; }
  .setup-screen, .template-screen { padding-top: 4rem; }
  .setup-card { padding: 1.4rem; }
  .template-card { padding: 1.55rem; }
  .template-section { padding: 1.15rem; }
  .template-section-text { font-size: 0.8rem; }
}

@media (max-width: 430px) {
  .app-shell { padding-inline: 0.9rem; }
  .brand { gap: 0.5rem; font-size: 0.9rem; }
  .brand-mark { width: 2.45rem; height: 2.45rem; }
  .picker-screen { padding-top: 3.2rem; }
  .setup-screen, .template-screen { padding-top: 1.55rem; }
  .back-button { margin-bottom: 1.55rem; }
  .setup-card { padding: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
