/* Дизайн-токены из design_handoff_diary_app/README.md */
:root {
  --bg: #121214;
  --surface: #1C1C1F;
  --surface2: #26262A;
  --border: rgba(255, 255, 255, 0.09);
  --text: #F2F2F3;
  --text2: #9A9AA1;
  --text3: #6C6C71;
  --accent: #5B8CFF;
  --green: #34C759;
  --yellow: #F2C94C;
  --yellow-bg: rgba(242, 201, 76, 0.16);
  --red: #FF453A;
  --red-bg: rgba(255, 69, 58, 0.14);
}
body.light {
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface2: #EEEEF1;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1C1C1E;
  --text2: #6E6E73;
  --text3: #9A9AA1;
  --accent: #3E6FE0;
  --green: #219653;
  --yellow: #B9860A;
  --yellow-bg: rgba(185, 134, 10, 0.12);
  --red: #FF3B30;
  --red-bg: rgba(255, 59, 48, 0.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.screen {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
}

/* ── Заголовки экрана ── */
.screen-title { font-size: 26px; font-weight: 700; }
.screen-sub { font-size: 14px; color: var(--text2); margin-top: 4px; }
.screen-sprint-left { font-size: 14px; color: var(--text2); margin-top: 2px; }
.screen-head { margin-bottom: 16px; }

/* ── Карточки ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card-caption {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 10px;
}

/* ── Прогресс ── */
.progress-row { display: flex; justify-content: space-between; align-items: baseline; }
.progress-row .name { font-weight: 600; }
.progress-row .value { font-weight: 700; font-variant-numeric: tabular-nums; }
.progress-track {
  height: 6px; border-radius: 3px;
  background: var(--surface2);
  margin: 8px 0 6px;
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.progress-note { font-size: 12px; color: var(--text3); }

/* ── Задачи ── */
.task-group-title {
  font-size: 12px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text3);
  margin: 12px 0 6px;
  display: flex; align-items: center; gap: 6px;
}
.task-group-title:first-child { margin-top: 0; }
.task-group-title.collapsible { cursor: pointer; user-select: none; }
.task-group-title .chevron { transition: transform 0.15s; font-size: 10px; }
.task-group-title.open .chevron { transform: rotate(90deg); }

.task {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 8px 0;
}
.task .check {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.6px solid var(--text3);
  background: transparent;
  cursor: pointer;
  margin-top: 1px;
  display: grid; place-items: center;
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
.task .check:hover { border-color: var(--accent); }
.task .check:active { transform: scale(0.9); }
.task.done .check { background: var(--green); border-color: var(--green); }
.task .check svg { width: 12px; height: 12px; stroke: #fff; stroke-width: 2.5; fill: none; display: none; }
.task.done .check svg { display: block; }
.task .task-text { flex: 1; line-height: 1.35; padding-top: 1px; }
.task.done .task-text { color: var(--text3); text-decoration: line-through; }
.task .days {
  flex: none; font-size: 12px; color: var(--text3);
  font-variant-numeric: tabular-nums; padding-top: 3px;
}

/* Подзадачи */
.subtasks { margin-left: 34px; }
.subtask { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; }
.subtask .check {
  flex: none; width: 18px; height: 18px;
  border-radius: 50%; border: 1.6px solid var(--text3);
  background: transparent; cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
.subtask .check:active { transform: scale(0.9); }
.subtask .check svg { width: 10px; height: 10px; stroke: #fff; stroke-width: 2.5; fill: none; display: none; }
.subtask .sub-text { flex: 1; line-height: 1.3; font-size: 14px; }
.subtask.done .check { background: var(--green); border-color: var(--green); }
.subtask.done .check svg { display: block; }
.subtask.done .sub-text { color: var(--text3); text-decoration: line-through; }
.subtask.ai { background: var(--yellow-bg); }
.subtask.ai .check { border-color: var(--yellow); }
.subtask.ai .ai-note { font-size: 11px; color: var(--yellow); }
.subtask.ai .sub-text { flex: none; }
.subtask.ai .ai-note { margin-left: auto; }

/* Крестик «отклонить жёлтую подсказку» */
.sub-reject {
  flex: none; background: none; border: none;
  color: var(--yellow); font-size: 16px; line-height: 1;
  padding: 0 2px; cursor: pointer;
}

/* ── План дня «Сегодня»: Пул / Утро / Вечер ── */
.plan-card { padding-top: 8px; }
.plan-section { padding: 4px 0; }
.plan-section + .plan-section { border-top: 1px solid var(--border); margin-top: 4px; }
.plan-section-title {
  font-size: 12px; font-weight: 600; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--text3);
  padding: 8px 2px 4px;
}
.plan-list { min-height: 8px; }
.plan-list:empty::after {
  content: "—"; display: block;
  color: var(--text3); font-size: 14px; padding: 4px 2px 8px;
}

/* Строка задачи в плане и в «Не забыть» */
.ptask { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.ptask .check {
  flex: none; width: 22px; height: 22px;
  border-radius: 50%; border: 1.6px solid var(--text3);
  background: transparent; cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
.ptask .check:active { transform: scale(0.9); }
.ptask .check svg { width: 12px; height: 12px; stroke: #fff; stroke-width: 2.5; fill: none; display: none; }
/* Важная задача — красный кружок */
.ptask.important .check { border-color: var(--red); border-width: 2px; }
.ptask-text { flex: 1; line-height: 1.35; cursor: text; }
.ptask .days {
  flex: none; font-size: 12px; color: var(--text3);
  font-variant-numeric: tabular-nums;
}
.ptask .promote {
  flex: none; background: var(--surface2); border: none;
  color: var(--accent); font-size: 16px; line-height: 1;
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
}

/* Редактор задачи: поле ввода + меню под ним (тап по тексту) */
.ptask-editor {
  flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 2px 0;
  animation: editorIn 0.14s ease;
}
@keyframes editorIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}
.pt-input {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; outline: none;
}
.pt-input:focus { border-color: var(--accent); }
.pt-menu { display: flex; gap: 8px; flex-wrap: wrap; }
.pt-opt {
  font-size: 13px; padding: 6px 12px; border-radius: 16px;
  background: var(--surface2); color: var(--text2);
  border: 1px solid var(--border); cursor: pointer;
}
.pt-opt.imp.on { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.pt-opt.disabled { opacity: 0.4; cursor: default; }

/* Свайп-обёртка (своя реализация). touch-action не ставим в pan-y — иначе
   браузер забирает вертикаль себе и Sortable не может тащить задачу вверх/вниз. */
.swipe { position: relative; overflow: hidden; }
.swipe .ptask, .swipe .task {
  position: relative; z-index: 1;
  background: var(--surface);
  transition: transform 0.18s ease;
}
.swipe-del {
  position: absolute; top: 0; right: 0; bottom: 0; width: 88px;
  border: none; background: var(--red); color: #fff;
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.swipe.removing { transition: height 0.18s ease, opacity 0.18s ease; }

/* Перетаскивание (SortableJS) — стили его служебных классов */
.sortable-ghost { opacity: 0.35; } /* место, куда встанет элемент */
.sortable-chosen .ptask,
.sortable-chosen .task {
  background: var(--surface2); border-radius: 10px;
}
.sortable-drag .ptask,
.sortable-fallback .ptask,
.sortable-drag .task,
.sortable-fallback .task {
  background: var(--surface); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.sortable-fallback { opacity: 0.95 !important; }

.empty-note { color: var(--text3); padding: 10px 0; font-size: 14px; }

/* Сегменты (категории задач, периоды статистики) */
.segments { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.segment {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.segment.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Подвал сделанного */
.done-vault { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.done-vault-header { color: var(--text2); font-size: 14px; cursor: pointer; user-select: none; display: flex; gap: 6px; align-items: center; }
.done-vault .more { color: var(--text3); font-size: 13px; padding: 6px 0; }

/* ── Цели ── */
.goal { padding: 9px 0; }
.goal-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.goal-name { line-height: 1.35; }
.goal-nums { font-size: 13px; color: var(--text2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.goal.completed .goal-name { color: var(--text3); text-decoration: line-through; }
.goal .goal-check { color: var(--green); margin-right: 6px; }
.month-switcher {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin-bottom: 14px;
}
.month-switcher button {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 16px;
}
.month-switcher button:disabled { opacity: 0.3; cursor: default; }
.month-switcher .month-label { font-weight: 600; min-width: 120px; text-align: center; }

/* ── Статистика ── */
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pill {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 20px; padding: 6px 12px; font-size: 13px; cursor: pointer;
  color: var(--text);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.pill.off { opacity: 0.35; }
.chart-card svg { display: block; width: 100%; height: auto; }
.point-detail {
  margin-top: 10px; padding: 10px 12px;
  background: var(--surface2); border-radius: 10px;
  font-size: 13px; display: flex; gap: 10px; align-items: flex-start;
}
.point-detail .close { margin-left: auto; cursor: pointer; color: var(--text3); background: none; border: none; font-size: 15px; }
.point-detail .comment { color: var(--text2); font-style: italic; }

.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table td { padding: 6px 4px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.stats-table tr:first-child td { border-top: none; }
.stats-table .m-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.stats-table .num { text-align: right; color: var(--text2); }

.critical-line { padding: 4px 0; font-size: 14px; }

/* ── Спарклайны ── */
.spark-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.spark-cell { padding: 4px 0; }
.spark-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); margin-bottom: 3px; }
.spark-head .val { color: var(--text); font-weight: 600; }

/* ── Таб-бар ── */
.tabbar {
  flex: none;
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  background: none; border: none;
  padding: 8px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text3); font-size: 11px; cursor: pointer;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.tab.active { color: var(--accent); }

.loading { color: var(--text3); text-align: center; padding: 40px 0; }

/* ── Редактор целей / добавление задач ── */
.tappable { cursor: pointer; }
.tappable:active { opacity: 0.7; }

.goal-editor {
  background: var(--surface2);
  border-radius: 12px;
  padding: 10px;
  margin: 8px 0;
  display: flex; flex-direction: column; gap: 8px;
}
.goal-editor input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  padding: 9px 10px;
  width: 100%;
  font-family: inherit;
}
.goal-editor input:focus { outline: none; border-color: var(--accent); }
.ge-emoji { display: flex; flex-wrap: wrap; gap: 4px; }
.ge-emoji button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  padding: 4px 7px;
  cursor: pointer;
}
.ge-emoji button:active { transform: scale(0.9); }
.ge-nums { display: flex; align-items: center; gap: 8px; }
.ge-nums input { width: 90px; }
.ge-slash { color: var(--text3); }
.ge-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ge-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.ge-btn.save { background: var(--accent); border-color: var(--accent); color: #fff; }
.ge-btn.danger { color: #FF5B5B; border-color: rgba(255, 91, 91, 0.4); }
.ge-btn:active { transform: scale(0.96); }

.add-btn {
  display: block;
  width: 100%;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text2);
  font-size: 14px;
  padding: 10px;
  margin-top: 10px;
  cursor: pointer;
  font-family: inherit;
}
.add-btn:hover { color: var(--accent); border-color: var(--accent); }
