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

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.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); filter: brightness(1.06); }
.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: 34px; padding: 0 12px; font-size: var(--fs-md); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

.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(--muted); }
.field-hint { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.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 { width: 20px; height: 20px; accent-color: var(--accent); }
.stack > * + * { margin-top: 14px; }

/* Переключатели */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: var(--fs-base);
}
.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: 52px; border-top: 1px solid var(--border); }
.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: 11px; border: 2px solid var(--muted); border-radius: 50%; }
.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: 700; }
.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: 4px; padding: 4px; border-radius: var(--radius-sm); background: var(--surface-2); }
.tab-link { flex: 1; display: grid; place-items: center; min-height: 38px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.tab-link[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Меню действий */
.sheet {
  width: min(480px, 100%);
  max-width: 100%;
  margin: auto auto 0;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  border: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / 40%); }
.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: 48px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font-size: var(--fs-body); 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(--tabbar-h) + var(--safe-bottom) + 84px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 25%);
  font-size: var(--fs-base);
  transform: translateX(-50%);
}
.toast-action { flex: none; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* Инструкции «Где взять?» и дополнительные поля */
.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: block; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); font-weight: 600; text-decoration: none; }
.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; } }
.proposal-text { margin: 0 0 8px; white-space: pre-line; }

/* Секундомер задачи в работе */
.stopwatch { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.stopwatch-time { font-size: var(--fs-2xl); font-weight: 700; 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: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: 4px 16px; font-size: var(--fs-xs); color: var(--muted); background: var(--surface);
  border-bottom: 1px solid var(--border, rgba(127, 127, 127, 0.2)); overflow: hidden;
}
.activity-bar[hidden] { display: none; }
.activity-line { position: absolute; left: 0; bottom: -1px; height: 2px; width: 30%; background: var(--accent); animation: activity-run 1.2s ease-in-out infinite; }
@keyframes activity-run { from { left: -30%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .activity-line, .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(360px, 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: 700; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }

/* «Открыть на Диске» — заметная кнопка у вложений задач и файлов заметок (пожелание пользователя 2026-09-27) */
.btn-drive { 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-drive:hover { background: var(--accent-soft); filter: brightness(0.97); }
.btn-drive 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; }
