/* Общие компоненты: карточки, кнопки, поля, переключатели, списки задач, меню, всплывающие сообщения */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--control);
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
html.is-touch .btn { min-height: 44px; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-small { min-height: 28px; padding: 0 10px; font-size: var(--fs-sm); }
html.is-touch .btn-small { min-height: 36px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--link); font: inherit; cursor: pointer; }
.link-btn:hover { color: var(--accent-hover); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-ok { background: var(--accent-soft); color: var(--accent); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-error { background: var(--danger-soft); color: var(--danger); }

/* Поля */
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field:first-child { margin-top: 0; }
.field-label { font-size: var(--fs-md); font-weight: 600; color: var(--text-2); }
.field-hint { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.input {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--control);
  border-radius: 9px;
  background: var(--field);
  color: var(--text);
  font-size: var(--fs-md);
}
html.is-touch .input { min-height: 44px; }
.input::placeholder { color: var(--muted); }
.input:focus { outline: 0; border-color: var(--accent); }
.textarea { min-height: 72px; resize: none; overflow-y: auto; line-height: 1.45; } /* без уголка: высота по тексту (ui/components/autogrow.js) */
.textarea.is-clamped:not(:focus) { -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent); mask-image: linear-gradient(to bottom, #000 75%, transparent); }
.grow-toggle { justify-self: start; margin-top: 4px; font-size: var(--fs-sm); }
.grow-toggle[hidden] { display: none; }
.secret { display: flex; align-items: center; gap: 4px; }
.secret .input { flex: 1; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row > .field { flex: 1 1 140px; margin-top: 0; }
.check-field { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 10px; cursor: pointer; }
.check-field input { flex: none; width: 20px; height: 20px; accent-color: var(--accent); } /* flex: none – длинный текст рядом не сжимает флажок */
.check-field input.switch { width: 38px; height: 22px; } /* ползунок в строке с подписью (ROADMAP 34) */
.stack > * + * { margin-top: 14px; }

/* Переключатели */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--control);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-size: var(--fs-sm);
}
html.is-touch .chip { min-height: 38px; }
.chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Подсказки к формулировке */
.hints { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hints:empty { display: none; }
.hints li { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warn-soft); font-size: var(--fs-md); }

/* Список задач */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-row { display: flex; align-items: center; gap: 2px; min-height: 40px; border-top: 1px solid var(--divider); }
html.is-touch .task-row { min-height: 48px; }
.task-row:first-child { border-top: 0; }
.card.task-list { padding: 4px 8px 4px 16px; } /* список-карточка («Входящие», «Идеи»): текст не у самого края */
.check { position: relative; flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: none; color: var(--on-accent); cursor: pointer; }
.check::before { content: ''; position: absolute; inset: 13px; border: 1.5px solid var(--control); border-radius: 50%; }
.check:hover::before { border-color: var(--accent); }
.check[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent); }
.check svg { position: relative; width: 14px; height: 14px; stroke-width: 3.2; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 8px 0; color: var(--text); text-decoration: none; }
.task-title { overflow-wrap: anywhere; }
.task-meta { font-size: var(--fs-sm); color: var(--muted); }
.task-row .icon-btn { flex: none; }
.task-row.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-row.is-now .task-title { font-weight: 600; }
.is-overdue { color: var(--danger); font-weight: 600; }
.is-active { color: var(--accent); font-weight: 600; }
.is-struck { text-decoration: line-through; color: var(--muted); }

/* Вкладки */
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-row); background: var(--surface); border: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab-link { flex: 1; display: grid; place-items: center; min-height: 30px; padding: 0 12px; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: var(--fs-md); white-space: nowrap; }
.tab-link:hover { color: var(--text); }
.tab-link[aria-current="page"] { background: var(--surface-2); color: var(--text); }

/* Меню действий */
.sheet {
  width: min(340px, 100%);
  max-width: 100%;
  margin: auto auto 0;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--popover);
  color: var(--text);
  box-shadow: var(--shadow-modal);
}
.sheet::backdrop { background: var(--overlay); }
/* На компьютере окна – по центру (макет), на телефоне – лист снизу */
@media (min-width: 760px) {
  .sheet { margin: auto; border-radius: var(--radius-lg); padding: 8px; }
}
.sheet.modal { width: min(560px, 100%); }
.modal-body { padding: 10px 12px 8px; }
.modal-head { display: flex; align-items: center; gap: 10px; }
.modal-title { flex: 1; margin: 0; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.015em; }
.modal-head .icon-btn { font-size: 20px; }
.sheet-title { margin: 8px 12px; overflow: hidden; color: var(--muted); font-size: var(--fs-md); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.sheet-item { display: block; width: 100%; min-height: 34px; padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font-size: var(--fs-sm); line-height: 1.35; text-align: left; cursor: pointer; }
.sheet-item:hover { background: var(--surface-2); }
.sheet-item.is-danger { color: var(--danger); }
.sheet-cancel { margin-top: 4px; color: var(--muted); }
.stage-dialog { padding: 18px 16px calc(16px + var(--safe-bottom)); max-height: 90dvh; overflow-y: auto; }

/* Всплывающее сообщение */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 24px);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--popover);
  border: 1px solid var(--control);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
  transform: translateX(-50%);
  animation: toast-in 0.18s ease-out;
}
@media (max-width: 759px) { .toast { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px); } }
.toast-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translateX(-50%); } }
.toast-action { flex: none; padding: 0; border: 0; background: none; color: var(--link); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }

/* Инструкции «Где взять?» и дополнительные поля */
.guide { margin-top: 12px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.guide summary { display: flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 600; cursor: pointer; }
.guide ol { margin: 0 0 10px; padding-left: 20px; }
.guide li + li { margin-top: 4px; }
.guide-links { display: flex; flex-wrap: wrap; gap: 14px; }
.advanced { margin-top: 14px; }
.advanced summary { display: flex; align-items: center; min-height: 40px; color: var(--muted); cursor: pointer; }

/* Мелочи */
.tip { margin-bottom: 0; font-size: var(--fs-md); color: var(--muted); }
.small { font-size: var(--fs-sm); }
.empty { margin: 8px 0 0; color: var(--muted); }
.empty-state { text-align: center; }
.notice { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); text-decoration: none; }
.notice::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.notice:hover { color: var(--text); border-color: var(--control); }
.warning { margin: 8px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: var(--fs-md); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.capture { display: flex; gap: 8px; }
.capture .input { flex: 1; min-width: 0; }
.section-title { margin: 0 0 4px; font-size: var(--fs-lg); }
.error-card { border-color: var(--danger); }

/* Статус синхронизации с TickTick */
.sync-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: var(--fs-md); }
.sync-status.is-error .sync-text { color: var(--danger); white-space: pre-line; }
.sync-status.is-compact .btn { min-height: 28px; padding: 0 8px; }

/* ИИ: кнопка ✨ у поля и окно предложения */
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-head .field-label { margin: 0; }
.ai-btn { width: 32px; height: 32px; min-height: 32px; color: var(--accent); }
.ai-btn svg { width: 20px; height: 20px; }
.ai-btn.is-busy { animation: ai-pulse 1s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: 0.35; } }


/* Секундомер задачи в работе */
.stopwatch { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.stopwatch-time { font-size: var(--fs-2xl); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }
.stage-time-btn { margin-left: 6px; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }

/* ИИ-сервисы: ключи и их состояние */
.profile-row.is-dead { border-left: 3px solid var(--danger); padding-left: 10px; }
.profile-alert { color: var(--danger); font-size: var(--fs-sm); font-weight: 600; }
.row-actions { display: flex; gap: 6px; align-items: center; }
.key-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.key-row.is-dead { background: var(--danger-soft); }
.key-label { font-family: ui-monospace, monospace; font-weight: 600; }
.key-message { flex-basis: 100%; }
.key-row.is-dead .key-message { color: var(--danger); }
.secret-area { -webkit-text-security: disc; font-family: ui-monospace, monospace; }
.ai-action { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }
.ai-action svg { width: 18px; height: 18px; }
.ai-note { color: var(--accent); }
.capture .ai-btn { align-self: center; }
.comment-text { white-space: pre-line; }

/* Быстрые клавиши */
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border: 1px solid var(--muted); border-bottom-width: 2px; border-radius: 5px; font: 600 0.8125rem ui-monospace, monospace; text-align: center; margin-right: 4px; }
.shortcut-list { list-style: none; margin: 0; padding: 0; display: grid; }
.shortcut-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--surface-2); }
.shortcut-row.is-capturing { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 6px 8px; }
.shortcut-label { flex: 1; min-width: 150px; }
.keys-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 6px 0 12px; }
.keys-list dt { white-space: nowrap; }
.keys-list dd { margin: 0; }

/* Напоминания в карточке задачи */
.reminder-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.reminder-list .input { width: auto; min-width: 170px; }
.reminder-chip { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.reminder-remove { border: 0; background: none; color: var(--muted); font-size: var(--fs-lg); line-height: 1; cursor: pointer; padding: 0 2px; }
.reminder-remove:hover { color: var(--danger); }
.input-short { width: 5.5em; flex: none; }

/* Шаблоны (6.4) */
.template-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.template-row { display: flex; align-items: center; gap: 8px; }
.template-row > .stack-tight { flex: 1; min-width: 0; display: grid; gap: 2px; }

/* Фото → задачи (6.1): список найденного с отметками */
.btn svg { width: 18px; height: 18px; flex: none; }
.pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 55vh; overflow-y: auto; }
.pick-row { display: flex; align-items: flex-start; gap: 10px; }
.pick-row > input[type="checkbox"] { margin-top: 12px; width: 18px; height: 18px; flex: none; }
.pick-row > .stack-tight { flex: 1; min-width: 0; display: grid; gap: 2px; }

/* Вложения (6.5) */
.attachment-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.attachment-row { display: flex; align-items: center; gap: 6px; }
.attachment-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.attachment-open > .stack-tight { min-width: 0; display: grid; gap: 2px; }
.attachment-name { overflow-wrap: anywhere; white-space: normal; }
.attachment-thumb { width: 48px; height: 48px; flex: none; border-radius: 8px; background: var(--surface-2, rgba(127,127,127,.12)); display: grid; place-items: center; overflow: hidden; }
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attachment-thumb svg { width: 22px; height: 22px; }
.attachment-preview img { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto 12px; border-radius: 8px; }
.sync-status.is-offline:not(.is-error) .sync-text { color: var(--muted); font-style: italic; }

/* Идёт работа (7.5 А): кнопка крутит значок, полоса под шапкой с подписью */
.btn.is-busy, .icon-btn.is-busy { position: relative; animation: none; cursor: progress; opacity: 0.85; }
.btn.is-busy::after {
  content: ''; display: inline-block; width: 14px; height: 14px; margin-left: 8px; vertical-align: -2px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite;
}
.icon-btn.is-busy > svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.activity-bar {
  position: fixed; right: 20px; bottom: calc(var(--safe-bottom) + 20px); z-index: 90; display: flex; align-items: center; gap: 8px;
  max-width: min(360px, calc(100vw - 32px)); padding: 7px 14px 7px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--popover); color: var(--text-2); font-size: var(--fs-xs); box-shadow: var(--shadow-pop); pointer-events: none;
  animation: toast-in-corner .18s ease-out;
}
.activity-bar[hidden] { display: none; }
.activity-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-spin { flex: none; width: 13px; height: 13px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes toast-in-corner { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 759px) {
  .activity-bar { right: auto; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 64px); transform: translateX(-50%); animation: none; }
}
@media (prefers-reduced-motion: reduce) { .activity-spin, .btn.is-busy::after, .icon-btn.is-busy > svg { animation-duration: 3s; } }

/* Всплывающие окна у значков (7.5 Б) */
.popover { max-height: min(80vh, 640px); overflow-y: auto; }
.popover-body { display: grid; gap: 10px; padding: 4px 4px 8px; }
.popover.is-anchored { position: fixed; margin: 0; width: min(320px, calc(100vw - 16px)); border-radius: var(--radius); box-shadow: var(--shadow); }
.popover.is-anchored::backdrop { background: transparent; }
.popover-option { display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.popover-option.is-selected { color: var(--accent); font-weight: 600; }

/* Быстрый ввод: что распознано и справка (7.5 Г) */
.quick-add-box { display: grid; gap: 6px; }
.quick-parts { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
.quick-part { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: var(--fs-sm); }
.quick-part .icon svg { width: 14px; height: 14px; }
.quick-part.is-warn { background: var(--warn-soft); color: var(--warn); }
.help-group { display: grid; gap: 4px; }
.help-list { margin: 0; padding-left: 18px; display: grid; gap: 2px; font-size: var(--fs-base); }
.quick-field { position: relative; flex: 1; min-width: 0; display: flex; }
.quick-field > .input { flex: 1; min-width: 0; padding-right: 84px; }
.quick-field-icons { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
.quick-field-icons .icon-btn { width: 36px; height: 36px; }
/* Содержимое окна не шире окна: длинные строки переносятся или обрезаются, а не растягивают сетку */
.popover-body { grid-template-columns: minmax(0, 1fr); }
.popover-body > * { min-width: 0; }
.nav-choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.nav-choice { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.nav-choice .check-field { flex: 1; min-width: 0; gap: 10px; }
.nav-choice .icon svg { width: 18px; height: 18px; }
.nav-choice-order { display: flex; gap: 2px; }
.widget-choice { display: grid; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.widget-options { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-left: 28px; font-size: var(--fs-md); }

/* Отклик на нажатие (ROADMAP 9.2): кнопка чуть «проседает», чтобы было видно, что нажатие принято */
.btn, .icon-btn, .chip, .meta-chip, .sheet-item, .tab, .nav-link, .check { transition: transform 0.08s ease, background-color 0.15s ease; }
.btn:active:not(:disabled), .icon-btn:active, .chip:active, .meta-chip:active, .sheet-item:active, .nav-link:active, .check:active { transform: var(--press); }
.tab:active .icon { transform: var(--press); }

/* Пустое состояние: значок в круге, заголовок, пояснение, действие */
.empty-state { display: grid; justify-items: center; gap: 4px; padding: 28px 16px; }
.empty-state h2 { margin: 0; font-size: var(--fs-lg); }
.empty-state p { margin: 0; max-width: 360px; }
.empty-state .btn { margin-top: 10px; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 6px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.empty-icon svg { width: 28px; height: 28px; }

/* Подзаголовок внутри карточки и два поля в строку (на узком экране – друг под другом) */
.subtitle { margin: 12px 0 4px; font-size: var(--fs-base); font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }

/* «По ссылке» – заметная кнопка своей ссылки на файл в просмотре */
.btn-external { display: inline-flex; align-items: center; gap: 6px; border-color: transparent; background: var(--accent-soft); color: var(--accent); font-weight: 600; text-decoration: none; }
.btn-external:hover { background: var(--accent-soft); filter: brightness(0.97); }
.btn-external svg { width: 16px; height: 16px; flex: none; }
.attachment-row { flex-wrap: wrap; }
.attachment-open { flex: 1 1 180px; min-width: 0; }
/* Выбранный чип с aria-pressed (типы заметок в окне добавления, закреплённое меню и т. п.) – как выбранный radio */
.chip[aria-pressed="true"]:not([class*=" any-"]) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Подсказка тегов по «#» (ROADMAP 18) */
.tag-suggest { position: fixed; inset: auto; z-index: 1000; margin: 0; max-height: 280px; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tag-suggest-item { display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.tag-suggest-item:hover, .tag-suggest-item.is-active { background: var(--accent-soft); color: var(--accent); }
textarea { resize: none; }
/* «Своё…» в выборе чипами (ROADMAP 19) */
.chip-custom { display: inline-flex; align-items: center; gap: 6px; }
.chip-input { width: 90px; height: 36px; padding: 4px 10px; }
.usage-bar { width: 100%; height: 8px; accent-color: var(--accent); }
.logout-dialog .warning { color: var(--danger); }
/* Просроченное – явно (ROADMAP 22): красная полоса слева и подложка */
.task-row.is-late { box-shadow: inset 3px 0 0 var(--danger); background: color-mix(in srgb, var(--danger-soft) 55%, transparent); }
.task-row.is-late .check { border-color: var(--danger); }
.pin-btn.is-subtle { width: 32px; height: 32px; opacity: 0.55; }
.pin-btn.is-subtle svg { width: 16px; height: 16px; }
.pin-btn.is-subtle:hover, .pin-btn.is-subtle.is-on { opacity: 1; }
/* Голосом (ROADMAP 22): во время записи – красная «Готово» с пульсом и подсказка */
.voice-wrap { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.voice-btn svg { width: 18px; height: 18px; }
.voice-btn.is-recording { border-color: var(--danger); color: var(--danger); font-weight: 600; }
.voice-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s ease-in-out infinite; }
.voice-hint { color: var(--danger); font-size: var(--fs-sm); }
.voice-hint[hidden] { display: none; }
.composer-ai { color: var(--accent); }
.composer-ai svg { width: 16px; height: 16px; }

/* Профиль и люди (ROADMAP 23) */
.profile-card { display: flex; align-items: center; gap: 16px; }
.profile-avatar { flex: none; display: grid; place-items: center; width: 72px; height: 72px; padding: 0; border: 0; border-radius: 50%; overflow: hidden; background: var(--accent); color: var(--on-accent); font-size: 28px; font-weight: 600; cursor: pointer; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-text { display: grid; gap: 4px; min-width: 0; }
img.rail-avatar { object-fit: cover; padding: 0; }
.person-row { display: grid !important; gap: 4px; }
.ical-link { font-family: monospace; font-size: var(--fs-xs); word-break: break-all; padding: 8px; border-radius: 8px; background: var(--surface-2); }
/* Выбор даты как в TickTick (ROADMAP 23) */
.date-picker .popover-body { width: min(340px, 100%); }
.dp-tabs { width: 100%; }
.dp-tabs .segment { flex: 1; justify-content: center; }
.dp-quick { display: flex; justify-content: space-around; }
.dp-quick-btn svg { width: 22px; height: 22px; }
.dp-plus7 { display: grid; place-items: center; width: 24px; height: 22px; border: 1.8px solid currentColor; border-radius: 5px; font-size: 11px; font-weight: 600; }
.dp-glyph { font-size: 20px; line-height: 1; filter: grayscale(0.3); }
.dp-month-head { display: flex; align-items: center; justify-content: space-between; text-transform: capitalize; }
.dp-month-nav { display: flex; }
.dp-month-nav .icon-btn { width: 32px; height: 32px; font-size: 18px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.dp-weekday { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; padding: 4px 0; }
.dp-day { aspect-ratio: 1; min-height: 34px; border: 0; border-radius: 50%; background: none; color: var(--text); font: inherit; cursor: pointer; }
.dp-day:hover { background: var(--surface-2); }
.dp-day.is-other { color: var(--muted); opacity: 0.55; }
.dp-day.is-today { color: var(--accent); font-weight: 600; }
.dp-day.is-selected { background: var(--accent); color: var(--on-accent); font-weight: 600; opacity: 1; }
.dp-row { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; list-style: none; }
.dp-row::-webkit-details-marker { display: none; }
.dp-row .icon svg { width: 18px; height: 18px; }
.dp-row-label { flex: 1; }
.dp-row .input { width: auto; min-width: 0; }
.dp-row-details { border-top: 1px solid var(--border); }
.dp-row-details > :not(summary) { padding-bottom: 8px; }
.dp-actions { display: grid; grid-template-columns: 1fr 1fr; }

/* Выбор даты компактнее (ROADMAP 24): всё видно без прокрутки */
.date-picker .popover-body { width: min(300px, 100%); gap: 6px; }
.date-picker .sheet-title { margin-bottom: 4px; }
.dp-tabs .segment { min-height: 30px; }
.dp-quick-btn { width: 36px; height: 36px; }
.dp-quick-btn svg { width: 20px; height: 20px; }
.dp-grid { gap: 0; }
.dp-weekday { padding: 2px 0; font-size: var(--fs-2xs); }
.dp-day { aspect-ratio: auto; height: 32px; min-height: 32px; width: 32px; justify-self: center; font-size: var(--fs-sm); }
.dp-row { min-height: 36px; gap: 8px; font-size: var(--fs-sm); }
.dp-row .input { min-height: 34px; padding: 4px 8px; font-size: var(--fs-sm); }
.dp-row .input[type="time"] { width: 96px; }
.dp-actions .btn { min-height: 38px; }
.dp-span { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 0.8fr); gap: 6px 8px; align-items: center; }
.dp-span-label { font-size: var(--fs-sm); color: var(--muted); }
.dp-span .input { min-height: 34px; padding: 4px 8px; font-size: var(--fs-sm); min-width: 0; }
.dp-switch { justify-content: space-between; cursor: pointer; }
.switch { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); position: relative; cursor: pointer; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform 0.15s; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(16px); background: var(--on-accent); }
.popover-search { margin-bottom: 6px; }
.popover-options { display: grid; gap: 2px; max-height: min(60vh, 420px); overflow-y: auto; }

/* Окно даты – ещё компактнее (ROADMAP 25) */
.date-picker .popover-body { width: min(264px, 100%); gap: 4px; font-size: var(--fs-sm); }
.date-picker .sheet-title { font-size: var(--fs-xs); margin: 0 0 2px; }
.dp-tabs .segment { min-height: 26px; font-size: var(--fs-xs); padding: 0 8px; }
.dp-quick-btn { width: 30px; height: 30px; }
.dp-quick-btn svg { width: 18px; height: 18px; }
.dp-plus7 { width: 20px; height: 18px; font-size: 10px; }
.dp-month-head strong { font-size: var(--fs-sm); }
.dp-month-nav .icon-btn { width: 26px; height: 26px; font-size: 15px; }
.dp-day { height: 28px; min-height: 28px; width: 28px; font-size: var(--fs-xs); }
.dp-weekday { font-size: 10px; }
.dp-row { min-height: 32px; gap: 6px; font-size: var(--fs-xs); }
.dp-row .icon svg { width: 16px; height: 16px; }
.dp-row .input, .dp-span .input { min-height: 30px; padding: 2px 6px; font-size: var(--fs-xs); }
.dp-row .input[type="time"] { width: 78px; }
.dp-actions .btn { min-height: 32px; font-size: var(--fs-sm); }
.dp-span-label { font-size: var(--fs-xs); }

/* Меню по правому клику (ROADMAP 25): у курсора */
.context-anchor { position: fixed; width: 1px; height: 1px; pointer-events: none; }
.context-menu .popover-body { min-width: 220px; gap: 0; }
.context-menu .sheet-item { min-height: 36px; padding: 6px 12px; font-size: var(--fs-sm); }
/* Выбор значка (ROADMAP 25) */
.emoji-picker .popover-body { width: min(320px, 100%); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; max-height: 240px; overflow-y: auto; margin: 6px 0; }
.emoji-btn { aspect-ratio: 1; border: 0; border-radius: 8px; background: none; font-size: 20px; cursor: pointer; }
.emoji-btn:hover, .emoji-btn.is-on { background: var(--surface-2); }
.emoji-choose { font-size: 22px; cursor: pointer; text-align: center; }

/* Прозрачность виджетов – крупным ползунком (ROADMAP 25) */
.widget-options input[type="range"] { width: min(260px, 100%); height: 28px; accent-color: var(--accent); cursor: pointer; }
.widget-options .check-field:has(input[type="range"]) { flex-basis: 100%; }
.composer.is-drop { outline: 2px dashed var(--accent); outline-offset: 4px; }
/* Окно даты на телефоне – во всю ширину листа (ROADMAP 26) */
@media (max-width: 759px) {
  .date-picker .popover-body { width: 100%; max-width: 440px; margin: 0 auto; }
  .date-picker .dp-day { width: 38px; height: 38px; min-height: 38px; justify-self: center; border-radius: 50%; font-size: var(--fs-sm); }
  .date-picker .dp-row .input[type="time"] { width: 92px; }
}

/* ---------- Этап 27: общие элементы макета ---------- */
.screen-head { display: flex; flex-direction: column; gap: 10px; }
.screen-eyebrow { margin: 0; font-family: var(--mono); font-size: var(--fs-xs); text-transform: uppercase; color: var(--accent); }
.screen-eyebrow.is-tag { color: var(--tag-fg); }
.screen-eyebrow.is-am { color: var(--am); }
.screen-eyebrow.is-pm { color: var(--pm); }
.screen-eyebrow.is-ok { color: var(--ok); }
.screen-eyebrow.is-danger { color: var(--danger); }
.screen-eyebrow.is-warn { color: var(--warn); }
.screen-title { margin: 0; font-weight: 500; font-size: var(--fs-3xl); line-height: 1.05; letter-spacing: -0.025em; }
.screen-about { margin: 0; max-width: 62ch; font-size: 0.875rem; line-height: 1.6; color: var(--text-2); text-wrap: pretty; }
@media (max-width: 759px) { .screen-title { font-size: var(--fs-2xl); } }
.screen-about[hidden], .screen-about-help[hidden] { display: none; }
.screen-about-close { margin-left: 6px; padding: 0 6px; border: 0; border-radius: 6px; background: none; color: var(--muted); font: inherit; font-size: 1rem; line-height: 1; cursor: pointer; vertical-align: baseline; }
.screen-about-close:hover { background: var(--surface-2); color: var(--text); }
.screen-about-help { margin-left: 10px; width: 22px; height: 22px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: none; color: var(--muted); font: inherit; font-size: 0.75rem; line-height: 1; vertical-align: middle; cursor: pointer; }
.screen-about-help:hover { color: var(--text); border-color: var(--control); }
.empty-dashed { margin: 0; padding: 14px 16px; border-radius: var(--radius); border: 1px dashed var(--control); color: var(--muted); font-size: var(--fs-md); line-height: 1.5; }
.inline-add { display: flex; gap: 8px; }
.inline-add .input { flex: 1; min-width: 0; }
.inline-add .btn { flex: none; }

/* Цвета типов и сфер (имена цветов Anytype) – точка в меню, полоса обложки */
.tone-grey { --tone: oklch(0.62 0.01 260); }
.tone-yellow { --tone: oklch(0.8 0.13 95); }
.tone-orange { --tone: oklch(0.72 0.14 55); }
.tone-red { --tone: oklch(0.68 0.17 25); }
.tone-pink { --tone: oklch(0.72 0.14 350); }
.tone-purple { --tone: oklch(0.72 0.13 300); }
.tone-blue { --tone: oklch(0.68 0.14 250); }
.tone-ice { --tone: oklch(0.74 0.11 225); }
.tone-teal { --tone: oklch(0.72 0.12 185); }
.tone-lime { --tone: oklch(0.76 0.14 130); }

/* Привычки */
.habit-list { display: flex; flex-direction: column; gap: 10px; }
.habit-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.habit-card.is-done { border-color: color-mix(in oklch, var(--ok) 45%, transparent); }
.habit-top { display: flex; align-items: center; gap: 12px; }
.habit-check {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 50%;
  border: 2px solid var(--control); background: none; color: var(--on-accent); font-size: 15px; cursor: pointer;
}
.habit-check:hover { border-color: var(--ok); }
.habit-card.is-done .habit-check { border-color: var(--ok); background: var(--ok); }
.habit-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.habit-main:hover { color: var(--text); }
.habit-name { font-size: var(--fs-body); font-weight: 500; overflow-wrap: anywhere; }
.habit-meta { font-size: var(--fs-sm); color: var(--muted); }
.habit-meta.is-on { color: var(--ok); }
.habit-del { font-size: 17px; }
.habit-strip { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 2px; }
.habit-strip span { height: 14px; border-radius: 3px; background: var(--surface-2); }
.habit-strip span.is-on { background: var(--ok); }

/* Командная палитра (Ctrl+K) */
.sheet.palette { width: min(600px, 100%); padding: 0; overflow: hidden; }
@media (min-width: 760px) { .sheet.palette { margin-top: 14vh; } }
.palette-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--divider); }
.palette-input { flex: 1; min-width: 0; padding: 4px 0; border: 0; outline: 0; background: none; color: var(--text); font-size: 17px; font-weight: 500; }
.palette-head kbd, .palette-item kbd { font-family: var(--mono); font-size: var(--fs-2xs); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border); color: var(--muted); }
.palette-list { max-height: min(60vh, 440px); overflow-y: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.palette-item[aria-selected="true"] { background: var(--accent-soft); }
.palette-kind { flex: none; width: 72px; font-family: var(--mono); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.palette-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-empty { margin: 0; padding: 14px; color: var(--muted); }
.palette-foot { display: flex; justify-content: space-between; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--divider); font-size: var(--fs-xs); color: var(--muted); }

/* Массовые действия (этап 27) */
.bulk-bar {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 20px); z-index: 85; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 24px);
  padding: 6px; border-radius: var(--radius); background: var(--popover); border: 1px solid var(--control); box-shadow: var(--shadow-pop);
}
@media (max-width: 759px) { .bulk-bar { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 10px); } }
.bulk-count { padding: 0 10px; font-weight: 600; white-space: nowrap; }
.bulk-btn { padding: 6px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: var(--fs-sm); white-space: nowrap; cursor: pointer; }
.bulk-btn:hover { background: var(--surface-2); }
.bulk-btn.is-ok { color: var(--ok); }
.bulk-btn.is-danger { color: var(--danger); }
.bulk-close { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.day-row.is-selected, .is-selected[data-task-id] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.day-row { transition: transform 0.15s ease; touch-action: pan-y; }
.day-row.swipe-done { background: var(--ok-soft); }
.day-row.swipe-later { background: var(--warn-soft); }

/* Панель выделения текста (этап 27) */
.selbar { position: fixed; z-index: 95; display: flex; gap: 2px; padding: 4px; border-radius: 9px; background: var(--popover); border: 1px solid var(--control); box-shadow: var(--shadow-pop); }
.selbar-btn { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--text-2); cursor: pointer; }
.selbar-btn svg { width: 16px; height: 16px; }
.selbar-btn:hover { background: var(--surface-2); color: var(--text); }
.must-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); vertical-align: 1px; }
/* Окно даты у значка – ровно по календарю (264 px + отступы 8 и рамка): «по содержимому» не работало – ширина содержимого в процентах от окна */
.popover.is-anchored.date-picker { width: 282px; max-width: calc(100vw - 16px); box-sizing: border-box; }
.popover.is-anchored.date-picker .popover-body { width: 100%; }

/* Окно действий: текст (что найдено) и главная кнопка – чтобы было видно, что нажимать (2026-10-14) */
.sheet-note { margin: 0 12px 6px; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.4; }
.sheet-item.is-primary { margin-top: 10px; background: var(--accent); color: var(--on-accent); font-weight: 600; text-align: center; }
.sheet-item.is-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }

/* «?» у названия раздела – подсказка окошком, а не абзацем под заголовком (2026-10-14) */
.help-tip { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 6px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: none; color: var(--muted); font: 600 11px/1 var(--font, inherit); letter-spacing: 0; text-transform: none; vertical-align: middle; cursor: pointer; }
.help-tip:hover, .help-tip:focus-visible { border-color: var(--accent); color: var(--accent); }
html.is-touch .help-tip { width: 24px; height: 24px; font-size: 13px; }
.help-pop { max-width: min(320px, calc(100vw - 16px)); }
.help-text { margin: 0; color: var(--text); font-size: var(--fs-sm); line-height: 1.5; }

/* Окна выбора и меню – компактные (2026-10-16: были огромные): строка в одну линию, подсказка справа мелко */
.popover.choose-pop { width: min(280px, calc(100vw - 16px)); --popover-limit: 460px; }
.choose-pop .sheet-title { margin: 4px 8px 6px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; }
.choose-pop .popover-option { flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; min-height: 34px; padding: 0 10px; font-size: var(--fs-sm); }
.choose-pop .popover-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choose-pop .popover-hint { flex: none; color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.choose-pop .popover-search { min-height: 34px; margin-bottom: 6px; font-size: var(--fs-sm); }
.context-menu .sheet-item { min-height: 32px; font-size: var(--fs-sm); }
.popover.prio-pop { width: min(240px, calc(100vw - 16px)); }
.prop-linked { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.prop-linked .prop-link { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-open { flex: none; padding: 0 5px; border-radius: 5px; color: var(--link); text-decoration: none; }
.prop-open:hover { background: var(--surface-2); }
/* Единая плотность меню: компактные действия, формы сохраняют собственную ширину. */
.popover .popover-options { max-height: min(calc(44dvh / var(--zoom, 1)), 300px); overscroll-behavior: contain; }
.popover .sheet-title { font-size: var(--fs-xs); margin: 4px 8px; white-space: normal; }
.type-open-link { display: flex; align-items: center; color: var(--link); text-decoration: none; border-bottom: 1px solid var(--border); border-radius: 0; overflow-wrap: anywhere; }
.type-change-label { margin: 4px 8px 0; color: var(--muted); }
.popover.account-menu { width: min(304px, calc(100vw - 16px)); --popover-limit: 520px; }
.popover.account-menu .popover-body { min-width: 0; max-height: none; gap: 2px; padding: 4px; }
.popover.account-menu .account-name { font-size: var(--fs-md); overflow-wrap: anywhere; }
.popover.account-menu .account-item { min-height: 34px; padding: 5px 8px; gap: 8px; font-size: var(--fs-sm); }
.popover.account-menu .account-sub { margin-top: 6px; }
.popover.account-menu .account-item-text { overflow-wrap: anywhere; }
@media (pointer: coarse) { .sheet:not(.modal) .sheet-item { min-height: 40px; } }

/* Советы на экранах (2026-11-14): только с «Пояснениями на экранах»; путеводитель и первый запуск (.is-key) – всегда */
:root:not(.show-hints) .tip:not(.is-key) { display: none; }

/* Пустые поля карточки – по запросу (2026-11-21): «+ Ещё поля» показывает пустые свойства, чек-лист и связи */
body:not(.show-empty-fields) .task-props .is-empty, body:not(.show-empty-fields) .task-props .prop-row-add, body:not(.show-empty-fields) .tc-empty-section { display: none; }
.tp-more { align-self: flex-start; margin-top: 6px; padding: 4px 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: var(--fs-sm, 13px); cursor: pointer; }
/* Подсказки к формулировке – только с «Пояснениями на экранах» */
:root:not(.show-hints) .hints { display: none; }

/* «На завтра» в строке (2026-11-21): на компьютере – при наведении, на телефоне – свайп влево */
.row-later { flex: none; font-size: 16px; }
.is-touch .row-later { display: none; }
@media (hover: hover) { .task-row:not(:hover):not(:focus-within) .row-later, .day-row:not(:hover):not(:focus-within) .row-later { opacity: 0; } }
