/* Кабинет офиса. Цвета переопределяются в рантайме из Telegram.WebApp.themeParams
   (см. app.js, applyTheme()) — здесь только запасные значения тёмной темы, на
   случай если параметры темы недоступны (открыли не из Telegram). */
:root {
  --tg-bg: #17212b;
  --tg-text: #f5f5f5;
  --tg-hint: #708499;
  --tg-link: #6ab7ff;
  --tg-button: #5288c1;
  --tg-button-text: #ffffff;
  --tg-secondary-bg: #232e3c;
  /* Предупреждения и статусы вне палитры Telegram: themeParams таких цветов не
     даёт, а полоса паузы/красная полоса слушателя обязаны быть заметны. */
  --danger: #e0554f;
  --warn: #d99a4e;
  --ok: #5fae6e;
  --radius: 12px;
  --nav-height: 56px;
  --gap: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--tg-bg);
  color: var(--tg-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  /* Горизонтальной прокрутки страницы быть не должно нигде, кроме каруселей. */
  overflow-x: hidden;
  width: 100%;
}

body { -webkit-tap-highlight-color: transparent; }

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

a { color: var(--tg-link); }

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

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

#appbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 16px 6px;
  flex: 0 0 auto;
}
.appbar-title {
  font-weight: 600;
  font-size: 15px;
}
.appbar-user {
  font-size: 13px;
  color: var(--tg-hint);
}

/* --- полосы наверху (пауза, слушатель стоит) ---------------------------- */

#banners { flex: 0 0 auto; }

.banner {
  margin: 0 12px 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.4;
}
.banner--danger { background: var(--danger); color: #fff; }
.banner--warn { background: var(--warn); color: #241a08; }

/* --- основная область ---------------------------------------------------*/

#view {
  flex: 1 1 auto;
  padding: 0 12px calc(var(--nav-height) + 16px);
  min-width: 0; /* иначе длинные строки внутри флекс-контейнера тянут ширину */
}

#view.view--item { padding-bottom: 180px; } /* место под липкую панель решений */

.loading, .empty, .error-line {
  color: var(--tg-hint);
  padding: 24px 4px;
  font-size: 15px;
}
.error-line { color: var(--danger); }

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

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--tg-secondary-bg);
  border-top: 1px solid rgba(255,255,255,0.06);
}
.bottom-nav.hidden { display: none; }
.nav-btn {
  flex: 1 1 0;
  background: none;
  border: none;
  font-size: 12px;
  color: var(--tg-hint);
  padding: 6px 2px;
}
.nav-btn.active { color: var(--tg-link); font-weight: 600; }

/* --- строка статуса вверху экрана решений -------------------------------*/

.status-line {
  font-size: 14px;
  color: var(--tg-hint);
  padding: 4px 4px 12px;
}
.status-line b { color: var(--tg-text); font-weight: 600; }

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

.card {
  background: var(--tg-secondary-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.card--tappable { cursor: pointer; }
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
}
.card-meta {
  font-size: 13px;
  color: var(--tg-hint);
  margin: 0 0 2px;
}
.card-wait {
  font-size: 13px;
  color: var(--tg-hint);
}
.card-change {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(217, 154, 78, 0.14);
  border: 1px solid rgba(217, 154, 78, 0.4);
  font-size: 13px;
}
.card-change b { color: var(--warn); }

/* --- свёрнутые группы ------------------------------------------------------*/

.group { margin-bottom: 8px; }
.group-toggle {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--tg-text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.group-toggle .count { color: var(--tg-hint); font-weight: 400; }
.group-toggle .chevron { transition: transform 180ms ease; color: var(--tg-hint); }
.group.open .group-toggle .chevron { transform: rotate(90deg); }
.group-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 200ms ease;
}
.group.open .group-body { max-height: 3000px; }

.row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 4px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 14px;
}
.row:first-child { border-top: none; }
.row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { flex: 0 0 auto; color: var(--tg-hint); text-align: right; font-size: 13px; }

/* --- точка статуса --------------------------------------------------------*/

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.dot--awaiting { background: var(--tg-link); }
.dot--approved { background: var(--tg-button); }
.dot--published { background: var(--tg-hint); }
.dot--revision { background: var(--warn); }
.dot--held, .dot--rejected { background: transparent; border: 1px solid var(--tg-hint); }
.dot--planned, .dot--built { background: transparent; border: 1px solid rgba(255,255,255,0.2); }

/* --- экран материала -------------------------------------------------------*/

.item-header { padding: 4px 4px 8px; }
.item-title { font-size: 19px; font-weight: 700; margin: 0 0 4px; }

.section { margin: 18px 0; }
.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--tg-hint);
  margin: 0 0 8px;
}

video.reel {
  display: block;
  width: 100%;
  max-height: 70vh;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  background: #000;
  border-radius: var(--radius);
}

/* Карусель карточек: прокручивается сама, страница вокруг неё не двигается. */
.carousel-wrap { position: relative; }
.carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.carousel img {
  flex: 0 0 auto;
  height: 62vh;
  max-height: 520px;
  width: auto;
  border-radius: 8px;
  scroll-snap-align: start;
  background: var(--tg-secondary-bg);
}
.carousel-count {
  text-align: center;
  font-size: 12px;
  color: var(--tg-hint);
  margin-top: 6px;
}

.caption-block {
  background: var(--tg-secondary-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.article-body {
  font-size: 16px;
  line-height: 1.6;
  max-width: 62ch;
}
.article-body p { margin: 0 0 1em; }
.article-heading {
  font-size: 17px;
  font-weight: 700;
  margin: 1.2em 0 0.5em;
}
.article-heading:first-child { margin-top: 0; }

.draft-link {
  display: block;
  text-align: center;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--tg-secondary-bg);
  color: var(--tg-link);
  font-weight: 600;
  text-decoration: none;
}

.history-list { font-size: 13px; }
.history-item { padding: 6px 0; border-top: 1px solid rgba(255,255,255,0.06); }
.history-item:first-child { border-top: none; }
.history-when { color: var(--tg-hint); }
.history-note { margin-top: 2px; }

/* --- липкая панель решений --------------------------------------------------*/

.decision-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--tg-secondary-bg);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0));
}
.decision-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.decision-btn {
  flex: 1 1 auto;
  min-width: 45%;
  border: none;
  border-radius: 10px;
  padding: 11px 10px;
  font-size: 14px;
  font-weight: 600;
  background: var(--tg-bg);
}
.decision-btn--primary { background: var(--tg-button); color: var(--tg-button-text); }
.decision-btn--quiet { background: none; color: var(--tg-hint); font-weight: 400; flex: 0 0 auto; min-width: 0; padding: 11px 6px; }
.decision-btn:disabled { opacity: 0.5; }

.revise-panel { margin-top: 10px; }
.revise-panel textarea {
  width: 100%;
  min-height: 72px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--tg-bg);
  color: var(--tg-text);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.revise-hint { font-size: 12px; color: var(--tg-hint); margin: 6px 0; }
.revise-actions { display: flex; gap: 8px; margin-top: 6px; }

.decision-error {
  margin-top: 8px;
  font-size: 13px;
  color: var(--danger);
}

/* --- тост «Готово» -----------------------------------------------------*/

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + 20px);
  transform: translateX(-50%);
  background: var(--tg-button);
  color: var(--tg-button-text);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
  z-index: 20;
}
.toast.show { opacity: 1; }

/* --- календарь -----------------------------------------------------------*/

.day {
  padding: 10px 4px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.day:first-child { border-top: none; }
.day--today .day-date { color: var(--tg-link); }
.day--overlap { background: rgba(217, 154, 78, 0.10); border-radius: 8px; }
.day-date { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.day-empty { color: var(--tg-hint); font-size: 13px; }
.day-item { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 14px; }
.day-item-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-item-time { color: var(--tg-hint); flex: 0 0 auto; font-size: 13px; }

/* --- здоровье --------------------------------------------------------------*/

.health-row {
  padding: 12px 4px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.health-row:first-child { border-top: none; }
.health-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.health-detail { font-size: 13px; color: var(--tg-hint); }
.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}
.tag--ok { background: rgba(95, 174, 110, 0.18); color: var(--ok); }
.tag--bad { background: rgba(224, 85, 79, 0.18); color: var(--danger); }
.fail-item, .revision-item { font-size: 13px; padding: 4px 0; }

/* --- план месяца -----------------------------------------------------------*/

.plan-head { padding: 4px 4px 12px; }
.plan-month { font-size: 15px; font-weight: 600; }
.plan-note {
  font-size: 13px;
  color: var(--tg-hint);
  margin-top: 6px;
  white-space: pre-wrap;
}
.plan-row {
  padding: 10px 4px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.plan-row:first-child { border-top: none; }
.plan-row-title { font-size: 14px; font-weight: 600; }
.plan-row-meta { font-size: 12px; color: var(--tg-hint); margin-top: 2px; }
.plan-layer {
  font-size: 11px;
  color: var(--tg-hint);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
}

/* --- экран отказа в доступе --------------------------------------------------*/

.access-blocked {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 24px;
  text-align: center;
  color: var(--tg-hint);
  font-size: 15px;
}

/* --- мобильная адаптивность 360-414px --------------------------------------*/

@media (max-width: 380px) {
  .decision-btn { min-width: 100%; }
  .carousel img { height: 56vh; }
}
