:root {
  /* Чистая палитра, обновлена 2026-10-09.
     Фон — ровный серо-голубой; карточки — чистый белый, разница только
     в тени; акценты — насыщенные, без «грязного» среднего тона. */
  --bg: #eef2f6;
  --card: #ffffff;
  --card-hover: #f6f9fb;
  --text: #0f1b26;
  --muted: #6a7684;
  --accent: #2563eb;        /* синий поярче, легче читается */
  --accent-weak: #e6efff;
  --ok: #16a34a;
  --ok-weak: #e4f6ea;
  --warn: #c87a0f;             /* янтарный, не кричит */
  --warn-weak: #faeed3;
  --busy: #94a7bc;             /* нейтральный серо-синий — для рабочих окон */
  --busy-weak: #e4ebf2;
  --bad: #dc2626;
  --bad-weak: #fde3e3;
  --line: #e2e8ef;
  --shadow: 0 1px 2px rgba(15, 27, 38, .06), 0 4px 16px rgba(15, 27, 38, .05);
}
:root[data-theme="dark"] {
  --bg: #0f1620;
  --card: #1a2432;
  --card-hover: #22303f;
  --text: #e8edf3;
  --muted: #8495a7;
  --accent: #5aa7e8;
  --accent-weak: #1b2b3f;
  --ok: #4fbf72;
  --ok-weak: #1a2d22;
  --warn: #d8a74a;
  --warn-weak: #2a1f10;
  --busy: #6e7f93;
  --busy-weak: #1e2630;
  --bad: #e85f5f;
  --bad-weak: #331a1a;
  --line: #27354a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .25);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  /* Полоса по бокам на айфонах с загнутыми краями. */
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 0 0 env(safe-area-inset-bottom);
}
header {
  display: flex; align-items: center; justify-content: space-between;
  /* Отступ сверху — под «чёлку» и строку состояния. Без него на айфоне
     кнопки «Календарь» и «Список» уезжают под часы и не нажимаются. */
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
h1 { font-size: 20px; margin: 0; font-weight: 650; }
.health { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.health.ok  { background: var(--ok); }
.health.bad { background: var(--bad); }

#view-list > .list-stats {
  display: flex; gap: 10px; padding: 12px 16px 2px;
  color: var(--muted); font-size: 12.5px;
}
#view-list > .list-stats span b { color: var(--text); font-weight: 600; font-size: 15px; }
#tabs {
  display: flex; gap: 6px; padding: 10px 16px; overflow-x: auto;
  scrollbar-width: none; position: sticky; background: var(--bg); z-index: 4;
  top: calc(48px + env(safe-area-inset-top));
}
#tabs::-webkit-scrollbar { display: none; }
#tabs button {
  flex: 0 0 auto; border: 0; border-radius: 999px; padding: 7px 14px;
  background: var(--card); color: var(--muted); font-size: 14px; cursor: pointer;
}
#tabs button.active { background: var(--accent); color: #fff; }

main { padding: 0 16px 120px; }
.task {
  background: var(--card); border-radius: 14px; padding: 14px 15px; margin-bottom: 10px;
  border-left: 3px solid transparent; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.task.pending   { border-left-color: var(--busy); }
.task.snoozed   { border-left-color: var(--muted); }
.task.done      { opacity: 1; }
.task.overdue   { border-left-color: var(--bad); }
.task h3 { margin: 0 0 5px; font-size: 15.5px; font-weight: 600; }
.meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.quote {
  margin: 8px 0 0; padding-left: 9px; border-left: 2px solid var(--line);
  color: var(--muted); font-size: 13px; font-style: italic;
}
.actions { display: flex; gap: 7px; margin-top: 10px; }
.actions button {
  flex: 1; border: 0; border-radius: 10px; padding: 9px; font-size: 13.5px;
  background: var(--card-hover); color: var(--text); cursor: pointer;
  font-weight: 500;
  transition: transform .12s ease, background .18s ease, box-shadow .18s ease;
}
.actions button:hover { background: var(--accent-weak); }
.actions button.primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}
.actions button.primary:hover {
  background: color-mix(in srgb, var(--accent) 90%, #000);
}
.actions button:active { transform: scale(.95); }
.actions button:disabled { opacity: .55; cursor: default; }
.empty { color: var(--muted); text-align: center; padding: 48px 0; }

/* Две строки: названию нужна вся ширина, выбору даты — своя.
   В одну строку поле даты зажималось и показывало «09.10.» вместо даты. */
form#add {
  position: fixed; left: 0; right: 0;
  bottom: calc(62px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 7px;
  padding: 11px 16px; background: var(--bg);
  border-top: 1px solid var(--line); box-shadow: 0 -8px 20px rgba(0,0,0,.08);
  z-index: 9;
}
.add-row { display: flex; gap: 6px; }
.add-row #add-when { flex: 1; min-width: 0; }
#add-close { background: var(--card-hover) !important; color: var(--muted) !important; }
form#add input {
  min-width: 0; border: 1px solid var(--line); background: var(--card);
  color: var(--text); border-radius: 10px; padding: 9px 11px; font-size: 15px;
}
form#add button {
  border: 0; background: var(--accent); color: #fff; border-radius: 10px;
  padding: 9px 15px; font-size: 14px; cursor: pointer;
}
.auth { padding: 24px 16px; }
.auth input { width: 100%; padding: 10px; margin: 10px 0; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); }
.auth button { width: 100%; padding: 11px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15px; }
.hidden { display: none !important; }

/* ───────────────────────── Переключатель вида ───────────────────────── */


/* ───────────────────────── Шапка месяца ───────────────────────── */
.month-bar { display: flex; align-items: center; gap: 6px; padding: 2px 16px 10px; }
.month-bar h2 {
  margin: 0; font-size: 17px; font-weight: 600; flex: 1; text-align: center;
}
.month-bar button {
  border: 0; background: var(--card); color: var(--text); width: 32px; height: 32px;
  border-radius: 9px; font-size: 18px; line-height: 1; cursor: pointer;
}
.month-bar .today-btn { width: auto; padding: 0 11px; font-size: 13px; color: var(--muted); }

/* ───────────────────────── Сетка дней ───────────────────────── */
.weekdays, .grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 0 16px;
}
.weekdays { color: var(--muted); font-size: 12px; text-align: center; padding-bottom: 5px; }
.weekdays .we { color: var(--bad); opacity: .65; }

.cell {
  position: relative; aspect-ratio: 1 / 1; border: 0; border-radius: 12px;
  background: var(--card); color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 0; overflow: hidden;
  transition: transform .14s ease, background .18s ease, box-shadow .18s ease;
}
.cell:hover { background: var(--accent-weak); }
.cell:active { transform: scale(.94); }
.cell .num { font-size: 15px; font-weight: 500; }
.cell.other { opacity: .32; }
.cell.today .num { color: var(--accent); font-weight: 700; }
.cell.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cell.selected {
  background: var(--accent);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 40%, transparent);
}
.cell.selected .num, .cell.selected .more { color: #fff; }
.cell.selected.today { box-shadow: none; }

/* Полоса снизу — рабочее окно по расписанию (проверки ДЗ). */
.cell.busy::after {
  content: ''; position: absolute; left: 22%; right: 22%; bottom: 5px;
  height: 3px; border-radius: 2px; background: var(--busy); opacity: .75;
}
.cell.selected.busy::after { background: #fff; opacity: .85; }

.cell .dots { display: flex; align-items: center; gap: 3px; height: 7px; }
.dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.accent { background: var(--accent); }
.dot.warn   { background: var(--busy); }
.dot.bad    { background: var(--bad); }
.cell.selected .dot { background: #fff; }
.more { font-size: 10px; font-weight: 600; color: var(--muted); }

/* ───────────────────────── Легенда ───────────────────────── */
.legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 16px 4px;
  color: var(--muted); font-size: 12px;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .stripe {
  width: 12px; height: 3px; border-radius: 2px; background: var(--busy); opacity: .8;
}

/* ───────────────────────── День и список под сеткой ───────────────────────── */
.day-head {
  padding: 14px 16px 8px; font-size: 14px; font-weight: 600;
  border-top: 1px solid var(--line); margin-top: 8px;
}
.day-head.muted { color: var(--muted); font-weight: 500; }
#agenda, #undated { padding: 0 16px; }
#undated { padding-bottom: 120px; }
#view-list { padding-bottom: 120px; }
#list { padding: 0 16px; }
#list .task:first-child { margin-top: 10px; }
#list .task h3 { font-size: 15.5px; margin-bottom: 6px; }
.empty.small { padding: 22px 0; font-size: 14px; }

@media (min-width: 720px) {
  body { max-width: 720px; margin: 0 auto; }
  .cell .num { font-size: 16px; }
}

/* ───────────────────────── Подсказка о результате ───────────────────────── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(132px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 15px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35); max-width: calc(100% - 32px);
}

/* ───────────────────────── Выбор срока в карточке ───────────────────────── */
.actions .ghost { flex: 0 0 42px; font-size: 15px; }
.when { display: none; gap: 6px; margin-top: 8px; }
.task.show-when .when { display: flex; }
.when input[type="datetime-local"] {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card-hover);
  color: var(--text); border-radius: 9px; padding: 7px 9px; font-size: 14px;
}
.when button {
  border: 0; border-radius: 9px; padding: 7px 11px; font-size: 13.5px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.when .clear-when { background: var(--card-hover); color: var(--muted); padding: 7px 10px; }

#add-when, .when input { color-scheme: light; }
:root[data-theme="dark"] #add-when,
:root[data-theme="dark"] .when input { color-scheme: dark; }

/* ───────────────────────── Отметка версии ───────────────────────── */
.version {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 18px 16px 10px; color: var(--muted); font-size: 12px;
}
.version button {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer;
}

/* ───────────────────────── Выполненные ───────────────────────── */
.done-head {
  padding: 16px 0 8px; font-size: 12.5px; color: var(--ok);
  text-transform: uppercase; letter-spacing: .04em;
}
.task.done {
  background: var(--ok-weak); border-left-color: var(--ok);
  box-shadow: none;
}
.task.done h3 { color: var(--muted); text-decoration: line-through; font-weight: 500; }
.task.done h3::before { content: '✓ '; color: var(--ok); text-decoration: none; font-weight: 700; }

/* ───────────────────────── Экран чатов ───────────────────────── */
#view-chats { padding: 0 16px 120px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 2px 0 12px; }
#chat-search {
  width: 100%; border: 1px solid var(--line); background: var(--card);
  color: var(--text); border-radius: 10px; padding: 9px 11px;
  font-size: 15px; margin-bottom: 10px;
}
.chat {
  background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
  box-shadow: var(--shadow); transition: transform .14s ease, box-shadow .18s ease;
}
.chat:hover { transform: translateY(-1px); }
.chat-head {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.chat-avatar {
  flex: 0 0 46px; width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 18px; color: #fff;
  letter-spacing: -.02em; user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}
.chat .chat-name {
  min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.chat-name b {
  font-size: 14.5px; font-weight: 600; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-name span { color: var(--muted); font-size: 12px; line-height: 1.3; }
.chat .modes {
  display: flex; gap: 5px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
.modes button {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 8px; padding: 5px 7px; font-size: 12px; cursor: pointer;
  white-space: nowrap;
}
.modes button { transition: background .18s ease, color .18s ease, transform .1s ease; }
.modes button:active { transform: scale(.93); }
.modes button.on.all       { background: var(--accent-weak); color: var(--accent); border-color: var(--accent); }
.modes button.on.addressed { background: var(--ok-weak);     color: var(--ok);     border-color: var(--ok); }
.modes button.on.mention   { background: var(--busy-weak);  color: var(--busy);   border-color: var(--busy); }
.modes button.on.off       { background: var(--line);        color: var(--text); }

/* ───────────────────────── Переключатель темы ───────────────────────── */
#theme {
  border: 0; background: transparent; cursor: pointer; font-size: 17px;
  line-height: 1; padding: 4px 6px; opacity: .75;
}
.head-right { display: flex; align-items: center; gap: 8px; }

/* ───────────────────── Нижняя панель вкладок ─────────────────────
   Наверху кнопки перекрывала строка состояния айфона, и нажать их было
   нельзя. Снизу они всегда под большим пальцем и ни с чем не спорят. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 7px; font-size: 11px; cursor: pointer; min-height: 54px;
  position: relative; transition: color .18s ease;
}
.tabbar button i { font-style: normal; font-size: 20px; line-height: 1; }
.tabbar button.active { color: var(--accent); font-weight: 600; }
.tabbar button.active::before {
  content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 2px;
  background: var(--accent); border-radius: 0 0 2px 2px;
}
.tabbar button:active i { transform: scale(.9); transition: transform .1s ease; }

/* Кнопка новой задачи — над вкладками, у большого пальца. */
#add-open {
  position: fixed; right: 16px; z-index: 11;
  bottom: calc(72px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; font-size: 30px; line-height: 1;
  font-weight: 300; cursor: pointer;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform .18s cubic-bezier(.2,.9,.4,1.3), box-shadow .18s ease;
}
#add-open:hover { transform: translateY(-2px); }
#add-open:active { transform: scale(.9); }

/* ───────────────────────── Правка названия ───────────────────────── */
.rename { display: none; gap: 6px; margin-top: 8px; }
.task.show-rename .rename { display: flex; }
.rename input {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card-hover);
  color: var(--text); border-radius: 9px; padding: 7px 9px; font-size: 14px;
}
.rename button {
  border: 0; border-radius: 9px; padding: 7px 11px; font-size: 13.5px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.actions .ghost { flex: 0 0 40px; }

/* Заголовок раздела внутри дня («Без срока»). */
.section-head {
  padding: 16px 0 8px; font-size: 12.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}

/* ───────────────────────── Анимации ───────────────────────── */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.task { animation: fadeInUp .22s ease both; }
.cell { animation: fadeInUp .18s ease both; }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.toast { animation: toastIn .18s ease; }

/* Уважение к людям, которые не любят движения. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Кнопка обновления в шапке — рядом с темой. */
#force-update {
  border: 0; background: transparent; cursor: pointer; font-size: 18px;
  line-height: 1; padding: 4px 6px; opacity: .7; color: var(--muted);
  transition: transform .25s ease, opacity .18s ease;
}
#force-update:hover  { opacity: 1; color: var(--accent); }
#force-update:active { transform: rotate(180deg); }
.version { padding: 18px 16px 10px; color: var(--muted); font-size: 12px; text-align: center; }
