@font-face {
  font-family: Prata;
  src: url("fonts/prata-cyrillic.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: Prata;
  src: url("fonts/prata-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: Montserrat;
  src: url("fonts/montserrat-cyrillic.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: Montserrat;
  src: url("fonts/montserrat-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: Montserrat;
  src: url("fonts/montserrat-500i-cyrillic.woff2") format("woff2");
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: Montserrat;
  src: url("fonts/montserrat-500i-latin.woff2") format("woff2");
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --ground: #121212;
  --panel: #181818;
  --shade: #202020;
  --ink: #dcdcdc;
  --muted: #aaaaaa;
  --hairline: #262626;
  --frame: #484848;
  --edge: #767676;
  --signal: #ca0000;
  --press: rgb(220 220 220 / .08);
  --display: Prata, Georgia, serif;
  --sans: Montserrat, Arial, sans-serif;
  --pad: 18px;
  --radius: 14px;
  --control-radius: 6px;
  --title-size: clamp(2rem, 10.1vw, 2.75rem);
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
}

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

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--edge) var(--ground);
  scrollbar-width: thin;
}

html:has(.reply-dock:not([hidden])) {
  scroll-padding-bottom: calc(78px + var(--safe-bottom));
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 .875rem/1.45 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--ink); color: var(--ground); }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

h1, h2, p, ul, dl, dd, fieldset, legend { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { min-width: 0; border: 0; }

button { color: inherit; font: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { opacity: .5; }

h1, h2, p, dd, .notice-title, .notice-meta, .notice-due, .opt-label, .opt-voters, .who, .text {
  overflow-wrap: anywhere;
}

.screen {
  display: flex;
  flex-direction: column;
  max-width: 536px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

.view { flex: 1; min-width: 0; }
.masthead { padding-inline: var(--pad); }

.masthead-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 47px;
  border-bottom: 1px solid var(--hairline);
}

.masthead-context {
  min-width: 0;
  padding-block: 5px;
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 600;
}

.back {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  padding: 0 1px;
  border: 0;
  background: transparent;
  font-size: .8125rem;
  font-weight: 600;
}

.back::before, .notice::after, .linkbar .link::after {
  content: "";
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 1px 1px 0;
  transform: rotate(-45deg);
}

.back::before { transform: rotate(135deg); }
.back + .masthead-context { margin-left: auto; text-align: right; }

.masthead-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-block: 20px 16px;
}

.masthead > .masthead-title { padding-block: 20px 16px; }

.masthead-title, .title {
  font: 400 var(--title-size)/1.08 var(--display);
  letter-spacing: -.015em;
  text-transform: uppercase;
  text-wrap: balance;
}

.body { padding: 0 var(--pad) 22px; }
.body > * + * { margin-top: 18px; }

.banner {
  position: sticky;
  z-index: 4;
  top: 6px;
  margin: 7px var(--pad);
  padding: 9px 12px;
  border: 1px solid var(--edge);
  border-radius: var(--control-radius);
  background: var(--panel);
  font-size: .8125rem;
}

.banner:not(.quiet)::before, .owing::before, .must-debt::before, .event-status.void::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-inline-end: 7px;
  border-radius: 50%;
  background: var(--signal);
  vertical-align: 1px;
}

.failure, .empty {
  padding: 16px;
  border: 1px solid var(--frame);
  border-radius: var(--radius);
  color: var(--muted);
}

.failure .btn { margin-top: 16px; }

/* Афиша события */

.event-poster {
  position: relative;
  isolation: isolate;
  overflow: clip;
  margin-top: 12px;
  border: 1px solid var(--frame);
  border-radius: var(--radius);
  background: linear-gradient(140deg, var(--shade), var(--ground) 70%);
}

.event-poster::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -127px;
  right: -108px;
  width: 252px;
  height: 252px;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 14px, var(--hairline) 14px 15px);
  pointer-events: none;
}

.poster-copy { padding: 17px 14px 14px; }
.title { max-inline-size: 13ch; }

.note {
  margin-top: 9px;
  color: var(--muted);
  font: italic 500 .8125rem/1.5 var(--sans);
  letter-spacing: .025em;
  text-transform: uppercase;
  text-wrap: pretty;
  white-space: pre-line;
}

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: baseline;
  gap: 4px 12px;
  margin-top: 12px;
  font-size: .8125rem;
}

.facts dt { color: var(--muted); }
.facts dd { font-weight: 600; }
.facts dd.pending { font-weight: 400; }
.poster-plan { margin-top: 4px; color: var(--muted); font-size: .8125rem; }

.event-status {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 9px;
  border: 1px solid var(--edge);
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.deadline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--frame);
  background: var(--ground);
}

.due-label, .due-date { display: block; }
.due-label {
  color: var(--muted);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.due-date { margin-top: 3px; font-size: .875rem; font-weight: 600; }
.due-time { color: var(--signal); font-size: 2rem; font-weight: 700; line-height: 1; }

.must-debt {
  grid-column: 1 / -1;
  padding-top: 7px;
  border-top: 1px solid var(--hairline);
  font-size: .8125rem;
  font-weight: 600;
}

/* Голосование */

.h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 7px;
  font: 400 1.25rem/1.2 var(--display);
  text-transform: uppercase;
}

.count { color: var(--muted); font: 600 .8125rem/1.3 var(--sans); }
.hint { margin-top: 6px; color: var(--muted); font-size: .8125rem; }
.poll-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 5px 8px; }
.poll-heading .link { margin: 0; }
.poll-hint { color: var(--muted); font-size: .75rem; }

.opts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
}

.opts > li { display: grid; min-width: 0; }
.opts-place > li:first-child,
.opts-place > li:last-child:nth-child(even),
.opts-time > li:last-child:nth-child(odd) { grid-column: 1 / -1; }

.opt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: start;
  align-items: start;
  gap: 4px 8px;
  min-height: 72px;
  padding: 8px 9px;
  border: 1px solid var(--edge);
  border-radius: var(--control-radius);
  background: var(--panel);
  cursor: pointer;
}

.opt input, .choice input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--ink);
}

.opt input { grid-column: 2; grid-row: 1; }
.opt-votes {
  grid-column: 1;
  grid-row: 1;
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 600;
  line-height: 17px;
}

.opt-label, .opt-voters { grid-column: 1 / -1; }
.opt-label { font-weight: 600; line-height: 1.32; }
.opt-voters { color: var(--muted); font-size: .75rem; line-height: 1.35; }
.opt.lead-opt .opt-votes { color: var(--ink); font-weight: 700; }
.opt:has(input:checked) { border-color: var(--ink); background: var(--shade); }

/* Состав */

.roster { margin-top: 6px; }
.roster > div, .rows > li {
  display: grid;
  align-items: baseline;
  gap: 5px 9px;
  padding-block: 8px;
  border-bottom: 1px solid var(--hairline);
}

.roster > div { grid-template-columns: 6.3rem minmax(0, 1fr); }
.roster dt { color: var(--muted); font-size: .8125rem; font-weight: 600; }
.roster .count { font-size: .75rem; }
.me { font-weight: 700; }

.debt-panel {
  padding: 12px;
  border: 1px solid var(--frame);
  border-radius: var(--radius);
}

.debt-panel .h2 + .names { margin-top: 8px; }
.rows { margin-top: 3px; }
.rows > li { grid-template-columns: minmax(0, 1fr) auto; }
.rows .who { font-weight: 600; }
.rows .since { color: var(--muted); font-size: .75rem; }
.debt-panel .actions { margin-top: 7px; }

/* Действия */

.btn, .icon-btn, .tab {
  border: 1px solid var(--ink);
  border-radius: var(--control-radius);
  background: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 7px 11px;
  text-align: center;
  font-weight: 600;
}

.btn.ghost, .btn.danger, .icon-btn { border-color: var(--edge); }
.btn.new { width: auto; padding-inline: 12px; font-size: .8125rem; }
.btn.new::after, .link.add::before {
  content: "";
  width: 11px;
  height: 11px;
  flex: none;
  background:
    linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1px 100% no-repeat;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 5px 0;
  border: 0;
  background: transparent;
  font-size: .8125rem;
  font-weight: 600;
  text-align: left;
}

.link.add { margin-top: 2px; }
.linkbar { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.linkbar .link { padding-inline: 12px; border: 1px solid var(--edge); border-radius: 50px; }
.linkbar .link::after { margin-inline-end: 2px; }

.actions > * + * { margin-top: 7px; }
.h2 + .actions { margin-top: 8px; }

@media (hover: hover) {
  :is(.btn, .icon-btn, .tab, .notice, .link, .back):hover:not(:disabled),
  :is(.opt, .choice):hover {
    background-image: linear-gradient(var(--press), var(--press));
  }
}

:is(.btn, .icon-btn, .tab, .notice, .link, .back):active:not(:disabled) {
  background-color: var(--shade);
}

/* Форма и правила */

.field { scroll-margin-top: 12px; }
.field + .field { margin-top: 17px; }

.field > label, .field > legend {
  display: block;
  width: 100%;
  padding-bottom: 6px;
  font-size: .8125rem;
  font-weight: 650;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 8px 9px;
  border: 1px solid var(--edge);
  border-radius: var(--control-radius);
  background: var(--ground);
  color: var(--ink);
  font: 400 1rem/1.3 var(--sans);
}

textarea.input { min-height: 74px; resize: vertical; }
.input::placeholder { color: var(--muted); opacity: 1; }
.input:focus-visible, .input[aria-invalid="true"] { border-color: var(--ink); }
.input[aria-invalid="true"] { outline: 1px dashed var(--ink); outline-offset: 2px; }
.input::-webkit-datetime-edit { padding: 0; }

.field-error { margin-top: 6px; font-size: .8125rem; font-weight: 600; }

.multi > li { display: flex; gap: 7px; }
.multi > li + li { margin-top: 6px; }
.multi .input { flex: 1; }
.multi + .link { margin-bottom: -5px; }

.icon-btn {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 44px;
  min-height: 44px;
}

.icon-btn svg { width: 15px; height: 15px; }

.inline-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-top: 8px;
}

.inline-add:has(input[type="datetime-local"]) { grid-template-columns: minmax(0, 1fr); }

.settings > section {
  padding: 12px;
  border: 1px solid var(--frame);
  border-radius: var(--radius);
}

.settings > section + section { margin-top: 10px; }
.settings .h2 { margin-bottom: 7px; }

.choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 3px 8px;
  min-height: 46px;
  padding: 8px 4px;
  border-top: 1px solid var(--hairline);
  cursor: pointer;
}

.choice:has(input:checked) { background: var(--panel); }
.choice input { margin-top: 2px; }
.choice-title { font-weight: 650; }
.choice-desc { grid-column: 2; color: var(--muted); font-size: .8125rem; overflow-wrap: anywhere; }

.phrases > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  padding-block: 6px;
  border-bottom: 1px solid var(--hairline);
}

.phrases .text { min-width: 0; }

/* Каталог сборов и чатов */

.notices { display: grid; gap: 8px; }

.notice {
  position: relative;
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 13px 12px 10px;
  border: 1px solid var(--frame);
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--panel), var(--ground) 64%);
  text-align: left;
}

.notice::after { position: absolute; top: 22px; right: 13px; color: var(--ink); }

.notice-title {
  display: block;
  padding-right: 18px;
  font: 400 1.25rem/1.18 var(--display);
  text-transform: uppercase;
}

.notice-meta, .notice-due {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: .8125rem;
}

.notice-due { margin-top: 3px; }

.notice-state {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 9px;
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: .75rem;
}

.notice-answer { color: var(--ink); font-weight: 650; }

/* Ответ закреплён у нижней кромки */

.reply-dock {
  position: sticky;
  z-index: 3;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 7px var(--pad) calc(7px + var(--safe-bottom));
  border-top: 1px solid var(--hairline);
  background: var(--ground);
}

.reply-dock[hidden] { display: none; }

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 48px;
  padding: 5px 4px;
  border-color: var(--edge);
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.15;
  text-transform: uppercase;
}

.tab::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border: 1px solid var(--edge);
  border-radius: 50%;
}

.tab[aria-pressed="true"] { border-color: var(--ink); font-weight: 700; }
.tab[aria-pressed="true"]::before { border-color: var(--signal); background: var(--signal); }
.tab:focus-visible { outline-offset: -4px; }

/* Загрузка */

.skeleton {
  margin: 0 var(--pad) 22px;
  padding: 16px;
  border: 1px solid var(--frame);
  border-radius: var(--radius);
}

.sk {
  width: 83%;
  height: 12px;
  margin-top: 9px;
  border-radius: 2px;
  background: var(--hairline);
  animation: pulse 1.1s ease-in-out infinite alternate;
}

.sk-title { width: 67%; height: 29px; margin-top: 0; }
.sk-short { width: 46%; }
@keyframes pulse { from { opacity: .45; } to { opacity: 1; } }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 359px) {
  :root { --pad: 14px; }
  .opt { padding-inline: 8px; }
  .tab { gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
}
