/* Дизайн-система Mini App.
   Цвета берутся из темы Telegram; свои — только три акцента поверх неё:
   danger (просрочка), warn (близкий срок), ok (сдано). */

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #0b0f14);
  --hint: var(--tg-theme-hint-color, #8a949e);
  --link: var(--tg-theme-link-color, #2f8ee0);
  --button: var(--tg-theme-button-color, #2f8ee0);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --section: var(--tg-theme-section-bg-color, #f3f4f7);
  --danger: var(--tg-theme-destructive-text-color, #e0393e);

  /* Своих токенов ровно три, остальное — их прозрачные подложки. */
  --warn: #c67b12;
  --ok: #1f8f63;

  --separator: color-mix(in srgb, var(--hint) 25%, transparent);
  --danger-bg: color-mix(in srgb, var(--danger) 9%, transparent);
  --warn-bg: color-mix(in srgb, var(--warn) 12%, transparent);
  --ok-bg: color-mix(in srgb, var(--ok) 12%, transparent);
  --link-bg: color-mix(in srgb, var(--link) 12%, transparent);
  --hint-bg: color-mix(in srgb, var(--hint) 14%, transparent);

  --radius: 12px;
  --tabbar-height: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Телеграм отдаёт схему через tg.colorScheme; media-запрос — на случай, когда её нет. */
:root[data-scheme="dark"] {
  --warn: #e0a54a;
  --ok: #4fbb8c;
  --separator: color-mix(in srgb, var(--hint) 40%, transparent);
  --hint-bg: color-mix(in srgb, var(--hint) 18%, transparent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --warn: #e0a54a;
    --ok: #4fbb8c;
    --separator: color-mix(in srgb, var(--hint) 40%, transparent);
    --hint-bg: color-mix(in srgb, var(--hint) 18%, transparent);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto,
    system-ui, sans-serif;
  overscroll-behavior-y: none;
}

[hidden] {
  display: none !important;
}

#root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

@keyframes shim {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: 320px 0;
  }
}

@keyframes pop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* --- каркас экрана --- */

.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: none;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--section);
  border-bottom: 1px solid var(--separator);
}

.topbar-titles {
  flex: 1;
  min-width: 0;
}

.topbar-title {
  font: 600 15.5px/1.2 system-ui;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sub {
  font: 11.5px/1.3 system-ui;
  color: var(--hint);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-action {
  flex: none;
  border: 1px solid var(--separator);
  background: var(--surface);
  cursor: pointer;
  color: var(--link);
  border-radius: 8px;
  padding: 6px 10px;
  font: 600 12.5px system-ui;
  display: flex;
  align-items: center;
  gap: 5px;
}

.body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

.screen {
  padding: 12px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.screen.wide {
  padding: 16px 14px 20px;
  gap: 16px;
}

.section-label {
  font: 600 11px system-ui;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--hint);
  padding: 2px 3px;
}

.section-label.spaced {
  padding-top: 12px;
}

.hint-note {
  font: 11.5px/1.45 system-ui;
  color: var(--hint);
  padding: 4px 4px 0;
  text-wrap: pretty;
}

/* --- служебные состояния --- */

.empty {
  padding: 56px 26px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

.empty-icon {
  font-size: 30px;
  line-height: 1;
}

.empty-title {
  font: 600 16px system-ui;
}

.empty-text {
  font: 13.5px/1.45 system-ui;
  color: var(--hint);
  max-width: 230px;
  text-wrap: pretty;
}

.skeleton {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.skeleton-bar {
  height: 10px;
  border-radius: 6px;
  background: var(--hint-bg);
}

.skeleton-bar.lead {
  height: 12px;
  width: 38%;
  background-image: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--bg) 55%, transparent),
    transparent
  );
  background-repeat: no-repeat;
  background-size: 180px 100%;
  animation: shim 1.25s infinite linear;
}

.blocker {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 32px;
  text-align: center;
}

.blocker-icon {
  font-size: 34px;
  line-height: 1;
}

.blocker h2 {
  margin: 0;
  font: 600 18px/1.25 system-ui;
}

.blocker p {
  margin: 0;
  font: 14px/1.5 system-ui;
  color: var(--hint);
  max-width: 250px;
  text-wrap: pretty;
}

.blocker code {
  font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--section);
  border: 1px solid var(--separator);
  border-radius: 9px;
  padding: 9px 13px;
  color: var(--text);
}

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

.card {
  position: relative;
  width: 100%;
  text-align: left;
  border: 1px solid var(--separator);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow: hidden;
}

button.card {
  cursor: pointer;
}

button.card:active {
  background: var(--section);
}

/* Просрочка — единственный сигнал с полосой и заливкой. */
.card.late::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--danger);
}

.card.late::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--danger-bg);
  pointer-events: none;
}

.card > * {
  position: relative;
}

.card-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.card-title {
  font: 600 15.5px system-ui;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-title.wrap {
  white-space: normal;
  line-height: 1.3;
  text-wrap: pretty;
}

.card-time {
  font: 11.5px system-ui;
  color: var(--hint);
  flex: none;
}

.card-preview {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.card-preview span.text {
  flex: 1;
  min-width: 0;
  font: 13.5px/1.35 system-ui;
  color: var(--hint);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font: 12px system-ui;
  color: var(--hint);
  margin-top: 1px;
}

.card-meta .danger {
  color: var(--danger);
  font-weight: 600;
}

.card-meta .warn {
  color: var(--warn);
  font-weight: 600;
}

.tag {
  border: 1px solid var(--separator);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
}

.chevron {
  color: var(--hint);
  font-size: 18px;
  flex: none;
}

/* Единственный бейдж в списке — непрочитанные. */
.badge {
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  font: 600 12px/20px system-ui;
  text-align: center;
  animation: pop 0.18s ease-out;
}

.pill {
  border-radius: 6px;
  padding: 3px 8px;
  font: 600 11.5px system-ui;
  background: var(--hint-bg);
  color: var(--hint);
  flex: none;
}

.pill.late {
  background: var(--danger);
  color: #fff;
}

.pill.open {
  background: var(--link-bg);
  color: var(--link);
}

.pill.done {
  background: var(--ok-bg);
  color: var(--ok);
}

.pill.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.pill.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Запас времени — полоса, а не третий бейдж. */
.timebar {
  height: 3px;
  border-radius: 2px;
  background: var(--hint-bg);
  overflow: hidden;
}

.timebar span {
  display: block;
  height: 100%;
  background: var(--link);
}

.timebar.late span {
  background: var(--danger);
}

.timebar.soon span {
  background: var(--warn);
}

.card.archived {
  background: transparent;
  gap: 7px;
}

.card.archived .card-title {
  font: 500 15px/1.3 system-ui;
  color: var(--hint);
  white-space: normal;
  text-wrap: pretty;
}

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

.chat-log {
  display: flex;
  flex-direction: column;
  padding: 12px 12px 4px;
}

.load-older {
  align-self: center;
  margin: 0 0 10px;
  border: 1px solid var(--separator);
  background: var(--section);
  color: var(--link);
  cursor: pointer;
  border-radius: 20px;
  padding: 6px 14px;
  font: 12.5px system-ui;
}

.bubble {
  align-self: flex-start;
  max-width: 82%;
  margin: 0 0 8px;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: 15px 15px 15px 5px;
  padding: 8px 11px 6px;
}

.bubble.me {
  align-self: flex-end;
  max-width: 80%;
  background: var(--button);
  color: var(--button-text);
  border-color: transparent;
  border-radius: 15px 15px 5px 15px;
}

.bubble.system {
  align-self: center;
  max-width: 86%;
  margin: 6px 0 10px;
  text-align: center;
  font: 12.5px/1.4 system-ui;
  color: var(--hint);
  background: var(--section);
  border: 0;
  border-radius: 10px;
  padding: 7px 12px;
}

.bubble-author {
  font: 600 12.5px system-ui;
  color: var(--link);
  margin-bottom: 2px;
}

.bubble-text {
  font: 15px/1.4 system-ui;
  word-break: break-word;
}

.bubble-time {
  font: 11px system-ui;
  color: var(--hint);
  text-align: right;
  margin-top: 3px;
}

.bubble.me .bubble-time {
  color: inherit;
  opacity: 0.75;
}

/* Служебная замена: видно, что это не текст автора. */
.mask {
  font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px dashed currentColor;
  color: var(--hint);
  opacity: 0.9;
}

.bubble.me .mask {
  color: inherit;
  opacity: 0.7;
}

.card-preview .mask {
  font-size: 12px;
  padding: 0 4px;
  border-radius: 4px;
  opacity: 0.62;
}

/* Приписки живут в подвале пузыря, за хайрлайном. */
.bubble-note {
  margin: 6px -11px -6px;
  padding: 6px 11px;
  border-top: 1px solid var(--separator);
  font: 11.5px/1.35 system-ui;
  color: var(--hint);
  border-radius: 0 0 14px 4px;
}

.bubble-note.flagged {
  color: var(--warn);
  background: var(--warn-bg);
}

/* На своём пузыре янтарный по синему нечитаем — берём цвет пузыря. */
.bubble.me .bubble-note {
  color: inherit;
  border-top-color: color-mix(in srgb, var(--button-text) 35%, transparent);
}

.bubble.me .bubble-note.flagged {
  background: rgba(0, 0, 0, 0.16);
  border-radius: 0 0 5px 14px;
}

.bubble-note.origin {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.4;
}

.bubble-note.origin b {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 2px;
}

.bubble-media {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 7px;
}

.bubble-media.single {
  grid-template-columns: 1fr;
}

/* Место под вложение занимается заранее — layout не прыгает. */
.media-slot {
  position: relative;
  height: 120px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--hint-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-slot.loading {
  background-image: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--bg) 50%, transparent),
    transparent
  );
  background-repeat: no-repeat;
  background-size: 180px 100%;
  animation: shim 1.2s infinite linear;
}

.media-slot span {
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--hint);
}

.media-slot img,
.media-slot video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.doc-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 7px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--section);
  color: var(--text);
  text-decoration: none;
}

.doc-row b {
  display: block;
  font: 600 12.5px/1.3 system-ui;
}

.doc-row small {
  font: 12.5px system-ui;
  color: var(--hint);
}

/* --- композер --- */

.dock {
  flex: none;
  background: var(--section);
  border-top: 1px solid var(--separator);
  padding: 8px 10px calc(12px + var(--safe-bottom));
}

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

.composer textarea {
  flex: 1;
  max-height: 110px;
  min-height: 34px;
  resize: none;
  border: 1px solid var(--separator);
  border-radius: 17px;
  padding: 7px 13px;
  font: 15px/1.35 system-ui;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.round-button {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 17px;
  background: var(--button);
  color: var(--button-text);
  font: 16px/1 system-ui;
  cursor: pointer;
}

.round-button.ghost {
  background: transparent;
  color: var(--hint);
  font-size: 17px;
}

.round-button:disabled {
  opacity: 0.5;
}

.observing {
  flex: none;
  padding: 14px 14px calc(18px + var(--safe-bottom));
  border-top: 1px solid var(--separator);
  background: repeating-linear-gradient(
    135deg,
    var(--hint-bg) 0 8px,
    transparent 8px 16px
  );
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font: 600 12.5px system-ui;
  letter-spacing: 0.04em;
  color: var(--hint);
  text-transform: uppercase;
}

/* --- формы --- */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.field-head span:first-child {
  font: 600 11px system-ui;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--hint);
}

.counter {
  font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--hint);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--separator);
  border-radius: 11px;
  padding: 12px;
  font: 15px system-ui;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.field textarea {
  min-height: 104px;
  resize: none;
  line-height: 1.45;
  padding: 11px 12px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--link);
}

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

.chip {
  border: 1px solid var(--separator);
  background: transparent;
  color: var(--text);
  border-radius: 20px;
  padding: 7px 14px;
  font: 13.5px system-ui;
  cursor: pointer;
}

.chip.active {
  border-color: var(--button);
  background: var(--button);
  color: var(--button-text);
  font-weight: 600;
}

.chip.quick {
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12.5px;
  background: var(--section);
  color: var(--link);
}

.chip.quick.active {
  border-color: var(--link);
  background: var(--link-bg);
  color: var(--link);
  font-weight: 600;
}

.button {
  width: 100%;
  border: 0;
  cursor: pointer;
  background: var(--button);
  color: var(--button-text);
  border-radius: 11px;
  padding: 14px;
  font: 600 15.5px system-ui;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.button.secondary {
  background: transparent;
  border: 1px solid var(--separator);
  color: var(--link);
}

.button.danger {
  background: transparent;
  border: 1px solid var(--separator);
  color: var(--danger);
  padding: 13px;
  font-size: 15px;
}

.button.compact {
  padding: 11px;
  font-size: 13.5px;
  border-radius: 10px;
}

.button:disabled {
  opacity: 0.55;
}

.button-row {
  display: flex;
  gap: 7px;
}

.button-row .button {
  flex: 1;
}

/* Ошибка фильтра живёт в форме, а не в системном алерте. */
.filter-error {
  border-radius: 11px;
  padding: 11px 13px;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
}

.filter-error b {
  display: block;
  font: 600 13px system-ui;
  color: var(--danger);
  margin-bottom: 4px;
}

.filter-error p {
  margin: 0;
  font: 12.5px/1.4 system-ui;
  opacity: 0.85;
}

.filter-error .words {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.filter-error .words span {
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--danger);
  color: #fff;
  border-radius: 5px;
  padding: 2px 7px;
}

.error-text {
  font: 13px system-ui;
  color: var(--danger);
}

/* --- вложения --- */

.attach-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.attach-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 9px;
  overflow: hidden;
  background: repeating-linear-gradient(
    135deg,
    var(--hint-bg) 0 7px,
    transparent 7px 14px
  );
  border: 1px solid var(--separator);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 10.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--hint);
}

.attach-item img,
.attach-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attach-item a {
  color: var(--link);
  text-decoration: none;
  font: 12px system-ui;
}

.attach-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font: 12px/1 system-ui;
  cursor: pointer;
}

.attach-add {
  aspect-ratio: 1;
  border: 1px dashed var(--separator);
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  color: var(--link);
  font: 22px/1 system-ui;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-wide {
  width: 100%;
  border: 1px dashed var(--separator);
  border-radius: 11px;
  background: transparent;
  cursor: pointer;
  color: var(--link);
  padding: 16px;
  font: 13.5px system-ui;
}

.attach-strip {
  display: flex;
  gap: 6px;
  overflow: auto;
  margin: 0 0 8px;
  padding: 0 0 2px;
}

.attach-strip .attach-item {
  flex: none;
  width: 58px;
  height: 58px;
  aspect-ratio: auto;
}

.attach-progress {
  font: 11.5px system-ui;
  color: var(--hint);
  margin-top: 6px;
}

.attach-hint {
  font: 11.5px/1.4 system-ui;
  color: var(--hint);
  margin-top: 6px;
}

/* --- карточка запроса --- */

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

.detail-status .late-text {
  font: 600 12.5px system-ui;
  color: var(--danger);
}

.detail-title {
  margin: 0;
  font: 600 20px/1.25 system-ui;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

.kv-table {
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  overflow: hidden;
}

.kv {
  display: flex;
  gap: 12px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--separator);
}

.kv:last-child {
  border-bottom: 0;
}

.kv > span:first-child {
  flex: none;
  width: 96px;
  font: 12.5px system-ui;
  color: var(--hint);
}

.kv > span:last-child {
  flex: 1;
  font: 13.5px/1.35 system-ui;
}

.detail-block {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.detail-text {
  font: 14.5px/1.5 system-ui;
  text-wrap: pretty;
}

.origin-note {
  font: 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--hint);
  border: 1px dashed var(--separator);
  border-radius: 9px;
  padding: 8px 10px;
}

.origin-note b {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
  margin-bottom: 3px;
}

.done-block {
  border: 1px solid var(--separator);
  border-left: 3px solid var(--ok);
  border-radius: 10px;
  padding: 11px 13px;
  background: var(--ok-bg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.done-block b {
  font: 600 12.5px system-ui;
  color: var(--ok);
}

.submit-head {
  background: var(--section);
  border-radius: 11px;
  padding: 11px 13px;
}

.submit-head .label {
  font: 11px system-ui;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hint);
  margin-bottom: 3px;
}

.submit-head .title {
  font: 600 14.5px/1.3 system-ui;
}

.submit-head .deadline {
  font: 600 12.5px system-ui;
  margin-top: 3px;
  color: var(--hint);
}

.submit-head .deadline.late {
  color: var(--danger);
}

.button-note {
  text-align: center;
  font: 11px system-ui;
  color: var(--hint);
}

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

.hero {
  width: 100%;
  text-align: left;
  border: 1px solid var(--danger);
  background: var(--danger-bg);
  border-radius: 14px;
  padding: 16px 16px 14px;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.hero.calm {
  border-color: var(--separator);
  background: var(--surface);
}

.hero-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.hero-num {
  font: 700 40px/1 system-ui;
  letter-spacing: -0.03em;
  color: var(--danger);
}

.hero.calm .hero-num {
  color: var(--ok);
}

.hero-label {
  font: 600 14.5px system-ui;
  color: var(--danger);
}

.hero.calm .hero-label {
  color: var(--ok);
}

.hero-sub {
  font: 13px/1.4 system-ui;
  opacity: 0.75;
  margin-top: 7px;
}

.hero-action {
  font: 600 13px system-ui;
  color: var(--danger);
  margin-top: 9px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Нечётное число плиток: последняя занимает строку целиком, а не половину. */
.stat-grid .stat:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.stat {
  border: 1px solid var(--separator);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 13px;
}

.stat b {
  font: 600 24px/1 system-ui;
  letter-spacing: -0.02em;
}

.stat span {
  display: block;
  font: 12.5px/1.3 system-ui;
  color: var(--hint);
  margin-top: 5px;
}

.nav-list {
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  overflow: hidden;
}

.nav-row {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--separator);
  background: var(--surface);
  cursor: pointer;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  font: inherit;
}

.nav-row:last-child {
  border-bottom: 0;
}

.nav-row .icon {
  font-size: 17px;
}

.nav-row .label {
  flex: 1;
  font: 14.5px system-ui;
}

.nav-row .meta {
  font: 12.5px system-ui;
  color: var(--hint);
}

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

.person .alias {
  font: 600 15px system-ui;
}

.person .meta {
  font: 12.5px system-ui;
  color: var(--hint);
  margin-top: 3px;
}

.icon-button {
  border: 0;
  background: transparent;
  color: var(--hint);
  font: 17px system-ui;
  cursor: pointer;
  padding: 2px 4px;
}

.word-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.word-row .word {
  flex: 1;
  font: 14.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-word;
}

.word-row .scope {
  font: 11.5px system-ui;
  color: var(--hint);
  width: 56px;
  flex: none;
}

.switch {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  flex: none;
}

.switch span {
  display: block;
  width: 38px;
  height: 23px;
  border-radius: 12px;
  background: var(--hint-bg);
  position: relative;
  transition: background 0.15s;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}

.switch.on span {
  background: var(--ok);
}

.switch.on span::after {
  transform: translateX(15px);
}

.event-body {
  font: 13.5px/1.45 system-ui;
  margin-top: 6px;
  word-break: break-word;
}

/* --- полноэкранный просмотр вложений --- */

body.viewer-open {
  overflow: hidden;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
  /* Только прозрачность: масштабировать слой во весь экран незачем. */
  animation: fade-in 0.16s ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.viewer-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  color: #fff;
}

.viewer-count {
  font: 600 13px system-ui;
  opacity: 0.75;
}

.viewer-close {
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 16px;
  font: 15px/1 system-ui;
  cursor: pointer;
}

.viewer-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px calc(14px + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}

.viewer-item {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-item.loading {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.08),
    transparent
  );
  background-repeat: no-repeat;
  background-size: 180px 100%;
  animation: shim 1.2s infinite linear;
}

.viewer-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.18s ease-out;
}

.viewer-media.zoomed {
  cursor: grab;
}

.viewer-hint {
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: rgba(255, 255, 255, 0.6);
}

.viewer-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.viewer-file-icon {
  font-size: 44px;
  line-height: 1;
}

/* Видео в пузыре — превью с меткой воспроизведения, само играет в просмотрщике. */
.media-slot .play-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  pointer-events: none;
}

.media-slot,
.attach-item {
  cursor: pointer;
}

/* --- нижние вкладки --- */

.tabbar {
  flex: none;
  display: flex;
  padding-bottom: var(--safe-bottom);
  background: var(--section);
  border-top: 1px solid var(--separator);
}

.tabbar button {
  position: relative;
  flex: 1;
  height: var(--tabbar-height);
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.tabbar .tab-icon {
  font-size: 20px;
  line-height: 1;
  opacity: 0.45;
  filter: grayscale(1);
}

.tabbar .tab-label {
  font: 10.5px system-ui;
  color: var(--hint);
}

.tabbar button.active .tab-icon {
  opacity: 1;
  filter: none;
}

.tabbar button.active .tab-label {
  font-weight: 600;
  color: var(--link);
}

.tabbar .tab-dot {
  position: absolute;
  top: 9px;
  left: 50%;
  margin-left: 8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font: 600 10px/16px system-ui;
  text-align: center;
  animation: pop 0.2s ease-out;
}
