/* Цвета берутся из темы Telegram (--tg-theme-*). Вне Telegram — запасные значения ниже. */
:root {
  --fb-bg: #ffffff;
  --fb-bg2: #f1f2f6;
  --fb-text: #111317;
  --fb-hint: #80858f;
  --fb-link: #2a7ad8;
  --fb-sep: rgba(0, 0, 0, .09);
  --fb-danger: #d93a32;

  --bg: var(--tg-theme-bg-color, var(--fb-bg));
  --bg2: var(--tg-theme-secondary-bg-color, var(--fb-bg2));
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --link: var(--tg-theme-link-color, var(--fb-link));
  --sep: var(--tg-theme-section-separator-color, var(--fb-sep));
  --danger: var(--tg-theme-destructive-text-color, var(--fb-danger));

  /* --accent, --accent-text, --accent-soft задаёт app.js из config.js */
  --accent: var(--tg-theme-button-color, #2a7ad8);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --accent-soft: rgba(42, 122, 216, .12);

  --radius: 14px;
  --gap: 16px;
  --tabbar-h: 58px;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fb-bg: #1c1d21;
    --fb-bg2: #111214;
    --fb-text: #f1f2f4;
    --fb-hint: #8d929b;
    --fb-link: #62a8f5;
    --fb-sep: rgba(255, 255, 255, .09);
    --fb-danger: #ff6b61;
  }
}
:root[data-theme="dark"] {
  --fb-bg: #1c1d21;
  --fb-bg2: #111214;
  --fb-text: #f1f2f4;
  --fb-hint: #8d929b;
  --fb-link: #62a8f5;
  --fb-sep: rgba(255, 255, 255, .09);
  --fb-danger: #ff6b61;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg2);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}

button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Каркас ---------- */
.app {
  padding: 12px var(--gap) calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
  max-width: 640px;
  margin: 0 auto;
}
body.typing .app { padding-bottom: 24px; }

.screen { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }

.screen-title {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
  margin: 8px 4px 6px;
  letter-spacing: -.01em;
}
.screen-intro {
  color: var(--hint);
  margin: 0 4px 16px;
}

.card {
  background: var(--section);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--hint);
  margin: 0 0 10px;
}

.disclaimer {
  margin: 24px 4px 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--hint);
  text-align: center;
}

.banner {
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
  padding: 8px var(--gap);
  text-align: center;
}

/* ---------- Кнопки ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-secondary { background: var(--accent-soft); color: var(--accent); }
.btn + .btn { margin-top: 10px; }
.btn svg { width: 20px; height: 20px; flex: none; }

/* ---------- Главная ---------- */
.hero {
  text-align: center;
  padding: 28px 16px 20px;
}
.logo {
  width: 84px;
  height: 84px;
  margin: 0 auto 14px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.02em;
  overflow: hidden;
}
.logo img { width: 100%; height: 100%; object-fit: cover; }
.hero h1 {
  font-size: 26px;
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -.015em;
}
.motto {
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 8px;
}
.description { color: var(--hint); margin: 0 0 20px; }

.row-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.row-icon {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.row-icon svg { width: 22px; height: 22px; }
.row-body { flex: 1; min-width: 0; }
.row-title { font-weight: 600; display: block; }
.row-sub { color: var(--hint); font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--hint); flex: none; width: 18px; height: 18px; }

/* ---------- Программа ---------- */
.acc { padding: 0; overflow: hidden; }
.acc + .acc { margin-top: 0; }
.acc summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 600;
}
.acc summary::-webkit-details-marker { display: none; }
.acc summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.num {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}
.acc-title { flex: 1; min-width: 0; }
.acc .chev { transition: transform .2s; }
.acc[open] .chev { transform: rotate(90deg); }
.acc-body { padding: 0 16px 16px 58px; color: var(--text); margin: 0; }

/* ---------- Формы ---------- */
.field { display: block; }
.label { display: block; font-weight: 600; margin-bottom: 8px; }
.input {
  display: block;
  width: 100%;
  border: 1.5px solid var(--sep);
  background: var(--bg2);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  font-size: 16px; /* без автозума в iOS */
  transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { min-height: 160px; resize: vertical; line-height: 1.45; }
.hint { display: block; color: var(--hint); font-size: 13px; margin-top: 6px; }
.error { color: var(--danger); }
.counter { text-align: right; }

.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}
.check input {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  flex: none;
  margin: 0;
  border: 2px solid var(--hint);
  border-radius: 7px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.check input::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid var(--accent-text);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  opacity: 0;
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { opacity: 1; }
.check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.5px;
  color: var(--hint);
}
.note svg { width: 20px; height: 20px; flex: none; color: var(--hint); margin-top: 1px; }
.note.warn { color: var(--text); }
.note.warn svg { color: var(--danger); }

/* ---------- Выборы ---------- */
.dates {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--accent);
  margin: 0 0 12px;
}
.facts { list-style: none; margin: 0; padding: 0; }
.facts li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0;
}
.facts li::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 8px;
  flex: none;
}

.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li {
  position: relative;
  padding: 0 0 18px 44px;
  counter-increment: s;
}
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 14px;
}
.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 34px;
  bottom: 4px;
  width: 2px;
  background: var(--sep);
}
.steps b { display: block; }
.steps span { color: var(--hint); }

.how { margin: 0; padding-left: 20px; }
.how li { padding: 4px 0; }

/* ---------- Ссылки ---------- */
.list { padding: 0; overflow: hidden; }
.list .row-link { padding: 12px 16px; }
.list .row-link + .row-link { border-top: 1px solid var(--sep); }

/* ---------- Нижняя панель ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1px solid var(--sep);
}
body.typing .tabbar { display: none; }
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--hint);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -.01em;
  cursor: pointer;
  padding: 4px 0;
}
.tab svg { width: 24px; height: 24px; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 10px; }

/* ---------- Окно предпросмотра (вне Telegram) ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-box {
  background: var(--bg);
  width: 100%;
  max-width: 640px;
  border-radius: 18px 18px 0 0;
  padding: 20px var(--gap) calc(20px + var(--safe-bottom));
}
.sheet-box h2 { margin: 0 0 6px; font-size: 18px; }
.sheet-box p { margin: 0 0 12px; color: var(--hint); }
.sheet-box pre {
  background: var(--bg2);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 14px;
  max-height: 40vh;
  overflow: auto;
}

/* ---------- Новости, ЦК, обращения ---------- */
.cover {
  margin: -28px -16px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--bg2);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover:not([hidden]) + .logo { position: relative; z-index: 1; margin-top: -58px; border: 4px solid var(--section); width: 92px; height: 92px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 4px 10px;
}
.section-head h3, .section-label { font-size: 17px; margin: 0; }
.section-label { margin: 4px 4px 10px; }
.link-btn {
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--link);
  font-weight: 600;
  cursor: pointer;
  flex: none;
}

.news { padding: 0; overflow: hidden; }
.news-photo { display: block; width: 100%; max-height: 360px; object-fit: cover; background: var(--bg2); }
.news-date { display: block; padding: 14px 16px 0; font-size: 13px; color: var(--hint); }
.news-text { margin: 4px 16px 16px; white-space: pre-line; }

.empty { color: var(--hint); text-align: center; }
.empty.pad { padding: 16px; margin: 0; }

.row-link.static { cursor: default; }
.row-sub.wrap { white-space: normal; }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin: 4px 0 14px;
  background: var(--section);
  border-radius: 12px;
}
.seg-btn {
  border: 0;
  background: none;
  border-radius: 9px;
  padding: 9px 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--hint);
  cursor: pointer;
  min-width: 0;
}
.seg-btn[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }

/* ---------- Главная v2 ---------- */
.hero.has-cover { padding-top: 28px; }
.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--section);
  color: var(--text);
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s;
}
.tile:active { transform: scale(.97); }
.tile-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.tile-icon svg { width: 22px; height: 22px; }
.tile.primary { background: var(--accent); color: var(--accent-text); }
.tile.primary .tile-icon { background: rgba(255, 255, 255, .2); color: var(--accent-text); }
.tile-label { line-height: 1.25; }

.countdown {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
}
.cd-icon {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.cd-icon svg { width: 26px; height: 26px; }
.countdown.live .cd-icon { background: var(--accent); color: var(--accent-text); }
.cd-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cd-label { font-size: 13px; color: var(--hint); }
.cd-big { font-size: 22px; font-weight: 800; letter-spacing: -.01em; color: var(--accent); }
.cd-small { font-size: 13px; color: var(--hint); }

.body-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  border: 0;
  cursor: pointer;
  color: var(--text);
}
.body-share { font-weight: 600; margin-top: 4px; }

.hscroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin: 0 calc(-1 * var(--gap)) 12px;
  padding: 0 var(--gap) 4px;
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--gap);
  scrollbar-width: none;
}
.hscroll::-webkit-scrollbar { display: none; }
.pcard {
  flex: 0 0 72%;
  max-width: 260px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  min-height: 118px;
  padding: 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--section);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.pcard-title { font-weight: 600; line-height: 1.3; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--section);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}
.chip svg { width: 18px; height: 18px; color: var(--accent); }

/* ---------- Инфографика ---------- */
.hemi { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto; }
.hemi.compact { max-width: 300px; }
.hemi circle { stroke: var(--section); stroke-width: 1.5; }
.hemi circle.vacant { fill: none; stroke: var(--hint); stroke-width: 1.5; stroke-dasharray: 3 2; }
.hemi-total { fill: var(--text); font-size: 30px; font-weight: 800; font-family: inherit; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 10px 0 4px; font-size: 13.5px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }
.swatch.vacant { border: 1.5px dashed var(--hint); }
.members { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--sep); }
.members li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--sep); }
.members li:last-child { border-bottom: 0; }
.m-num { width: 22px; flex: none; color: var(--hint); font-size: 13px; text-align: right; }
.m-name { flex: 1; min-width: 0; font-weight: 500; }
.m-party { color: var(--hint); font-size: 13px; text-align: right; max-width: 45%; }
.muted { color: var(--hint); }
.section-head .muted { font-size: 13px; }

/* ---------- Вступить ---------- */
.join-image {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--section);
}
.join-image img { display: block; width: 100%; height: auto; max-height: 340px; object-fit: cover; }
.join-text p { margin: 0; white-space: pre-line; }
.check.spaced { margin-top: 16px; }
[data-screen="join"] .section-label { margin-top: 28px; }

/* ---------- v3: объявление, отсчёты, этапы, кандидаты ---------- */
.tiles.three { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tiles.three .tile { padding: 12px 10px; gap: 8px; font-size: 13px; }
.tiles.three .tile-icon { width: 34px; height: 34px; border-radius: 10px; }
.tiles.three .tile-icon svg { width: 20px; height: 20px; }

.announce {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--accent);
  color: var(--accent-text);
}
.ann-icon { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .2); }
.ann-icon svg { width: 20px; height: 20px; }
.ann-body { min-width: 0; flex: 1; }
.ann-body p { margin: 0; white-space: pre-line; font-weight: 600; overflow-wrap: anywhere; }
.announce .link-btn { color: var(--accent-text); text-decoration: underline; padding: 6px 0 0; }

.cd-grid { display: grid; gap: 10px; margin-bottom: 12px; }
.cd-grid.two { grid-template-columns: 1fr 1fr; }
.cd-grid .card { margin: 0; }
.cd-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
  border: 0;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.cd-card .cd-label { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--hint); font-size: 13px; line-height: 1.25; }
.cd-card .cd-label svg { width: 18px; height: 18px; flex: none; color: var(--accent); }
.cd-card.warn .cd-label svg { color: #E5484D; }
.cd-card.live { background: var(--accent); color: var(--accent-text); }
.cd-card.live .cd-label, .cd-card.live .cd-label svg, .cd-card.live .cd-small { color: var(--accent-text); }
.cd-card.done { opacity: .75; }
.cd-blocks { display: flex; gap: 6px; flex-wrap: wrap; }
.cd-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 54px;
  padding: 6px 6px 5px;
  border-radius: 10px;
  background: var(--accent-soft);
}
.cd-unit b { font-size: 24px; line-height: 1.1; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.cd-unit small { font-size: 11px; color: var(--hint); }
.cd-blocks.small .cd-unit { min-width: 0; flex: 1; padding: 5px 2px 4px; }
.cd-blocks.small .cd-unit b { font-size: 19px; }
.cd-blocks.small .cd-unit small { font-size: 10px; }
.cd-card.warn .cd-unit { background: rgba(229, 72, 77, .12); }
.cd-card.warn .cd-unit b { color: #E5484D; }
.cd-card.live .cd-unit { background: rgba(255, 255, 255, .18); }
.cd-card.live .cd-unit b, .cd-card.live .cd-unit small { color: var(--accent-text); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 38px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li i {
  position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--sep); background: var(--section); display: grid; place-items: center; box-sizing: border-box;
}
.timeline li i svg { width: 14px; height: 14px; }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 28px; bottom: 2px; width: 2px; background: var(--sep); }
.timeline li.done i { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.timeline li.done::after { background: var(--accent); }
.timeline li.cur i { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline li.cur i::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline b { display: block; }
.timeline span { color: var(--hint); font-size: 14px; }

.cands { display: grid; gap: 10px; margin-bottom: 12px; }
.cands .card { margin: 0; }
.cand { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 15px;
}
.cand-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cand-body span { color: var(--hint); font-size: 14px; white-space: pre-line; overflow-wrap: anywhere; }

.steps.path li { padding-bottom: 14px; }
.steps.path li b { padding-top: 4px; font-weight: 600; }
.num.q { font-weight: 800; }

@media (max-width: 370px) {
  .cd-grid.two { grid-template-columns: 1fr; }
  .tiles.three .tile { font-size: 12px; padding: 10px 8px; }
}

/* ---------- v4: непрочитанное, срочное, итоги, анимации ---------- */
.btn-danger { background: var(--danger); color: #fff; }

/* значки на вкладках */
.tab { position: relative; }
.tab-ico { position: relative; display: inline-flex; transition: transform .15s; }
.tab .badge {
  position: absolute; top: -5px; left: 15px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.tab .badge[hidden] { display: none; }
.tab .badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: -2px; left: 18px; animation: blink 1s ease-in-out infinite; }
.tab .badge.pop { animation: pop .5s cubic-bezier(.3, 1.6, .5, 1); }
.tab[aria-current="page"] .tab-ico { animation: hop .35s ease-out; }
.tab:active .tab-ico { transform: scale(.86); }
@keyframes pop { 0% { transform: scale(0); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-4px); } 100% { transform: translateY(0); } }
@keyframes blink { 50% { opacity: .35; transform: scale(.8); } }

/* всплывашка «1 непрочитанное сообщение» */
.toast {
  position: fixed; left: 12px; right: 12px; z-index: 25;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left;
  border: 0; border-radius: 16px; background: var(--section); color: var(--text); font: inherit;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22); cursor: pointer;
  animation: toast-in .45s cubic-bezier(.2, 1.3, .4, 1) both;
}
.toast.out { animation: toast-out .3s ease-in both; }
.toast-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--danger); color: #fff; }
.toast-icon svg { width: 22px; height: 22px; animation: ring-bell 1.2s ease-in-out 2; transform-origin: 50% 10%; }
.toast-body { display: flex; flex-direction: column; min-width: 0; }
.toast-body b { font-size: 15px; }
.toast-body span { font-size: 13px; color: var(--hint); }
@keyframes toast-in { from { opacity: 0; transform: translateY(30px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(20px); } }
@keyframes ring-bell { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(16deg); } 30% { transform: rotate(-14deg); }
  45% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } 75% { transform: rotate(2deg); } }

/* «Новое» на карточке новости */
.card.news.fresh { position: relative; box-shadow: 0 0 0 2px var(--accent) inset; }
.new-pill { position: absolute; top: 10px; right: 10px; z-index: 1; padding: 2px 8px; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-size: 11px; font-weight: 700; animation: pop .5s cubic-bezier(.3, 1.6, .5, 1); }

/* мигающая плашка срочного на главной */
.urgent-bar {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 var(--gap); padding: 14px;
  border: 0; border-radius: var(--radius); text-align: left; font: inherit; cursor: pointer;
  color: #fff; background: linear-gradient(115deg, #d93a32, #ff5a3c, #d93a32); background-size: 220% 100%;
  animation: urgent-flow 2.4s linear infinite, urgent-pulse 1.6s ease-in-out infinite;
}
.urgent-bar.results { background: linear-gradient(115deg, var(--accent), #f5b301, var(--accent)); background-size: 220% 100%;
  animation: urgent-flow 2.4s linear infinite; }
.ub-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, .22); }
.ub-icon svg { width: 24px; height: 24px; animation: shake 1.8s ease-in-out infinite; }
.ub-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ub-body b { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.ub-body span { font-size: 15px; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ub-chev { width: 20px; height: 20px; flex: none; opacity: .8; }
@keyframes urgent-flow { to { background-position: -220% 0; } }
@keyframes urgent-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 58, 50, .55); } 50% { box-shadow: 0 0 0 8px rgba(217, 58, 50, 0); } }
@keyframes shake { 0%, 60%, 100% { transform: rotate(0); } 10%, 30%, 50% { transform: rotate(-12deg); } 20%, 40% { transform: rotate(12deg); } }

/* окно срочного */
.alert-wrap {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(150, 0, 0, .5); animation: alert-bg 1.2s ease-in-out infinite alternate; overflow: hidden;
}
.alert-wrap.results { background: rgba(0, 0, 0, .55); animation: fade .25s ease-out; }
.alert-wrap.out { animation: fade-out .25s ease-in both; }
.alert-box {
  position: relative; width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto; padding: 26px 20px 20px; text-align: center;
  border-radius: 22px; background: var(--section); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  animation: alert-in .55s cubic-bezier(.2, 1.4, .4, 1) both, alert-shake .5s .55s ease-in-out;
}
.alert-wrap.results .alert-box { animation: alert-in .55s cubic-bezier(.2, 1.4, .4, 1) both; }
.siren { position: relative; width: 76px; height: 76px; margin: 0 auto 14px; }
.siren-core { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%; background: var(--danger); color: #fff; }
.alert-wrap.results .siren-core { background: linear-gradient(135deg, #f5b301, #ff8a00); }
.siren-core svg { width: 38px; height: 38px; animation: shake 1.4s ease-in-out infinite; }
.siren .ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--danger); animation: ripple 1.6s ease-out infinite; }
.siren .ring.r2 { animation-delay: .8s; }
.alert-wrap.results .siren .ring { border-color: #f5b301; }
.alert-kicker { margin: 0; color: var(--danger); font-size: 14px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  animation: blink 1s ease-in-out infinite; }
.alert-wrap.results .alert-kicker { color: #e09a00; animation: none; }
.alert-from { margin: 4px 0 12px; color: var(--hint); font-size: 13px; }
.alert-box h2 { margin: 6px 0 16px; font-size: 20px; }
.alert-text { margin: 0 0 18px; font-size: 17px; line-height: 1.45; white-space: pre-wrap; text-align: left; overflow-wrap: anywhere; }
.alert-box .res { text-align: left; margin-bottom: 18px; }
@keyframes ripple { from { transform: scale(1); opacity: .8; } to { transform: scale(1.9); opacity: 0; } }
@keyframes alert-in { from { opacity: 0; transform: scale(.6) translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes alert-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes alert-bg { from { background-color: rgba(120, 0, 0, .45); } to { background-color: rgba(200, 20, 10, .62); } }
@keyframes fade-out { to { opacity: 0; } }

/* итоги выборов */
.results-card .card-title { display: flex; align-items: center; gap: 6px; }
.results-card .card-title svg { width: 20px; height: 20px; color: #e09a00; }
.res { display: flex; flex-direction: column; gap: 12px; }
.res-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; font-size: 15px; }
.res-head b { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.res-cup { width: 18px; height: 18px; color: #e09a00; flex: none; }
.res-num { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.res-num small { font-weight: 400; color: var(--hint); }
.res-track { height: 12px; border-radius: 6px; background: var(--bg2); overflow: hidden; }
.res-bar { display: block; height: 100%; width: 0; border-radius: 6px; background-color: var(--hint);
  transition: width 1.3s cubic-bezier(.2, .9, .3, 1) var(--d, 0ms); }
.res.go .res-bar { width: var(--w); }
.res-row.ours .res-bar { background-color: var(--accent); }
.res-row.win .res-bar { background-image: linear-gradient(90deg, transparent, rgba(255, 255, 255, .4), transparent);
  background-size: 200% 100%; background-repeat: no-repeat; animation: shine 2s 1.4s ease-in-out infinite; }
.res-row.ours .res-head b { color: var(--accent); }
@keyframes shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* конфетти */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -14px; width: 8px; height: 14px; border-radius: 2px; opacity: .9;
  animation: fall 2s cubic-bezier(.3, .6, .6, 1) both; }
@keyframes fall { to { transform: translate(var(--x), 105vh) rotate(var(--r)); opacity: .7; } }

/* оживление карточек */
.screen:not([hidden]) .card, .screen:not([hidden]) .tile { animation: rise .4s cubic-bezier(.2, .9, .3, 1) both; }
.screen:not([hidden]) .tiles .tile:nth-child(2) { animation-delay: .04s; }
.screen:not([hidden]) .tiles .tile:nth-child(3) { animation-delay: .08s; }
.screen:not([hidden]) .tiles .tile:nth-child(4) { animation-delay: .12s; }
.screen:not([hidden]) .tiles .tile:nth-child(5) { animation-delay: .16s; }
.screen:not([hidden]) .tiles .tile:nth-child(6) { animation-delay: .2s; }
.cd-unit b { display: inline-block; }
.card.cd-card.warn .cd-unit b, .card.cd-card.live .cd-unit b { animation: tick 2s ease-in-out infinite; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes tick { 50% { transform: scale(1.07); } }

@media (prefers-reduced-motion: reduce) {
  .tab .badge, .tab-ico, .toast, .toast-icon svg, .new-pill, .urgent-bar, .ub-icon svg, .alert-wrap, .alert-box,
  .siren-core svg, .siren .ring, .alert-kicker, .res-row.win .res-bar, .screen .card, .screen .tile, .cd-unit b { animation: none !important; }
  .res-bar { transition: none; }
}

/* потеря связи после смены адреса туннеля */
.banner-warn { background: #b42318; color: #fff; font-weight: 600; position: sticky; top: 0; z-index: 50; }

/* ---------- Опросы ---------- */
.poll-card.live { box-shadow: inset 0 0 0 2px var(--accent); }
.poll-card .card-title { display: flex; align-items: center; gap: 6px; color: var(--accent); }
.poll-card .card-title svg { width: 16px; height: 16px; }
.poll-q { margin: 0 0 12px; font-size: 17px; line-height: 1.3; }
.poll-opts { display: grid; gap: 8px; }
.poll-opts .btn + .btn { margin-top: 0; }
.poll-opt { justify-content: flex-start; text-align: left; min-height: 44px; }
.poll-note { color: var(--hint); font-size: 12.5px; margin: 10px 0 0; line-height: 1.35; }
.poll-mine { display: flex; align-items: center; gap: 6px; font-weight: 600; margin: 0 0 10px; }
.poll-mine svg { width: 18px; height: 18px; color: var(--accent); flex: none; }

/* ---------- Версия ---------- */
.version { margin: 6px 4px 0; font-size: 11px; color: var(--hint); text-align: center; opacity: .8; }

/* ---------- Комитеты ---------- */
.council-home { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; font: inherit; color: var(--text); cursor: pointer; }
.council-home.live { box-shadow: inset 0 0 0 2px var(--accent); }
.ch-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.ch-icon svg { width: 22px; height: 22px; }
.ch-body { flex: 1; min-width: 0; }
.ch-body b { display: block; }
.ch-body span { color: var(--hint); font-size: 13.5px; }
.chip.static { cursor: default; }
.bill-card.live { box-shadow: inset 0 0 0 2px var(--accent); }
.bill-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.bill-status { font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--bg2); }
.bill-status.s-voting { background: var(--accent); color: var(--accent-text); }
.bill-status.s-passed { background: rgba(48, 164, 108, .16); color: #2a9461; }
.bill-status.s-rejected { background: rgba(217, 58, 50, .14); color: var(--danger); }
.bill-status.s-wait { background: rgba(245, 179, 1, .18); color: #b07f00; }
.bill-title { margin: 10px 0 8px; font-size: 17px; line-height: 1.3; }
.bill-meta { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 13.5px; color: var(--hint); }
.bill-meta svg { width: 16px; height: 16px; flex: none; }
.vote-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.vote-row .btn + .btn { margin-top: 0; }
.vote-btn { min-height: 46px; padding: 8px 6px; font-size: 14.5px; background: var(--bg2); color: var(--text); gap: 4px; }
.vote-btn svg { width: 16px; height: 16px; }
.vote-btn.on.v-y { background: #2a9461; color: #fff; }
.vote-btn.on.v-n { background: var(--danger); color: #fff; }
.vote-btn.on.v-a { background: var(--hint); color: #fff; }
.bill-res { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg2); font-size: 13.5px; }
.bill-res p { margin: 0; }
.bill-res.ok { border-left: 3px solid #2a9461; }
.bill-res.bad { border-left: 3px solid var(--danger); }
.roll summary, .bill-text summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-top: 8px; font-size: 14px; }
.roll pre { white-space: pre-wrap; font: inherit; margin: 6px 0 0; }
.bill-text { margin-top: 12px; }
.bill-body { white-space: pre-wrap; margin-top: 8px; font-size: 14.5px; line-height: 1.5; max-height: 60vh; overflow: auto; overflow-wrap: anywhere; }
.chat-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.msg { align-self: flex-start; max-width: 85%; background: var(--section); border-radius: 14px 14px 14px 4px; padding: 8px 12px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-radius: 14px 14px 4px 14px; }
.msg-name { display: block; font-size: 12.5px; color: var(--accent); margin-bottom: 2px; }
.msg-text { display: block; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.4; }
.msg-time { display: block; text-align: right; font-size: 11px; opacity: .65; margin-top: 2px; }
.chat-form { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px); display: flex; gap: 8px; align-items: flex-end;
  background: var(--bg2); padding: 8px 0; }
body.typing .chat-form { bottom: 8px; }
.chat-input { flex: 1; min-width: 0; resize: none; border: 1px solid var(--sep); border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 15px;
  background: var(--section); color: var(--text); max-height: 140px; }
.chat-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chat-send { width: 46px; min-height: 46px; padding: 0; flex: none; margin-top: 0; }
.chat-send svg { width: 20px; height: 20px; }
