/* Доска наследует тему Telegram пользователя (светлую или тёмную) */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #eef1f4);
  --card: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #101318);
  --hint: var(--tg-theme-hint-color, #8a919c);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);

  /* Конвейер статусов: очередь → эфир → проверка → готово */
  --c-todo: #8e9aaf;
  --c-doing: #3d8bfd;
  --c-review: #f0a12b;
  --c-done: #2fa864;
  --danger: #e5484d;

  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 96px;
  -webkit-tap-highlight-color: transparent;
}

/* --- Шапка --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}

.title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.seg {
  display: flex;
  background: var(--card);
  border-radius: 10px;
  padding: 3px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--hint);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--btn);
  color: var(--btn-text);
}

/* --- Вкладки колонок --- */

.cols {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cols::-webkit-scrollbar { display: none; }

.col-tab {
  flex: 1;
  min-width: max-content;
  border: 0;
  background: var(--card);
  color: var(--hint);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px 10px;
  border-radius: 10px;
  cursor: pointer;
  border-top: 3px solid transparent;
}

.col-tab .count {
  font-weight: 600;
  opacity: 0.75;
  margin-left: 4px;
}

.col-tab.active {
  color: var(--text);
  border-top-color: var(--col-color);
}

/* --- Список карточек --- */

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

.card {
  display: flex;
  align-items: stretch;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
}

.card-rail {
  width: 4px;
  flex: none;
  background: var(--col-color, var(--hint));
}

.card-main {
  flex: 1;
  padding: 11px 12px;
  min-width: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: break-word;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--hint);
  flex-wrap: wrap;
}

.chip {
  background: var(--bg);
  border-radius: 6px;
  padding: 2px 7px;
  font-weight: 600;
}

.due { font-weight: 600; }
.due.today { color: var(--c-review); }
.due.overdue { color: var(--danger); }

.advance {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--hint);
  font-size: 20px;
  padding: 0 14px;
  cursor: pointer;
  align-self: stretch;
}
.advance:active { color: var(--text); }

.empty {
  text-align: center;
  color: var(--hint);
  font-size: 14px;
  padding: 48px 24px;
  line-height: 1.5;
}

/* --- Кнопка добавления --- */

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

/* --- Шторка задачи --- */

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet.hidden, .hidden { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.sheet-body {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 88vh;
  overflow-y: auto;
}

.sheet-grip {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--hint);
  opacity: 0.4;
  margin: 4px auto 2px;
}

.inp {
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--hint) 35%, transparent);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  /* 16px и выше — иначе iOS Safari/WebView зумит страницу при фокусе на поле
     (правило действует для любого поля ввода с font-size < 16px), из-за чего
     форма визуально "сужается" при открытии клавиатуры. */
  font-size: 16px;
}
.inp:focus { outline: 2px solid var(--btn); outline-offset: -1px; }

textarea.inp { resize: vertical; }

.row { display: flex; gap: 10px; }
.row .lbl { flex: 1; min-width: 0; }

.lbl {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--hint);
}

.status-pick { display: flex; gap: 6px; }

.status-btn {
  flex: 1;
  border: 0;
  background: var(--bg);
  color: var(--hint);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 9px 4px;
  border-radius: 9px;
  cursor: pointer;
  border-top: 3px solid transparent;
}

.status-btn.active {
  color: var(--text);
  border-top-color: var(--sb-color);
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  flex: 1;
  background: var(--btn);
  color: var(--btn-text);
}

.btn.danger {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--card);
  font-size: 13.5px;
  padding: 9px 14px;
  border-radius: 10px;
  max-width: 86vw;
  z-index: 30;
}

@media (prefers-reduced-motion: no-preference) {
  .sheet-body { animation: rise 0.18s ease-out; }
  @keyframes rise {
    from { transform: translateY(24px); opacity: 0.6; }
    to { transform: translateY(0); opacity: 1; }
  }
}

/* --- Экран «Люди» --- */

.icon-btn {
  border: 0;
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
}

.people-title {
  font-size: 17px;
  font-weight: 800;
  margin: 4px 0 6px;
}

.people-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}

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

.people-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.role-badge {
  border: 1px solid color-mix(in srgb, var(--hint) 35%, transparent);
  background: var(--bg);
  color: var(--hint);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.role-badge.active {
  background: var(--btn);
  color: var(--btn-text);
  border-color: var(--btn);
}

.people-row .name {
  font-weight: 600;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.people-row select.inp {
  width: auto;
  flex: none;
}

/* --- Переключатель «исполнитель / роль» --- */

.assignee-mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mode-toggle {
  border: 0;
  background: none;
  color: var(--btn);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.claim {
  flex: none;
  border: 0;
  background: var(--btn);
  color: var(--btn-text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 0 12px;
  margin: 8px 10px 8px 0;
  border-radius: 8px;
  cursor: pointer;
  align-self: center;
}

/* --- Фильтр по проекту --- */

.project-filter-row {
  padding: 0 16px 10px;
}

.project-filter-row select {
  width: 100%;
  border: 0;
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
}

/* --- Мультивыбор исполнителей в шторке задачи --- */

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

.assignee-badge {
  border: 1px solid color-mix(in srgb, var(--hint) 35%, transparent);
  background: var(--bg);
  color: var(--hint);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.assignee-badge.active {
  background: var(--btn);
  color: var(--btn-text);
  border-color: var(--btn);
}

/* --- Персональная отметка готовности --- */

.ready-btn {
  flex: none;
  border: 0;
  background: var(--c-done);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 0 12px;
  margin: 8px 10px 8px 0;
  border-radius: 8px;
  cursor: pointer;
  align-self: center;
  white-space: nowrap;
}

.ready-btn.done {
  background: transparent;
  color: var(--c-done);
  cursor: default;
  padding: 0 10px 0 0;
}

/* --- Дэшборд --- */

.dash-section {
  margin-bottom: 4px;
}

.dash-heading {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.dash-empty {
  font-size: 13px;
  color: var(--hint);
  padding: 6px 0;
}

.dash-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--hint) 15%, transparent);
  font-size: 13.5px;
}

.dash-list > div:last-child {
  border-bottom: 0;
}

.dash-counts {
  color: var(--hint);
  font-size: 12.5px;
  white-space: nowrap;
}

.dash-list .title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-list .due {
  font-size: 12px;
  white-space: nowrap;
  color: var(--danger);
  font-weight: 600;
}

.dash-project-row {
  padding: 7px 0;
}

.dash-project-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.dash-project-top .name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-project-top .percent {
  color: var(--hint);
  white-space: nowrap;
  margin-left: 8px;
}

.dash-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg);
  overflow: hidden;
}

.dash-bar-fill {
  height: 100%;
  background: var(--c-done);
  border-radius: 3px;
}

.dash-velocity {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
}

.dash-velocity-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
}

.dash-velocity-bar {
  width: 100%;
  background: var(--btn);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.dash-velocity-label {
  font-size: 9.5px;
  color: var(--hint);
}
