/* V-PAC design system (Brand Kit, edition 2): ink, newsprint and cobalt. Editorial; hairlines over boxes,
   one cobalt accent per screen, serif headlines, numbers in mono. No red anywhere. Map-first: controls float over it in frosted glass. */
:root {
  --sand: #F2EEE6; --surface: #FBF9F5; --ink: #141414; --muted: #5E5A53; --line: #D9D2C5; --sunk: #E9E4DA;
  --accent: #1F45C8; --on-accent: #FFFFFF; --tint: #E4E9F8; --accent-soft: #9AA9D6;
  --good: #1F6B43; --warn: #8A5200; --bad: #141414;
  --glass: rgba(251, 249, 245, .76); --glass-line: rgba(255, 255, 255, .6);
  --display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --body: "Host Grotesk", "Anek Telugu", system-ui, sans-serif;
  --te: "Anek Telugu", "Host Grotesk", sans-serif;
  --mono: "Martian Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --fast: 150ms; --base: 220ms;
  --r-control: 10px; --r-card: 16px; --r-sheet: 24px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .06), 0 12px 32px rgba(20, 20, 20, .08);
  color-scheme: light;
}

* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { height: 100% }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale }
body { margin: 0; background: var(--sand); color: var(--ink); font: 400 15px/1.5 var(--body) }
h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: -.01em; margin: 0; text-wrap: balance }
h1 { font-size: 40px; line-height: 1 }
h2 { font-size: 26px; line-height: 1.1 }
p { margin: 0; text-wrap: pretty }
.muted { color: var(--muted) }
.fine { font-size: 12px; color: var(--muted) }
.te { font-family: var(--te); color: var(--muted); font-size: .88em; font-weight: 400 }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums }
.label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted) }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }

/* Brand */
.brand { display: flex; align-items: center; gap: 9px }
.mark { width: 14px; height: 22px; border-radius: 8px; background: var(--ink); position: relative; flex: none }
.mark::after { content: ""; position: absolute; left: 3px; right: 3px; top: 3px; height: 7px; border-radius: 4px; background: var(--accent) }
.wordmark { font: 400 24px/1 var(--display); letter-spacing: 0 }

/* Controls */
.btn { font: 600 15px var(--body); min-height: 44px; padding: 0 18px; border-radius: var(--r-control); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  transition-property: transform, background-color, border-color; transition-duration: var(--fast); transition-timing-function: var(--ease) }
.btn:hover { border-color: var(--muted) }
.btn:active { transform: scale(.97) }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent) }
.btn.big { min-height: 52px; font-size: 16px }
.btn.ghost { background: transparent }
.link { background: none; border: 0; padding: 0; font: 600 14px var(--body); color: var(--accent); cursor: pointer }
input, select, textarea { font: 400 16px var(--body); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control); padding: 10px 12px; width: 100%; min-width: 0 }
.chips { display: flex; flex-wrap: wrap; gap: 6px }
.chip { font: 500 14px var(--body); min-height: 40px; padding: 0 12px; border-radius: var(--r-control); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition-property: background-color, border-color, color, transform; transition-duration: var(--fast); transition-timing-function: var(--ease) }
.chip:active { transform: scale(.97) }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--sand) }
.chip .n { font: 400 11px var(--mono); opacity: .7 }
.seg { display: flex; flex-wrap: wrap; gap: 6px }
.seg .chip { flex-direction: column; justify-content: center; gap: 0; line-height: 1.15; min-height: 46px }
.seg .chip small { font: 400 11px var(--te); opacity: .75 }
.seg .chip[data-v="lives"][aria-pressed="true"] { background: var(--good); border-color: var(--good); color: #fff }
.seg .chip[data-v="shifted"][aria-pressed="true"], .seg .chip[data-v="deceased"][aria-pressed="true"], .seg .chip[data-v="duplicate"][aria-pressed="true"] { background: var(--warn); border-color: var(--warn); color: #fff }
.pill { font-size: 12px; font-weight: 600; white-space: nowrap }
.pill.good { color: var(--good) } .pill.warn { color: var(--warn) } .pill.bad { color: var(--bad) } .pill.muted { color: var(--muted) }
.glass { background: var(--glass); -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6); border: 1px solid var(--glass-line); box-shadow: var(--shadow) }

/* Sign in */
.signin { min-height: 100%; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)) }
.signin-card { width: min(440px, 100%); display: grid; gap: 16px }
.signin-card h1 { font-size: 44px; margin-top: 18px }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600 }
.roles { border: 0; padding: 0; margin: 0; display: grid; gap: 0; border-top: 1px solid var(--line) }
.roles legend { font-size: 14px; font-weight: 600; padding: 0 0 8px }
.role { display: flex; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer }
.role input { width: auto; accent-color: var(--accent); margin-top: 4px }
.role span { display: grid } .role small { color: var(--muted); font-size: 13px }

/* Shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: auto 1fr; height: 100% }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 14px max(24px, env(safe-area-inset-right)) 14px max(24px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line) }
.campaign { color: var(--muted); font-size: 14px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.viewas select { width: auto; min-height: 36px; padding: 6px 10px; font-size: 14px }
.sidenav { border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px }
.sidenav button { text-align: left; font: 500 15px var(--body); color: var(--muted); background: none; border: 0; border-radius: var(--r-control); padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between;
  transition-property: background-color, color; transition-duration: var(--fast) }
.sidenav button:hover { background: var(--sunk); color: var(--ink) }
.sidenav button[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line) }
.sidenav .count, .tabbar .count { font: 400 11px var(--mono); color: var(--warn); margin-left: 6px }
.view { overflow-y: auto; min-width: 0; outline: none; position: relative }
.page { padding: 32px max(24px, env(safe-area-inset-right)) 48px 40px; display: grid; gap: 28px; align-content: start; max-width: 1180px }
.tabbar { display: none }
.example-bar { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); padding: 10px 0; border-bottom: 1px dashed var(--line) }

/* Structure: hairline lists and stat strips instead of boxes */
.head { display: grid; gap: 8px }
.head .lede { font-size: 17px; color: var(--muted); max-width: 60ch }
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line) }
.strip > div { padding: 18px 20px 18px 0; display: grid; gap: 2px }
.strip > div + div { padding-left: 20px; border-left: 1px solid var(--line) }
.strip .v { font: 400 40px/1 var(--display); letter-spacing: 0; font-variant-numeric: tabular-nums }
.strip .s { font-size: 13px; color: var(--muted) }
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line) }
.rows > li { border-bottom: 1px solid var(--line) }
.row-btn { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 14px 4px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
  transition-property: background-color; transition-duration: var(--fast) }
.row-btn:hover { background: var(--sunk) }
.row-btn .house { font: 400 15px var(--mono) }
.row-btn .sub { grid-column: 1 / -1; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.card { background: var(--surface); border-radius: var(--r-card); padding: 20px; display: grid; gap: 14px; min-width: 0 }
.card.quiet { background: var(--sunk) }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 32px; align-items: start }
.map { width: 100%; height: 100%; min-height: 300px; border-radius: var(--r-card); overflow: hidden; background: var(--sunk) }
.bars { display: grid; gap: 10px }
.bar { display: grid; grid-template-columns: minmax(96px, 150px) 1fr 44px; gap: 12px; align-items: center; font-size: 14px }
.bar .track { height: 8px; border-radius: 4px; background: var(--sunk); overflow: hidden }
.bar .fill { display: block; height: 100%; border-radius: 4px; background: var(--ink); transform-origin: left }
.bar.past .fill { background: var(--line) }
.bar .num { font-size: 11px; text-align: right }
.mood { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--sunk) }
.mood .p { background: var(--good) } .mood .n { background: var(--line) } .mood .u { background: var(--bad) }
table { width: 100%; border-collapse: collapse; font-size: 14px }
th { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted) }
td { padding: 14px 12px 14px 0; border-bottom: 1px solid var(--line); vertical-align: middle }
.tablewrap { overflow-x: auto }

/* Field: walk map with floating glass controls */
.walk { position: relative; height: 100% }
.walk .map { position: absolute; inset: 0; border-radius: 0; min-height: 0 }
.walk-top { position: absolute; top: 14px; left: 14px; right: 60px; display: grid; gap: 8px; z-index: 2 }
.walk-top .search { display: flex; align-items: center; gap: 10px; border-radius: 14px; padding: 0 14px; height: 48px }
.walk-top .search input { border: 0; background: transparent; padding: 0; height: 100% }
.walk-top .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none }
.walk-top .chip { flex: none; border-radius: 999px; min-height: 36px }
.walk-list { position: absolute; left: 14px; bottom: 14px; width: min(400px, calc(100% - 28px)); max-height: 46%; overflow-y: auto; border-radius: var(--r-card); padding: 4px 16px; z-index: 2 }
.ring { display: block }
.ring circle { fill: none; stroke-width: 8 }
.ring .bg { stroke: var(--sunk) } .ring .fg { stroke: var(--accent); stroke-linecap: round }
.next { background: var(--sunk); border-radius: var(--r-card); padding: 20px; display: grid; gap: 12px }
.next .house { font: 400 22px var(--mono) }

/* Sheet: bottom sheet on phone, side panel on desktop */
.scrim { position: fixed; inset: 0; background: rgba(20, 20, 20, .36); z-index: 40 }
.sheet { position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); display: grid; grid-template-rows: auto 1fr auto; box-shadow: var(--shadow) }
.sheet-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: max(18px, env(safe-area-inset-top)) 22px 14px }
.sheet-head h2 { font: 400 24px var(--mono); letter-spacing: 0; view-transition-name: house }
.grab { display: none }
.sheet-body { overflow-y: auto; padding: 4px 22px 22px; display: grid; gap: 24px; align-content: start }
.sheet-foot { display: flex; align-items: center; gap: 12px; padding: 14px 22px max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line) }
.sheet-foot .status { flex: 1; font-size: 13px; color: var(--muted) }
.block { display: grid; gap: 10px }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 12px }
.voter { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line) }
.voter .who { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap }
.voter .meta { font-size: 13px; color: var(--muted) }
.stepper { display: inline-flex; align-items: center; gap: 14px }
.stepper output { font: 400 18px var(--mono); min-width: 22px; text-align: center }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 16px; flex: none }
.note { background: var(--tint); border-radius: var(--r-control); padding: 10px 12px; font-size: 14px }

/* Review stack */
.stack { position: relative; height: 470px; max-width: 460px }
.stack .rv { position: absolute; inset: 0 0 auto 0; background: var(--surface); border-radius: 20px; padding: 22px; display: grid; gap: 12px; box-shadow: var(--shadow); touch-action: pan-y; cursor: grab }
.stack .rv.behind { transform: translateY(12px) scale(.96); opacity: .6; pointer-events: none; box-shadow: none }
.rv dl { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0; font-size: 14px }
.rv dt, .rv dd { padding: 9px 0; border-top: 1px solid var(--line); margin: 0 }
.rv dt { color: var(--muted); padding-right: 16px }
.rv .actions { display: flex; gap: 10px; margin-top: 6px }
.rv .actions .btn { flex: 1 }

/* Briefing */
.verdict { font: 400 24px/1.3 var(--display); max-width: 40ch }
.things { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line) }
.things li { display: grid; grid-template-columns: 32px 1fr; gap: 2px 8px; padding: 14px 0; border-bottom: 1px solid var(--line) }
.things .k { font: 400 12px var(--mono); color: var(--accent); padding-top: 3px }
.things .k { grid-row: span 2; grid-column: 1 }
.things b { grid-column: 2; font-weight: 600 } .things span { grid-column: 2; font-size: 13px; color: var(--muted) }
.map-moment { position: relative; height: 420px }
.map-moment .map { height: 100% }
.map-moment .cap { position: absolute; left: 12px; right: 12px; bottom: 40px; display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 12px; font-size: 13px; z-index: 2 }
.booths { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding-bottom: 4px }
.booths .card { flex: none; width: min(300px, 82%); scroll-snap-align: start; background: var(--sunk) }
.quote { font: italic 400 20px/1.4 var(--display) }

/* Map chrome follows the theme */
.maplibregl-popup-content { background: var(--surface); color: var(--ink); border-radius: 12px; box-shadow: var(--shadow); font: 14px var(--body); padding: 10px 12px }
.maplibregl-popup-tip { display: none }
.maplibregl-ctrl-group { background: var(--glass) !important; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-radius: 12px !important; box-shadow: var(--shadow) !important }
.maplibregl-ctrl-attrib { font-size: 11px }

.toast { position: fixed; left: 50%; translate: -50% 0; bottom: max(24px, calc(env(safe-area-inset-bottom) + 76px)); background: var(--ink); color: var(--sand); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 60 }

/* View transitions: quick cross-fade between screens; the house number travels into the sheet */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 200ms; animation-timing-function: var(--ease) }

@media (max-width: 1080px) { .grid-2 { grid-template-columns: minmax(0, 1fr) } .strip { grid-template-columns: repeat(2, minmax(0, 1fr)) } .strip > div:nth-child(3) { padding-left: 0; border-left: 0 } }
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto }
  .sidenav { display: none }
  .topbar { padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)) }
  .campaign { display: none }
  .viewas { margin-left: auto }
  .page { padding: 22px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left)); gap: 24px }
  h1 { font-size: 34px }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-top: 1px solid var(--line); background: var(--sand); padding: 4px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)) }
  .tabbar button { background: none; border: 0; font: 500 13px var(--body); color: var(--muted); padding: 12px 4px; cursor: pointer }
  .tabbar button[aria-current="page"] { color: var(--ink); font-weight: 600 }
  .strip .v { font-size: 32px }
  .sheet { top: auto; left: 0; width: 100%; height: 92%; border-radius: var(--r-sheet) var(--r-sheet) 0 0 }
  .grab { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 0 }
  .walk-list { left: 0; right: 0; bottom: 0; width: 100%; max-height: 40%; border-radius: var(--r-sheet) var(--r-sheet) 0 0 }
  .map-moment { height: 300px }
  .stack { height: 500px }
}
@media (prefers-reduced-motion: reduce) { *, ::view-transition-old(root), ::view-transition-new(root) { transition-duration: 1ms !important; animation-duration: 1ms !important } }

/* Polish pass: sliding nav indicator, offline pill, skeletons, influence map */
.sidenav, .tabbar { position: relative }
.sidenav button, .tabbar button { position: relative; z-index: 1; transition: color 150ms var(--ease, ease-out), transform 120ms ease-out }
.sidenav button:active, .tabbar button:active { transform: scale(.97) }
.sidenav button[aria-current="page"] { background: none; box-shadow: none }
.nav-ind { position: absolute; left: 0; top: 0; border-radius: var(--r-control); background: var(--surface); box-shadow: 0 0 0 1px var(--line); pointer-events: none }
.tabbar .nav-ind { background: var(--tint); box-shadow: none }
.offline { font: 500 12px var(--body); color: var(--warn); background: #F3E8D4; border-radius: 999px; padding: 4px 10px; white-space: nowrap }
.skel { background: linear-gradient(90deg, var(--sunk), #F6F3EE, var(--sunk)); background-size: 200% 100%; border-radius: 8px; animation: skel 1.2s ease-in-out infinite; min-height: 16px }
@keyframes skel { to { background-position: -200% 0 } }
.influence { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden }
.influence > div { background: var(--surface); padding: 16px; display: grid; gap: 4px; align-content: start }
.influence b { font: 600 15px var(--body) }
.influence .n { font: 400 22px var(--mono); font-variant-numeric: tabular-nums; color: var(--accent) }
.influence .first { background: var(--tint) }
@media (prefers-reduced-motion: reduce) { .skel { animation: none } }

/* Plan: segments, phase band, calendar */
.seg-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--sunk); gap: 2px }
.seg-bar > span { display: block; height: 100%; transform-origin: left }
.champ { background: var(--ink) } .persuade { background: var(--accent) } .bulk { background: var(--muted) } .against { background: var(--line) }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 1px }
.cal-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap }
.cal-head .v { font: 400 40px/1 var(--display) }
.phases { display: flex; gap: 2px; border-radius: 12px; overflow: hidden }
.phases > div { background: var(--sunk); padding: 10px 12px; display: grid; gap: 2px; min-width: 0 }
.phases > div.on { background: var(--accent); color: var(--on-accent) }
.phases > div.on .fine { color: var(--tint) }
.cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px 32px }
.cal-row { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 12px 4px }
.cal-row > span:last-child { display: grid; gap: 2px }
.cal-row.past { opacity: .45 }
.cal-row.k-poll b, .cal-row.k-rule b { text-decoration: underline; text-underline-offset: 3px }
.cal-row.k-custom b { color: var(--accent) }
.add-event { display: grid; grid-template-columns: 1fr 170px auto; gap: 8px }
@media (max-width: 820px) { .add-event { grid-template-columns: 1fr 1fr } .add-event .btn { grid-column: 1 / -1 } .phases .fine { display: none } }

/* Brand Kit edition 2 additions */
.btn.ink { background: var(--ink); border-color: var(--ink); color: var(--sand) }
.pill.bad { text-decoration: underline; text-underline-offset: 3px }
.scroll-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px }
.scroll-row::-webkit-scrollbar { display: none }
.scroll-row .chip { flex: none }
.danger-zone { border-top: 1px dashed var(--line); padding-top: 16px }
