/* Цвета — из темы Telegram (--tg-theme-*). Запасные значения — для открытия в обычном браузере. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-2: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --text: var(--tg-theme-text-color, #16161a);
  --hint: var(--tg-theme-hint-color, #8a8a93);
  --link: var(--tg-theme-link-color, #2d7fd3);
  --accent: var(--tg-theme-accent-text-color, var(--link));
  --button: var(--tg-theme-button-color, #2d7fd3);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --heading: var(--tg-theme-section-header-text-color, var(--accent));
  --danger: var(--tg-theme-destructive-text-color, #d93b3b);

  --display: "Unbounded", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius-outer: 18px;
  --pad: 16px;
  --radius-inner: 10px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #17171b;
    --bg-2: #0f0f12;
    --text: #f2f2f5;
    --hint: #8d8d97;
    --link: #6ab2f2;
    --button: #3d8fe0;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg-2);
  color: var(--text);
  font: 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  padding: 0 0 calc(24px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin-inline: auto;
  overflow-wrap: anywhere;
}

h1, h2 { text-wrap: balance; margin: 0; }
p { margin: 0; text-wrap: pretty; }

.masthead { padding: 20px var(--pad) 8px; }
.fest {
  font: 700 22px/1.1 var(--display);
  letter-spacing: -0.01em;
}
.hello { color: var(--hint); margin-top: 6px; }
.hello:empty { display: none; }

main { display: grid; gap: 12px; padding: 8px 12px 0; }

.state { color: var(--hint); padding: 32px var(--pad); text-align: center; }

.section, .state-card, .balance {
  background: var(--section);
  border-radius: var(--radius-outer);
  padding: var(--pad);
  display: grid;
  gap: 10px;
}
.section-plain { background: transparent; padding-block: 4px; }
.section h2, .state-card h2 {
  font: 600 15px/1.3 var(--body);
  color: var(--heading);
}
/* Главная кабинета: названия разделов жирнее (Денис, 3518) и чёрные, как «Мои заявки» (Денис, 3539). Админка и остальные экраны — прежние. */
#home .section h2:not(.audience-total) { font: 700 15px/1.3 var(--body); color: var(--text); }
.hint { color: var(--hint); font-size: 14px; }

/* Баланс — главная и единственная крупная деталь экрана. */
.balance { padding-block: 22px 18px; }
.balance-caption { color: var(--hint); font-size: 14px; }
.balance-value {
  font: 700 clamp(40px, 13vw, 52px)/1 var(--display);
  letter-spacing: -0.03em;
  color: var(--text);
}
.audience { gap: 4px; }
.audience[hidden] { display: none; }
.audience-total {
  font: 700 20px/1.1 var(--display);
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.section h2.audience-total { font: 700 20px/1.1 var(--display); color: var(--text); }
.audience-detail { color: var(--hint); font-size: 14px; }
.balance-split { display: flex; gap: 24px; margin: 4px 0 0; }
.balance-split div { display: grid; gap: 2px; }
.balance-split dt { color: var(--hint); font-size: 13px; }
.balance-split dd { margin: 0; font: 500 17px/1.2 var(--display); }

.ref-link {
  background: var(--bg-2);
  border-radius: var(--radius-inner); /* внешний 18 ≈ 10 + отступ блока */
  padding: 10px 12px;
  font-size: 15px;
  user-select: all;
}

.row-actions, .form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.button {
  appearance: none;
  border: 0;
  border-radius: var(--radius-inner);
  background: var(--button);
  color: var(--button-text);
  font: 600 15px/1 var(--body);
  min-height: 44px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition-property: scale, opacity;
  transition-duration: 160ms;
  transition-timing-function: var(--ease);
}
.button:active { scale: 0.96; }
.button:disabled { opacity: 0.55; cursor: default; }
.button-quiet {
  background: var(--bg-2);
  color: var(--link);
}
.row-actions .button { flex: 1 1 140px; }

.link-button {
  appearance: none;
  background: none;
  border: 0;
  color: var(--link);
  font: inherit;
  min-height: 44px;
  padding: 0 4px;
  cursor: pointer;
}

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

/* Команда: три ступени — уровень 1, 2, 3. */
.team { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.team details {
  background: var(--bg-2);
  border-radius: var(--radius-inner);
}
.team summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 12px;
  cursor: pointer;
}
.team summary::-webkit-details-marker { display: none; }
.team .step {
  font: 700 13px/1 var(--display);
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--button);
  color: var(--button-text);
  flex: none;
}
.team li:nth-child(2) .step { opacity: 0.75; }
.team li:nth-child(3) .step { opacity: 0.5; }
.team .level-name { flex: 1; }
.team .level-count { font: 500 17px/1 var(--display); }
.team .chevron {
  color: var(--hint);
  transition: rotate 200ms var(--ease);
}
.team details[open] .chevron { rotate: 90deg; }
.people-fold { background: var(--bg-2); border-radius: var(--radius-inner); margin-top: 12px; }
.people-fold summary { list-style: none; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 12px; cursor: pointer; }
.people-fold summary::-webkit-details-marker { display: none; }
.people-fold .level-name { flex: 1; font-weight: 600; }
.person .blocked-mark { color: var(--danger); font-weight: 600; }
.people-fold .people-count { color: var(--hint); font-variant-numeric: tabular-nums; }
.people-fold .chevron { color: var(--hint); transition: rotate 200ms var(--ease); }
.people-fold[open] .chevron { rotate: 90deg; }
.people-fold .people, .people-fold .hint { padding: 0 12px; }
.people-fold .fest-more { width: calc(100% - 24px); margin: 8px 12px 12px; }
.team .members { list-style: none; margin: 0; padding: 0 12px 10px 52px; display: grid; gap: 8px; }
.team .members li { display: grid; }
.team .members small, .team .members .muted { color: var(--hint); font-size: 13px; }

.ops { list-style: none; margin: 0; padding: 0; display: grid; }
.ops li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--hint) 20%, transparent);
}
.ops li:last-child { box-shadow: none; }
.ops .what { display: grid; gap: 2px; min-width: 0; }
.ops .what small { color: var(--hint); font-size: 13px; }
.ops .amount { font: 500 16px/1.3 var(--display); white-space: nowrap; }
.ops .plus { color: var(--accent); }
.empty { color: var(--hint); font-size: 15px; }

/* Анкета */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field span { font-size: 14px; color: var(--hint); }
.field input, .field textarea, .field select, .search input, .refund-form input {
  font: 16px/1.3 var(--body); /* 16px — чтобы iOS не увеличивал страницу при фокусе */
  color: var(--text);
  background: var(--bg-2);
  border: 0;
  border-radius: var(--radius-inner);
  padding: 12px;
  min-height: 46px;
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow 160ms var(--ease);
}
.field textarea { resize: vertical; min-height: 120px; }

/* Выбор из карточек вместо выпадающего списка (ADR-0064): тариф, задание.
   Кнопки явные, зона нажатия — не меньше 44px, у каждой видно нажатие. */
.choices { display: grid; gap: 10px; }
.choice {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-inner);
  background: var(--bg-2);
  box-shadow: inset 0 0 0 2px transparent;
  transition: box-shadow 160ms var(--ease);
}
.choice.selected { box-shadow: inset 0 0 0 2px var(--button); }
.choice-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field .choice-title { font: 600 16px/1.3 var(--body); color: var(--text); overflow-wrap: anywhere; }
.field .choice-side { font: 500 16px/1.3 var(--display); color: var(--text); white-space: nowrap; }
.claim-form .choice { background: var(--section); }
.claim-form .choice:not(.selected) .choice-pick, .claim-form .choice-more { background: var(--bg-2); }
.choice-desc { margin: 0; font-size: 15px; line-height: 1.4; color: var(--text); overflow-wrap: anywhere; }
.choice-plain { white-space: pre-line; }
.choice-bullets { list-style: none; padding: 0; display: grid; gap: 4px; }
.choice-bullets li { position: relative; padding-left: 16px; }
.choice-bullets li::before { content: "•"; position: absolute; left: 2px; color: var(--hint); }
.choice-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; }
.choice-more {
  appearance: none;
  border: 0;
  border-radius: var(--radius-inner);
  background: var(--section);
  color: var(--link);
  font: 600 15px/1 var(--body);
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--link) 45%, transparent);
  transition-property: scale, background-color;
  transition-duration: 160ms;
  transition-timing-function: var(--ease);
}
.choice-more:active { scale: 0.96; background: color-mix(in srgb, var(--link) 16%, var(--section)); }
.choice-pick { flex: 1 1 120px; }
.choice-pick:active { scale: 0.96; filter: brightness(0.9); }
.choice:not(.selected) .choice-pick { background: var(--section); color: var(--button); box-shadow: inset 0 0 0 1.5px var(--button); }
.choice-pick:disabled { opacity: 0.55; }
.field input:focus, .field textarea:focus, .field select:focus, .search input:focus, .refund-form input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--link);
}
.field [aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--danger); }
.consent { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; cursor: pointer; }
/* Свой чекбокс: родной в тёмной теме Telegram оставался ярко-белым. */
.consent input {
  appearance: none;
  width: 22px; height: 22px;
  margin: 1px 0 0;
  flex: none;
  border-radius: 6px;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--hint) 70%, transparent);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition-property: background-color, box-shadow;
  transition-duration: 160ms;
  transition-timing-function: var(--ease);
}
.consent input::before {
  content: "";
  width: 12px; height: 12px;
  background: var(--button-text);
  clip-path: polygon(14% 44%, 0 58%, 40% 96%, 100% 22%, 86% 8%, 38% 68%);
  scale: 0.25;
  opacity: 0;
  transition-property: scale, opacity;
  transition-duration: 160ms;
  transition-timing-function: var(--ease);
}
.consent input:checked { background: var(--button); box-shadow: none; }
.consent input:checked::before { scale: 1; opacity: 1; }
.consent input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--danger); }
.error { color: var(--danger); font-size: 13px; }

/* Согласия на обработку ПДн (ADR-0025): два флажка подряд, ссылки на документы. */
.consents { display: grid; gap: 10px; }
.consent .doc-link { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.operator { font-size: 13px; }
.operator a { color: inherit; }
/* Плашка повторного согласия — над балансом, выделена рамкой акцента. */
.reconsent { margin: 0 0 12px; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent); }
.error:empty { display: none; }

.net-hint {
  position: fixed; inset: max(12px, env(safe-area-inset-top)) 16px auto; z-index: 20;
  margin: 0; padding: 10px 14px; border-radius: 12px; text-align: center; text-wrap: balance;
  background: var(--bg-2); color: var(--text); font-size: 14px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}
.net-hint[hidden] { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  translate: -50% 8px;
  opacity: 0;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  pointer-events: none;
  transition-property: opacity, translate;
  transition-duration: 200ms;
  transition-timing-function: var(--ease);
}
.toast.shown { opacity: 1; translate: -50% 0; }

/* --- Админка ------------------------------------------------------------ */

/* Переключатель «Кабинет / Админка»: внешний радиус 13 = 10 + отступ 3. */
.tabs {
  display: flex;
  margin-top: 14px;
  padding: 3px;
  border-radius: 13px;
  background: var(--section);
}
.tab {
  appearance: none;
  flex: 1;
  border: 0;
  border-radius: var(--radius-inner);
  background: transparent;
  color: var(--hint);
  font: 600 15px/1 var(--body);
  min-height: 40px;
  cursor: pointer;
  transition-property: background-color, color;
  transition-duration: 160ms;
  transition-timing-function: var(--ease);
}
.tab[aria-pressed="true"] { background: var(--button); color: var(--button-text); }

#home, #admin, .panel { display: grid; gap: 12px; }
#admin > .back { justify-self: start; }

.search { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; }

.people { list-style: none; margin: 0; padding: 0; display: grid; }
.person {
  appearance: none;
  width: 100%;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 0;
  cursor: pointer;
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--hint) 20%, transparent);
}
.people li:last-child .person { box-shadow: none; }
.person .what { display: grid; gap: 2px; min-width: 0; }
.person small, .people .muted { color: var(--hint); font-size: 13px; }
.person .amount { font: 500 16px/1.3 var(--display); white-space: nowrap; }

.facts { margin: 0; display: grid; gap: 10px; }
.facts div { display: grid; grid-template-columns: minmax(0, 9.5em) minmax(0, 1fr); gap: 12px; }
.facts dt { color: var(--hint); font-size: 14px; }
.facts dd { margin: 0; }
.facts .muted { color: var(--hint); }
@media (max-width: 360px) {
  .facts div { grid-template-columns: 1fr; gap: 2px; }
}

.ops .struck { text-decoration: line-through; color: var(--hint); }
.ops li.sale { flex-wrap: wrap; }
.refund { flex-basis: 100%; }
.refund > .link-button { padding-inline: 0; }
.refund-form { display: grid; gap: 8px; padding-top: 4px; }
.button-danger { background: var(--danger); color: #fff; }

.form h3, .report h3 { margin: 0; font: 700 15px/1.3 var(--body); }

/* Предпросмотр начислений — до подтверждения продажи. */
.preview {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-inner);
  background: var(--bg-2);
}
.split { list-style: none; margin: 0; padding: 0; display: grid; }
.split li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--hint) 20%, transparent);
}
.split li:last-child { box-shadow: none; }
.split .what { display: grid; gap: 2px; min-width: 0; }
.split small { color: var(--hint); font-size: 13px; }
.split .amount { font: 500 17px/1.2 var(--display); white-space: nowrap; }
.split .plus { color: var(--accent); }
.split .total { font-weight: 600; }

.segmented {
  display: flex;
  margin: 0;
  padding: 3px;
  border: 0;
  border-radius: 13px;
  background: var(--bg-2);
}
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: grid;
  place-items: center;
  min-height: 40px;
  border-radius: var(--radius-inner);
  color: var(--hint);
  font-weight: 600;
  cursor: pointer;
  transition-property: background-color, color;
  transition-duration: 160ms;
  transition-timing-function: var(--ease);
}
.segmented input:checked + span { background: var(--button); color: var(--button-text); }
.segmented input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }

.report { display: grid; gap: 10px; padding-top: 6px; }
.missing { margin: 0; padding-left: 20px; display: grid; gap: 4px; color: var(--danger); }

/* --- Комкойны за активность ------------------------------------------------ */

/* Из бота кабинет открывается на этом блоке — оставляем воздух над ним. */
#activities { scroll-margin-top: 12px; }
/* Заголовок блока — тем же дисплейным шрифтом, что баланс и число подписчиков,
   но заметно меньше баланса: баланс остаётся главной деталью экрана. */
#activities-title {
  font: 700 clamp(18px, 5.6vw, 22px)/1.15 var(--display);
  letter-spacing: -0.02em;
  color: var(--text);
}
.subhead { margin: 6px 0 0; font: 700 15px/1.3 var(--body); }

/* Виды активности: награда — главное число строки, как баланс на экране. */
.kinds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.kinds li {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-inner);
  background: var(--bg-2);
}
.kinds .what { display: grid; gap: 2px; min-width: 0; }
.kinds .what span { font-weight: 600; }
.kinds small { color: var(--hint); font-size: 13px; }
.kinds .reward {
  font: 700 22px/1 var(--display);
  letter-spacing: -0.02em;
  color: var(--accent);
  white-space: nowrap;
}
.kinds .empty { background: none; padding: 0; }
.kinds .what { flex: 1 1 0; }
.kind-do, #home-buy-ticket { flex: 1 1 100%; min-height: 44px; }
.kind-do:active, #home-buy-ticket:active { scale: 0.96; filter: brightness(0.9); }
.kind-form { flex: 1 1 100%; padding: 4px 0 0; background: none; }

.claim-form {
  padding: 12px;
  border-radius: var(--radius-inner);
  background: var(--bg-2);
}
/* Поля внутри серой формы — на цвете карточки, иначе сливаются с фоном. */
.claim-form .field input, .claim-form .field select { background: var(--section); }

/* Статус заявки — цветом текста, без плашек. */
.status-pending { color: var(--hint); }
.status-approved { color: var(--accent); }
.status-rejected { color: var(--danger); }
.ops .status { font: 500 14px/1.3 var(--body); white-space: nowrap; }
.ops .reason { flex-basis: 100%; color: var(--danger); font-size: 13px; margin-top: -4px; }
.claims-mine li { flex-wrap: wrap; }

/* Очередь заявок у администратора. */
.claims { list-style: none; margin: 0; padding: 0; display: grid; }
.claim {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--hint) 20%, transparent);
}
.claim:last-child { box-shadow: none; }
.claim .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.claim .head .what { display: grid; gap: 2px; min-width: 0; }
.claim small { color: var(--hint); font-size: 13px; }
.claim .amount { font: 500 16px/1.3 var(--display); white-space: nowrap; color: var(--accent); }
/* Ссылка — только текстом: её не встраиваем и не делаем кликабельной разметкой. */
.claim-url {
  background: var(--bg-2);
  border-radius: var(--radius-inner);
  padding: 10px 12px;
  font-size: 14px;
  user-select: all;
}
.claim .note { font-size: 14px; }
.claim .form-actions .button { flex: 1 1 120px; }
.claim .refund-form { padding-top: 0; }

/* Одно появление при загрузке: блоки кабинета выходят по очереди. */
#home > * { animation: rise 360ms var(--ease) both; }
#home > *:nth-child(2) { animation-delay: 60ms; }
#home > *:nth-child(3) { animation-delay: 120ms; }
#home > *:nth-child(4) { animation-delay: 180ms; }
#home > *:nth-child(n+5) { animation-delay: 240ms; }
@keyframes rise { from { opacity: 0; translate: 0 8px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0ms !important; }
}

/* Тихая кнопка вне карточки стоит прямо на фоне страницы — даём ей фон карточки. */
.panel > .row-actions .button-quiet { background: var(--section); }

/* Таймпад: состояние сверки рядом с кнопкой «Сверить сейчас». */
.sync-state { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sync-state .hint { margin: 0; flex: 1 1 180px; text-wrap: pretty; }
.sync-state .error { margin: 0; }
/* Возвраты, задержанные предохранителем сверки: предупреждение и подтверждение. */
.refunds-held { display: grid; gap: 8px; margin-top: 12px; }
.refunds-held > .error { margin: 0; font-size: 14px; text-wrap: pretty; }
.refunds-held .hint { margin: 0; text-wrap: pretty; }
.claim .amount.plain { color: inherit; }
.claim .note.warn { color: var(--danger); }
.claim .people { margin-top: 4px; }
.claim .note.muted { color: var(--hint); }

/* Роли (ADR-0013): переключатель с пояснением, что он даёт; строка — не меньше 44px под палец. */
#adm-role .consent { min-height: 44px; align-items: center; }
#adm-role .consent span { display: grid; gap: 2px; }
.role-note { color: var(--hint); font-size: 13px; text-wrap: pretty; }
.consent input:disabled, .consent input:disabled + span { opacity: 0.55; cursor: default; }

/* --- Билет за комкойны (срез 8) ---------------------------------------------- */

#ticket { scroll-margin-top: 12px; }
.ticket-form { gap: 12px; }

/* Пять процентов в ряд: на узком телефоне — чуть плотнее. */
.percents span { min-height: 40px; font-size: 15px; }
.segmented input:disabled + span { opacity: 0.35; cursor: default; }
@media (max-width: 360px) {
  .percents span { font-size: 14px; }
}

/* Выданный код — главное на экране: крупно, моноширинно, выделяется целиком. */
.promo {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-inner);
  background: var(--bg-2);
}
.promo-caption { color: var(--hint); font-size: 14px; }
.promo-code {
  font: 600 24px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  color: var(--accent);
  user-select: all;
  -webkit-user-select: all;
  overflow-wrap: anywhere;
}

/* Наборы в админке: не кнопка — без нажатия, числа свободных справа. */
.code-set { cursor: default; }
.code-set .warn { color: var(--danger); }
.code-set { flex-wrap: wrap; }
.code-set .code-remove { flex-basis: 100%; min-height: 36px; padding-block: 6px; font-size: 14px; color: var(--danger); }
.screen-title { font-size: 22px; margin-block: 12px; }

/* --- «О фестивале» (ADR-0028): лента анонсов, HTML поста — от сервера ---------------- */
.fest-list { display: grid; gap: 12px; }
.post {
  background: var(--section);
  border-radius: var(--radius-outer);
  padding: var(--pad);
  display: grid;
  gap: 10px;
  min-width: 0;
}
.post-date { color: var(--hint); font-size: 13px; }
.post-body { display: grid; gap: 10px; min-width: 0; }
.post-body > *, .post-body blockquote > *, .post-body details > * { margin: 0; }
.post-body h3, .post-body h4, .post-body h5, .post-body h6 {
  font: 600 18px/1.25 var(--body);
  text-wrap: balance;
  margin: 0;
}
.post-body h3 { font: 700 20px/1.2 var(--display); }
.post-body h5, .post-body h6 { font-size: 16px; }
.post-body a { color: var(--link); }
.post-body pre, .post-body code {
  font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-2);
  border-radius: 6px;
}
.post-body code { padding: 1px 4px; }
.post-body pre { padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-body pre code { padding: 0; background: none; }
.post-body blockquote {
  margin: 0;
  padding: 2px 0 2px 12px;
  box-shadow: inset 3px 0 0 var(--accent);
  display: grid;
  gap: 6px;
}
.post-body blockquote.pullquote { font-size: 18px; font-style: italic; }
.post-body cite { color: var(--hint); font-size: 14px; font-style: normal; }
.post-body ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.post-body hr { border: 0; height: 1px; background: var(--bg-2); margin: 4px 0; width: 100%; }
.post-body details summary { cursor: pointer; color: var(--link); min-height: 32px; }
.post-footer, .post-thinking { color: var(--hint); font-size: 14px; }
.post-table { overflow-x: auto; }
.post-body table { border-collapse: collapse; font-size: 14px; }
.post-body th, .post-body td { padding: 6px 8px; text-align: left; vertical-align: top; }
.post-body table.bordered th, .post-body table.bordered td { box-shadow: inset 0 0 0 0.5px var(--hint); }
.post-body caption { color: var(--hint); caption-side: bottom; padding-top: 4px; text-align: left; }

/* Спойлер — закрашенный текст, открывается нажатием. */
.spoiler { background: var(--hint); color: transparent; border-radius: 4px; cursor: pointer; transition-property: color, background-color; transition-duration: 160ms; }
.spoiler.shown { background: transparent; color: inherit; cursor: auto; }

.post-media { margin: 0; display: grid; gap: 6px; position: relative; }
.post-media img, .post-media video {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: var(--bg-2);
  border-radius: var(--radius-inner);
  outline: 1px solid rgba(0, 0, 0, 0.1);
  outline-offset: -1px;
}
@media (prefers-color-scheme: dark) {
  .post-media img, .post-media video { outline-color: rgba(255, 255, 255, 0.1); }
}
.post-media[data-kind="video_note"] video {
  width: min(100%, 280px);
  aspect-ratio: 1;
  max-height: none;
  margin-inline: auto;
  object-fit: cover;
  border-radius: 50%;
  outline-offset: 0;
}
.post-media audio { width: 100%; }
.post-media figcaption { color: var(--hint); font-size: 14px; }
.post-media-spoiler { cursor: pointer; overflow: hidden; border-radius: var(--radius-inner); }
.post-media-spoiler img, .post-media-spoiler video { filter: blur(24px); }
.post-media-spoiler::after {
  content: "Нажмите, чтобы посмотреть";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.post-media-failed { color: var(--hint); font-size: 14px; background: var(--bg-2); border-radius: var(--radius-inner); padding: 10px 12px; }
.post-file {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-inner);
  background: var(--bg-2);
  text-decoration: none;
}
.post-file::before { content: "📎 "; }
.post-collage .post-row, .post-slideshow .post-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px; }
.post-slideshow .post-row { grid-auto-flow: column; grid-auto-columns: 85%; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x mandatory; }
.post-slideshow .post-row > * { scroll-snap-align: start; }
.post-collage, .post-slideshow { margin: 0; display: grid; gap: 6px; }
.post-collage figcaption, .post-slideshow figcaption { color: var(--hint); font-size: 14px; }
.post-buttons, .post-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.post-actions .button { flex: 1 1 160px; }
.post-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-inner);
  background: var(--bg-2);
  text-decoration: none;
}
.fest-more { width: 100%; margin-top: 12px; }
#fest-view .state { padding-block: 24px; }

/* --- Посты из мини-приложения (ADR-0031 — ADR-0033) ------------------------------------- */
.post-add { width: 100%; margin-bottom: 12px; }
.content-lead { margin: -4px 0 12px; }

/* Действия под постом: скопировать, скачать, скрыть — тихие, чтобы не спорить с кнопками поста. */
.post-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.post-tool {
  appearance: none;
  border: 0;
  background: var(--bg-2);
  color: var(--link);
  font: 500 14px/1 var(--body);
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-inner);
  cursor: pointer;
  transition-property: scale, opacity;
  transition-duration: 160ms;
  transition-timing-function: var(--ease);
}
.post-tool:active { scale: 0.96; }
.post-tool:disabled { opacity: 0.55; }
.post-tool-danger { color: var(--danger); }
.post-hidden { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--hint) 45%, transparent); }
.post-hidden .post-body { opacity: 0.6; }
.post-badge { color: var(--hint); font-size: 13px; font-weight: 600; }

/* Редактор */
.post-form { gap: 18px; }
.pe-toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.pe-tool {
  appearance: none;
  border: 0;
  background: var(--bg-2);
  color: var(--text);
  font: 500 15px/1 var(--body);
  min-width: 44px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-inner);
  cursor: pointer;
  transition-property: scale, background-color;
  transition-duration: 160ms;
  transition-timing-function: var(--ease);
}
.pe-tool:active { scale: 0.96; }
.pe-tool[aria-expanded="true"] { background: color-mix(in srgb, var(--link) 18%, var(--bg-2)); }
.pe-bold { font-weight: 800; }
.pe-italic { font-style: italic; font-family: Georgia, serif; }
.pe-strike { text-decoration: line-through; }
.pe-spoiler { background: color-mix(in srgb, var(--hint) 35%, var(--bg-2)); }
.pe-emoji-open { font-size: 18px; }
.pe-link { display: flex; gap: 8px; }
.pe-link input { flex: 1; min-width: 0; }
.pe-emoji { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 2px; }
.pe-emoji-item {
  appearance: none; border: 0; background: none; cursor: pointer;
  font-size: 22px; min-height: 44px; border-radius: var(--radius-inner);
}
.pe-emoji-item:active { background: var(--bg-2); }
.post-form textarea { min-height: 180px; }

.pe-media { display: grid; gap: 8px; }
.pe-media-frame img, .pe-media-frame video {
  display: block; width: 100%; max-height: 40vh; object-fit: contain;
  background: var(--bg-2); border-radius: var(--radius-inner);
  outline: 1px solid rgba(0, 0, 0, 0.1); outline-offset: -1px;
}
@media (prefers-color-scheme: dark) {
  .pe-media-frame img, .pe-media-frame video { outline-color: rgba(255, 255, 255, 0.1); }
}
.pe-progress { height: 4px; border-radius: 2px; background: var(--bg-2); overflow: hidden; }
.pe-progress i {
  display: block; height: 100%; background: var(--button);
  transform-origin: left; scale: var(--done, 0) 1;
  transition: scale 200ms var(--ease);
}

.pe-buttons { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pe-buttons:empty { display: none; }
.pe-button-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 8px;
  border-radius: calc(var(--radius-inner) + 8px);
  background: color-mix(in srgb, var(--bg-2) 50%, transparent);
}
.pe-button-row input:nth-of-type(2) { grid-column: 1; }
.pe-button-row .pe-row-remove { grid-column: 2; grid-row: 1 / span 2; }
.pe-button-row .pe-row-error { grid-column: 1 / -1; }
.pe-row-remove {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--danger); font: 500 14px/1 var(--body);
  min-width: 44px; padding: 0 6px; border-radius: var(--radius-inner);
}
.pe-mail small { display: block; margin-top: 2px; }

/* Предпросмотр: тот же пост, что в разделе, в рамке «образец». */
.pe-preview { display: grid; gap: 10px; margin-top: 12px; }
.pe-preview-title { font: 600 15px/1.3 var(--body); color: var(--heading); padding-inline: 4px; }
.pe-preview .post { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--link) 40%, transparent); }

@media (prefers-reduced-motion: reduce) {
  .pe-progress i { transition: none; }
}


/* --- аукцион: табло видно со сцены, если вывести экран на проектор --- */
.lot-live h2 { font: 700 22px/1.2 var(--display); color: var(--text); }
.lot-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}
.lot-cell {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-inner); /* внешний 18 ≈ 10 + отступ блока */
  background: var(--bg-2);
}
.lot-label { color: var(--hint); font-size: 13px; }
.lot-figure {
  font: 700 clamp(28px, 9vw, 56px)/1 var(--display);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  transition-property: color;
  transition-duration: 200ms;
  transition-timing-function: var(--ease);
}
.lot-figure.urgent { color: var(--danger); }
.lot-figure.waiting { font-size: 17px; line-height: 1.3; font-weight: 500; color: var(--hint); align-self: end; }
.lot-leader { font-size: 16px; }
.lot-leader .muted { color: var(--hint); }
#auc-bids .amount { font-variant-numeric: tabular-nums; }
#auc-bids .struck-row .amount { text-decoration: line-through; color: var(--hint); }
.ops li.lot-row { flex-wrap: wrap; }
.lot-actions { flex-basis: 100%; padding-top: 4px; }


/* --- розыгрыш: логин кандидата виден со сцены, если вывести экран на проектор --- */
.rf-live h2 { text-wrap: balance; }
.rf-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rf-figure {
  font: 700 clamp(24px, 7vw, 40px)/1 var(--display);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.rf-card {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
  padding: 24px 16px 16px;
  border-radius: var(--radius-outer);
  background: var(--bg-2);
}
.rf-card .row-actions { width: 100%; margin-top: 10px; }
.rf-prize { color: var(--hint); font-size: 15px; text-wrap: balance; }
.rf-login {
  font: 700 clamp(34px, 11vw, 72px)/1.05 var(--display);
  letter-spacing: -0.02em;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-wrap: balance;
  color: var(--text);
}
.rf-login.rf-login-long { font-size: clamp(22px, 7vw, 48px); }
.rf-sub { font-size: 18px; color: var(--hint); font-variant-numeric: tabular-nums; }
.rf-card .hint { margin-top: 4px; }
.rf-card.rf-enter .rf-login { animation: rf-pop 320ms var(--ease) both; }
.rf-card.rf-enter .rf-sub { animation: rf-pop 320ms var(--ease) 80ms both; }
@keyframes rf-pop {
  from { opacity: 0; transform: scale(0.96) translateY(6px); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
.rf-round { margin: -4px 0 12px; }
.lb-actions { margin-top: 16px; }
.lb-row { align-items: baseline; gap: 10px; }
.lb-rank { flex: 0 0 2ch; min-width: 2ch; color: var(--hint); font-variant-numeric: tabular-nums; }
.lb-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.lb-row .amount { font-variant-numeric: tabular-nums; }
.rf-round-bar { display: grid; gap: 6px; justify-items: start; margin-top: 20px; padding-top: 16px; box-shadow: 0 -1px 0 rgba(128, 128, 128, 0.22); }
.rf-round-bar .button { color: var(--danger); min-height: 44px; }
.rf-mark { flex: 0 0 auto; min-height: 44px; align-self: center; }
@media (prefers-reduced-motion: reduce) {
  .rf-card.rf-enter .rf-login, .rf-card.rf-enter .rf-sub { animation: none; }
}

/* Маркет за комкойны (ADR-0056): карточки лотов и заказы, в Админке — лоты и заказы списками. */
.mk-lots, .mk-orders { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mk-card, .mk-order {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border-radius: var(--radius-inner);
  background: var(--bg-2);
}
.mk-title { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.mk-media {
  display: block; width: 100%; max-width: 100%; max-height: 60vh; object-fit: contain;
  border-radius: var(--radius-inner); background: var(--section);
  outline: 1px solid rgba(0, 0, 0, 0.1); outline-offset: -1px;
}
@media (prefers-color-scheme: dark) {
  .mk-media { outline-color: rgba(255, 255, 255, 0.1); }
}
.mk-text { color: var(--hint); font-size: 14px; overflow-wrap: anywhere; white-space: pre-wrap; }
.mk-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.mk-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mk-price { font: 700 20px/1.1 var(--display); letter-spacing: -0.02em; color: var(--accent); white-space: nowrap; }
.mk-buy { flex: 1 1 160px; min-height: 48px; }
.mk-meta { color: var(--hint); font-size: 13px; }
.mk-status { font-weight: 500; font-size: 14px; }
.mk-status.mk-status-waiting_details { color: var(--accent); }
.mk-status.mk-status-cancelled { color: var(--hint); }
.mk-details { margin: 0; padding: 8px 10px; border-radius: var(--radius-inner); background: var(--section); font-size: 14px; overflow-wrap: anywhere; white-space: pre-wrap; }
.mk-details-form { display: grid; gap: 8px; }
.mk-details-form .button { min-height: 48px; }
.mk-notice { color: var(--accent); font-weight: 500; overflow-wrap: anywhere; }
.mk-lot-form { margin-top: 12px; padding: 12px; border-radius: var(--radius-inner); background: var(--bg-2); }
.mk-lot-form .field input, .mk-lot-form .field select, .mk-lot-form .field textarea { background: var(--section); }
.mk-admin-lots li, .mk-admin-orders li { flex-wrap: wrap; min-width: 0; }
.mk-admin-lots .what, .mk-admin-orders .what { flex: 1 1 200px; overflow-wrap: anywhere; }
.mk-admin-orders .row-actions { flex-basis: 100%; }
.mk-admin-orders .row-actions .button, .mk-admin-lots .button { min-height: 44px; }
