/* 1. Design tokens */
:root {
  --font-sans: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --color-bg: #f7f8ff;
  --color-surface: rgba(255, 255, 255, 0.78);
  --color-surface-strong: rgba(255, 255, 255, 0.94);
  --color-text: #07132f;
  --color-muted: #7e8498;
  --color-accent: #4167e8;
  --color-accent-strong: #3158f4;
  --color-accent-soft: #f1f2ff;
  --color-border: rgba(30, 44, 89, 0.08);
  --color-progress: #e8e8f8;
  --shadow-card: 0 18px 48px rgba(61, 75, 140, 0.055);
  --shadow-control: 0 10px 24px rgba(67, 78, 145, 0.07);
  --shadow-action: 0 18px 34px rgba(49, 81, 240, 0.23);
  --radius-card: 22px;
  --radius-control: 18px;
  --radius-small: 14px;
  --app-height: 100vh;
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
}

@supports (height: 100svh) {
  :root { --app-height: 100svh; }
}

/* 2. Reset and base styles */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
html {
  background: var(--color-bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  display: flex;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  color: var(--color-text);
  background: var(--color-bg);
  font-family: var(--font-sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}
button, a, input, textarea { color: inherit; font: inherit; }
button {
  margin: 0;
  padding: 0;
  border: 0;
  appearance: none;
  background: none;
  cursor: pointer;
}
a { color: inherit; text-decoration: none; }
img, svg, video, iframe, button, input, select, textarea { max-width: 100%; }
img, svg, video { display: block; }
button, input, select, textarea { min-width: 0; }
h1, h2, h3, p, button { overflow-wrap: anywhere; }
button, a { -webkit-tap-highlight-color: transparent; }

@font-face {
  font-family: "SF Pro Display";
  src: url("fonts/SF-Pro-Display-Light.otf") format("opentype");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "SF Pro Display";
  src: url("fonts/SF-Pro-Display-Regular.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "SF Pro Display";
  src: url("fonts/SF-Pro-Display-Medium.otf") format("opentype");
  font-weight: 500 700;
  font-display: swap;
}

/* 3. Application shell */
.app-shell {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  width: min(100%, 430px);
  max-width: 100%;
  height: var(--app-height);
  margin-inline: auto;
  overflow: hidden;
  background:
    radial-gradient(82% 62% at 102% 100%, rgba(195, 209, 255, 0.42), transparent 70%),
    linear-gradient(180deg, #fbfbff 0%, #f5f6fd 100%);
}
.app-background { display: none; }
.app-shell::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA0MzAgOTAwJyBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSdub25lJz48cGF0aCBkPSdNIDgwIDkyMCBDIDc0IDc5MCAxMDUgNjc1IDE5MCA1NzUgQyAyNzAgNDgyIDM2NSA0MjAgNDUwIDIzNScgZmlsbD0nbm9uZScgc3Ryb2tlPScjQ0JDQUNCJyBzdHJva2Utd2lkdGg9JzInIHZlY3Rvci1lZmZlY3Q9J25vbi1zY2FsaW5nLXN0cm9rZScvPjxwYXRoIGQ9J00gMTA1IDkyMCBDIDk4IDgwNSAxMjggNjk1IDIxMCA1OTggQyAyODUgNTEwIDM3NSA0NDcgNDUwIDMyMCcgZmlsbD0nbm9uZScgc3Ryb2tlPScjMzY3RkZFJyBzdHJva2Utd2lkdGg9JzInIHZlY3Rvci1lZmZlY3Q9J25vbi1zY2FsaW5nLXN0cm9rZScvPjxwYXRoIGQ9J00gMTMwIDkyMCBDIDEyNCA4MjAgMTUyIDcxNSAyMjggNjI4IEMgMzAwIDU0NSAzODIgNDg2IDQ1MCA0MDAnIGZpbGw9J25vbmUnIHN0cm9rZT0nI0ZFMjcyNicgc3Ryb2tlLXdpZHRoPScyJyB2ZWN0b3ItZWZmZWN0PSdub24tc2NhbGluZy1zdHJva2UnLz48L3N2Zz4=");
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  content: "";
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to top, transparent 0%, rgba(0, 0, 0, 0.35) 18%, #000 42%, #000 100%);
  mask-image: linear-gradient(to top, transparent 0%, rgba(0, 0, 0, 0.35) 18%, #000 42%, #000 100%);
}

/* 4. Top navigation */
.topbar {
  position: relative;
  z-index: 3;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: calc(var(--safe-top) + 8px) 22px 14px;
}
.topbar.start {
  position: absolute;
  visibility: hidden;
  pointer-events: none;
}
.icon-button {
  display: grid;
  flex: 0 0 48px;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--color-border);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-control);
  color: var(--color-accent);
}
.icon-button svg { width: 25px; height: 25px; }
.back-button span {
  width: 16px;
  height: 16px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  border-radius: 1px;
  transform: rotate(45deg);
}

/* 5. Progress indicator */
.progress {
  display: flex;
  flex: 1 1 auto;
  gap: 8px;
  min-width: 0;
  height: 5px;
}
.progress-part {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--color-progress);
}
.progress-part.is-filled,
.progress-part.is-current {
  background: linear-gradient(90deg, #3158f4, #5777ee);
}

/* 6. Main screen card */
.screen {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  margin: 0 20px var(--safe-bottom);
  padding: 26px 24px 24px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}
.screen.welcome {
  margin: max(14px, var(--safe-top)) 21px max(18px, var(--safe-bottom));
  padding: clamp(150px, 25svh, 214px) 30px 28px;
}
.screen.welcome::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA0MzAgOTAwJyBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSdub25lJz48cGF0aCBkPSdNIDgwIDkyMCBDIDc0IDc5MCAxMDUgNjc1IDE5MCA1NzUgQyAyNzAgNDgyIDM2NSA0MjAgNDUwIDIzNScgZmlsbD0nbm9uZScgc3Ryb2tlPScjQ0JDQUNCJyBzdHJva2Utd2lkdGg9JzInIHZlY3Rvci1lZmZlY3Q9J25vbi1zY2FsaW5nLXN0cm9rZScvPjxwYXRoIGQ9J00gMTA1IDkyMCBDIDk4IDgwNSAxMjggNjk1IDIxMCA1OTggQyAyODUgNTEwIDM3NSA0NDcgNDUwIDMyMCcgZmlsbD0nbm9uZScgc3Ryb2tlPScjMzY3RkZFJyBzdHJva2Utd2lkdGg9JzInIHZlY3Rvci1lZmZlY3Q9J25vbi1zY2FsaW5nLXN0cm9rZScvPjxwYXRoIGQ9J00gMTMwIDkyMCBDIDEyNCA4MjAgMTUyIDcxNSAyMjggNjI4IEMgMzAwIDU0NSAzODIgNDg2IDQ1MCA0MDAnIGZpbGw9J25vbmUnIHN0cm9rZT0nI0ZFMjcyNicgc3Ryb2tlLXdpZHRoPScyJyB2ZWN0b3ItZWZmZWN0PSdub24tc2NhbGluZy1zdHJva2UnLz48L3N2Zz4=");
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  content: "";
  pointer-events: none;
}

.screen.welcome > * { position: relative; z-index: 1; }

/* 7. Typography */
h1 {
  max-width: 100%;
  margin: 0;
  color: var(--color-text);
  font-size: clamp(31px, 8.6vw, 38px);
  font-weight: 300;
  letter-spacing: -0.035em;
  line-height: 1.1;
}
.accent { color: var(--color-accent); }
.subtitle {
  max-width: 34ch;
  margin: 18px 0 0;
  color: var(--color-muted);
  font-size: clamp(16px, 4.5vw, 19px);
  font-weight: 300;
  line-height: 1.42;
}
.screen-step {
  margin: 0 0 14px;
  color: var(--color-muted);
  font-size: 14px;
  font-weight: 300;
}
.territory-screen h1,
.district-screen h1,
.letter-screen h1,
.street-screen h1,
.range-screen h1,
.house-screen h1,
.decision-screen h1 {
  white-space: pre-line;
}
.eyebrow {
  margin: 0 0 14px;
  color: var(--color-accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.screen.welcome h1 {
  font-size: clamp(22px, 6.1vw, 27px);
  font-weight: 300;
  letter-spacing: 0.29em;
  line-height: 1.05;
  text-transform: uppercase;
  white-space: nowrap;
}
.screen.welcome h1 .accent {
  display: block;
  margin-top: 12px;
  font-size: clamp(82px, 23vw, 102px);
  font-weight: 300;
  letter-spacing: -0.055em;
  line-height: 0.92;
  text-transform: none;
}
.screen.welcome h1::after {
  display: block;
  width: 88px;
  height: 3px;
  margin-top: 32px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    #cbcacb 0 31%,
    transparent 31% 34.5%,
    #367ffe 34.5% 65.5%,
    transparent 65.5% 69%,
    #fe2726 69% 100%
  );
  content: "";
}
.screen.welcome .subtitle {
  max-width: 23ch;
  margin-top: 24px;
  color: #555b6c;
  font-size: clamp(18px, 5vw, 21px);
  line-height: 1.48;
  white-space: pre-line;
}

/* 8. Icon containers */
.screen-icon {
  display: grid;
  flex: 0 0 50px;
  place-items: center;
  width: 50px;
  height: 50px;
  margin-bottom: 32px;
  border-radius: 16px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
}
.screen-icon svg { width: 27px; height: 27px; }

/* 9. Option cards */
.actions {
  display: grid;
  gap: 14px;
  margin-top: 0;
  padding-top: 36px;
}
.choice {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  width: 100%;
  min-height: 86px;
  padding: 16px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-strong);
  box-shadow: 0 8px 22px rgba(66, 77, 135, 0.035);
  color: var(--color-text);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.25;
  text-align: left;
}
.choice.secondary { background: rgba(255, 255, 255, 0.72); }
.choice.compact { min-height: 66px; }
.choice-icon {
  display: grid;
  flex: 0 0 50px;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
}
.choice-icon svg { width: 27px; height: 27px; }
.choice-name { flex: 1 1 auto; min-width: 0; }
.choice-chevron,
.range-chevron {
  flex: 0 0 11px;
  width: 11px;
  height: 11px;
  margin-right: 3px;
  border-top: 2px solid var(--color-accent);
  border-right: 2px solid var(--color-accent);
  transform: rotate(45deg);
}
.choice-arrow {
  display: grid;
  flex: 0 0 25px;
  place-items: center;
}
.choice-arrow svg { width: 25px; height: 25px; }

/* 10. Letter grid */
.actions.letter-grid {
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 0;
  padding-top: 26px;
}
.actions.letter-grid .choice {
  justify-content: center;
  min-width: 0;
  min-height: 52px;
  padding: 6px 2px;
  border-radius: 15px;
  font-size: 17px;
  text-align: center;
}
.actions.letter-grid .choice-name { flex: none; }
.actions.letter-grid .choice.wide { grid-column: span 3; }
.actions.letter-grid .choice.wide .choice-name {
  color: var(--color-accent);
  font-size: 15px;
  white-space: nowrap;
}

.district-screen .screen-icon { margin-bottom: 24px; }
.district-screen .screen-step { margin-bottom: 14px; }
.district-screen .actions { gap: 10px; padding-top: 24px; }
.district-screen .choice {
  min-height: 68px;
  padding: 9px 16px;
}
.district-screen .choice-icon {
  flex-basis: 44px;
  width: 44px;
  height: 44px;
}

/* 11. Paged lists and house number grid */
.paged-actions {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  margin-top: 0;
  padding-top: 24px;
}
.paged-list {
  display: grid;
  gap: 10px;
  min-height: 0;
}
.paged-actions.scroll-list .paged-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.street-screen .paged-actions.scroll-list .paged-list {
  align-content: start;
  grid-auto-rows: 58px;
}
.paged-actions.scroll-list .paged-list::-webkit-scrollbar {
  width: 0;
  height: 0;
}
.paged-list .choice {
  min-height: 58px;
  padding: 10px 17px;
  border-radius: 16px;
  font-size: 17px;
}
.choice.choice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}
.choice-row .choice-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.choice-meta {
  color: #4265cf;
  font-size: 14px;
  white-space: nowrap;
}
.paged-list.house-page {
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-content: start;
}
.paged-list.house-page .choice {
  justify-content: center;
  min-height: 60px;
  padding: 8px;
  text-align: center;
}
.paged-list.house-page .choice-name { flex: none; }

.house-scroll {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.house-scroll::-webkit-scrollbar { display: none; }
.house-track {
  display: flex;
  width: 100%;
  height: 100%;
}
.house-track .house-page {
  flex: 0 0 100%;
  grid-template-rows: repeat(5, 60px);
  height: 100%;
  padding-inline: 1px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.house-scroller .pager {
  flex: 0 0 50px;
  margin-top: 0;
}

/* 12. Range cards */
.paged-list .range-card {
  min-height: 88px;
  padding: 12px 16px;
}
.range-badge {
  display: grid;
  flex: 0 0 84px;
  place-items: center;
  min-width: 84px;
  height: 62px;
  padding-inline: 8px;
  border-radius: 17px;
  background: linear-gradient(145deg, #3158f4, #4869ee);
  box-shadow: 0 10px 20px rgba(49, 88, 244, 0.2), inset 0 1px rgba(255, 255, 255, 0.3);
  color: #fff;
  overflow: hidden;
  font-size: 18px;
  font-weight: 400;
  white-space: nowrap;
}
.range-badge.is-long { font-size: 15px; letter-spacing: -0.035em; }
.range-badge.is-xlong { font-size: 13px; letter-spacing: -0.055em; }
.range-body {
  flex: 1 1 auto;
  min-width: 0;
  padding-left: 16px;
  border-left: 1px solid rgba(62, 88, 180, 0.13);
  font-size: 15px;
  line-height: 1.35;
  text-align: left;
}
.range-screen .paged-actions { overflow: hidden; }
.range-screen .paged-list {
  flex: 1 1 auto;
  align-content: start;
  min-height: 0;
  padding: 1px 1px 8px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.range-screen .paged-list::-webkit-scrollbar { display: none; }
.range-screen .pager {
  flex: 0 0 50px;
  margin-top: 0;
}

/* 13. Pagination */
.pager {
  display: grid;
  grid-template-columns: 102px 1fr 102px;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}
.pager-button {
  min-height: 50px;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  background: rgba(247, 247, 255, 0.92);
  font-size: 16px;
}
.pager-button:disabled { opacity: 0.42; cursor: default; }
.pager-button:first-child::before {
  margin-right: 9px;
  color: var(--color-accent);
  content: "‹";
}
.pager-button:last-child::after {
  margin-left: 9px;
  color: var(--color-accent);
  content: "›";
}
.pager-counter {
  color: var(--color-muted);
  font-size: 16px;
  text-align: center;
}

/* 14. Primary actions */
.screen.welcome .actions { margin-top: auto; padding-top: 28px; }
.screen.welcome .choice,
.choice.primary-action,
.deg-screen .actions .choice {
  min-height: 74px;
  border-color: transparent;
  border-radius: 20px;
  background: linear-gradient(110deg, #3158f4, #4a68ef);
  box-shadow: var(--shadow-action);
  color: #fff;
}
.screen.welcome .choice-icon,
.choice.primary-action .choice-icon {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 64px;
  border-radius: 18px;
  background: var(--color-accent-strong);
  color: #fff;
  font-size: 18px;
}

/* 15. Result screen */
.decision-screen {
  padding-top: 22px;
  padding-bottom: 28px;
}
.decision-screen .screen-icon { margin-bottom: 20px; }
.decision-screen .screen-step { margin-bottom: 10px; }
.decision-screen h1 { max-width: none; }
.decision-screen .subtitle { margin-top: 15px; font-size: 16px; }
.candidate-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.candidate-card {
  position: relative;
  display: flex;
  min-height: 108px;
  padding: 15px 76px 13px 18px;
  border: 1px solid var(--color-border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
}
.candidate-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.candidate-eyebrow {
  max-width: 26ch;
  color: #3458bd;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.35;
  text-transform: uppercase;
}
.candidate-surname {
  margin-top: 12px;
  overflow: hidden;
  color: #07143a;
  font-size: clamp(23px, 6.6vw, 29px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.candidate-given {
  margin-top: 8px;
  color: #777d8d;
  font-size: 14px;
}
.candidate-badge {
  position: absolute;
  top: 50%;
  right: 16px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  transform: translateY(-50%);
}
.candidate-badge svg { width: 29px; height: 29px; }
.candidate-chevron { display: none; }
.decision-screen .actions {
  gap: 10px;
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 0;
}
.decision-screen .choice {
  min-height: 66px;
  gap: 10px;
  padding: 10px 12px;
  font-size: 16px;
}
.decision-screen .choice.primary-action { min-height: 70px; }
.decision-screen .choice-icon {
  flex-basis: 46px;
  width: 46px;
  height: 46px;
}

/* 16. DEG registration screen */
.deg-screen { padding-top: 24px; }
.deg-screen .screen-icon { margin-bottom: 22px; }
.deg-screen .screen-step { margin-bottom: 10px; }
.deg-screen h1 {
  font-size: clamp(29px, 8vw, 36px);
  white-space: pre-line;
}
.deg-date {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  margin-top: 22px;
  padding: 18px 14px 0;
  border-top: 1px solid var(--color-border);
  color: #252b3a;
  font-size: 15px;
  line-height: 1.35;
}
.deg-date > span:last-child {
  flex: 0 1 auto;
  max-width: 238px;
}
.deg-date-icon,
.deg-play-icon {
  display: grid;
  flex: 0 0 48px;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
}
.deg-date-icon svg { width: 26px; height: 26px; }
.deg-date strong { color: var(--color-accent); font-weight: 500; }
.deg-instruction {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 11px 14px;
  border-radius: 16px;
  background: #f0f2ff;
  color: #303647;
  font-size: 14px;
  line-height: 1.35;
}
.deg-play-icon {
  flex-basis: 52px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-control);
}
.deg-play-icon svg { width: 31px; height: 31px; fill: currentColor; stroke: none; }
.video-box {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 70px;
  max-height: min(30svh, 230px);
  margin-top: clamp(8px, 1.6svh, 14px);
  overflow: hidden;
  border-radius: 17px;
  background: #111723;
  box-shadow: 0 12px 25px rgba(18, 30, 65, 0.16);
}
.deg-video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border: 0;
  object-fit: contain;
}
.deg-screen .actions {
  margin-top: 14px;
  padding-top: 0;
}
.deg-screen .actions .choice {
  gap: 10px;
  padding-inline: 17px;
  font-size: 17px;
}

/* 17. Form, notices and precinct */
.house-form { margin-top: 28px; }
.house-input {
  width: 100%;
  height: 66px;
  padding: 0 20px;
  border: 1px solid var(--color-border);
  border-radius: 17px;
  outline: none;
  background: var(--color-surface-strong);
  font-size: 21px;
}
.house-form .primary { margin-top: 16px; }
.notice,
.precinct-card {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: 18px;
  background: var(--color-surface-strong);
}
.issue-notice { color: #76560a; background: #fff9e9; }
.precinct-number { margin: 0 0 18px; color: var(--color-accent); font-size: 27px; }
.detail-label { margin: 15px 0 5px; color: var(--color-muted); font-size: 14px; }
.detail-value { margin: 0; font-size: 17px; line-height: 1.4; }
.loading { margin-top: 26px; color: var(--color-muted); }
.toast {
  position: absolute;
  right: 20px;
  bottom: calc(var(--safe-bottom) + 10px);
  left: 20px;
  z-index: 10;
  padding: 15px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-control);
  color: #b3333b;
  text-align: center;
}

/* 18. States and accessibility */
.choice:active, .icon-button:active, .pager-button:active:not(:disabled) {
  transform: scale(0.985);
}
.choice:focus-visible,
.icon-button:focus-visible,
.pager-button:focus-visible,
.candidate-card:focus-visible,
.primary:focus-visible,
.house-input:focus-visible {
  outline: 3px solid rgba(65, 103, 232, 0.3);
  outline-offset: 3px;
}
.choice:disabled, .primary:disabled { opacity: 0.48; cursor: default; }
.u-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.u-hidden { display: none !important; }

/* 19. Unified responsive rules */
@media (max-width: 699px) {
  .topbar {
    gap: clamp(8px, 4vw, 18px);
    padding: max(8px, var(--safe-top)) clamp(12px, 5vw, 22px) clamp(7px, 1.8svh, 14px);
  }
  .icon-button {
    flex-basis: clamp(42px, 6.5svh, 48px);
    width: clamp(42px, 6.5svh, 48px);
    height: clamp(42px, 6.5svh, 48px);
  }
  .screen {
    margin: 0 clamp(10px, 5vw, 20px) var(--safe-bottom);
    padding: clamp(10px, 2.7svh, 24px) clamp(12px, 5.5vw, 24px) clamp(10px, 2.5svh, 24px);
  }
  .screen.welcome {
    margin: max(10px, var(--safe-top)) clamp(10px, 5vw, 21px) max(12px, var(--safe-bottom));
    padding: clamp(82px, 20svh, 190px) clamp(18px, 7vw, 30px) clamp(16px, 3svh, 28px);
  }
  h1 { font-size: clamp(23px, 8vw, 36px); line-height: 1.06; }
  .subtitle {
    margin-top: clamp(7px, 1.8svh, 18px);
    font-size: clamp(13px, 4vw, 18px);
    line-height: 1.32;
  }
  .screen-step {
    margin-bottom: clamp(4px, 1.4svh, 12px);
    font-size: clamp(11px, 3.5vw, 14px);
  }
  .screen-icon {
    flex-basis: clamp(34px, 6.2svh, 50px);
    width: clamp(34px, 6.2svh, 50px);
    height: clamp(34px, 6.2svh, 50px);
    margin-bottom: clamp(6px, 2.2svh, 24px);
  }
  .screen-icon svg { width: clamp(21px, 3.6svh, 27px); height: clamp(21px, 3.6svh, 27px); }
  .actions {
    gap: clamp(5px, 1.4svh, 12px);
    padding-top: clamp(7px, 2.4svh, 24px);
  }
  .choice {
    gap: clamp(9px, 3.5vw, 18px);
    min-height: clamp(44px, 8svh, 74px);
    padding: clamp(8px, 1.7svh, 16px) clamp(11px, 4vw, 20px);
    font-size: clamp(14px, 4.3vw, 18px);
  }
  .choice.compact { min-height: clamp(44px, 7svh, 62px); }
  .choice-icon {
    flex-basis: clamp(38px, 6svh, 50px);
    width: clamp(38px, 6svh, 50px);
    height: clamp(38px, 6svh, 50px);
  }
  .district-screen .screen-icon { margin-bottom: clamp(6px, 1.8svh, 18px); }
  .district-screen .screen-step { margin-bottom: clamp(4px, 1.2svh, 10px); }
  .district-screen .actions { gap: clamp(5px, 1.1svh, 10px); padding-top: clamp(7px, 1.8svh, 20px); }
  .district-screen .choice { min-height: clamp(44px, 7svh, 64px); }
  .actions.letter-grid {
    gap: clamp(4px, 1.1svh, 9px);
    padding-top: clamp(7px, 2svh, 20px);
  }
  .actions.letter-grid .choice {
    min-height: clamp(34px, 6.2svh, 48px);
    padding: 4px 2px;
    font-size: clamp(14px, 4vw, 17px);
  }
  .actions.letter-grid .choice.wide .choice-name { font-size: clamp(12px, 3.7vw, 15px); }
  .paged-actions {
    gap: clamp(5px, 1.2svh, 10px);
    padding-top: clamp(7px, 2svh, 20px);
  }
  .paged-list { gap: clamp(5px, 1.2svh, 9px); }
  .street-screen .paged-actions.scroll-list .paged-list { grid-auto-rows: clamp(44px, 7svh, 58px); }
  .paged-list .choice {
    min-height: clamp(44px, 7svh, 58px);
    padding: 7px clamp(10px, 4vw, 17px);
    font-size: clamp(14px, 4vw, 17px);
  }
  .paged-list.house-page { gap: clamp(5px, 1.2svh, 10px); }
  .house-track .house-page {
    grid-template-rows: repeat(5, clamp(36px, 6.4svh, 50px));
    gap: clamp(5px, 1.2svh, 10px);
  }
  .house-track .house-page .choice {
    height: auto;
    min-height: clamp(36px, 6.4svh, 50px);
    padding: 4px;
    font-size: clamp(14px, 4vw, 17px);
  }
  .paged-list .range-card {
    min-height: clamp(64px, 11svh, 86px);
    padding: clamp(7px, 1.5svh, 12px) clamp(9px, 3vw, 16px);
  }
  .range-badge {
    flex-basis: clamp(64px, 20vw, 84px);
    min-width: clamp(64px, 20vw, 84px);
    height: clamp(48px, 8svh, 62px);
  }
  .range-body { padding-left: clamp(9px, 3vw, 16px); font-size: clamp(12px, 3.7vw, 15px); }
  .pager {
    grid-template-columns: minmax(78px, 102px) 1fr minmax(78px, 102px);
    gap: clamp(4px, 2vw, 8px);
  }
  .pager-button { min-height: clamp(44px, 7svh, 50px); font-size: clamp(13px, 4vw, 16px); }
  .pager-counter { font-size: clamp(13px, 4vw, 16px); }
  .decision-screen { padding-top: clamp(10px, 2svh, 20px); padding-bottom: clamp(10px, 2.5svh, 22px); }
  .decision-screen .screen-icon { margin-bottom: clamp(5px, 1.6svh, 14px); }
  .decision-screen .screen-step { margin-bottom: clamp(3px, 1svh, 8px); }
  .decision-screen h1 { font-size: clamp(23px, 7.6vw, 32px); }
  .decision-screen .subtitle { margin-top: clamp(5px, 1.4svh, 12px); font-size: clamp(12px, 3.8vw, 15px); line-height: 1.25; }
  .decision-screen .candidate-list { gap: clamp(5px, 1svh, 8px); margin-top: clamp(7px, 1.8svh, 14px); }
  .decision-screen .candidate-card { min-height: clamp(70px, 12svh, 100px); padding: clamp(8px, 1.4svh, 12px) 58px clamp(7px, 1.3svh, 11px) 13px; }
  .decision-screen .candidate-surname { margin-top: clamp(5px, 1svh, 8px); font-size: clamp(20px, 6vw, 25px); }
  .decision-screen .candidate-given { margin-top: clamp(4px, .8svh, 6px); font-size: clamp(11px, 3.4vw, 13px); }
  .decision-screen .candidate-badge { right: 10px; width: clamp(38px, 6svh, 46px); height: clamp(38px, 6svh, 46px); }
  .decision-screen .actions { gap: clamp(5px, 1svh, 8px); margin-top: auto; }
  .decision-screen .choice { min-height: clamp(44px, 7.5svh, 60px); padding: 6px 9px; font-size: clamp(13px, 3.8vw, 15px); }
  .decision-screen .choice.primary-action { min-height: clamp(48px, 8svh, 64px); }
  .deg-screen { padding-top: clamp(9px, 2svh, 18px); padding-bottom: clamp(9px, 2svh, 18px); }
  .deg-screen .screen-icon { margin-bottom: clamp(5px, 1.5svh, 12px); }
  .deg-screen .screen-step { margin-bottom: clamp(3px, 1svh, 7px); }
  .deg-screen h1 { font-size: clamp(22px, 7vw, 29px); line-height: 1.02; }
  .deg-date { gap: clamp(8px, 3vw, 12px); margin-top: clamp(6px, 1.5svh, 13px); padding: clamp(6px, 1.4svh, 12px) clamp(8px, 3vw, 11px) 0; font-size: clamp(11px, 3.5vw, 14px); line-height: 1.25; }
  .deg-date-icon, .deg-play-icon { flex-basis: clamp(36px, 6svh, 48px); width: clamp(36px, 6svh, 48px); height: clamp(36px, 6svh, 48px); }
  .deg-instruction { gap: clamp(8px, 3vw, 11px); margin-top: clamp(6px, 1.4svh, 12px); padding: clamp(5px, 1.2svh, 8px) clamp(8px, 3vw, 11px); font-size: clamp(11px, 3.3vw, 13px); line-height: 1.25; }
  .deg-play-icon svg { width: clamp(24px, 4svh, 29px); height: clamp(24px, 4svh, 29px); }
  .video-box { min-height: 70px; max-height: min(27svh, 210px); }
  .deg-screen .actions { flex: 0 0 auto; margin-top: clamp(6px, 1.4svh, 10px); }
  .deg-screen .actions .choice { min-height: clamp(44px, 7.5svh, 62px); font-size: clamp(14px, 4.2vw, 17px); }
}
@media (max-width: 359px) {
  .topbar { padding-inline: 10px; }
  .screen { margin-inline: 8px; padding-inline: 11px; }
  .progress { gap: 5px; }
  .choice-arrow { flex-basis: 20px; }
  .choice-arrow svg { width: 20px; height: 20px; }
}
@media (max-height: 650px) and (max-width: 699px) {
  .topbar { padding-bottom: 5px; }
  .screen { padding-top: 8px; padding-bottom: 8px; }
  .screen-icon { flex-basis: 32px; width: 32px; height: 32px; margin-bottom: 5px; border-radius: 11px; }
  .screen-icon svg { width: 20px; height: 20px; }
  h1 { font-size: clamp(21px, 7.2vw, 25px); line-height: 1.02; }
  .subtitle { margin-top: 5px; font-size: 12px; line-height: 1.2; }
  .screen-step { margin-bottom: 3px; font-size: 11px; }
  .actions, .paged-actions { gap: 5px; padding-top: 6px; }
  .choice, .choice.compact { min-height: 44px; padding-block: 6px; }
  .actions.letter-grid { gap: 4px; padding-top: 6px; }
  .actions.letter-grid .choice { min-height: 32px; }
  .decision-screen .candidate-card { min-height: 66px; }
  .decision-screen .choice, .decision-screen .choice.primary-action { min-height: 44px; }
  .deg-screen h1 { font-size: 21px; }
  .deg-date { margin-top: 5px; padding-top: 5px; font-size: 11px; }
  .deg-instruction { margin-top: 5px; padding-block: 4px; font-size: 11px; }
  .deg-date-icon, .deg-play-icon { flex-basis: 34px; width: 34px; height: 34px; }
  .video-box { min-height: 60px; max-height: 20svh; margin-top: 5px; }
  .deg-screen .actions { margin-top: 5px; }
  .deg-screen .actions .choice { min-height: 44px; }
}
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  .app-shell::before {
    position: absolute;
    inset: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 24px;
    border: 1px solid var(--color-border);
    border-radius: 22px;
    background: var(--color-surface);
    color: var(--color-text);
    content: "Поверните устройство в вертикальное положение";
    font-size: clamp(20px, 4vw, 28px);
    text-align: center;
  }
  .topbar, .screen { visibility: hidden; }
}
@media (min-width: 700px) {
  body { background: #eef1fa; }
  .app-shell {
    height: calc(var(--app-height) - 40px);
    border-radius: 28px;
    box-shadow: 0 28px 70px rgba(38, 48, 100, 0.16);
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
