/*
 * Стили mini app. Фон страницы, карточек и основной текст — из переменных темы Telegram (--tg-theme-*),
 * запасные значения нужны обычному браузеру и старым клиентам. Цвета модулей, тарифов и видов чатов —
 * насыщенные заливки под белый текст; их задаёт app.js переменными --m и --m-lite на узле (класс .tinted).
 * Вставки поверх цветной заливки (кнопка выбора чата, метка чата, кнопки шапки) — затемняющие:
 * белый текст на них читается не хуже, чем на самой заливке (контраст не ниже 4.5:1).
 */

/* ---------- Запасные цвета ---------- */

:root {
  --fb-page: #efeff4;
  --fb-card: #ffffff;
  --fb-text: #000000;
  --fb-hint: #707579;
  --fb-link: #2481cc;
  --fb-button: #2481cc;
  --fb-button-text: #ffffff;
  --fb-danger: #d93025;
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) {
    --fb-page: #0f0f0f;
    --fb-card: #212121;
    --fb-text: #ffffff;
    --fb-hint: #aaaaaa;
    --fb-link: #8ab4f8;
    --fb-button: #3e88f7;
    --fb-button-text: #ffffff;
    --fb-danger: #ff6b66;
  }
}

:root.theme-dark {
  --fb-page: #0f0f0f;
  --fb-card: #212121;
  --fb-text: #ffffff;
  --fb-hint: #aaaaaa;
  --fb-link: #8ab4f8;
  --fb-button: #3e88f7;
  --fb-button-text: #ffffff;
  --fb-danger: #ff6b66;
}

/* ---------- Цвета страницы ---------- */

:root {
  --c-page: var(--tg-theme-secondary-bg-color, var(--fb-page));
  --c-card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-card)));
  --c-text: var(--tg-theme-text-color, var(--fb-text));
  --c-hint: var(--tg-theme-hint-color, var(--fb-hint));
  --c-head: var(--tg-theme-section-header-text-color, var(--c-hint));
  --c-link: var(--tg-theme-link-color, var(--fb-link));
  --c-accent: var(--tg-theme-accent-text-color, var(--c-link));
  --c-button: var(--tg-theme-button-color, var(--fb-button));
  --c-button-text: var(--tg-theme-button-text-color, var(--fb-button-text));
  --c-danger: var(--tg-theme-destructive-text-color, var(--fb-danger));

  /* производные; без color-mix — нейтральные полупрозрачные */
  --c-muted: var(--c-hint);
  --c-line: rgba(128, 128, 128, 0.28);
  --c-soft: rgba(128, 128, 128, 0.14);
  --c-off: rgba(128, 128, 128, 0.45);
  --c-warn-bg: var(--c-card);
  --c-scrim: rgba(0, 0, 0, 0.5);
  --c-shadow: none;

  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
  --radius: 16px;
}

:root.theme-light {
  --c-shadow: 0 1px 3px rgba(16, 24, 40, 0.07);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root {
    --c-muted: color-mix(in srgb, var(--c-text) 66%, transparent);
    --c-line: color-mix(in srgb, var(--c-text) 13%, transparent);
    --c-soft: color-mix(in srgb, var(--c-text) 7%, transparent);
    --c-off: color-mix(in srgb, var(--c-text) 26%, transparent);
    --c-warn-bg: color-mix(in srgb, var(--c-danger) 12%, var(--c-card));
  }
}

/* цвет модуля, тарифа или вида чата: --m — заливка, --m-ink — им же написанный текст на карточке */
.tinted {
  --m-ink: var(--m);
}

.theme-dark .tinted {
  --m-ink: var(--m-lite);
}

/* ---------- Основа ---------- */

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--c-page);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: break-word;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

body.has-dialog,
body.has-sheet {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  text-align: inherit;
  cursor: pointer;
}

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

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--m-ink, var(--c-button));
  outline-offset: 2px;
}

.app {
  max-width: 560px;
  margin: 0 auto;
}

.page {
  padding: calc(12px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
}

body.has-bottom-bar .page {
  padding-bottom: calc(104px + var(--safe-bottom));
}

.icon {
  display: block;
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

/* ---------- Заголовки ---------- */

.top-bar {
  margin: -6px 0 6px -8px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 12px 0 4px;
  border-radius: 10px;
  color: var(--m-ink, var(--c-link));
  font-size: 16px;
  font-weight: 600;
}

.page-head {
  margin: 6px 0 14px;
  padding: 0 2px;
}

.page-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title {
  min-width: 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 800;
}

.page-sub {
  margin-top: 6px;
  font-size: 15px;
  color: var(--c-muted);
}

.section-title {
  margin: 22px 4px 8px;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-head);
}

.section-tinted {
  color: var(--m-ink);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 18px;
  border-radius: 14px;
  background: var(--c-card);
  color: var(--m-ink, var(--c-accent));
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.12s;
}

.btn:active,
.back-btn:active,
.mod-main:active,
.check:active,
.gear:active,
.option:active,
.tab:active,
.pill:active,
.pick-row:active,
.hero-pick:active,
.hero-tool:active,
.sheet-close:active {
  opacity: 0.6;
}

.btn-primary {
  background: var(--c-button);
  color: var(--c-button-text);
}

/* кнопка в цвете модуля или вида чата */
.btn-fill {
  background: var(--m, var(--c-button));
  color: #ffffff;
}

.btn-danger {
  background: var(--c-soft);
  color: var(--c-danger);
}

.btn-plain {
  background: none;
  color: var(--m-ink, var(--c-link));
  font-weight: 600;
}

.btn-small {
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 15px;
}

.btn-small:not(.btn-fill) {
  background: var(--c-soft);
}

.btn-wide {
  display: flex;
  width: 100%;
}

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

.is-busy {
  opacity: 0.55;
  cursor: progress;
}

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

.card {
  background: var(--c-card);
  border-radius: var(--radius);
  box-shadow: var(--c-shadow);
}

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

.card-title {
  display: block;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 700;
}

.card-text {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  color: var(--c-muted);
}

.chevron {
  color: var(--c-hint);
}

.avatar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--m, var(--c-button));
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  align-self: flex-start;
  min-height: 26px;
  padding: 0 11px;
  border-radius: 13px;
  background: var(--m, var(--c-button));
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

/* цветная плитка со значком модуля */
.tile {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: var(--m, #52606d);
  color: #ffffff;
}

.tile-icon {
  width: 26px;
  height: 26px;
}

.tile-small {
  width: 28px;
  height: 28px;
  border-radius: 9px;
}

.tile-small > .tile-icon {
  width: 17px;
  height: 17px;
}

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

.note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--c-card);
  box-shadow: var(--c-shadow);
  font-size: 14px;
  line-height: 1.4;
}

.note-warn {
  background: var(--c-warn-bg);
  box-shadow: inset 4px 0 0 var(--c-danger);
}

/* подсказка в цвете модуля: что сделать, чтобы модуль заработал */
.note-accent {
  box-shadow: inset 4px 0 0 var(--m, var(--c-button));
  font-weight: 600;
}

.note-accent .note-icon {
  color: var(--m-ink, var(--c-button));
}

.note + .card,
.note + .form {
  margin-top: 10px;
}

.section-title + .note {
  margin-top: 0;
}

.note-action {
  align-items: center;
  margin: 12px 0 0;
}

.note-action .btn {
  flex: none;
}

.note-icon {
  color: var(--m-ink, var(--c-hint));
}

.note-warn .note-icon {
  color: var(--c-danger);
}

.note-text {
  flex: 1;
  min-width: 0;
}

.inline-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.35;
}

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

.inline-icon {
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.inline-warn {
  color: var(--c-danger);
}

.inline-lock {
  color: var(--c-muted);
}

/* ---------- Состояния экрана ---------- */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 12px 24px;
  text-align: center;
}

.state-full {
  justify-content: center;
  min-height: calc(var(--tg-viewport-stable-height, 100vh) - 96px);
  padding-top: 24px;
}

.state-icon {
  width: 44px;
  height: 44px;
  stroke-width: 1.6;
  color: var(--c-hint);
}

.state-icon-danger {
  color: var(--c-danger);
}

.state-title {
  font-size: 19px;
  line-height: 1.25;
  font-weight: 700;
}

.state-text {
  max-width: 320px;
  font-size: 15px;
  color: var(--c-muted);
}

.state > .btn {
  min-width: 200px;
  margin-top: 10px;
}

.empty-line {
  margin: 28px 8px;
  font-size: 15px;
  color: var(--c-muted);
  text-align: center;
}

/* во вкладке нет модулей для этого вида чатов */
.empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 22px 18px 18px;
  text-align: center;
}

.empty-art,
.add-card-art {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--m);
  color: #ffffff;
}

.empty-art > .icon {
  width: 30px;
  height: 30px;
}

.empty-title {
  margin-top: 4px;
  font-size: 17px;
  line-height: 1.3;
  font-weight: 800;
}

.empty-text {
  max-width: 300px;
  font-size: 14px;
  color: var(--c-muted);
}

.empty-card > .btn {
  min-width: 220px;
  margin-top: 6px;
}

/* экран модуля без чата: сначала добавить бота */
.add-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  box-shadow: inset 0 0 0 2px var(--m);
}

.add-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.add-card-art {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.add-card-art > .icon {
  width: 24px;
  height: 24px;
}

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

.add-card-title {
  font-size: 16px;
  line-height: 1.3;
  font-weight: 800;
}

.add-card-text {
  font-size: 14px;
  line-height: 1.4;
  color: var(--c-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--c-line);
  border-top-color: var(--m-ink, var(--c-button));
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  flex: none;
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.is-spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.wait-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  font-size: 15px;
  color: var(--c-muted);
}

/* ---------- Главный экран: цветная шапка ---------- */

.hero {
  padding: 12px 14px 14px;
  border-radius: 22px;
  background: var(--m);
  color: #ffffff;
}

.theme-light .hero {
  box-shadow: 0 10px 24px -14px var(--m);
}

.hero :focus-visible,
.mod-hero :focus-visible {
  outline-color: #ffffff;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.hero-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero .spinner {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
}

.hero-tools {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.hero-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 70px;
  min-height: 50px;
  padding: 5px 8px 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
  color: #ffffff;
}

.hero-tool > .icon {
  width: 20px;
  height: 20px;
}

.hero-tool-text {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
  white-space: nowrap;
}

.hero-tool.is-busy {
  opacity: 1;
}

.hero-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  margin-top: 8px;
  padding: 10px 12px 10px 10px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.2);
  color: #ffffff;
  text-align: left;
}

.hero-pick-icon {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #ffffff;
  color: var(--m);
}

.hero-pick-icon > .icon {
  width: 24px;
  height: 24px;
}

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

/* название чата — до двух строк: чаты, различающиеся концом названия, не сливаются */
.hero-pick-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.hero-pick-title.is-long {
  font-size: 16px;
}

.hero-pick-sub {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 600;
}

.hero-pick-arrow {
  width: 24px;
  height: 24px;
}

/* подсказка в режиме без чата */
.cta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 10px 10px 12px;
  border-radius: var(--radius);
  background: var(--c-card);
  box-shadow: var(--c-shadow);
}

.cta-icon {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--m);
  color: #ffffff;
}

.cta-text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.35;
}

.cta > .btn {
  flex: none;
}

/* ---------- Вкладки тарифов ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin-top: 14px;
  padding: 4px;
  border-radius: 16px;
  background: var(--c-card);
  box-shadow: var(--c-shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 1 0 auto;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 12px;
  color: var(--c-muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.tab.is-on {
  background: var(--m);
  color: #ffffff;
}

.tab-body > .section-title:first-child {
  margin-top: 18px;
}

/* ---------- Группы / Каналы ---------- */

.pills {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px 0 14px;
  border-radius: 22px;
  background: var(--c-card);
  box-shadow: inset 0 0 0 1.5px var(--c-line);
  color: var(--c-text);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

/* «Группы / Каналы» во всю ширину над шапкой: главный выбор экрана */
.pills-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 12px;
  padding: 4px;
  border-radius: 26px;
  background: var(--c-card);
}

.pills-top .pill {
  justify-content: center;
  min-width: 0;
  min-height: 46px;
  padding: 0 12px;
  background: transparent;
  box-shadow: none;
}

.pills-top .pill.is-on {
  background: var(--m);
}

.pill-icon {
  color: var(--m-ink);
}

.pill.is-on {
  background: var(--m);
  box-shadow: none;
  color: #ffffff;
}

.pill.is-on > .pill-icon {
  color: #ffffff;
}

/* ---------- Карточка модуля ---------- */

.mod-card {
  position: relative;
}

.mod-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  text-align: left;
}

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

.mod-title {
  min-height: 26px;
  padding: 2px 64px 0 0;
}

.mod-count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--m-ink);
}

.mod-count-main {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.mod-count-icon {
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

/* модуль выключен: строка приглушённая, без цвета модуля */
.mod-count.is-off {
  color: var(--c-muted);
  font-weight: 600;
}

/* модуль включён, но ни одна функция не отмечена */
.mod-count.is-alert {
  color: var(--c-danger);
}

/* тумблер стоит на одной линии с названием и не заходит на описание */
.mod-side {
  position: absolute;
  top: 3px;
  right: 4px;
}

.mod-side > .badge {
  margin: 14px 10px 0 0;
}

/* будущие функции заглушки: список с цветными точками, без рамок — не похоже на кнопки */
.planned {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.planned-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--c-muted);
}

.planned-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--m);
}

/* ---------- Тумблер и галочка ---------- */

.switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 48px;
  border-radius: 12px;
}

.switch-track {
  position: relative;
  display: block;
  flex: none;
  width: 50px;
  height: 30px;
  border-radius: 15px;
  background: var(--c-off);
  transition: background-color 0.15s, opacity 0.15s;
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s, background-color 0.15s;
}

.is-on > .switch-track {
  background: var(--m, var(--c-button));
}

.is-on > .switch-track > .switch-knob {
  transform: translateX(20px);
}

.is-off-limits > .switch-track,
.is-off-limits > .check-box {
  opacity: 0.4;
}

.switch.is-busy,
.switch-row.is-busy,
.check.is-busy {
  opacity: 1;
}

.is-busy > .switch-track,
.is-busy > .check-box {
  opacity: 0.6;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 10px 14px;
  border-radius: var(--radius);
  text-align: left;
}

.switch-label {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
}

.check-box {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border: 2px solid var(--m-ink, var(--c-hint));
  border-radius: 8px;
  color: transparent;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}

.check-mark {
  width: 18px;
  height: 18px;
  stroke-width: 2.8;
}

.check.is-on > .check-box {
  border-color: var(--m, var(--c-button));
  background: var(--m, var(--c-button));
  color: #ffffff;
}

/* ---------- Экран модуля ---------- */

.mod-hero {
  padding: 16px 16px 6px;
  border-radius: 24px;
  background: var(--m);
  color: #ffffff;
}

.theme-light .mod-hero {
  box-shadow: 0 12px 26px -16px var(--m);
}

.mod-hero-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.tile-big {
  width: 60px;
  height: 60px;
  border-radius: 19px;
  background: #ffffff;
  color: var(--m);
}

.tile-big > .tile-icon {
  width: 32px;
  height: 32px;
}

/* где настраивается модуль: вид и полное название чата, до двух строк */
.place {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 7px 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
}

.place-icon {
  width: 20px;
  height: 20px;
}

.place-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.place-label {
  font-size: 12px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.place-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 700;
}

.mod-hero-title {
  min-width: 0;
  font-size: 25px;
  line-height: 1.2;
  font-weight: 800;
}

.mod-hero-text {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.4;
}

.hero-switch {
  min-height: 56px;
  margin-top: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 0;
}

.hero-switch .switch-track {
  background: rgba(255, 255, 255, 0.34);
}

.hero-switch.is-on > .switch-track {
  background: #ffffff;
}

.hero-switch.is-on > .switch-track > .switch-knob {
  background: var(--m);
}

.hero-switch:active {
  opacity: 0.75;
}

/* строка функции: галочка с текстом и шестерёнка настроек */
.feature {
  display: flex;
  align-items: stretch;
}

.feature + .feature {
  border-top: 1px solid var(--c-line);
}

.check {
  display: flex;
  flex: 1;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  min-height: 56px;
  padding: 14px 6px 14px 14px;
  border-radius: var(--radius);
  text-align: left;
}

.gear {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 52px;
  border-radius: var(--radius);
  color: var(--m-ink, var(--c-hint));
}

.gear > .icon {
  width: 23px;
  height: 23px;
  stroke-width: 1.8;
}

.feature.is-dim .card-title,
.feature.is-dim .card-text,
.feature.is-dim .check-box,
.feature.is-dim .gear {
  opacity: 0.5;
}

/* строка «модуль → функция» над настройками */
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 2px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--m-ink);
}

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

/* ---------- Форма ---------- */

.form.is-saving {
  opacity: 0.6;
  pointer-events: none;
}

.form-error {
  margin-bottom: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--c-warn-bg);
  box-shadow: inset 4px 0 0 var(--c-danger);
  font-size: 14px;
}

.form-error-line + .form-error-line {
  margin-top: 6px;
}

.field {
  padding: 14px;
}

.field:not([hidden]) ~ .field {
  border-top: 1px solid var(--c-line);
}

.field-label {
  display: block;
  min-width: 0;
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 700;
}

.field-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.counter {
  flex: none;
  font-size: 13px;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
}

.counter.is-over {
  color: var(--c-danger);
  font-weight: 600;
}

.field-help,
.field-hint {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--c-muted);
}

.field-hint + .field-help {
  margin-top: 2px;
}

.field-error {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--c-danger);
}

.field-bool > .switch-row {
  min-height: 44px;
  padding: 0;
  border-radius: 8px;
}

.field-bool .switch-label {
  font-size: 15px;
}

.field-bool > .field-help {
  margin-top: 4px;
  padding-right: 64px;
}

.field-unknown > .field-help {
  margin-top: 0;
}

.input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px;
  border: 1.5px solid var(--c-line);
  border-radius: 12px;
  background: var(--c-soft);
  color: var(--c-text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--c-hint);
  opacity: 1;
}

.input:focus {
  border-color: var(--m-ink, var(--c-button));
  outline: none;
}

.input:disabled {
  opacity: 0.7;
}

.has-error .input {
  border-color: var(--c-danger);
}

.textarea {
  min-height: 92px;
  overflow: hidden;
  resize: none;
}

.select {
  -webkit-appearance: menulist;
  appearance: auto;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-wrap > .input {
  flex: 0 1 140px;
  min-width: 0;
}

.input-unit {
  font-size: 15px;
  color: var(--c-muted);
}

.options {
  display: flex;
  flex-direction: column;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 8px 0;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.3;
  text-align: left;
}

.option-label {
  min-width: 0;
}

.radio-mark {
  position: relative;
  flex: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--c-hint);
  border-radius: 50%;
}

.option.is-on > .radio-mark {
  border-color: var(--m, var(--c-button));
}

.option.is-on > .radio-mark::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  bottom: 4px;
  left: 4px;
  border-radius: 50%;
  background: var(--m, var(--c-button));
}

.is-readonly .switch-track,
.is-readonly .radio-mark {
  opacity: 0.5;
}

.is-readonly .option,
.is-readonly .switch-row {
  cursor: default;
}

/* список строк в настройках */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 40px;
  padding-left: 14px;
  border-radius: 20px;
  background: var(--c-soft);
  box-shadow: inset 0 0 0 1.5px var(--m-ink, transparent);
}

.is-readonly .chip {
  padding-right: 14px;
}

.chip-text {
  min-width: 0;
  padding: 8px 0;
  font-size: 15px;
  line-height: 1.3;
}

.chip-del {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--c-muted);
}

.chip-del > .icon {
  width: 18px;
  height: 18px;
}

.list-empty {
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--c-muted);
}

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

.list-add > .input {
  flex: 1;
  min-width: 0;
}

.list-add > .btn {
  flex: none;
  min-height: 48px;
}

/* ---------- Журнал ---------- */

.log-row {
  padding: 12px 14px;
}

.log-row + .log-row {
  border-top: 1px solid var(--c-line);
}

.log-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.log-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--m);
}

.log-action {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
}

.log-time {
  flex: none;
  font-size: 13px;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
}

.log-who {
  margin-top: 4px;
  padding-left: 20px;
  font-size: 15px;
}

.log-from {
  margin-top: 4px;
  padding-left: 20px;
  font-size: 13px;
  color: var(--c-muted);
}

.log-card + .btn {
  margin-top: 16px;
}

/* ---------- Нижняя шторка ---------- */

.sheet-layer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 35;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--c-scrim);
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 8px 16px calc(20px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--c-card);
  transition: transform 0.18s ease-out;
}

/* появление — только при открытии; когда приходят данные, шторка не дёргается */
.sheet-enter {
  animation: sheet-in 0.2s ease-out;
}

.sheet.is-dragging {
  transition: none;
}

.sheet:focus {
  outline: none;
}

@keyframes sheet-in {
  from {
    transform: translateY(24px);
  }
}

/* ручка: шторку можно смахнуть вниз */
.sheet-grip {
  width: 40px;
  height: 5px;
  margin: 0 auto 8px;
  border-radius: 3px;
  background: var(--c-off);
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.sheet-title {
  flex: 1;
  min-width: 0;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 800;
}

.sheet-close {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: -6px;
  border-radius: 50%;
  color: var(--c-muted);
}

.sheet-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 8px auto 4px;
  border-radius: 24px;
  background: var(--m);
  color: #ffffff;
}

.sheet-art > .icon {
  width: 38px;
  height: 38px;
}

.sheet-has-art {
  position: relative;
}

.sheet-has-art .sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  margin: 0;
}

.sheet-has-art .sheet-title {
  padding: 0 8px;
  text-align: center;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

.sheet-center {
  text-align: center;
}

.sheet-text {
  font-size: 15px;
  line-height: 1.45;
  color: var(--c-muted);
}

.sheet-body > .note-action {
  margin: 0;
  text-align: left;
}

.pick-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 -8px;
}

.pick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 8px;
  border-radius: 16px;
  text-align: left;
}

.pick-row.is-on {
  background: var(--c-soft);
}

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

.pick-title {
  font-size: 16px;
  line-height: 1.3;
  font-weight: 700;
}

.pick-check {
  width: 24px;
  height: 24px;
  stroke-width: 2.6;
  color: var(--m-ink);
}

/* ---------- Нижняя полоса, всплывающая строка, окно ---------- */

.bottom-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--c-line);
  background: var(--c-card);
}

.bottom-bar > .btn {
  max-width: 528px;
  margin: 0 auto;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  left: 16px;
  z-index: 50;
  max-width: 528px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--c-text);
  color: var(--c-card);
  font-size: 15px;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
}

.toast-error {
  box-shadow: inset 0 -3px 0 var(--c-danger);
}

body.has-bottom-bar .toast {
  bottom: calc(84px + var(--safe-bottom));
}

.dialog-layer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--c-scrim);
}

.dialog {
  width: 100%;
  max-width: 340px;
  padding: 20px;
  border-radius: 18px;
  background: var(--c-card);
}

.dialog-title {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 800;
}

.dialog-text {
  margin-bottom: 18px;
  font-size: 15px;
  color: var(--c-muted);
}

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

/* ---------- Прочее ---------- */

@media (max-width: 359px) {
  .page {
    padding-right: 12px;
    padding-left: 12px;
  }

  .page-title,
  .mod-hero-title {
    font-size: 22px;
  }

  .tab {
    padding: 0 8px;
    font-size: 13px;
  }
}

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

  .sheet-enter {
    animation: none;
  }

  .spinner,
  .is-spinning {
    animation-duration: 2s;
  }
}
