:root {
  --bg: #f7f8f4;
  --surface: #ffffff;
  --surface-2: #f0f2ed;
  --text: #24362e;
  --muted: #64716a;
  --line: #e2e7df;
  --accent: #27624f;
  --danger: #dc2626;
  --ok: #16a34a;
  --q1: #ef4444;
  --q2: #3b82f6;
  --q3: #f59e0b;
  --q4: #9ca3af;
  --radius: 16px;
  --shadow: 0 2px 8px rgb(29 49 38 / .025);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17201d;
    --surface: #1e2b24;
    --surface-2: #28372f;
    --text: #e7eee7;
    --muted: #a8b8ad;
    --line: #35483c;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    --accent: #78b99a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ── Шапка ─────────────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) 12px 0;
}
.tabs { display: flex; gap: 4px; max-width: 1100px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 12px 12px 10px; color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 12px; line-height: 18px; text-align: center;
}

main { max-width: 1100px; margin: 0 auto; padding: 12px 16px; }

/* ── Общие блоки ───────────────────────────────────────────────── */
.bar { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
.bar h1 { font-size: 20px; margin: 0; flex: 1; min-width: 0; }
.bar .sub { color: var(--muted); font-size: 13px; width: 100%; }
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 7px 12px; min-height: 36px;
}
.btn.icon { padding: 7px 11px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }

.section { margin: 18px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.empty { color: var(--muted); padding: 16px 4px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }

.quick { display: flex; gap: 8px; }
.quick input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
}

/* ── Задача в списке ───────────────────────────────────────────── */
.items { display: flex; flex-direction: column; gap: 6px; }
.item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 4px solid var(--sphere, var(--line));
}
.item .check {
  flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--qc, var(--q4)); background: transparent; padding: 0;
  display: grid; place-items: center; color: #fff; font-size: 13px;
}
.item.done .check { background: var(--ok); border-color: var(--ok); }
.item.cancelled .check { border-style: dashed; }
.item .body { flex: 1; min-width: 0; cursor: pointer; }
.item .title { overflow-wrap: anywhere; }
.item.done .title, .item.cancelled .title { color: var(--muted); text-decoration: line-through; }
.item .time { font-variant-numeric: tabular-nums; font-weight: 600; margin-right: 6px; }
.item .meta { color: var(--muted); font-size: 13px; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.item .meta .warn { color: var(--danger); }
.item .side { flex: none; }
.q1 { --qc: var(--q1); } .q2 { --qc: var(--q2); } .q3 { --qc: var(--q3); } .q4 { --qc: var(--q4); }

.tag { background: var(--surface-2); border-radius: 6px; padding: 0 6px; }

/* ── Неделя ────────────────────────────────────────────────────── */
.week { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .week { grid-template-columns: repeat(7, 1fr); } }
.wday { padding: 10px; min-height: 80px; }
.wday h3 { margin: 0 0 6px; font-size: 14px; display: flex; justify-content: space-between; cursor: pointer; }
.wday.today h3 { color: var(--accent); }
.wday .load { color: var(--muted); font-weight: 400; font-size: 12px; }
.mini {
  display: block; width: 100%; text-align: left; border: 0; background: var(--surface-2);
  border-left: 3px solid var(--sphere, var(--line)); border-radius: 6px; padding: 4px 6px; margin: 3px 0;
  font-size: 13px; overflow-wrap: anywhere;
}
.mini.done { color: var(--muted); text-decoration: line-through; }

/* ── Доска ─────────────────────────────────────────────────────── */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 16px;
  padding: 4px 10px; white-space: nowrap; font-size: 13px;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.board { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(240px, 1fr)); overflow-x: auto; align-items: start; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.col h2 { font-size: 14px; margin: 2px 4px 8px; display: flex; justify-content: space-between; }
.col.drop { outline: 2px dashed var(--accent); }
.col .item { cursor: grab; }

/* ── Входящие ──────────────────────────────────────────────────── */
.inbox-row { padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; }
.inbox-row .text { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.inbox-row .when { color: var(--muted); font-size: 12px; }
.inbox-row .err { color: var(--danger); font-size: 12px; }
.inbox-row .acts { display: flex; gap: 6px; flex: none; }

/* ── Карточка задачи (шторка) ──────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .4); z-index: 10; }
.sheet {
  position: fixed; z-index: 11; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 32px rgb(0 0 0 / .2);
}
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 6vh; width: 640px; transform: translateX(-50%); border-radius: 16px; max-height: 88vh; }
}
.sheet .title-input {
  width: 100%; font-size: 19px; font-weight: 600; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; padding: 6px 0; margin-bottom: 10px;
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  color: var(--text); background: var(--surface-2); border: 1px solid transparent; border-radius: 8px;
  padding: 8px 10px; min-height: 38px; width: 100%;
}
.field textarea { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 6px; align-items: center; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); }
.toggle { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
.qlabel { font-size: 13px; padding: 2px 8px; border-radius: 6px; color: #fff; background: var(--qc); }
.actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }
.actions .spacer { flex: 1; }

.blocks { display: flex; flex-direction: column; gap: 8px; }
.blk-md p { margin: 0 0 6px; }
.blk-md ul { margin: 0 0 6px; padding-left: 20px; }
.blk-md code, .blk-code { background: var(--surface-2); border-radius: 4px; padding: 0 4px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.blk-code { display: block; padding: 8px; white-space: pre-wrap; overflow-x: auto; }
.blk-check label { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
.blk-check label.done span { color: var(--muted); text-decoration: line-through; }
.blk-callout { border-left: 3px solid var(--accent); padding: 6px 10px; background: var(--surface-2); border-radius: 6px; }
.blk-callout.warn { border-color: var(--q3); }
.blk-callout.ok { border-color: var(--ok); }
.blk-comment { font-size: 13px; color: var(--muted); }
.blk-table { border-collapse: collapse; font-size: 13px; }
.blk-table td, .blk-table th { border: 1px solid var(--line); padding: 4px 6px; }
.subtasks .item { box-shadow: none; background: var(--surface-2); }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: 6px 0; }
.progress i { display: block; height: 100%; background: var(--ok); }

/* ── Прочее ────────────────────────────────────────────────────── */
.fab {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 6;
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  font-size: 30px; line-height: 1; box-shadow: 0 6px 20px rgb(59 130 246 / .45);
}
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 20;
  max-width: calc(100vw - 32px);
}
.login { max-width: 420px; margin: 15vh auto; text-align: center; padding: 24px; }
.login h1 { margin-top: 0; }

/* Пустые дни недели на телефоне — одной строкой. */
@media (max-width: 899px) {
  .wday:not(:has(.mini)) { min-height: 0; padding: 8px 10px; }
  .wday:not(:has(.mini)) h3 { margin: 0; }
}

/* ── Аналитика ─────────────────────────────────────────────────── */
:root {
  --viz-1: #2a78d6;       /* основной ряд (категориальный слот 1) */
  --viz-ctx: #a3a9b4;     /* фоновый ряд (de-emphasis) */
  --viz-grid: #e6e8ec;
}
@media (prefers-color-scheme: dark) {
  :root { --viz-1: #3987e5; --viz-ctx: #5d6472; --viz-grid: #2a2f39; }
}
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { padding: 12px 14px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.kpi .delta { font-size: 12px; color: var(--muted); }
.charts { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .charts { grid-template-columns: 1fr 1fr; } .charts .span2 { grid-column: 1 / -1; } }
.chart { padding: 14px; min-width: 0; }
.chart h2 { font-size: 15px; margin: 0; }
.chart .hint { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart svg text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; background: var(--k); }
.legend i.dot { width: 9px; height: 9px; border-radius: 50%; }
.hbars { display: grid; grid-template-columns: max-content 1fr; gap: 6px 10px; align-items: center; font-size: 13px; }
.hbars .track { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hbars .bar { height: 18px; background: var(--viz-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbars .val { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mark:hover, .mark:focus { opacity: .8; outline: none; }
.chart details { margin-top: 8px; font-size: 13px; color: var(--muted); }
.chart table { border-collapse: collapse; margin-top: 6px; width: 100%; font-variant-numeric: tabular-nums; }
.chart th, .chart td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); color: var(--text); }
.chart th { color: var(--muted); font-weight: 500; }
.dumb { display: grid; grid-template-columns: minmax(0, 40%) 1fr; gap: 6px 10px; align-items: center; font-size: 13px; }
.dumb .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip {
  position: fixed; z-index: 30; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: var(--shadow);
  max-width: 240px;
}
.tip b { font-size: 14px; }
.tip .k { display: inline-block; width: 12px; height: 2px; background: var(--k); vertical-align: middle; margin-right: 6px; }
.lists { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 12px; }
@media (min-width: 900px) { .lists { grid-template-columns: 1fr 1fr; } }

/* ── Граф ──────────────────────────────────────────────────────── */
.graph { padding: 0; overflow: hidden; touch-action: none; }
.graph svg { display: block; width: 100%; height: 70vh; cursor: grab; }
.graph .edge { stroke: var(--muted); stroke-width: 1.2; opacity: .55; }
.graph .edge.blocks { stroke: var(--viz-1); opacity: .9; stroke-width: 1.6; }
.graph .edge.parent { stroke-width: 1.8; }
.graph .node circle { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.graph .node { cursor: pointer; }
.graph .node text { fill: var(--text); font-size: 11px; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.graph .node.done { opacity: .45; }
.graph.focus .node:not(.near), .graph.focus .edge:not(.near) { opacity: .12; }
.graph-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 0; }

/* ── Связи в карточке ──────────────────────────────────────────── */
.rels .rel { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 14px; }
.rels .rel .t { color: var(--muted); font-size: 12px; min-width: 92px; }
.rels .rel .name { flex: 1; min-width: 0; cursor: pointer; overflow-wrap: anywhere; }
.rels .add { display: flex; gap: 6px; margin-top: 6px; }
.rels .add input { flex: 1; min-width: 0; }
.rels select, .rels input { background: var(--surface-2); border: 0; border-radius: 8px; padding: 6px 8px; }

/* ── v4: офлайн, прогресс, дневник ─────────────────────────────── */
.offline { max-width: 1100px; margin: 0 auto; padding: 6px 4px; font-size: 13px; color: var(--q3); }
.top { display: flex; flex-wrap: wrap; align-items: center; }
.top .tabs { flex: 1; min-width: 0; }
.badge.queue { background: var(--q3); white-space: nowrap; text-decoration: none; margin: 0 4px; }
.offline { flex-basis: 100%; }
.mini-progress { gap: 8px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.mini-progress .progress { flex: 1; max-width: 160px; margin: 0; }
.weight-box { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); }
.weight-box input { width: 48px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px; }
.moods { display: flex; gap: 8px; margin: 6px 0 12px; }
.moods button { font-size: 26px; border: 2px solid transparent; background: var(--surface); border-radius: 12px; padding: 4px 8px; box-shadow: var(--shadow); }
.moods button.on { border-color: var(--accent); }
.journal textarea { width: 100%; min-height: 160px; resize: vertical; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 10px 12px; }
.summary { padding: 10px 12px; margin: 10px 0; border-left: 3px solid var(--accent); }
.entries .entry { padding: 10px 12px; display: flex; gap: 10px; cursor: pointer; }
.entries .entry .d { color: var(--muted); font-size: 13px; min-width: 64px; }
.entries .entry .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-list .q { padding: 8px 12px; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.queue-detail { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.queue-error { color: var(--danger); margin-top: 4px; }
.queue-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.footer-links { margin: 28px 0 8px; text-align: center; font-size: 13px; }
.footer-links button { background: none; border: 0; color: var(--muted); text-decoration: underline; }

/* ── Заметки ───────────────────────────────────────────────────── */
.notes .note { padding: 12px 14px; cursor: pointer; border-left: 4px solid var(--sphere, var(--line)); }
.notes .note h3 { margin: 0 0 4px; font-size: 15px; }
.notes .note p { margin: 0; color: var(--muted); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notes .note .meta { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Вложения ── */
.blk-file { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.blk-file a { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; color: inherit; text-decoration: none;
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.blk-file a:hover { border-color: var(--accent); }
.blk-file img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; }
.blk-file .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk-file .size, .pending-files .size { color: var(--muted); font-size: 12px; flex: none; }
.dropzone { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; border: 1px dashed var(--line); border-radius: 10px; }
.dropzone.over { border-color: var(--accent); background: var(--surface-2); }
.dropzone .hint { color: var(--muted); font-size: 13px; }
.pending-files { flex-basis: 100%; font-size: 14px; }
.inbox-row .blk-file { margin-top: 6px; }

/* ── Настройки сфер ── */
.spheres-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.sphere-card { padding: 12px 14px; }
.sphere-card.archived { opacity: .7; }
.sphere-card .head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sphere-card .head input:not(.icon-input) { flex: 1; min-width: 0; font-weight: 600; }
.icon-input { width: 3.2em; text-align: center; flex: none; }
.swatch { width: 14px; align-self: stretch; border-radius: 4px; flex: none; background: var(--light); }
@media (prefers-color-scheme: dark) { .swatch { background: var(--dark); } }
.sphere-card input[type=color] { width: 100%; height: 36px; padding: 2px; border-radius: 8px; }
.gdot { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 1px solid var(--line); }
.sphere-card .slug { color: var(--muted); font: 12px ui-monospace, monospace; }
.new-sphere { padding: 12px 14px; }
.new-sphere .row input:not(.icon-input):not([type=color]) { flex: 1; min-width: 0; }
.new-sphere input[type=color] { width: 44px; height: 36px; padding: 2px; flex: none; }
.sphere-card .head input, .new-sphere input:not([type=color]) {
  color: var(--text); background: var(--surface-2); border: 1px solid transparent; border-radius: 8px;
  padding: 8px 10px; min-height: 38px;
}
.sphere-card .field textarea { min-height: 60px; }

/* ── Workspace: shared desktop and mobile hierarchy ────────────────────── */
:root { --sidebar-width: 232px; --accent-soft: #e6eee5; --warm: #a65e3c; }
body { font-size: 14px; line-height: 1.55; padding: 0; letter-spacing: -.012em; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: wait; }
button, input, select, textarea { outline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.ui-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: fixed; left: 16px; top: -70px; z-index: 100; background: var(--surface); padding: 12px 20px; border-radius: 10px; }
.skip-link:focus { top: 12px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); padding: 30px 20px 20px; background: var(--surface); border-right: 1px solid var(--line); z-index: 9; display: flex; flex-direction: column; overflow-y: auto; }
.brand-row { display: flex; align-items: center; justify-content: space-between; margin: 0 6px 32px; }
.brand { display: flex; gap: 11px; align-items: center; text-decoration: none; color: var(--text); font-size: 23px; font-weight: 700; letter-spacing: -1px; }
.brand small { display: block; font-size: 10px; color: var(--muted); font-weight: 400; letter-spacing: .01em; margin-top: -2px; }
.brand-mark { display: grid; place-content: center; width: 35px; height: 39px; position: relative; background: var(--accent); color: white; border-radius: 11px 11px 11px 3px; font-size: 25px; font-weight: 600; }
.brand-mark span { position: absolute; right: 5px; bottom: 3px; color: #d7eabb; }
.nav-create { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; margin-bottom: 30px; font-size: 13px; }
kbd { font: 10px/1.6 ui-monospace, monospace; border: 1px solid currentColor; opacity: .45; border-radius: 4px; min-width: 18px; text-align: center; }
.nav-create kbd { margin-left: auto; }
.tabs { display: block; max-width: none; margin: 0; overflow: visible; }
.nav-group { margin-bottom: 24px; }
.nav-label { display: block; font-size: 10px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 0 12px 8px; }
.tabs .nav-link, .sidebar-footer .nav-link { display: flex; gap: 11px; align-items: center; padding: 10px 12px; margin: 3px 0; border: 0; border-radius: 9px; font-size: 13px; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500; }
.tabs .nav-link.active, .sidebar-footer .nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link .badge { margin-left: auto; }
.sidebar-footer { margin-top: auto; padding-top: 24px; }
.sidebar-caption { display: block; font-size: 10px; color: var(--muted); margin: 20px 10px 0; }
.workspace { margin-left: var(--sidebar-width); min-height: 100vh; }
.top { height: 77px; display: flex; align-items: center; justify-content: space-between; padding: 0 40px; gap: 20px; background: var(--bg); backdrop-filter: none; border-bottom: 1px solid var(--line); }
.breadcrumb { display: flex; gap: 13px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.breadcrumb strong { font-weight: 500; color: var(--text); }
.breadcrumb-divider { opacity: .35; }
.top-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.global-search { display: flex; gap: 9px; align-items: center; color: var(--muted); }
.global-search input { width: 208px; border: 0; background: transparent; padding: 8px 0; font-size: 12px; min-width: 0; }
.global-search .ui-icon { width: 16px; }
.global-search input::placeholder { color: var(--muted); }
.queue { position: static; font-size: 11px; text-decoration: none; padding: 3px 8px; background: var(--surface); color: var(--accent); border: 1px solid var(--line); }
.offline { margin: 12px 40px 0; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 12px; }
main { width: 100%; max-width: 1320px; padding: 36px 40px 60px; margin: 0 auto; outline: none; }
main > .bar { margin: 0 0 24px; }
.bar h1 { font-size: 28px; font-weight: 650; letter-spacing: -1px; }
.bar .sub { margin-top: 2px; }
.btn { min-height: 40px; padding: 8px 14px; border-radius: 9px; font-weight: 550; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; }
.card { border: 1px solid var(--line); box-shadow: var(--shadow); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.eyebrow { font-size: 10px; color: var(--accent); font-weight: 650; text-transform: uppercase; letter-spacing: .11em; margin-bottom: 6px; }
.page-title { font-size: clamp(24px, 2.5vw, 34px); line-height: 1.2; font-weight: 650; letter-spacing: -1.2px; margin: 0; }
.page-description { color: var(--muted); font-size: 13px; margin: 9px 0 0; }
.page-head-actions, .date-nav { display: flex; align-items: center; gap: 6px; }
.date-nav { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.date-nav .btn { min-height: 32px; border: 0; padding: 5px 11px; background: transparent; font-size: 12px; }
.date-nav .btn:hover { background: var(--surface-2); }
.day-summary { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 25px; gap: 12px; }
.summary-stat { padding: 17px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.summary-value { font-size: 24px; letter-spacing: -.7px; font-weight: 600; color: var(--text); display: block; }
.summary-label { color: var(--muted); font-size: 11px; display: block; margin-top: 3px; }
.day-summary .summary-stat:first-child { background: var(--accent-soft); border-color: transparent; }
.day-summary .summary-stat:first-child .summary-value { color: var(--accent); }
.quick.card { padding: 18px 20px; margin-bottom: 26px; display: flex; flex-wrap: wrap; gap: 10px; background: var(--surface); }
.quick-label { flex-basis: 100%; font-size: 13px; font-weight: 600; }
.quick-hint { flex-basis: 100%; font-size: 11px; color: var(--muted); }
.quick input { padding: 12px 14px; background: var(--bg); border-color: var(--line); }
.quick input:focus { outline-offset: 1px; }
.day-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .62fr); gap: 24px; align-items: start; }
.day-main, .day-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.panel { overflow: hidden; padding: 20px; }
.panel-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 17px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.25px; }
.count { border-radius: 6px; padding: 2px 7px; font-size: 11px; color: var(--muted); background: var(--surface-2); font-weight: 500; }
.items { gap: 0; }
.item { padding: 14px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; gap: 12px; background: transparent; }
.item:last-child { border-bottom: 0; }
.item .check { width: 24px; height: 24px; border: 1.5px solid var(--line); border-radius: 8px; margin: 1px 0 0; color: white; position: relative; }
.item .check::before { content: ''; position: absolute; inset: -9px; }
.item .check:hover { border-color: var(--accent); }
.item.done .check { background: var(--accent); border-color: var(--accent); }
.item .title { font-size: 14px; font-weight: 500; line-height: 1.5; }
.task-title-button { display: block; background: transparent; border: 0; text-align: left; padding: 0; width: 100%; color: inherit; font-weight: inherit; }
.item .meta { font-size: 11px; margin-top: 6px; gap: 5px 10px; }
.item .meta > span { max-width: 100%; }
.item .time { color: var(--accent); font-size: 12px; }
.item .tag { font-size: 10px; padding: 1px 6px; }
.day-side .panel { background: color-mix(in srgb, var(--surface) 65%, var(--bg)); }
.day-side .item .meta { font-size: 10px; }
.day-fold { padding: 0 20px; }
.day-fold > summary { cursor: pointer; padding: 18px 0; display: flex; align-items: center; gap: 9px; list-style: none; font-size: 13px; font-weight: 550; }
.day-fold > summary::-webkit-details-marker { display: none; }
.day-fold > summary::before { content: '›'; font-size: 20px; color: var(--muted); transition: transform .15s; }
.day-fold[open] > summary::before { transform: rotate(90deg); }
.day-fold > summary .count { margin-left: auto; }
.day-fold > .items { padding-bottom: 12px; }
.panel .empty { font-size: 12px; padding: 18px 0; }
.section { font-size: 11px; font-weight: 600; margin-top: 24px; }
.board { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; overflow: visible; }
.col { border-radius: 12px; padding: 12px; background: var(--surface-2); min-width: 0; }
.col h2 { font-size: 12px; margin-bottom: 16px; }
.col .item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.col .item .body { flex-basis: 65%; }
.board-move { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 11px; min-height: 34px; }
.board-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.board-toolbar .chips { margin: 0; flex: 1; }
.board-status-filter { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px; }
.chip { min-height: 34px; padding: 6px 12px; font-size: 12px; }
.chip.on { background: var(--accent); color: white; border-color: var(--accent); }
.week { gap: 12px; }
.wday { border-top: 3px solid transparent; padding: 14px 10px; min-width: 0; }
.wday.today { border-top-color: var(--accent); }
.wday h3 { font-size: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.mini { padding: 8px; margin-bottom: 7px; font-size: 11px; min-height: 34px; }
.inbox-composer { padding: 20px; margin-bottom: 28px; }
.inbox-composer textarea { width: 100%; resize: vertical; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 12px; min-height: 84px; }
.inbox-group { margin: 24px 0; }
.inbox-group h2 { font-size: 15px; }
.inbox-row { padding: 20px; margin-bottom: 12px; gap: 18px; }
.inbox-row .acts { flex-wrap: wrap; justify-content: flex-end; max-width: 210px; }
.inbox-row .acts .btn { font-size: 12px; }
.inbox-row .text { font-size: 14px; }
.notes { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.notes .note { padding: 22px; border-left-width: 3px; }
.notes .note h3 { margin-bottom: 10px; }
.notes .note p { line-height: 1.7; }
.sheet-backdrop { z-index: 30; background: rgb(20 36 27 / .35); backdrop-filter: blur(3px); }
.sheet { z-index: 31; padding: 26px; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 80px rgb(0 0 0 / .16); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.sheet-head h2 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0; }
.sheet .title-input { font-size: 23px; letter-spacing: -.6px; padding: 4px 0 16px; }
.editor-section { margin: 22px 0; }
.editor-section .section { margin: 0 0 12px; }
.field { gap: 7px; font-size: 12px; }
.field input, .field select, .field textarea { background: var(--bg); border-color: var(--line); min-height: 42px; }
.grid { gap: 16px; }
.editor-details { border-top: 1px solid var(--line); padding: 14px 0; }
.editor-details > summary { cursor: pointer; font-size: 13px; font-weight: 550; }
.editor-details .grid { margin-top: 16px; }
.sheet-actions { position: sticky; bottom: -26px; background: var(--surface); padding: 16px 0; border-top: 1px solid var(--line); margin-top: 20px; z-index: 2; }
.fab { display: none; }
.toast { bottom: 24px; font-size: 13px; z-index: 60; box-shadow: 0 8px 28px rgb(0 0 0 / .1); }
.mobile-nav, .mobile-brand, .nav-close { display: none; }
.nav-backdrop { position: fixed; inset: 0; border: 0; background: rgb(15 27 20 / .4); z-index: 8; }
.search-results { max-width: 840px; }
.search-results .panel { margin-bottom: 16px; }
.search-results .item { padding: 16px 0; }
@media (prefers-color-scheme: dark) {
  :root { --accent-soft: #293d30; --warm: #dfa680; }
  .btn.primary, .chip.on, .brand-mark { color: #15251c; }
  .item.done .check { color: #15251c; }
}
@media (max-width: 1199px) and (min-width: 900px) {
  :root { --sidebar-width: 208px; }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  main { padding: 28px; }
  .top { padding: 0 28px; }
  .day-layout { grid-template-columns: minmax(0,1fr); }
  .day-side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .board { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .week { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (min-width: 1200px) { .week { grid-template-columns: repeat(7,minmax(0,1fr)); } }
@media (max-width: 899px) {
  body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .sidebar { transform: translateX(-100%); width: min(300px, 86vw); transition: transform .2s ease; padding-top: calc(24px + env(safe-area-inset-top)); z-index: 22; }
  .sidebar.is-open { transform: translateX(0); visibility: visible; }
  .sidebar:not(.is-open) { visibility: hidden; }
  .nav-backdrop { z-index: 21; }
  .nav-open { overflow: hidden; }
  .nav-close { display: grid; place-items: center; }
  .brand-row { margin-bottom: 24px; }
  .workspace { margin-left: 0; }
  .top { height: calc(67px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 20px 0; gap: 20px; }
  .breadcrumb { display: none; }
  .mobile-brand { display: block; font-size: 22px; font-weight: 700; text-decoration: none; letter-spacing: -.8px; color: var(--text); }
  .mobile-brand span { color: var(--accent); }
  .global-search { background: var(--surface); border: 1px solid var(--line); padding: 0 9px; border-radius: 9px; gap: 7px; }
  .global-search input { width: min(38vw,230px); padding: 9px 0; font-size: 12px; }
  .global-search kbd { display: none; }
  .top-actions { gap: 6px; }
  main { padding: 24px 20px 85px; }
  .offline { margin: 10px 20px; }
  .page-head { align-items: flex-start; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
  .page-title { font-size: 28px; }
  .page-description { font-size: 12px; max-width: 260px; }
  .page-head-actions { margin-top: 8px; }
  .day-summary { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; margin-bottom: 18px; }
  .summary-stat { padding: 13px 16px; }
  .summary-value { font-size: 22px; }
  .quick.card { padding: 16px; margin-bottom: 18px; }
  .quick input { font-size: 14px; }
  .day-layout { grid-template-columns: minmax(0,1fr); gap: 18px; }
  .day-main, .day-side { gap: 18px; }
  .panel { padding: 18px; }
  .day-fold { padding: 0 18px; }
  .item { padding: 16px 0; }
  .item .check { margin-right: 3px; }
  .item .side { padding: 6px; font-size: 11px; }
  .board { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .board-toolbar { display: block; }
  .board-toolbar .chips { margin-bottom: 10px; }
  .board-status-filter { width: 100%; }
  .week { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .mobile-nav { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 7px 8px calc(8px + env(safe-area-inset-bottom)); z-index: 12; }
  .mobile-nav .nav-link { background: transparent; color: var(--muted); border: 0; display: flex; align-items: center; flex-direction: column; gap: 5px; text-decoration: none; font-size: 10px; padding: 7px 1px; border-radius: 9px; min-height: 49px; }
  .mobile-nav .nav-link.active { color: var(--accent); background: var(--accent-soft); font-weight: 650; }
  .mobile-nav .ui-icon { width: 21px; height: 21px; }
  .fab { display: flex; gap: 7px; align-items: center; justify-content: center; width: auto; height: 46px; padding: 0 17px; border-radius: 13px; bottom: calc(90px + env(safe-area-inset-bottom)); right: 20px; font-size: 12px; font-weight: 600; box-shadow: 0 5px 16px rgb(30 65 42 / .18); }
  .toast { bottom: calc(145px + env(safe-area-inset-bottom)); width: max-content; }
  .sheet { padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 92dvh; border-radius: 20px 20px 0 0; }
  .sheet-actions { bottom: -20px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .inbox-row { flex-direction: column; padding: 18px; }
  .inbox-row .acts { max-width: none; justify-content: flex-start; width: 100%; }
  .inbox-row .acts .btn { flex: 1; }
  .nav-create kbd { display: none; }
  .notes { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 479px) {
  .board, .week { grid-template-columns: minmax(0,1fr); }
  .top { padding-left: 16px; padding-right: 16px; gap: 9px; }
  main { padding-left: 16px; padding-right: 16px; }
  .global-search input { width: 115px; }
  .global-search input::placeholder { font-size: 11px; }
  .quick.card .btn { padding: 8px 12px; }
  .summary-stat { padding: 12px 14px; }
  .grid { gap: 12px; }
  .bar h1 { font-size: 24px; }
  .queue-list .q { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
.quick-controls { display: flex; gap: 10px; width: 100%; }
.quick-controls input { flex: 1; min-width: 0; }
.panel-add { font-size: 11px; min-height: 30px; padding: 4px 8px; margin-left: auto; }
.panel-head .count { margin-right: auto; }
.fold-hint { color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.board-filtered { grid-template-columns: minmax(0,1fr); max-width: 800px; }
.sheet-open { overflow: hidden; }
.editor-title > input { background: transparent !important; }
.inbox-composer .actions { margin-top: 12px; }
@media (max-width: 599px) {
  .day-summary { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
  .summary-stat { padding: 10px 8px; border-radius: 10px; }
  .summary-value { font-size: 19px; }
  .summary-label { font-size: 9px; line-height: 1.4; }
  .quick.card { padding: 14px; gap: 8px; }
  .quick-hint { font-size: 10px; }
  .global-search input { font-size: 16px; }
  .field input, .field select, .field textarea, .quick input, .inbox-composer textarea { font-size: 16px; }
}
.item .check { border-color: color-mix(in srgb, var(--muted) 35%, var(--surface)); }
.item.done .check { border-color: var(--accent); }
@media (max-width: 899px) {
  .day-main { display: contents; }
  .day-side { grid-row: 2; }
}
@media (prefers-color-scheme: dark) { .fab { color: #15251c; } }

/* Задача на несколько дней: пунктирная полоса слева и метка периода. */
.item.period { border-left-style: dashed; }
.tag.period { background: color-mix(in srgb, var(--sphere, var(--line)) 18%, transparent); }

/* Неделя на широком экране: одна сетка — заголовки, полосы дел на несколько дней
   сквозь дни (без наложений: у каждой своя строка), затем дела дня. */
.week-grid { display: none; }
@media (min-width: 1200px) {
  .week-grid {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: auto repeat(var(--lanes, 0), auto) 1fr;
    column-gap: 12px; row-gap: 6px; min-height: 320px;
  }
  .week-narrow { display: none; }
}
.wday-bg { margin: 0; z-index: 0; }
.wday-bg.today { outline: 2px solid var(--accent); }
.wday-head, .wday-items { position: relative; z-index: 1; padding: 0 12px; }
.wday-head { padding-top: 12px; }
.wday-head h3 { margin: 0; cursor: pointer; display: flex; justify-content: space-between; }
.wday-items { display: flex; flex-direction: column; gap: 6px; padding-bottom: 12px; }
.week-bar {
  position: relative; z-index: 2; margin: 0 8px;
  text-align: left; padding: 6px 10px; border: 0; border-radius: 8px; cursor: pointer;
  color: var(--text); font: inherit; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--sphere, var(--accent)) 45%, var(--surface));
  border-left: 4px solid var(--sphere, var(--accent));
}
/* Полоса идёт сквозь промежутки между днями — как одна лента. */
.week-bar { margin-right: 8px; }
.week-bar.cont-left { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; }
.week-bar.cont-right { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.week-bar.done { opacity: .55; text-decoration: line-through; }
.wday-head h3 { font-size: 14px; }
.wday-head .load { color: var(--muted); font-weight: 400; font-size: 12px; }
.wday-head.today h3 { color: var(--accent); }
.wday-items .mini { margin: 0; }

/* Дела из одной записи во входящих: каждое — своей строкой со своими кнопками. */
.inbox-drafts { list-style: decimal; margin: 12px 0 0; padding-left: 22px; display: grid; gap: 8px; white-space: normal; }
.inbox-drafts .draft { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 8px 10px; border-radius: 8px; background: var(--surface-2, rgba(127,127,127,.08)); }
.inbox-drafts .draft.accepted, .inbox-drafts .draft.rejected { opacity: .55; }
.inbox-drafts .draft.rejected .draft-text { text-decoration: line-through; }
.inbox-drafts .draft-text { flex: 1; font-size: 13px; }
.inbox-drafts .draft-acts { display: flex; gap: 6px; flex: none; }
.inbox-drafts .btn.small { padding: 4px 10px; font-size: 12px; }
/* Уточнения к записи ответами в боте — цепочкой под исходным текстом. */
.inbox-clarifications { list-style: none; margin: 6px 0 4px; padding: 0 0 0 12px; border-left: 2px solid var(--line); display: grid; gap: 4px; white-space: normal; }
.inbox-clarifications li { font-size: 13px; color: var(--muted); }
.inbox-clarifications li::before { content: "↪ "; }

/* Деньги */
.money-add { padding: 12px 14px; margin-bottom: 14px; display: grid; gap: 8px; }
.money-add textarea { width: 100%; resize: vertical; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 10px 12px; font: inherit; color: var(--text); }
.money-add .chips { margin: 0; align-items: center; }
.money-add .actions { margin-top: 0; align-items: center; }
.expenses { display: grid; gap: 6px; margin-bottom: 14px; }
.expense { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; }
.expense .ic { font-size: 18px; }
.expense .t { flex: 1; min-width: 0; }
.expense .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbars .bar.rest { background: var(--viz-ctx); border-radius: 0 4px 4px 0; margin-left: -4px; }
.hbars .track .bar.rest:first-child { margin-left: 0; }
.hbars .track .bar:has(+ .bar.rest) { border-radius: 0; }
.expense .amt.income { color: var(--accent, #2f7d4f); }
.kpi.short .value { color: var(--warm, #a65e3c); }
.money-pending, .insight { padding: 14px; margin-bottom: 14px; }
.money-pending h2, .insight h2 { font-size: 15px; margin: 0; }
.money-pending .hint, .insight .hint { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
.pending-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.pending-row .t { flex: 1 1 160px; min-width: 0; }
.pending-row .hint { margin: 0; }
.pending-row input, .recurring-add input, .recurring-add select { border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 10px; font: inherit; min-width: 0; }
.pending-row input { width: 120px; }
.insight-head { display: flex; align-items: center; gap: 8px; }
.insight-head .spacer { flex: 1; }
.insight-text p { margin: 6px 0; line-height: 1.45; }
.recurring-add { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; padding: 12px; margin: 8px 0 20px; align-items: center; }
.recurring-add .check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.expense select { border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 6px 8px; font: inherit; }
.insight > input { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 10px 12px; font: inherit; margin-bottom: 8px; }
.kpi.range .value { font-size: 21px; }
