/* =====================================================================
   Джарвис · Mini App · «Пульт COO»
   Единый файл стилей. Все цвета, шрифты, радиусы и отступы лежат в блоке :root ниже:
   чтобы сменить тему, правь только его. Палитра тёмная и фиксированная, от темы Telegram
   не зависит (фон шапки Telegram выставляется из app.js теми же значениями).
   ===================================================================== */

:root {
  /* Поверхности */
  --bg: #0F1318;            /* фон страницы */
  --surface: #171D25;       /* карточки, поля, нижние панели */
  --surface-deep: #1B222B;  /* чипы, тосты, скелетоны, вложенные плашки */
  --line: #252D38;          /* границы карточек */
  --line-strong: #2B3440;   /* границы полей и вторичных кнопок */
  --nav-bg: #12171D;
  --nav-line: #232B35;
  --track: #232B35;         /* трек полос прогресса, пустые столбики */
  --shimmer: #212935;       /* блик скелетонов */
  --scrim: rgba(7, 10, 13, .66);

  /* Текст (контраст не ниже 4.5:1 на --bg, --surface и --surface-deep) */
  --text: #E4EAF0;
  --muted: #8E9AA8;
  --faint: #7F8A98;

  /* Акцент */
  --accent: #E8B04B;        /* заливка кнопок, активных чипов, столбиков */
  --accent-text: #E8B04B;   /* акцент для текста и иконок на фоне темы (в светлой темы темнее) */
  --on-accent: #14181D;     /* текст на акцентном фоне */

  /* Сферы */
  --s-biz: #6FA8FF;
  --s-life: #7ED6A0;
  --s-health: #F08A8A;
  --s-learn: #C9A7FF;
  /* текст на заливке цветом сферы / приоритета */
  --on-s-biz: #14181D;
  --on-s-life: #14181D;
  --on-s-health: #14181D;
  --on-s-learn: #14181D;
  --on-p1: #14181D;

  /* Приоритеты (левая полоса карточки) */
  --p1: #F08A8A;
  --p2: #E8B04B;
  --p3: #3A4452;

  /* Состояния */
  --danger: #F08A8A;
  --danger-bg: #1E1618;
  --danger-line: #4A2A2D;
  --success: #7ED6A0;
  --success-text: #7ED6A0;  /* успех как текст (в светлой теме темнее) */
  --on-success: #14181D;    /* галочка на зелёной заливке чекбокса */
  --check-border: #5B6676;
  --est: #8E9AA8;           /* оценка времени справа в карточке */
  --meta-overdue: #8E9AA8;  /* мета просроченной задачи */
  --toast-bg: #1B222B;
  --toast-text: #E4EAF0;
  --toast-line: #2B3440;

  /* Радиусы */
  --r-card: 10px;
  --r-chip: 6px;
  --r-check: 6px;
  --r-sheet: 16px;

  /* Шрифты */
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Размеры текста */
  --fs-title: 24px;
  --fs-task: 15px;
  --fs-meta: 12px;
  --fs-label: 12px;
  --fs-body: 14px;

  /* Отступы и размеры */
  --pad: 16px;
  --gap: 8px;
  --touch: 44px;           /* минимальная цель касания */
  --field-h: 46px;
  --nav-h: 64px;

  color-scheme: dark;       /* нативные поля, скроллбары, календарь */
}

/* Светлая тема: те же имена переменных. Включается атрибутом data-theme="light" на <html>
   (app.js выставляет его по Telegram.WebApp.colorScheme или prefers-color-scheme). */
[data-theme="light"] {
  --bg: #F2F4F7;
  --surface: #FFFFFF;
  --surface-deep: #E5E9EE;
  --line: #DDE3EA;
  --line-strong: #D3DAE2;
  --nav-bg: #FFFFFF;
  --nav-line: #DDE3EA;
  --track: #E5E9EE;
  --shimmer: #F0F2F5;
  --scrim: rgba(23, 32, 42, .45);

  --text: #17202A;
  --muted: #5A6777;
  --faint: #566373;

  --accent: #E8B04B;
  --accent-text: #8C5A0F;
  --on-accent: #14181D;

  --s-biz: #2F6FD6;
  --s-life: #1F9D5C;
  --s-health: #D3403A;
  --s-learn: #7C4DDB;
  --on-s-biz: #FFFFFF;
  --on-s-life: #14181D;
  --on-s-health: #FFFFFF;
  --on-s-learn: #FFFFFF;
  --on-p1: #FFFFFF;

  --p1: #D3403A;
  --p2: #D99A1E;
  --p3: #C3CBD6;

  --danger: #BC312B;
  --danger-bg: #FDF0EF;
  --danger-line: #F0C9C6;
  --success: #1F8A52;
  --success-text: #17743F;
  --on-success: #FFFFFF;
  --check-border: #A3AEBB;
  --est: #36424F;
  --meta-overdue: #A5504B;
  --toast-bg: #17202A;
  --toast-text: #FFFFFF;
  --toast-line: #17202A;

  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 400 var(--fs-body)/1.45 var(--font-sans);
  padding-bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.has-quick { padding-bottom: calc(var(--nav-h) + 92px + env(safe-area-inset-bottom)); }
body.sheet-open { overflow: hidden; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
ul { margin: 0; }
h1, h2 { margin: 0; }

/* видимый фокус для клавиатуры и переключения кнопками */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mono, .group-title, .chip, .nav-item span, .step-ind, .toast, .tile-value, .tile-label, .tile-caption,
.ov-score-num, .ov-row-val, .task-est, .rec-energy, .goal-pct, .goal-sub, .plan-task-min, .sheet-kicker,
.field-label, .seg button, .seg2 button, .badge, .ov-badge, .ov-tag, .count, .legend, .col-label,
.ov-col span, .load-num, .load-legend, .voice-status, .ptr {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.screen { max-width: 560px; margin: 0 auto; padding: var(--pad) var(--pad) 24px; }

/* ---------- Шапка ---------- */
.top, .head { margin-bottom: 14px; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.top h1, .head h1 { font-size: var(--fs-title); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.top .count, .head .count { margin-top: 4px; color: var(--muted); font-size: var(--fs-meta); }
.top-actions { display: flex; gap: 2px; flex: none; margin-right: -10px; }
.icon-btn {
  position: relative; width: var(--touch); height: var(--touch); border-radius: var(--r-card);
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active, .icon-btn.active { background: var(--surface); color: var(--text); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }

.bar { height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .25s; }
.bar > i.s-biz { background: var(--s-biz); }
.bar > i.s-life { background: var(--s-life); }
.bar > i.s-health { background: var(--s-health); }
.bar > i.s-learn { background: var(--s-learn); }
.head .bar { margin-top: 10px; }

/* ---------- Чипы, переключатели ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 calc(var(--pad) * -1) 10px; padding: 0 var(--pad); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chip {
  position: relative; flex: none; height: 32px; padding: 0 11px; border-radius: var(--r-chip);
  background: var(--surface-deep); color: var(--muted); font-size: var(--fs-label); font-weight: 500;
  letter-spacing: .02em; white-space: nowrap; display: inline-flex; align-items: center;
}
.chip::after { content: ""; position: absolute; inset: -6px -2px; }   /* цель касания >= 44px */
.chip.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.chip.s-biz.active { background: var(--s-biz); color: var(--on-s-biz); }
.chip.s-life.active { background: var(--s-life); color: var(--on-s-life); }
.chip.s-health.active { background: var(--s-health); color: var(--on-s-health); }
.chip.s-learn.active { background: var(--s-learn); color: var(--on-s-learn); }
.chip.prio.p1.active { background: var(--p1); color: var(--on-p1); }
.chip.prio.p2.active { background: var(--p2); }
.chip.prio.p3.active { background: var(--p3); color: var(--text); }
.chips.small .chip { height: 30px; }

.seg, .seg2 { display: flex; gap: 4px; padding: 3px; border-radius: var(--r-card); background: var(--surface-deep); }
.seg { margin-bottom: 14px; }
.seg button, .seg2 button {
  flex: 1; min-height: 38px; padding: 0 4px; border-radius: 7px; font-size: var(--fs-label);
  color: var(--muted); font-weight: 500; position: relative;
}
.seg button::after, .seg2 button::after { content: ""; position: absolute; inset: -3px 0; }
.seg button.active, .seg2 button.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ---------- Поиск ---------- */
.search-row { margin-bottom: 12px; }
.search, .quick-input, .est-input, .date-input, .goal-select, .plan-text, .sheet-title {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-card); outline: none;
}
.search { width: 100%; height: var(--field-h); padding: 0 14px; }
.search:focus, .quick-input:focus, .est-input:focus, .date-input:focus, .goal-select:focus, .plan-text:focus {
  border-color: var(--accent);
}

/* ---------- Группы и карточки задач ---------- */
.group-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  margin: 18px 0 8px; min-height: 20px; font-size: var(--fs-label); font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; text-align: left;
}
.group-title.overdue { color: var(--danger); }
.group-title .group-count, .group-title .group-share { font-weight: 500; }
.group-title .chev {
  display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor; transform: rotate(-45deg); transition: transform .15s; vertical-align: 1px;
}
.group-title[aria-expanded="true"] .chev { transform: rotate(45deg); }
.group-title.collapsible { cursor: pointer; min-height: var(--touch); margin-top: 8px; }

.card {
  position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 12px 14px;
  margin-bottom: 8px; border: 1px solid var(--line); border-left: 3px solid var(--p3); border-radius: var(--r-card);
  background: var(--surface); cursor: pointer; transition: opacity .25s, transform .25s, max-height .25s, margin .25s, padding .25s;
  max-height: 240px; user-select: none; -webkit-user-select: none; overflow: hidden;
}
.card.pr-p1 { border-left-color: var(--p1); }
.card.pr-p2 { border-left-color: var(--p2); }
.card.pr-p3 { border-left-color: var(--p3); }
.card:active { background: var(--surface-deep); }
.card.overdue { background: var(--danger-bg); border-color: var(--danger-line); border-left-color: var(--danger); }
.card.leaving { opacity: 0; transform: translateX(24px); max-height: 0; padding-top: 0; padding-bottom: 0; margin-bottom: 0; border-width: 0; }
.card.pending { opacity: .6; align-items: center; cursor: default; }
.card-main { flex: 1; min-width: 0; }
.task-title { font-size: var(--fs-task); font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.card.done .task-title { text-decoration: line-through; color: var(--faint); }
.task-meta { margin-top: 4px; font-size: var(--fs-meta); color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; }
.task-meta .late { color: var(--danger); }
.card.overdue .task-meta { color: var(--meta-overdue); }
.task-meta .repeat { color: var(--accent-text); }
.task-meta .stuck { color: var(--danger); font-weight: 500; }
.task-meta .sphere { display: inline-flex; align-items: center; gap: 5px; }
.task-est { flex: none; padding-top: 2px; font-size: var(--fs-label); font-weight: 500; color: var(--est); }

.sdot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 2px; background: var(--muted); }
.sdot.s-biz { background: var(--s-biz); }
.sdot.s-life { background: var(--s-life); }
.sdot.s-health { background: var(--s-health); }
.sdot.s-learn { background: var(--s-learn); }

.cb {
  position: relative; flex: none; width: 22px; height: 22px; margin-top: 0; border-radius: var(--r-check);
  border: 2px solid var(--check-border); display: grid; place-items: center; padding: 0; background: transparent;
  transition: background .15s, border-color .15s;
}
.cb::after { content: ""; position: absolute; inset: -11px; }   /* цель касания 44px */
.cb svg { width: 13px; height: 13px; stroke: var(--on-success); fill: none; stroke-width: 3; opacity: 0; }
.cb:active svg { opacity: .5; }
.cb.checked { background: var(--success); border-color: var(--success); }
.cb.checked svg { opacity: 1; }

.goal-tag {
  display: inline-block; max-width: 160px; vertical-align: bottom; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.goal-tag::before { content: "цель: "; }

/* ---------- Нагрузка дня ---------- */
.load-card { margin-bottom: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.load-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.load-label { font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.load-num { font-size: 22px; font-weight: 600; }
.load-num small { font-size: var(--fs-label); font-weight: 400; color: var(--muted); }
.load-num.over { color: var(--danger); }
.load-bar { display: flex; height: 10px; margin-top: 10px; border-radius: 5px; background: var(--track); overflow: hidden; }
.load-bar i { display: block; height: 100%; }
.load-bar i.s-biz { background: var(--s-biz); }
.load-bar i.s-life { background: var(--s-life); }
.load-bar i.s-health { background: var(--s-health); }
.load-bar i.s-learn { background: var(--s-learn); }
.load-bar i.s-none { background: var(--muted); }
.load-bar { position: relative; }
.load-bar.over::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 4px; background: var(--danger); }
.load-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: var(--fs-meta); color: var(--muted); }
.load-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Состояния ---------- */
.empty, .soon { padding: 32px 0; text-align: center; color: var(--muted); }
.soon h2 { margin: 0 0 4px; color: var(--text); font-size: 20px; }
.error { padding: 20px 14px; margin: 8px 0; text-align: center; border: 1px solid var(--danger-line); border-radius: var(--r-card); background: var(--danger-bg); color: var(--danger); }
.error button { margin-top: 12px; min-height: var(--touch); padding: 0 18px; border-radius: var(--r-card); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.skeleton { height: 56px; margin-bottom: 8px; border-radius: var(--r-card); background: var(--surface-deep); }
.skeleton.tall { height: 120px; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton {
    background: linear-gradient(90deg, var(--surface-deep) 0%, var(--shimmer) 50%, var(--surface-deep) 100%);
    background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
  }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .3; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.spinner {
  flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite;
}

/* ---------- Навигация ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--nav-bg); border-top: 1px solid var(--nav-line);
}
.nav-item {
  flex: 1; min-height: var(--touch); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--muted); border-radius: var(--r-card);
}
.nav-item span { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.nav-item svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { color: var(--accent-text); }

/* ---------- Уведомление ---------- */
.toast {
  position: fixed; left: var(--pad); right: var(--pad); z-index: 60; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  max-width: 528px; margin: 0 auto; padding: 12px 14px; border-radius: var(--r-card);
  background: var(--toast-bg); border: 1px solid var(--toast-line); color: var(--toast-text);
  font-size: 13px; text-align: center;
}
body.has-quick .toast { bottom: calc(var(--nav-h) + 76px + env(safe-area-inset-bottom)); }
.toast[hidden] { display: none; }
.toast-action { color: var(--accent-text); font-weight: 600; background: none; border: 0; padding: 0 2px; min-height: 24px; }

.ptr {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50; padding: 8px; text-align: center;
  font-size: 12px; color: var(--muted); background: var(--bg);
}
.ptr.ready { color: var(--accent-text); }

/* ---------- Быстрый ввод ---------- */
.quickadd {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 20;
  padding: 8px var(--pad); background: var(--bg); border-top: 1px solid var(--line);
}
.quickadd[hidden] { display: none; }
.quick-row { display: flex; gap: var(--gap); max-width: 560px; margin: 0 auto; }
.quick-field {
  position: relative; flex: 1; min-width: 0; display: flex; align-items: center; height: var(--field-h);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-card);
}
.quick-field:focus-within { border-color: var(--accent); }
.quick-prefix { flex: none; padding: 0 0 0 14px; font-family: var(--font-mono); font-size: 18px; font-weight: 600; color: var(--accent-text); }
.quick-input {
  flex: 1; min-width: 0; height: 100%; padding: 0 12px 0 8px; border: 0; background: transparent;
  font-family: var(--font-mono); font-size: 14px;
}
.quick-input::placeholder { color: var(--faint); }
.quick-input:focus-visible { outline: none; }
.quickadd .mic, .send-btn {
  flex: none; width: var(--field-h); height: var(--field-h); border-radius: var(--r-card);
  display: grid; place-items: center; padding: 0;
}
.quickadd .mic { background: var(--accent); color: var(--on-accent); }
.quickadd .mic svg, .send-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.quickadd .mic.rec { background: var(--danger); color: var(--on-accent); }
.send-btn { background: var(--surface-deep); border: 1px solid var(--line-strong); color: var(--accent-text); }
.quickadd .mic:disabled, .send-btn:disabled { opacity: .5; }
.quick-status { max-width: 560px; margin: 0 auto; }
.quick-status:not(:empty) { margin-bottom: 8px; }

.voice-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.voice-hint { margin-left: auto; text-align: right; }
.rec-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
.voice-notice { padding: 10px 12px; border-radius: var(--r-card); background: var(--surface-deep); border: 1px solid var(--line-strong); font-size: 13px; }
.voice-notice .chat-btn { margin-top: 8px; min-height: 40px; padding: 0 12px; border-radius: var(--r-card); background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ---------- Кнопки ---------- */
.btn {
  flex: 1; min-height: var(--touch); padding: 0 14px; border-radius: var(--r-card); background: transparent;
  border: 1px solid var(--line-strong); color: var(--text); font-weight: 500; text-align: center; white-space: nowrap;
}
.btn:active { background: var(--surface-deep); }
.btn.danger, .warn-actions .danger { color: var(--danger); border-color: var(--danger-line); }
.btn.close { width: 100%; margin-top: 8px; }
.primary-btn, .btn.primary-btn, .sheet-btn.primary {
  width: 100%; margin-top: 16px; background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600;
}
.primary-btn:disabled, .btn:disabled { opacity: .55; }
.plan-btn { width: 100%; margin-top: 8px; border: 1px solid var(--accent); color: var(--accent-text); background: transparent; }
.sheet-btn { min-height: var(--touch); padding: 0 12px; border-radius: var(--r-card); border: 1px solid var(--line-strong); font-weight: 500; text-align: center; }

/* ---------- Нижние панели ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  background: var(--scrim); animation: fade-in .18s ease-out;
}
.sheet, .task-sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 8px var(--pad) calc(16px + env(safe-area-inset-bottom));
  border-radius: var(--r-sheet) var(--r-sheet) 0 0; background: var(--surface); border-top: 1px solid var(--line-strong);
  color: var(--text); animation: sheet-up .22s ease-out;
}
.task-sheet.no-anim { animation: none; }
.sheet-grip { width: 36px; height: 4px; margin: 4px auto 14px; border-radius: 2px; background: var(--line-strong); }
.sheet-kicker { margin-bottom: 4px; font-size: var(--fs-label); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sheet-date { font-size: var(--fs-body); color: var(--muted); }
.sheet-energy { margin: 4px 0 12px; }
.sheet-energy-num { font-family: var(--font-mono); font-size: 44px; font-weight: 600; line-height: 1.1; color: var(--accent-text); }
.sheet-energy-max { font-family: var(--font-mono); font-size: 20px; color: var(--muted); }
.sheet-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.sheet-label { color: var(--muted); }
.sheet-value { font-family: var(--font-mono); font-weight: 500; text-align: right; }
.sheet-note {
  margin-top: 4px; padding: 12px; border-radius: var(--r-card); background: var(--surface-deep);
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5;
}
.sheet-actions { display: flex; flex-direction: column; gap: var(--gap); margin-top: 16px; }
.sheet-title {
  width: 100%; margin-bottom: 14px; padding: 10px 12px; font-size: 18px; font-weight: 600;
}
.sheet-actions2 { display: flex; gap: var(--gap); flex-wrap: wrap; margin-top: 16px; }

.field { margin-bottom: 14px; }
.field-label { margin-bottom: 6px; font-size: var(--fs-label); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.date-input, .est-input {
  margin-top: 8px; min-height: 40px; padding: 0 12px; font-size: var(--fs-body); font-family: var(--font-mono);
}
.est-row { display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap; }
.est-input { width: 88px; margin-top: 0; }
.time-input { margin-top: 0; }
.goal-select { width: 100%; min-height: 42px; padding: 0 12px; font-size: var(--fs-body); }
.plan-text { width: 100%; padding: 10px 12px; font-size: var(--fs-body); resize: vertical; }
.sheet-warn {
  margin-bottom: 14px; padding: 12px; border-radius: var(--r-card);
  background: var(--danger-bg); border: 1px solid var(--danger-line); font-size: var(--fs-body); color: var(--text);
}
.warn-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.warn-actions button {
  min-height: 40px; padding: 0 12px; border-radius: var(--r-card); border: 1px solid var(--line-strong);
  font-size: 13px; font-weight: 500; background: var(--surface);
}

/* ---------- Рутины ---------- */
.add-routine {
  width: 100%; min-height: var(--touch); margin: 0 0 10px; padding: 0 12px; border-radius: var(--r-card);
  border: 1px dashed var(--line-strong); color: var(--accent-text); font-weight: 600; background: transparent;
}
.add-routine:active { background: var(--surface); }
.rcard { align-items: center; border-left-color: var(--p3); }
.rcard.off { opacity: .55; }
.rcard .badge { padding: 0 6px; border-radius: var(--r-chip); background: var(--surface-deep); font-size: 11px; }
.rcard .badge.p1 { color: var(--text); box-shadow: inset 2px 0 0 var(--p1); padding-left: 8px; }
.rcard .badge.p2 { color: var(--text); box-shadow: inset 2px 0 0 var(--p2); padding-left: 8px; }
.switch {
  position: relative; flex: none; width: 48px; height: 28px; border-radius: 14px; padding: 0;
  background: var(--track); border: 1px solid var(--line-strong); transition: background .15s;
}
.switch::after { content: ""; position: absolute; inset: -8px -4px; }
.switch i {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--muted); transition: transform .15s, background .15s;
}
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on i { transform: translateX(20px); background: var(--on-accent); }

/* ---------- Цели ---------- */
.goal {
  margin-bottom: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface);
}
.goal.tappable { cursor: pointer; }
.goal.tappable:active { background: var(--surface-deep); }
.goal-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; align-items: baseline; }
.goal-name { font-size: var(--fs-task); font-weight: 500; overflow-wrap: anywhere; display: inline-flex; gap: 8px; align-items: baseline; }
.goal-name .sdot { align-self: center; width: 9px; height: 9px; }
.goal-pct { color: var(--muted); font-size: var(--fs-label); white-space: nowrap; }
.goal-sub { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: var(--fs-meta); color: var(--muted); }
.goal-level { font-size: var(--fs-meta); color: var(--muted); margin-top: 2px; }
.goal-sheet-title { margin-bottom: 12px; font-size: 20px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.goal-hint { margin: 8px 0; padding: 10px 12px; border-radius: var(--r-card); background: var(--surface-deep); font-size: var(--fs-body); color: var(--muted); }
.goal-tasks { margin-top: 12px; }
.goal-task { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.goal-task.done .task-title { text-decoration: line-through; color: var(--faint); }
.goal-task-dot { flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: 2px; background: var(--p3); }
.goal-task-dot.p1 { background: var(--p1); }
.goal-task-dot.p2 { background: var(--p2); }
.goal-filter {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px;
  padding: 0 4px 0 12px; min-height: var(--touch); border-radius: var(--r-card);
  border: 1px solid var(--line-strong); background: var(--surface-deep);
  color: var(--accent-text); font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500;
}
.goal-filter span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-filter button { flex: none; width: var(--touch); height: var(--touch); display: grid; place-items: center; color: var(--accent-text); }
.goal-filter svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ---------- План цели ---------- */
.plan-loading { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; color: var(--muted); font-size: var(--fs-body); }
.plan-error {
  margin: 8px 0; padding: 10px 12px; border-radius: var(--r-card); background: var(--danger-bg);
  border: 1px solid var(--danger-line); color: var(--danger); font-size: var(--fs-body);
}
.plan-goal { font-size: var(--fs-task); line-height: 1.45; }
.plan-milestones { padding-left: 18px; font-size: var(--fs-body); line-height: 1.5; }
.plan-day { margin: 14px 0 2px; font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.plan-task { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; min-height: var(--touch); }
.plan-task input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.plan-task-title { flex: 1; min-width: 0; font-size: var(--fs-task); overflow-wrap: anywhere; }
.plan-task-min { flex: none; font-size: var(--fs-label); color: var(--muted); white-space: nowrap; padding-top: 3px; }
.plan-task.off .plan-task-title { color: var(--faint); text-decoration: line-through; }
.plan-regen { display: flex; gap: var(--gap); margin-top: 14px; align-items: center; }
.plan-accent { flex: 1; min-width: 0; width: auto; }
.plan-regen .btn { flex: none; }

/* ---------- Энергия ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); margin-bottom: 4px; }
.tile { padding: 12px 10px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); min-width: 0; }
.tile-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { margin-top: 6px; font-size: 24px; font-weight: 600; }
.tile-caption { font-size: var(--fs-meta); color: var(--muted); }

.chart { position: relative; height: 150px; padding: 8px 0 0 24px; margin-top: 4px; }
.chart .grid { position: absolute; left: 24px; right: 0; border-top: 1px dashed var(--line-strong); height: 0; }
.chart .grid span { position: absolute; left: -24px; top: -8px; width: 20px; font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-align: right; }
.chart .g10 { top: 8px; }
.chart .g5 { top: calc(8px + (100% - 8px - 18px) / 2); }
.cols { position: relative; display: flex; gap: 3px; height: 100%; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.track { position: relative; flex: 1; border-radius: 4px; background: var(--track); }
.col.nodata .track { background: var(--track); opacity: .55; }
.bar-fill { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 4px; background: var(--accent); min-height: 3px; }
.wdot { position: absolute; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--text); }
.wdot.static { position: static; display: inline-block; margin: 0 4px 0 0; vertical-align: middle; }
.col-label { height: 18px; line-height: 18px; text-align: center; font-size: 10px; color: var(--muted); white-space: nowrap; }
.chart.dense .cols { gap: 2px; }
.legend { margin-top: 6px; font-size: var(--fs-meta); color: var(--muted); }

.section-title { margin: 20px 0 8px; font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.rec-item {
  margin-bottom: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface);
}
.rec-item.tappable { cursor: pointer; }
.rec-item.tappable:active { background: var(--surface-deep); }
.rec-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.rec-date { font-weight: 500; }
.rec-energy { color: var(--accent-text); font-weight: 600; }
.rec-meta { margin-top: 4px; font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); }
.rec-note { margin-top: 6px; font-size: var(--fs-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }

/* ---------- Опрос ---------- */
.today-card { margin-bottom: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.today-title { font-size: 17px; font-weight: 600; }
.today-sub { margin: 4px 0 10px; font-size: var(--fs-meta); color: var(--muted); }
.today-facts { margin: 6px 0; font-family: var(--font-mono); font-size: 13px; }
.today-note { margin: 4px 0 10px; font-size: var(--fs-meta); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today-card .btn { width: 100%; margin-top: 4px; }
.today-card .primary-btn { margin-top: 12px; }
.step-ind { font-size: var(--fs-label); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.step-dots { display: flex; gap: 4px; margin: 8px 0 12px; }
.step-dots i { flex: 1; height: 4px; border-radius: 2px; background: var(--track); }
.step-dots i.on { background: var(--accent); }
.survey-count { margin: 10px 0 4px; font-weight: 600; }
.survey-list { padding-left: 18px; margin-bottom: 6px; font-size: var(--fs-body); line-height: 1.55; }
.survey-list.muted { color: var(--muted); }
.energy-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--gap); margin: 8px 0 6px; }
.energy-btn {
  height: var(--touch); min-height: var(--touch); border-radius: var(--r-card); background: var(--surface-deep);
  border: 1px solid var(--line-strong); font-family: var(--font-mono); font-size: 17px; font-weight: 500;
}
.energy-btn.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.energy-scale { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); margin-bottom: 4px; }
.big-choice { display: flex; gap: 10px; margin: 10px 0; }
.big-btn {
  flex: 1; min-height: 64px; padding: 0 8px; border-radius: var(--r-card); background: var(--surface-deep);
  border: 1px solid var(--line-strong); font-size: 16px; font-weight: 500;
}
.big-btn.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.survey-nav { display: flex; gap: var(--gap); margin-top: 16px; }
.survey-nav .btn { margin: 0; width: auto; flex: 1; }
.survey-nav .primary-btn { flex: 2; margin-top: 0; }
.survey-nav.column { flex-direction: column; }
.survey-nav.column .btn { width: 100%; flex: none; }
.carry-list { margin-top: 6px; }
.result-text {
  margin: 4px 0 14px; padding: 12px; border-radius: var(--r-card); background: var(--surface-deep);
  white-space: pre-wrap; line-height: 1.55; font-size: var(--fs-task);
}

/* ---------- Обзор ---------- */
.ov-card { margin-bottom: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.ov-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.ov-title { font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ov-link { min-height: 32px; color: var(--accent-text); font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500; }
.ov-badge { font-size: var(--fs-meta); color: var(--muted); }
.ov-empty { padding: 8px 0; color: var(--muted); font-size: var(--fs-body); }
.ov-ok { padding: 6px 0; color: var(--success-text); font-size: var(--fs-task); }
.ov-note { margin-top: 10px; font-size: 11px; line-height: 1.45; color: var(--faint); }
.ov-sub { margin: 12px 0 4px; }
.ov-score { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ov-score-num { font-size: 44px; font-weight: 600; line-height: 1; }
.ov-delta { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.ov-delta.up { color: var(--success-text); font-weight: 500; }
.ov-delta.down { color: var(--danger); font-weight: 500; }
.ov-chart { display: flex; align-items: flex-end; gap: 4px; height: 92px; margin-top: 14px; }
.ov-chart.dense { gap: 2px; }
.ov-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.ov-col i { display: block; width: 100%; border-radius: 3px; background: var(--accent); }
.ov-col.zero i { background: var(--track); }
.ov-col span { height: 14px; margin-top: 4px; font-size: 10px; line-height: 14px; color: var(--muted); }
.ov-row { margin: 12px 0; }
.ov-row-top { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-body); }
.ov-row-top > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.ov-row-val { color: var(--muted); font-size: var(--fs-meta); white-space: nowrap; }
.ov-track { height: 8px; margin-top: 6px; border-radius: 4px; background: var(--track); overflow: hidden; }
.ov-track i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.ov-track i.s-biz { background: var(--s-biz); }
.ov-track i.s-life { background: var(--s-life); }
.ov-track i.s-health { background: var(--s-health); }
.ov-track i.s-learn { background: var(--s-learn); }
.ov-warn { margin-bottom: 8px; padding: 10px 12px; border-radius: var(--r-card); background: var(--danger-bg); border: 1px solid var(--danger-line); }
.ov-warn-title { font-weight: 500; font-size: var(--fs-body); color: var(--danger); }
.ov-warn-facts { margin-top: 3px; font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); }
.ov-growth { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; align-items: center; width: 100%; min-height: var(--touch); padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; }
.ov-growth-title { font-size: var(--fs-body); overflow-wrap: anywhere; }
.ov-growth-meta { grid-column: 2; font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); }
.ov-tag { padding: 1px 7px; border-radius: var(--r-chip); font-size: 11px; font-weight: 500; white-space: nowrap; }
.ov-tag.good { background: var(--surface-deep); color: var(--success-text); }
.ov-tag.risk { background: var(--danger-bg); border: 1px solid var(--danger-line); color: var(--danger); }
.ov-stuck { padding: 10px 12px; margin-bottom: 8px; border-radius: var(--r-card); background: var(--danger-bg); border: 1px solid var(--danger-line); }
.ov-stuck:last-child { margin-bottom: 0; }
.ov-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ov-actions .btn { flex: 1 1 calc(50% - 6px); min-height: 40px; padding: 0 6px; font-size: 13px; background: var(--surface); }
.ov-deadline { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%; min-height: var(--touch); padding: 9px 0; border-bottom: 1px solid var(--line); text-align: left; }
.ov-dl-title { font-size: var(--fs-body); overflow-wrap: anywhere; }
.ov-dl-date { flex: none; font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); white-space: nowrap; }
.ov-dl-date.late { color: var(--danger); font-weight: 500; }
.ov-goal { display: block; width: 100%; min-height: var(--touch); padding: 10px 0; border-bottom: 1px solid var(--line); text-align: left; }
.ov-goal .goal-top { margin-bottom: 8px; }
.ov-card .tile { background: var(--surface-deep); }

/* ---------- Цели: шапка, подсказки ---------- */
.goals-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.add-goal { flex: none; min-height: 36px; padding: 0 14px; border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.goal-note { margin: 12px 0; text-align: center; font-size: var(--fs-meta); color: var(--faint); }
.goal-note.warn { margin: 0 0 12px; padding: 10px 12px; text-align: left; border-radius: var(--r-card); background: var(--surface-deep); color: var(--muted); }
