/* Панель «Ассистент Максим»: нейтральные тона выводим из --hue, акцент — из
   --accent-rgb. Палитру ставит core.applyAccent (data-accent), тему —
   core.applyTheme (data-theme); медиазапросов нет. */

:root {
  --hue: 146;
  --accent-rgb: 62, 232, 127;
  --accent: rgb(var(--accent-rgb));
  --accent-bright: #4bf58c;
  --accent-2: #12b45e;
  --accent-on: #04170c;
  --accent-soft: rgba(var(--accent-rgb), 0.14);
  --accent-ring: rgba(var(--accent-rgb), 0.35);
  --accent-halo: rgba(var(--accent-rgb), 0.24);
  --accent-shadow: rgba(var(--accent-rgb), 0.22);
  --accent-glow: rgba(var(--accent-rgb), 0.07);

  --bg: hsl(var(--hue), 58%, 5%);
  --bg-glow: hsl(var(--hue), 71%, 13%);
  --surface: hsl(var(--hue), 49%, 8%);
  --surface-2: hsl(var(--hue), 47%, 10%);
  --surface-3: hsl(var(--hue), 46%, 14%);
  --border: hsl(var(--hue), 44%, 20%);
  --border-soft: hsl(var(--hue), 47%, 15%);
  --text: hsl(var(--hue), 100%, 96%);
  --muted: hsl(var(--hue), 22%, 64%);
  --dim: hsl(var(--hue), 16%, 44%);
  /* Своё сообщение в комментариях, пока «Цвет чата» не выбран. */
  --chat-accent-auto: hsl(var(--hue), 70%, 27%);
  /* Семантика от палитры не зависит. */
  --success: #3ee87f;
  --warning: #f2c14e;
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.16);
  --hero-1: hsl(var(--hue), 60%, 11%);
  --hero-2: hsl(var(--hue), 58%, 7%);
  --bar: var(--bg);
  --nav: hsl(var(--hue), 57%, 5%);
  --radius: 18px;
  --radius-sm: 12px;
  --gap: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* Цвета имён авторов в чате комментариев. */
  --name-0: #7bd88f;
  --name-1: #7ab8ff;
  --name-2: #c79bff;
  --name-3: #ffb86b;
  --name-4: #ff8fa3;
  --name-5: #6fd6d6;
}

/* Светлая палитра: data-theme ставит core.applyTheme («auto» разворачивается
   по системной настройке), поэтому медиазапросов здесь нет. --accent-bright,
   --accent-2 и --accent-on берутся из блока палитры без изменений: пары
   подобраны так, чтобы надпись читалась на обоих фонах. */
:root[data-theme="light"] {
  --accent-rgb: 12, 131, 62;
  --accent-soft: rgba(var(--accent-rgb), 0.12);
  --accent-ring: rgba(var(--accent-rgb), 0.30);
  --accent-halo: rgba(var(--accent-rgb), 0.18);
  --accent-shadow: rgba(var(--accent-rgb), 0.18);
  --accent-glow: rgba(var(--accent-rgb), 0.06);

  --bg: hsl(var(--hue), 47%, 97%);
  --bg-glow: hsl(var(--hue), 49%, 87%);
  --surface: #ffffff;
  --surface-2: hsl(var(--hue), 36%, 95%);
  --surface-3: hsl(var(--hue), 35%, 91%);
  --border: hsl(var(--hue), 30%, 84%);
  --border-soft: hsl(var(--hue), 35%, 90%);
  --text: hsl(var(--hue), 65%, 9%);
  --muted: hsl(var(--hue), 21%, 37%);
  --dim: hsl(var(--hue), 14%, 54%);
  /* «Рапорт Стража» в светлой теме — светлый оттенок палитры: иначе тёмный
     текст на тёмной подложке не читается. */
  --hero-1: hsl(var(--hue), 35%, 92%);
  --hero-2: hsl(var(--hue), 40%, 96%);
  --success: #0f9f4d;
  --warning: #a56a10;
  --danger: #cf3f3f;
  --danger-soft: rgba(207, 63, 63, 0.14);
  --bar: var(--bg);
  --nav: #ffffff;
  --name-0: #0f7a3d;
  --name-1: #1f5fbf;
  --name-2: #6b3fa0;
  --name-3: #a25a00;
  --name-4: #b02a4a;
  --name-5: #0a6b6b;
}

/* Палитры: --accent-on читается на градиенте --accent-bright → --accent-2
   (контраст ≥ 4.7), --accent — на --bg (≥ 5.3 в тёмной теме, ≥ 4.6 в
   светлой). */
:root[data-accent="blue"] {
  --hue: 215;
  --accent-rgb: 91, 151, 236;
  --accent-bright: #0e6df1;
  --accent-2: #1258ba;
  --accent-on: #ffffff;
}

:root[data-accent="violet"] {
  --hue: 268;
  --accent-rgb: 164, 100, 237;
  --accent-bright: #8e35f3;
  --accent-2: #6513c3;
  --accent-on: #ffffff;
}

:root[data-accent="pink"] {
  --hue: 330;
  --accent-rgb: 235, 82, 158;
  --accent-bright: #de0d75;
  --accent-2: #a7115c;
  --accent-on: #ffffff;
}

:root[data-accent="orange"] {
  --hue: 25;
  --accent-rgb: 233, 134, 63;
  --accent-bright: #f48a3e;
  --accent-2: #cc6114;
  --accent-on: #160b04;
}

:root[data-accent="teal"] {
  --hue: 176;
  --accent-rgb: 54, 231, 220;
  --accent-bright: #48f4e9;
  --accent-2: #11a79d;
  --accent-on: #041716;
}

/* На светлом фоне текст и значки красятся тёмным оттенком палитры. */
:root[data-theme="light"][data-accent="blue"] { --accent-rgb: 15, 75, 159; }
:root[data-theme="light"][data-accent="violet"] { --accent-rgb: 82, 15, 159; }
:root[data-theme="light"][data-accent="pink"] { --accent-rgb: 159, 15, 87; }
:root[data-theme="light"][data-accent="orange"] { --accent-rgb: 159, 75, 15; }
:root[data-theme="light"][data-accent="teal"] { --accent-rgb: 11, 121, 114; }

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image: radial-gradient(circle at 50% -10%, var(--bg-glow) 0%, transparent 55%);
  background-repeat: no-repeat;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

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

/* ------------------------------------------------------------------ шапка */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 14px 8px;
  /* Непрозрачная подложка: прокрученный контент не просвечивает и не «режет» заголовок. */
  background-color: var(--bar);
  background-image: linear-gradient(180deg, var(--bar), var(--bar));
}

.topbar__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__text {
  flex: 1;
  min-width: 0;
}

.topbar__logo {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

.topbar__title {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.iconbtn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}

.iconbtn:active {
  background: var(--surface-3);
}

/* ------------------------------------------------------------------ контент */

.content {
  flex: 1;
  padding: 4px 16px calc(88px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.greeting {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 4px 2px 0;
}

/* ------------------------------------------------------------------ герой */

.hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 88% 16%, var(--accent-halo), transparent 62%),
    linear-gradient(135deg, var(--hero-1), var(--hero-2) 72%);
  overflow: hidden;
}

.hero__text {
  flex: 1;
  min-width: 0;
}

.hero__title {
  font-size: 16px;
  font-weight: 650;
}

.hero__sub {
  font-size: 12px;
  color: var(--muted);
}

.hero__count {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 2px;
  color: var(--text);
}

.hero__count-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 6px;
}

.hero__art {
  width: 118px;
  height: 118px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--accent-ring);
  box-shadow: 0 0 0 4px var(--accent-glow), 0 8px 24px rgba(0, 0, 0, 0.45);
  margin: -4px -2px -4px 0;
}

/* Постер для первого запуска: одна картинка, без обрезки надписи. */
.onboard-banner {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ------------------------------------------------------------------ карточки */

.card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card--current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft) inset;
}

.card__head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card__title {
  font-size: 16px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card__icon {
  font-size: 17px;
  line-height: 1;
  flex: 0 0 auto;
}

.card__desc {
  font-size: 12.5px;
  color: var(--muted);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ------------------------------------------------------------------ KPI */

.kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.kpi__tile {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 10px 8px;
  text-align: center;
}

.kpi__value {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kpi__label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.kpi__icon {
  margin-right: 3px;
}

/* ------------------------------------------------------------------ график */

.chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart__body {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.chart__plot {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 132px;
  touch-action: pan-y;
}

.chart__svg {
  display: block;
  width: 100%;
  height: 100%;
  color: var(--accent);
  overflow: visible;
}

.chart__dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.chart__dot--danger {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.chart__tip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--surface-3);
  border: 1px solid var(--accent-ring);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.chart__yaxis {
  width: 34px;
  height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 10px;
  line-height: 1;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.chart__xaxis {
  position: relative;
  height: 14px;
  margin-right: 40px;
  font-size: 10px;
  color: var(--dim);
}

.chart__day {
  position: absolute;
  top: 0;
  font-variant-numeric: tabular-nums;
}

.chart__sum {
  font-size: 11.5px;
  color: var(--muted);
}

.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 11.5px;
  color: var(--muted);
}

.chart__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart__swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.chart__swatch--danger {
  background: var(--danger);
}

/* ------------------------------------------------------------------ строки */

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border-soft);
}

.row:first-child {
  border-top: none;
  padding-top: 0;
}

.card__head + .row {
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
}

.row--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.row--click {
  cursor: pointer;
}

.row--warn .row__label {
  color: var(--warning);
}

.row__text {
  flex: 1;
  min-width: 0;
}

.row__label {
  font-size: 14px;
  font-weight: 550;
}

.row__hint {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.row__icon {
  font-size: 16px;
  line-height: 1;
  width: 20px;
  text-align: center;
  flex: 0 0 auto;
}

.row__value {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.row--stack .row__value {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: left;
}

/* Числовые поля в стеке: слайдер во всю ширину, счётчик слева,
   подпись остаётся в одну строку. */
.row--stack .range {
  width: 100%;
}

.row--stack .range input[type="range"] {
  min-width: 0;
}

.row--stack .stepper {
  align-self: flex-start;
}

.row__error {
  width: 100%;
  font-size: 12px;
  color: var(--danger);
}

.field--error .row__label {
  color: var(--danger);
}

/* ------------------------------------------------------------------ контролы */

.switch {
  flex: 0 0 auto;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
  padding: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch[aria-checked="true"] {
  background: linear-gradient(135deg, var(--accent-bright), var(--accent-2));
  border-color: transparent;
}

.switch[aria-checked="true"]::after {
  transform: translateX(18px);
  background: var(--accent-on);
}

.switch:disabled {
  opacity: 0.55;
  cursor: default;
}

.row--locked .row__label {
  color: var(--muted);
}

.control {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.control--stack {
  flex-direction: column;
  align-items: stretch;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper__btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.stepper__btn:disabled {
  opacity: 0.4;
}

.stepper__value {
  min-width: 42px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.range {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.range input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.range input[type="number"] {
  width: 76px;
  text-align: center;
}

input,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  width: 100%;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.45;
}

.input--search {
  background: var(--surface-2);
}

.input--time {
  max-width: 110px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.counter {
  font-size: 11px;
  color: var(--dim);
  text-align: right;
}

.counter--warn {
  color: var(--warning);
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.option {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}

.option--active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

/* ------------------------------------------------------------------ кнопки */

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn--primary {
  border: none;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent-2));
  color: var(--accent-on);
  box-shadow: 0 6px 18px var(--accent-shadow);
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

/* ------------------------------------------------------------------ чипы */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}

.chip--on,
.chip--pick.chip--on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.chip__count {
  font-size: 11px;
  color: var(--dim);
  background: var(--surface-3);
  border-radius: 999px;
  padding: 0 6px;
}

.chip__x {
  border: none;
  background: transparent;
  color: var(--dim);
  padding: 0 0 0 2px;
  font-size: 14px;
  line-height: 1;
}

.chip__add {
  display: flex;
  gap: 8px;
}

.period__row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.period__field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.period__label {
  font-size: 11px;
  color: var(--dim);
}

.input--date {
  padding: 9px 10px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
}

:root[data-theme="light"] .input--date {
  color-scheme: light;
}

.period__apply {
  flex: 0 0 auto;
  padding: 10px 14px;
}

.period__hint {
  font-size: 11.5px;
  color: var(--dim);
}

/* ------------------------------------------------------------------ бейджи */

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--muted);
  font-size: 10.5px;
  padding: 1px 7px;
  white-space: nowrap;
}

.badge--accent {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent-2));
  color: var(--accent-on);
}

.badge--plan {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}

/* Кнопка демо в шапке: видна на всех экранах чата, пока демо включён. */
.topbar__demo {
  cursor: pointer;
  font-size: 11px;
  padding: 3px 9px;
}

/* ------------------------------------------------------------------ чаты */

.chatrow {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.chatrow:active {
  background: var(--surface-2);
}

.chatrow__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chatrow__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14.5px;
  font-weight: 600;
  flex-wrap: wrap;
}

.chatrow__meta {
  font-size: 12px;
  color: var(--muted);
}

.chatrow__warn {
  font-size: 11.5px;
  color: var(--warning);
}

.chatrow__arrow {
  color: var(--dim);
  font-size: 18px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent-2));
  color: var(--accent-on);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  overflow: hidden;
  flex: 0 0 auto;
  padding: 0;
  border: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--sm {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

/* ------------------------------------------------------------------ разделы */

.sectionrow {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.sectionrow:active {
  background: var(--surface-2);
}

.sectionrow__icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sectionrow__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sectionrow__title {
  font-size: 14.5px;
  font-weight: 600;
}

.sectionrow__desc {
  font-size: 12px;
  color: var(--muted);
}

.sectionrow__arrow {
  color: var(--dim);
  font-size: 18px;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.group__title {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------------ предупреждение */

.warn {
  border: 1px solid rgba(242, 193, 78, 0.35);
  background: rgba(242, 193, 78, 0.1);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.warn__title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--warning);
}

.warn__text {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ------------------------------------------------------------------ состояния */

.state {
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.state__icon {
  font-size: 32px;
}

.state__title {
  font-size: 17px;
  font-weight: 650;
}

.state__text {
  font-size: 13px;
  color: var(--muted);
  max-width: 380px;
}

.state__actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 22px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty__text {
  font-size: 13px;
  color: var(--muted);
}

.skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton {
  height: 76px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ------------------------------------------------------------------ профиль */

.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 0 4px;
  text-align: center;
}

.profile__name {
  font-size: 19px;
  font-weight: 700;
}

.profile__meta {
  font-size: 12px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ тарифы */

.features {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.features li {
  font-size: 13px;
  color: var(--muted);
  padding-left: 18px;
  position: relative;
}

.features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--success);
  font-size: 12px;
}

.note {
  font-size: 12px;
  color: var(--dim);
  text-align: center;
  padding: 0 8px;
}

/* ------------------------------------------------------------------ мануал */

.manual__lead {
  font-size: 13.5px;
  color: var(--muted);
  padding: 0 2px;
}

.manual__text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}

.manual__list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}

.manual__list li::marker {
  color: var(--accent);
}

/* ------------------------------------------------------------------ аккордеон */

.accordion {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.accordion__item {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.accordion__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 12px 14px;
  text-align: left;
}

.accordion__text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.accordion__title {
  font-size: 13.5px;
  font-weight: 600;
}

.accordion__tag {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.accordion__mark {
  color: var(--dim);
  font-size: 16px;
  flex: 0 0 auto;
}

.accordion__head:hover .accordion__mark {
  color: var(--accent);
}

.accordion__body {
  padding: 0 14px 12px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: pre-line;
}

/* Панель внутри блока: свои отступы, без внешнего текста-подсказки. */
.accordion__body--panel {
  padding: 0 14px 14px;
  white-space: normal;
  color: var(--text);
  font-size: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.accordion__body--panel[hidden] {
  display: none;
}

/* Права в две колонки на широком экране: 13 переключателей в один столбец
   растягивают карточку на два экрана. */
.perm-group {
  margin: 6px 0 2px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0 18px;
}

.perm-grid .row {
  border-top: 1px solid var(--border-soft);
  padding: 8px 0;
}

.perm-grid .row:first-child {
  border-top: none;
  padding-top: 0;
}

.accordion__item--open .accordion__head {
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 10px;
}

/* ------------------------------------------------------------------ листы */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 10, 5, 0.66);
  z-index: 40;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(620px, 100%);
  max-height: 78vh;
  overflow-y: auto;
  background: var(--surface);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 16px 16px calc(20px + var(--safe-b));
  z-index: 41;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet__title {
  font-size: 15px;
  font-weight: 650;
}

.sheet__hint {
  font-size: 12px;
  color: var(--muted);
}

.sheet__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
  font-size: 14px;
}

.sheet__item--active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.sheet__tag {
  font-size: 12px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ тост */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translate(-50%, 12px);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  max-width: min(92vw, 460px);
  text-align: center;
}

.toast--show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast--error {
  border-color: var(--danger);
  color: var(--danger);
}

/* ------------------------------------------------------------------ сейвбар */

.savebar[hidden] {
  display: none;
}

.savebar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(64px + var(--safe-b));
  width: min(620px, 100%);
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(180deg, transparent, var(--bar) 40%);
  z-index: 30;
}

.savebar .btn {
  flex: 1;
}

/* ------------------------------------------------------------------ навигация */

/* hidden задаём атрибутом: правило .bottomnav ниже иначе перебивает display:none */
.bottomnav[hidden] {
  display: none;
}

.bottomnav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(620px, 100%);
  height: calc(64px + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: var(--nav);
  border-top: 1px solid var(--border-soft);
  z-index: 25;
}

.bottomnav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--dim);
  padding: 0;
}

.bottomnav__item--active {
  color: var(--accent);
}

.bottomnav__icon {
  font-size: 17px;
  line-height: 1;
}

.bottomnav__label {
  font-size: 10.5px;
}

/* ------------------------------------------------------------------ юр. страница */

.legal__page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.legal__page h1 {
  font-size: 22px;
  font-weight: 700;
}

.legal__page p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.legal__page .btn {
  align-self: flex-start;
  margin-top: 12px;
  text-decoration: none;
}

.legal__text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* ------------------------------------------------------------------ комментарии поста */

/* Чат: свои сообщения справа, чужие слева, настройки — только внутри .chat. */
.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  --chat-font: 15px;
  font-size: var(--chat-font);
}

.chat[data-accent="green"] {
  --chat-accent: #128a4a;
}

.chat[data-accent="blue"] {
  --chat-accent: #2f6fed;
}

.chat[data-accent="violet"] {
  --chat-accent: #7a4ddb;
}

.chat[data-accent="orange"] {
  --chat-accent: #c05a12;
}

.chat[data-accent="pink"] {
  --chat-accent: #c2185b;
}

.comments-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--muted);
}

/* Обрезка живёт на вложенном блоке: у flex-элемента display:-webkit-box
   blockified в flow-root и -webkit-line-clamp не действует. */
.comments-preview__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* место под закреплённый композер */
  padding-bottom: calc(var(--composer-h, 112px) + 16px);
}

.comment-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  margin-top: 10px;
}

.comment-row--own {
  flex-direction: row-reverse;
}

.comment-row--group {
  margin-top: 2px;
}

.comment-row--c0 {
  --comment-name: var(--name-0);
}

.comment-row--c1 {
  --comment-name: var(--name-1);
}

.comment-row--c2 {
  --comment-name: var(--name-2);
}

.comment-row--c3 {
  --comment-name: var(--name-3);
}

.comment-row--c4 {
  --comment-name: var(--name-4);
}

.comment-row--c5 {
  --comment-name: var(--name-5);
}

.comment-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--comment-name, var(--muted));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 650;
  flex: 0 0 auto;
}

/* Место под аватар сохраняется: пузыри группы выровнены по одной линии. */
.comment-avatar--hidden {
  visibility: hidden;
}

.comment-bubble {
  max-width: 84%;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 8px 10px 6px;
}

.comment-row--own .comment-bubble {
  background: var(--chat-accent, var(--chat-accent-auto));
  border-color: transparent;
  color: #fff;
}

.comment__author {
  font-size: calc(var(--chat-font) - 2px);
  font-weight: 650;
  color: var(--comment-name, var(--muted));
  margin-bottom: 2px;
}

.comment__text {
  font-size: var(--chat-font);
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment__foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-size: calc(var(--chat-font) - 4px);
  color: var(--muted);
  margin-top: 2px;
}

.comment-row--own .comment__foot {
  color: rgba(255, 255, 255, 0.78);
}

.comment__menu {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 6px;
}

.comment__menu:active {
  background: rgba(127, 127, 127, 0.25);
}

/* Кнопка ответа: видна всегда, цвет наследует пузырь. */
.comment__reply-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: -3px auto -3px -5px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.72;
  border-radius: 8px;
}

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

.comment__reply-btn:active {
  opacity: 1;
  background: rgba(127, 127, 127, 0.25);
}

.comment__reply {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  margin-bottom: 4px;
  padding: 4px 8px;
  border: none;
  border-left: 3px solid var(--chat-accent, var(--chat-accent-auto));
  border-radius: 6px;
  background: rgba(127, 127, 127, 0.12);
  text-align: left;
  color: inherit;
  font-size: calc(var(--chat-font) - 3px);
}

.comment-row--own .comment__reply {
  border-left-color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.14);
}

.comment__reply-author {
  font-weight: 650;
}

.comment__reply-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  opacity: 0.85;
}

.comment__photo {
  display: block;
  padding: 0;
  border: none;
  background: transparent;
  margin-bottom: 4px;
}

.comment__photo img {
  display: block;
  max-width: min(260px, 100%);
  max-height: 320px;
  border-radius: 10px;
}

.chat-day {
  align-self: center;
  margin: 12px 0 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
}

.comment-row--flash .comment-bubble {
  outline: 2px solid var(--chat-accent, var(--accent));
  outline-offset: 1px;
}

.comments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  /* Не sticky: шапка экрана уже sticky, вторая липкая полоса её перекрывает. */
  padding: 2px 0 6px;
}

.comments-count {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--muted);
}

.comments-count__num {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.comments-head__actions {
  display: flex;
  gap: 8px;
}

.iconbtn--ghost {
  background: transparent;
}

.comments-empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 0;
}

/* Композер закреплён снизу: чат прокручивается под ним. */
.chat-composer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(620px, 100%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 16px calc(10px + var(--safe-b));
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

.chat-composer__row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.chat-composer__row .iconbtn {
  flex: none;
  margin-bottom: 2px;
}

.chat-composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: var(--chat-font);
}

.chat-composer__send {
  flex: none;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-composer__send svg {
  width: 20px;
  height: 20px;
}

.chat-composer__reply,
.chat-composer__photo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

/* display:flex у панелей сильнее UA-правила [hidden] — гасим явно. */
.chat-composer__reply[hidden],
.chat-composer__photo[hidden] {
  display: none;
}

.chat-composer__reply-author {
  font-weight: 650;
  color: var(--text);
  flex: none;
}

.chat-composer__reply-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-composer__photo img {
  max-height: 64px;
  border-radius: 8px;
}

.chat-composer__cancel {
  flex: none;
  border: none;
  background: var(--surface-3);
  color: var(--text);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
}

.emoji-panel {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(100% - 4px);
  max-height: 42vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 30;
}

.emoji-panel__tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px;
  border-bottom: 1px solid var(--border-soft);
}

.emoji-panel__tab {
  flex: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
}

.emoji-panel__tab--on {
  background: var(--surface-3);
  color: var(--text);
}

.emoji-panel__grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  overflow-y: auto;
  padding: 6px;
}

.emoji-panel__item {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  padding: 6px 0;
  border-radius: 8px;
}

.emoji-panel__item:active {
  background: var(--surface-3);
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* --------------------------------------------------------------- настройки чата */
.accent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}

.accent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: left;
}

.accent-item--on {
  border-color: var(--accent);
}

.accent-item__dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: none;
}

.accent-item__dot--green {
  background: #128a4a;
}

.accent-item__dot--blue {
  background: #2f6fed;
}

.accent-item__dot--violet {
  background: #7a4ddb;
}

.accent-item__dot--orange {
  background: #c05a12;
}

.accent-item__dot--pink {
  background: #c2185b;
}

/* Лист «Оформление»: подпись группы над образцами цвета. */
.look-sheet {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}

.look-sheet__label {
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
}

.look-sheet__hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: -2px;
}

/* Выбор аватара в листе «Оформление»: три образца с подписями. */
.mascot-picker {
  display: flex;
  gap: 10px;
  padding: 2px 0 6px;
}

.mascot-picker__item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.mascot-picker__item:hover {
  border-color: var(--accent-ring);
}

.mascot-picker__item[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.mascot-picker__img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.mascot-picker__name {
  font-size: 11px;
  line-height: 1.25;
  color: var(--muted);
  text-align: center;
}

.mascot-picker__item[aria-pressed="true"] .mascot-picker__name {
  color: var(--text);
  font-weight: 600;
}

/* Выбор цвета панели в листе «Оформление»: кружок-образец размером под палец. */
.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 2px 0 8px;
}

.palette__dot {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: hsl(var(--dot-hue), 80%, 52%);
}

.palette__dot--green { --dot-hue: 146; }
.palette__dot--teal { --dot-hue: 176; }
.palette__dot--blue { --dot-hue: 215; }
.palette__dot--violet { --dot-hue: 268; }
.palette__dot--pink { --dot-hue: 330; }
.palette__dot--orange { --dot-hue: 25; }

.palette__dot[aria-pressed="true"] {
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.accent-item__label {
  flex: 1;
}

.accent-item__check {
  color: var(--accent);
  font-weight: 700;
}

.font-sheet {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 6px;
}

.font-preview {
  text-align: center;
  line-height: 1.4;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

.font-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.font-stepper__btn {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 18px;
}

.font-stepper__value {
  min-width: 64px;
  text-align: center;
  font-weight: 650;
}

@media (max-width: 380px) {
  .kpi {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero__art {
    width: 96px;
    height: 96px;
  }

  .mascot-picker__img {
    width: 60px;
    height: 60px;
  }

  .mascot-picker__name {
    font-size: 10px;
  }

  .mascot-picker__item {
    padding: 8px 4px;
  }
}
