:root {
  /* безопасные зоны (вырез/статус-бар, индикатор «домой»): Safari, PWA standalone и WKWebView (viewport-fit=cover);
     вне iPhone — 0. Переменные можно переопределить (тесты эмулируют вырез; нативная оболочка — если WebView
     не сообщает env()) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --bg: #f6f6fa;
  --surface: #ffffff;
  --surface-2: #f1f1f6;
  --surface-3: #e9e9f1;
  --border: #e4e4ec;
  --border-strong: #d3d3df;
  --text: #1b1c24;
  --text-2: #5b5d6e;
  --text-3: #9091a2;
  --accent: #5b5bf0;
  --accent-2: #7c6cf6;
  --accent-soft: #ececfe;
  --accent-text: #4a48d6;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --p1: #e5484d;
  --p2: #f08c1a;
  --p3: #3b82f6;
  --p4: #a3a4b3;
  --success: #16a34a;
  --shadow-sm: 0 1px 2px rgba(20, 20, 40, .06);
  --shadow: 0 1px 2px rgba(20, 20, 40, .05), 0 4px 16px rgba(20, 20, 40, .06);
  --shadow-lg: 0 10px 40px rgba(20, 20, 40, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 268px;
  --drawer-w: 420px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101117;
    --surface: #17181f;
    --surface-2: #1e1f28;
    --surface-3: #272833;
    --border: #262733;
    --border-strong: #353646;
    --text: #ececf2;
    --text-2: #a4a5b6;
    --text-3: #6d6e80;
    --accent: #7373ff;
    --accent-2: #9383ff;
    --accent-soft: #23234a;
    --accent-text: #a9a8ff;
    --danger: #f2555a;
    --danger-soft: #3a1d20;
    --p4: #6d6e80;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101117;
  --surface: #17181f;
  --surface-2: #1e1f28;
  --surface-3: #272833;
  --border: #262733;
  --border-strong: #353646;
  --text: #ececf2;
  --text-2: #a4a5b6;
  --text-3: #6d6e80;
  --accent: #7373ff;
  --accent-2: #9383ff;
  --accent-soft: #23234a;
  --accent-text: #a9a8ff;
  --danger: #f2555a;
  --danger-soft: #3a1d20;
  --p4: #6d6e80;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 16px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html:not(:has(body.auth-mode)) { overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
kbd {
  font: 11px/1 var(--font); padding: 3px 6px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3);
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- layout ---------- */
.app { display: flex; height: 100vh; height: 100dvh; }

.sidebar {
  width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; gap: 14px;
  padding: calc(18px + var(--sat)) 14px 12px; background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 4px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.brand-logo svg { width: 20px; height: 20px; stroke-width: 3; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--text-3); }

.search {
  display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 36px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 10px; color: var(--text-3);
  transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: var(--accent); background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); }
.search input::-webkit-search-cancel-button { display: none; }
.search svg { width: 16px; height: 16px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 9px;
  color: var(--text-2); font-weight: 500; transition: background .12s, color .12s; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item em { font-style: normal; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item.active em { color: var(--accent-text); }
.nav-item em.alert { color: var(--danger); font-weight: 600; }
.nav-item .dot { width: 10px; height: 10px; border-radius: 50%; margin: 0 4px; flex: none; }
.nav-item .nav-more {
  opacity: 0; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--text-3);
}
.nav-item:hover .nav-more { opacity: 1; }
.nav-item .nav-more:hover { background: var(--surface-3); color: var(--text); }
.nav-item .nav-more svg { width: 14px; height: 14px; }
.nav-item.drop-hover { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -2px; }

.nav-section-head {
  display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 4px;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.foot-row { display: flex; gap: 6px; }
.foot-btn {
  height: 34px; min-width: 34px; padding: 0 9px; border-radius: 9px; display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-2); font-size: 13px; font-weight: 500;
}
.foot-btn:first-child { flex: 1; justify-content: flex-start; }
.foot-btn:hover { background: var(--surface-2); color: var(--text); }
.foot-btn.on { color: var(--accent-text); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: calc(22px + var(--sat)) 32px 14px; flex: none;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.subtitle { color: var(--text-3); font-size: 13px; margin-top: 2px; text-transform: none; }
.subtitle::first-letter { text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar .menu-btn { display: none; }

.view { flex: 1; overflow-y: auto; padding: 4px 32px 80px; scroll-behavior: smooth; container-type: inline-size; }
.offline-bar {
  display: flex; align-items: center; gap: 8px; margin: 0 32px 8px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--p2) 14%, var(--surface)); color: var(--text); font-size: 13px; font-weight: 500;
}
.offline-bar[hidden] { display: none; }
.offline-bar svg { width: 16px; height: 16px; flex: none; color: var(--p2); fill: none; stroke: currentColor; stroke-width: 2; }
/* скелетон первого запуска (нет снимка): заменяется первой отрисовкой */
.skeleton { display: grid; gap: 14px; padding-top: 12px; }
.sk-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 12px; }
.sk-card i { display: block; height: 14px; border-radius: 7px; background: var(--surface-2); }
.sk-card i:nth-child(odd) { width: 72%; } .sk-card i:nth-child(even) { width: 54%; } .sk-card i:first-child { width: 36%; height: 16px; }
.sk-short { opacity: .7; }
@media (prefers-reduced-motion: no-preference) {
  .sk-card i { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: skShine 1.4s ease-in-out infinite; }
}
@keyframes skShine { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; color: var(--text-2);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 24px; height: 24px; border-radius: 6px; }
.icon-btn.sm svg { width: 15px; height: 15px; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.btn {
  height: 34px; padding: 0 14px; border-radius: 9px; display: inline-flex; align-items: center; gap: 7px;
  font-weight: 600; font-size: 13px; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: background .12s, border-color .12s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-group { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.btn-group .icon-btn { border-radius: 0; height: 32px; }
.btn-group .btn { border: 0; border-radius: 0; height: 32px; }

/* ---------- today layout ---------- */
.today-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; max-width: 1200px; }
.side-col { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.card-head h3 { margin: 0; font-size: 13px; font-weight: 700; }
.card-head a { font-size: 12.5px; color: var(--accent-text); font-weight: 600; }
.card-head a:hover { text-decoration: underline; }

.progress-card { padding: 16px; display: flex; align-items: center; gap: 16px; }
.ring { width: 64px; height: 64px; flex: none; position: relative; }
.ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring circle { stroke-width: 7; fill: none; }
.ring .track { stroke: var(--surface-3); }
.ring .bar { stroke: var(--accent); transition: stroke-dashoffset .5s cubic-bezier(.2, .8, .2, 1); }
.ring .pct { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.progress-text b { display: block; font-size: 15px; }
.progress-text span { color: var(--text-3); font-size: 12.5px; }

/* mini calendar */
.mini-cal { padding: 4px 12px 12px; }
.mini-cal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 4px 8px; }
.mini-cal-head b { font-size: 13px; text-transform: capitalize; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.mini-grid .wd { font-size: 10.5px; color: var(--text-3); font-weight: 600; padding: 4px 0; text-transform: uppercase; }
.mini-day {
  position: relative; height: 34px; border-radius: 8px; font-size: 12.5px; font-variant-numeric: tabular-nums;
  display: grid; place-items: center; color: var(--text); transition: background .1s;
}
.mini-day:hover { background: var(--surface-2); }
.mini-day.out { color: var(--text-3); opacity: .55; }
.mini-day.weekend { color: var(--text-2); }
.mini-day.today { background: var(--accent); color: #fff; font-weight: 700; }
.mini-day .dots { position: absolute; bottom: 4px; left: 0; right: 0; display: flex; justify-content: center; gap: 2px; }
.mini-day .dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.mini-day .dots i.p1 { background: var(--p1); }
.mini-day.today .dots i { background: #fff; }

.upnext { padding: 0 8px 10px; }
.upnext-day { padding: 8px 8px 4px; }
.upnext-day h4 { margin: 0 0 4px; font-size: 12px; color: var(--text-3); font-weight: 600; display: flex; justify-content: space-between; }
.upnext-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.upnext-item:hover { background: var(--surface-2); }
.upnext-item .pdot { width: 8px; height: 8px; border-radius: 50%; flex: none; border: 2px solid var(--p4); }
.upnext-item .pdot.p1 { border-color: var(--p1); }
.upnext-item .pdot.p2 { border-color: var(--p2); }
.upnext-item .pdot.p3 { border-color: var(--p3); }
.upnext-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upnext-item time { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.upnext-empty { padding: 4px 16px 16px; color: var(--text-3); font-size: 13px; }

/* ---------- sections & tasks ---------- */
.content { max-width: 820px; }
.section { margin-bottom: 22px; }
.section-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 2px 8px; border-bottom: 1px solid var(--border); margin-bottom: 2px;
}
.section-head h2 { margin: 0; font-size: 14px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.section-head h2 small { font-weight: 500; font-size: 12.5px; color: var(--text-3); }
.section-head .count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.section-head .spacer { flex: 1; }
.section.overdue .section-head h2 { color: var(--danger); }
.section.is-today .section-head h2 { color: var(--accent-text); }
.section.drop-hover { background: var(--accent-soft); border-radius: var(--radius-sm); outline: 2px dashed var(--accent); outline-offset: 4px; }
/* «Предстоящие»: день — карточка; пустой день — компактная строка */
.up-day { margin-bottom: 10px; overflow: hidden; scroll-margin-top: 100px; }  /* под липкой полосой недели */
.up-day-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px 8px; }
.up-day-head h2 { margin: 0; font-size: 14.5px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 0; }
.up-day-head h2 small { font-weight: 500; font-size: 12.5px; color: var(--text-3); }
.up-day-head .count { font-size: 12px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums;
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--surface-2); display: inline-grid; place-items: center; }
.up-day-body { padding: 0 12px 4px; border-top: 1px solid var(--border); }
.up-day-body > .task:last-of-type { border-bottom: 0; }
.up-day-body .events-block { padding-top: 10px; }
.up-day-body .add-row { padding-left: 6px; }
.up-day-body .quick-add { margin: 8px 0 10px; }
.up-day.is-today { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow-sm); }
.up-day.is-today .up-day-head { background: var(--accent-soft); }
.up-day.is-today .up-day-head h2 { color: var(--accent-text); }
.up-day.is-today .up-day-head .count { background: var(--accent); color: #fff; }
.up-day.overdue .up-day-head h2 { color: var(--danger); }
.up-day.overdue .up-day-head .btn { flex: none; }
.up-day.up-empty { margin-bottom: 6px; box-shadow: none; background: color-mix(in srgb, var(--surface) 55%, transparent); }
.up-day.up-empty .up-day-head { padding: 6px 8px 6px 16px; min-height: 40px; }
.up-day.up-empty .up-day-head h2 { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.up-day.up-empty.is-today .up-day-head h2 { color: var(--accent-text); }
.up-day-head .up-none { font-size: 12.5px; color: var(--text-3); }
.up-day.up-empty .icon-btn { width: 28px; height: 28px; }
.up-day.up-empty .icon-btn svg { width: 16px; height: 16px; }
.up-day.drop-hover { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -2px; }

.collapse-toggle {
  display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; font-weight: 600; padding: 8px 2px;
}
.collapse-toggle:hover { color: var(--text); }
.collapse-toggle svg { width: 14px; height: 14px; transition: transform .15s; }
.collapse-toggle.open svg { transform: rotate(90deg); }

.task {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 6px 10px 4px; border-bottom: 1px solid var(--border);
  position: relative; cursor: pointer; border-radius: 0; transition: background .12s;
  /* без анимации появления: перерисовка и переход между разделами не должны «мигать»;
     только что добавленная задача анимируется из JS (animateFresh) */
}
.task:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.task.selected { background: var(--accent-soft); }
.task.dragging { opacity: .4; }
.task.completing { animation: taskOut .35s ease-in forwards; }
@keyframes taskOut { 60% { opacity: .6; } to { opacity: 0; transform: translateX(12px); } }

.check {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--p4); flex: none; margin-top: 1px;
  display: grid; place-items: center; color: transparent; transition: background .15s, border-color .15s, color .15s, transform .1s;
  background: transparent;
}
.check svg { width: 12px; height: 12px; stroke-width: 3.2; }
.check:hover { color: var(--p4); }
.check:active { transform: scale(.88); }
.task.p1 .check { border-color: var(--p1); background: color-mix(in srgb, var(--p1) 10%, transparent); }
.task.p2 .check { border-color: var(--p2); background: color-mix(in srgb, var(--p2) 10%, transparent); }
.task.p3 .check { border-color: var(--p3); background: color-mix(in srgb, var(--p3) 10%, transparent); }
.task.p1 .check:hover { color: var(--p1); }
.task.p2 .check:hover { color: var(--p2); }
.task.p3 .check:hover { color: var(--p3); }
.task.done .check, .task.completing .check { background: var(--success); border-color: var(--success); color: #fff; }
.task.done.p1 .check, .task.completing.p1 .check { background: var(--p1); border-color: var(--p1); }
.task.done.p2 .check, .task.completing.p2 .check { background: var(--p2); border-color: var(--p2); }
.task.done.p3 .check, .task.completing.p3 .check { background: var(--p3); border-color: var(--p3); }
.task.done.p4 .check, .task.completing.p4 .check { background: var(--p4); border-color: var(--p4); }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.task.done .task-title { color: var(--text-3); text-decoration: line-through; }
.task-notes { font-size: 12.5px; color: var(--text-3); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; font-size: 12px; color: var(--text-3); }
.task-meta:empty { display: none; }
.meta { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.meta svg { width: 13px; height: 13px; }
.meta.date { color: var(--text-2); }
.meta.date.today { color: var(--success); }
.meta.date.tomorrow { color: var(--p2); }
.meta.date.overdue { color: var(--danger); }
.meta.list .dot { width: 8px; height: 8px; border-radius: 50%; }
.meta.time { color: var(--accent-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.task-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.task:hover .task-actions, .task:focus-within .task-actions { opacity: 1; }

.add-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px; color: var(--text-3); font-size: 14px; width: 100%; text-align: left;
  border-radius: 8px;
}
.add-row:hover { color: var(--accent-text); }
.add-row .plus { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; transition: background .12s, color .12s; }
.add-row:hover .plus { background: var(--accent); color: #fff; }
.add-row .plus svg { width: 14px; height: 14px; stroke-width: 2.5; }

/* quick add */
.quick-add {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin: 4px 0 20px; transition: border-color .15s, box-shadow .15s;
}
.quick-add:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent), var(--shadow); }
.quick-add .qa-row { display: flex; align-items: center; gap: 10px; padding: 0 8px 0 14px; }
.quick-add .qa-row > svg { color: var(--accent); }
/* поле + подложка подсветки: одинаковые шрифт, отступы и высота строки, подложка прокручивается вместе с полем */
.qa-field { position: relative; flex: 1; min-width: 0; display: flex; font-size: 15px; --qa-h: 48px; }
.quick-add input.qa-input {
  position: relative; z-index: 1; flex: 1; min-width: 0; width: 100%; height: var(--qa-h); border: 0; background: none; outline: none;
  font: inherit; letter-spacing: normal; padding: 0; margin: 0; line-height: var(--qa-h);
}
.quick-add input.qa-input::placeholder { color: var(--text-3); }
.qa-mirror {
  position: absolute; inset: 0; z-index: 0; overflow: hidden; white-space: pre; pointer-events: none; user-select: none;
  font: inherit; letter-spacing: normal; line-height: var(--qa-h); color: transparent; padding: 0; margin: 0;
}
/* серая подсказка-продолжение после курсора (Tab / → / касание — принять) */
.qa-ghost { color: var(--text-3); }
.qa-hl { color: transparent; background: var(--qa-hl-bg); border-radius: 4px; box-shadow: 0 0 0 2px var(--qa-hl-bg); }
.qa-hl.k-list, .qa-hl.k-mention { --qa-hl-bg: color-mix(in srgb, var(--accent) 16%, transparent); }
.qa-hl.k-ambiguous { --qa-hl-bg: color-mix(in srgb, var(--p2) 26%, transparent); box-shadow: 0 0 0 2px var(--qa-hl-bg), 0 2px 0 1px var(--p2); }
.quick-add { --qa-hl-bg: color-mix(in srgb, var(--text) 10%, transparent); position: relative; }
.quick-add.ac-open { z-index: 20; }

/* автодополнение #список / @участник */
.qa-ac-anchor { position: relative; height: 0; }
.qa-ac {
  position: absolute; top: 2px; left: 34px; width: min(380px, calc(100% - 42px)); z-index: 30;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: pop .12s ease-out;
}
.qa-ac[hidden] { display: none; }
.qa-ac-list { max-height: min(300px, 46vh); overflow-y: auto; overscroll-behavior: contain; padding: 4px; }
.qa-ac-group + .qa-ac-group { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.qa-ac-head {
  display: flex; align-items: center; gap: 7px; padding: 6px 8px 4px; font-size: 11.5px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em;
}
.qa-ac-head span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-ac-item {
  display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 0 10px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--text); -webkit-tap-highlight-color: transparent;
}
.qa-ac-item .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.qa-ac-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-ac-item .sub { flex: none; max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-3); }
.qa-ac-item.active { background: var(--accent-soft); color: var(--accent-text); }
.qa-ac-item.active .sub { color: var(--accent-text); opacity: .8; }
@media (hover: hover) { .qa-ac-item:hover:not(.active) { background: var(--surface-2); } }
.qa-ac-ico { width: 18px; height: 18px; display: inline-grid; place-items: center; flex: none; color: var(--text-3); }
.qa-ac-ico svg, .qa-ac-hint svg, .qa-opt-ico svg { width: 14px; height: 14px; }
.qa-ac-hint { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; font-size: 13px; line-height: 1.4; color: var(--text-2); }
.qa-ac-hint svg { flex: none; margin-top: 2px; color: var(--p2); }
.sp-ico.xs { width: 18px; height: 18px; border-radius: 5px; }
.sp-ico.xs svg { width: 12px; height: 12px; }
.modal .qa-ac-anchor, .day-panel .qa-ac-anchor { height: auto; }
.modal .qa-ac, .day-panel .qa-ac { position: static; width: auto; margin: 0 8px 8px; box-shadow: var(--shadow); animation: none; }

/* неоднозначный #список */
.qa-warn { padding: 0 14px 10px 42px; font-size: 13px; color: var(--text-2); }
.qa-warn:empty, .qa-warn[hidden] { display: none; }
.qa-warn-text { display: flex; gap: 7px; align-items: flex-start; line-height: 1.4; margin-bottom: 8px; }
.qa-warn-text svg { flex: none; width: 15px; height: 15px; margin-top: 2px; color: var(--p2); }
.qa-warn-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.qa-opt {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 6px; border-radius: 8px; max-width: 100%;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2);
}
.qa-opt:hover, .qa-opt:focus-visible { border-color: var(--accent); color: var(--text); }
.qa-opt b { color: var(--text); font-weight: 600; }
.qa-opt > span:not(.sp-ico):not(.qa-opt-ico)::after { content: " /"; color: var(--text-3); }
.qa-opt-ico { width: 18px; height: 18px; border-radius: 5px; display: inline-grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.quick-add.qa-bad { border-color: var(--p2); animation: qaShake .3s; }
@keyframes qaShake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.qa-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px 42px; }
.qa-chips:empty { display: none; }
/* кнопки-уточнения «+ время», «+ повтор» …: одна строка, на телефоне прокручивается по горизонтали */
.qa-slots {
  display: flex; gap: 6px; padding: 0 14px 10px 42px; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.qa-slots::-webkit-scrollbar { display: none; }
.qa-slots[hidden], .qa-slots:empty { display: none; }
.qa-slot {
  flex: none; display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px dashed var(--border-strong); background: none; color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.qa-slot:hover, .qa-slot:focus-visible { border-color: var(--accent); color: var(--accent-text); }
.qa-slot.opt { border: 1px solid transparent; background: var(--accent-soft); color: var(--accent-text); }
.qa-slot.close { padding: 0 8px; }
.qa-slot svg { width: 13px; height: 13px; }
.qa-hl.k-amount, .qa-hl.k-split { --qa-hl-bg: color-mix(in srgb, var(--success) 20%, transparent); }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.chip svg { width: 12px; height: 12px; }
.chip.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.chip.p1 { color: var(--p1); } .chip.p2 { color: var(--p2); } .chip.p3 { color: var(--p3); }
.qa-hint { font-size: 12px; color: var(--text-3); padding: 0 14px 10px 42px; display: none; }
.quick-add:focus-within .qa-hint { display: block; }
.qa-hint code { background: var(--surface-2); border-radius: 4px; padding: 1px 5px; font-size: 11.5px; color: var(--text-2); }
.inline-add { margin: 6px 0 4px; }

/* empty states */
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-3);
}
.empty .art {
  width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 24px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 40%, transparent)); color: var(--accent);
}
.empty .art svg { width: 38px; height: 38px; stroke-width: 1.6; }
.empty h3 { color: var(--text); margin: 0 0 4px; font-size: 16px; }
.empty p { margin: 0; font-size: 13.5px; }
.empty.small { padding: 18px 8px; }
.empty.small .art { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 8px; }
.empty.small .art svg { width: 22px; height: 22px; }

/* ---------- upcoming ---------- */
.week-strip {
  display: grid; grid-template-columns: auto repeat(7, 1fr) auto; gap: 6px; align-items: stretch;
  position: sticky; top: -4px; z-index: 5; background: var(--bg); padding: 4px 0 14px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.week-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; border-radius: 10px; border: 1px solid transparent;
  transition: background .12s;
}
.week-day:hover { background: var(--surface); border-color: var(--border); }
.week-day .wd { font-size: 11px; color: var(--text-3); text-transform: uppercase; font-weight: 600; }
.week-day .num { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.week-day .cnt { font-size: 11px; color: var(--text-3); height: 14px; }
.week-day.today .num { color: var(--accent-text); }
.week-day.today { background: var(--accent-soft); }
.week-day.past { opacity: .45; }
/* день, карточка которого вверху ленты (scroll-spy) или выбран тапом */
.week-day.active { background: var(--surface); border-color: var(--accent); box-shadow: var(--shadow-sm); }
.week-day.today.active { background: var(--accent-soft); }
.up-feed .up-day { scroll-margin-top: calc(var(--up-strip, 96px) + 4px); }
.up-more { display: flex; justify-content: center; align-items: center; min-height: 48px; padding: 8px 0 24px; color: var(--text-3); font-size: 13px; }
.up-more a { color: var(--accent-text); }
.week-strip .icon-btn { align-self: center; }

/* ---------- calendar ---------- */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.cal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div {
  padding: 10px 10px 8px; font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.cal-cell {
  min-height: 118px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 3px; cursor: pointer; transition: background .1s; min-width: 0; position: relative;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.cal-cell.out { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.cal-cell.out .cal-num { color: var(--text-3); }
.cal-cell.weekend .cal-num { color: var(--text-2); }
/* Выделение дня — скруглённая рамка с отступом внутрь: у угловых ячеек не срезается скруглением сетки (.cal overflow:hidden) */
.cal-cell.selected { background: none; box-shadow: none; }
.cal-cell.selected::before {
  content: ""; position: absolute; inset: 3px; border-radius: 9px; pointer-events: none;
  background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); z-index: 0;
}
.cal-cell.selected > *:not(.cal-add) { position: relative; z-index: 1; }
.cal-cell.selected > .cal-add { z-index: 2; }
.cal-cell.drop-hover { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: 10px; }
.cal-num {
  font-size: 12.5px; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  font-variant-numeric: tabular-nums; margin-bottom: 1px;
}
.cal-cell.today .cal-num { background: var(--accent); color: #fff; }
.cal-add {
  position: absolute; top: 6px; right: 6px; opacity: 0; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  color: var(--text-3);
}
.cal-add svg { width: 14px; height: 14px; }
.cal-cell:hover .cal-add { opacity: 1; }
.cal-add:hover { background: var(--accent); color: #fff; }
.cal-chip {
  display: flex; align-items: center; gap: 5px; font-size: 12px; line-height: 1.25; padding: 3px 6px; border-radius: 5px;
  background: var(--surface-2); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
  border-left: 3px solid var(--p4);
}
.cal-chip span { overflow: hidden; text-overflow: ellipsis; }
.cal-chip time { color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; flex: none; }
.cal-chip.p1 { border-left-color: var(--p1); }
.cal-chip.p2 { border-left-color: var(--p2); }
.cal-chip.p3 { border-left-color: var(--p3); }
.cal-chip.done { opacity: .5; text-decoration: line-through; }
.cal-chip.overdue { background: var(--danger-soft); }
.cal-chip:hover { background: var(--surface-3); }

.day-panel { position: sticky; top: 0; }
.day-panel .card-head { padding-bottom: 4px; align-items: flex-start; }
.day-panel .card-head h3 { font-size: 16px; }
.day-panel .card-head .subtitle { margin: 0; }
.day-panel .body { padding: 0 14px 12px; max-height: calc(100vh - 220px); overflow-y: auto; }
.day-panel .quick-add { margin: 6px 0 8px; box-shadow: none; }
.day-panel .qa-field { --qa-h: 40px; font-size: 14px; }
.day-panel .qa-hint, .day-panel .qa-chips, .day-panel .qa-warn, .day-panel .qa-slots { padding-left: 14px; }

/* ---------- drawer ---------- */
.drawer {
  width: 0; flex: none; background: var(--surface); border-left: 1px solid var(--border); overflow: hidden;
  transition: width .22s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column;
}
.drawer.open { width: var(--drawer-w); }
.drawer-inner { width: var(--drawer-w); height: 100%; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: calc(14px + var(--sat)) 14px 10px 20px; border-bottom: 1px solid var(--border); }
.drawer-head .crumb { flex: 1; font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; min-width: 0; }
.drawer-head .crumb .dot { width: 8px; height: 8px; border-radius: 50%; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 24px; display: flex; flex-direction: column; gap: 18px; }
.drawer-title-row { display: flex; gap: 12px; align-items: flex-start; }
.drawer-title-row .check { width: 22px; height: 22px; margin-top: 5px; }
.drawer textarea.title {
  flex: 1; border: 0; outline: none; resize: none; background: none; font-size: 19px; font-weight: 650; line-height: 1.35; padding: 2px 0; min-height: 32px;
  letter-spacing: -.01em;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .field-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.field-label svg { width: 13px; height: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input, .select {
  height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); outline: none; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
textarea.input { height: auto; min-height: 96px; padding: 9px 10px; resize: vertical; line-height: 1.5; }
.input-wrap { position: relative; display: flex; }
.input-wrap .input { padding-right: 32px; }
.input-wrap .clear { position: absolute; right: 4px; top: 6px; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--text-3); }
.input-wrap .clear:hover { background: var(--surface-2); color: var(--text); }
.input-wrap .clear svg { width: 13px; height: 13px; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  height: 28px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 12.5px; font-weight: 500; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface);
}
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.active { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.pill svg { width: 13px; height: 13px; }
.prio-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.prio-seg .pill { justify-content: center; }
.prio-seg .pill[data-p="1"] svg { color: var(--p1); }
.prio-seg .pill[data-p="2"] svg { color: var(--p2); }
.prio-seg .pill[data-p="3"] svg { color: var(--p3); }
.prio-seg .pill[data-p="4"] svg { color: var(--p4); }
/* проекции будущих повторов (без записей): одна отметка «↻ +N по плану», по нажатию — список (бледнее, без чекбокса) */
.proj-block { display: flex; flex-direction: column; }
.proj-row { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.proj-none { font-size: 12.5px; color: var(--text-3); padding-left: 6px; }
.proj-toggle {
  display: inline-flex; align-items: center; gap: 5px; align-self: flex-start; padding: 3px 8px 3px 6px; margin: 4px 0;
  border-radius: 999px; font-size: 12.5px; font-weight: 500; color: var(--text-3); background: transparent;
  border: 1px dashed var(--border-strong); cursor: pointer; white-space: nowrap; transition: color .12s, background .12s, border-color .12s;
}
.proj-toggle:hover, .proj-toggle.open { color: var(--text-2); background: var(--surface-2); border-color: transparent; }
.proj-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.proj-toggle .proj-sym { font-size: 13px; line-height: 1; }
.proj-toggle .proj-chev { width: 11px; height: 11px; transition: transform .15s; opacity: .8; }
.proj-toggle.open .proj-chev { transform: rotate(90deg); }
.up-day-body > .proj-block { padding: 2px 0 0; }
.up-day-body > .proj-block .proj-row { min-height: 0; }
.up-day-body > .proj-block .proj-toggle { margin-left: 3px; }
.up-day-head .up-sep { margin: 0 -3px; }
.up-day-head .proj-toggle { margin: 0; padding: 2px 7px 2px 5px; font-size: 12px; }
.up-day.up-empty.has-proj .up-none:first-of-type { flex: none; }
.up-day.up-empty .up-day-body.proj-block { padding: 0 12px 6px; }
.up-day.up-empty .up-day-head h2 { flex: 1; white-space: nowrap; overflow: hidden; }
.up-day.up-empty .up-day-head h2 small { overflow: hidden; text-overflow: ellipsis; }
@container (max-width: 640px) {  /* телефон: в строке пустого дня — «Нет дел · ↻ +N» (полная подпись — в aria-label/title) */
  .up-day-head .proj-toggle .proj-txt, .up-day-head .proj-toggle .proj-chev { display: none; }
  .up-day-head .proj-toggle { padding: 2px 8px; }
}
.proj-list { display: flex; flex-direction: column; padding: 2px 0 4px; }
.proj-task { display: flex; align-items: flex-start; gap: 10px; padding: 7px 8px 7px 4px; border-radius: 10px; cursor: pointer; opacity: .72; }
.proj-task:hover, .proj-task:focus-visible { opacity: 1; background: var(--surface-2); }
.proj-ico { width: 20px; height: 20px; flex: none; display: grid; place-items: center; border: 1.5px dashed var(--border-strong); border-radius: 50%; color: var(--text-3); margin-top: 1px; }
.proj-ico svg { width: 11px; height: 11px; }
.proj-body { min-width: 0; }
.proj-title { font-size: 14px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.day-panel .proj-block { margin: 2px 0; }
/* точки дня в ячейке месяца: событие — закрашенная, задача — кружок-контур цвета списка, повтор по плану — бледная */
.cal-dots { display: flex; align-items: center; gap: 3px; padding: 1px 4px 0; flex-wrap: wrap; min-height: 8px; }
.cal-dots.narrow { display: none; }
.cal-dots .cd { width: 7px; height: 7px; border-radius: 50%; flex: none; box-sizing: border-box; }
.cal-dots .cd-ev { background: var(--c); }
.cal-dots .cd-task { border: 1.5px solid var(--c); background: transparent; }
.cal-dots .cd-proj { width: 5px; height: 5px; background: var(--text-3); opacity: .45; }
.cal-dots .cd-more { font-size: 10px; line-height: 7px; font-weight: 700; color: var(--text-3); }
.mini-day .dots i.proj { background: var(--text-3); opacity: .45; }
.proj-dot { display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--text-3); opacity: .45; vertical-align: middle; }
/* «до» — конец диапазона в карточке задачи (end_date / end_time) */
.range-row { margin-top: 8px; }
.range-row .input-wrap .range-to { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--text-3); pointer-events: none; }
.range-row .input-wrap .input { padding-left: 32px; }
.task-meta .span-day { color: var(--accent-text); }
/* редактор повтора в карточке задачи (Повтор → «Настроить…») */
.rp-editor { display: flex; flex-direction: column; gap: 10px; padding: 12px; margin-top: -4px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.rp-row { display: flex; align-items: center; gap: 8px; }
.rp-word { font-size: 13px; color: var(--text-2); flex: none; }
.rp-n.input { width: 64px; flex: none; text-align: center; font-variant-numeric: tabular-nums; padding: 0 6px; }
.rp-unit.select { flex: 1; min-width: 0; }
.rp-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.rp-days .pill { justify-content: center; padding: 0; height: 34px; }
.rp-month { display: flex; flex-direction: column; gap: 8px; }
.rp-opt { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.rp-opt input[type="radio"] { flex: none; width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.rp-opt .select { flex: 1; min-width: 0; }
.rp-note { line-height: 1.45; }
.rp-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; font-size: 13px; color: var(--text); }
.rp-summary svg { width: 13px; height: 13px; align-self: center; color: var(--accent-text); }
@media (max-width: 860px) {
  .rp-n.input, .rp-editor .select { font-size: 16px; height: 40px; }
  .rp-days .pill { height: 40px; font-size: 14px; }
}

.subtasks { display: flex; flex-direction: column; }
.subtask { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.subtask .check { width: 17px; height: 17px; margin: 0; }
.subtask .check svg { width: 10px; height: 10px; }
.subtask.done .check { background: var(--success); border-color: var(--success); color: #fff; }
.subtask input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 13.5px; padding: 2px 0; }
.subtask.done input { text-decoration: line-through; color: var(--text-3); }
.subtask .icon-btn { opacity: 0; }
.subtask:hover .icon-btn { opacity: 1; }
.subtask-add { display: flex; align-items: center; gap: 10px; padding: 7px 0; color: var(--text-3); }
.subtask-add svg { width: 17px; height: 17px; }
.subtask-add input { flex: 1; border: 0; outline: none; background: none; font-size: 13.5px; }
.sub-progress { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-bottom: 4px; }
.sub-progress i { display: block; height: 100%; background: var(--success); transition: width .25s; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drawer-foot .stamp { font-size: 12px; color: var(--text-3); }

/* ---------- toasts & modals ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 16px; min-width: 260px; max-width: calc(100vw - 32px);
  background: #1f2030; color: #f3f3f8; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13.5px;
  animation: toastIn .22s cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme="dark"] .toast { background: #2c2d3c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #2c2d3c; } }
.toast span { flex: 1; }
.toast button { color: #a9a8ff; font-weight: 700; padding: 6px 10px; border-radius: 8px; }
.toast button:hover { background: rgba(255, 255, 255, .08); }
.toast.error { background: var(--danger); }
.toast.error button { color: #fff; }
.toast.out { animation: toastOut .18s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 10, 20, .4); backdrop-filter: blur(2px); z-index: 90;
  display: grid; place-items: center; padding: 16px; animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  animation: pop .18s cubic-bezier(.2, .8, .2, 1);
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 8px 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.modal-foot .left { margin-right: auto; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }
.shortcuts { display: grid; grid-template-columns: 1fr auto; gap: 10px 20px; font-size: 13.5px; align-items: center; }
.shortcuts span { color: var(--text-2); }
.shortcuts kbd { justify-self: end; }
.scrim { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .drawer.open { position: fixed; right: 0; top: 0; bottom: 0; z-index: 60; box-shadow: var(--shadow-lg); }
}
@container (max-width: 940px) {
  .today-grid { grid-template-columns: minmax(0, 1fr); }
  .side-col { position: static; display: grid; grid-template-columns: 1fr 1fr; }
  .side-col .progress-card { grid-column: 1 / -1; }
  .cal-wrap { grid-template-columns: minmax(0, 1fr); }
  .day-panel { position: static; }
  .day-panel .body { max-height: none; }
}
@container (max-width: 640px) {
  .side-col { grid-template-columns: minmax(0, 1fr); }
  .side-col .card:has(.mini-cal) { order: 2; }
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-chip, .cal-dots.wide { display: none; }  /* узкая сетка — только ряд точек под числом */
  .cal-dots.narrow { display: flex; justify-content: center; gap: 1.5px; padding: 0; flex-wrap: nowrap; }
  .cal-dots.narrow .cd-more { font-size: 9px; }
  .cal-dots.narrow .cd { width: 6px; height: 6px; }
  .cal-dots.narrow .cd-proj { width: 4px; height: 4px; }
  .cal-add { display: none; }
  .cal-head div { padding: 8px 4px; text-align: center; font-size: 10.5px; }
  .cal-num { margin: 0 auto 2px; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%; max-height: 84dvh; z-index: 70;
    border-right: 0; border-radius: 22px 22px 0 0; padding: 8px 16px calc(16px + var(--sab));
    transform: translateY(105%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 10, 20, .4); z-index: 65; animation: fade .2s; }
  .sheet-handle { display: block; }
  .sidebar .brand { display: none; }
  .sidebar .nav-item { height: 46px; font-size: 15px; }
  .sidebar .search { height: 44px; }
  .sidebar .search kbd, #helpBtn { display: none; }
  .avatar-btn { display: grid; }
  .tabbar { display: grid; }
  .topbar { padding: calc(14px + var(--sat)) calc(16px + var(--sar)) 10px calc(16px + var(--sal)); }
  .topbar h1 { font-size: 21px; }
  .view { padding: 4px 16px calc(96px + var(--sab)); }
  .offline-bar { margin: 0 16px 8px; }
  .toasts { bottom: calc(84px + var(--sab)); }
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { max-width: 100%; border-radius: 22px 22px 0 0; border-bottom: 0; padding-bottom: var(--sab);
    animation: sheetUp .26s cubic-bezier(.2, .8, .2, 1); max-height: min(92dvh, calc(100dvh - var(--sat) - 8px)); overflow-y: auto; }
  .modal-backdrop.sheet .quick-add { margin: 0; }
  .acc-hero { grid-template-columns: auto minmax(0, 1fr); }
  .acc-stats { grid-column: 1 / -1; }
  .acc-tabs { margin: 0 -16px 16px; padding: 0 16px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .drawer.open { width: 100%; left: 0; }
  .drawer-inner { width: 100%; }
  .task-actions { display: none; }
  .qa-hint { display: none !important; }
  .week-strip { grid-template-columns: repeat(7, 1fr); }
  .week-strip .icon-btn { display: none; }
  .topbar-actions .btn span { display: none; }
  .qa-chips, .qa-hint, .qa-warn, .qa-slots { padding-left: 14px; }
  .qa-slots { padding-bottom: 6px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }  /* ряд не выше 36px; край — намёк на прокрутку */
  .qa-slot { height: 30px; padding: 0 12px; font-size: 14px; }
  /* 16px — iOS не увеличивает страницу при фокусе поля */
  .qa-field, .day-panel .qa-field { font-size: 16px; }
  .qa-ac { left: 8px; width: calc(100% - 16px); }
  .qa-ac-item { min-height: 44px; font-size: 15px; }
  .qa-ac-list { max-height: min(264px, 38vh); }
  .modal .qa-ac-list { max-height: min(240px, calc(var(--vv-h, 100dvh) * .34)); }
  .qa-opt { height: 38px; }
  /* лист «Новая задача» держится над экранной клавиатурой (visualViewport), поле не перекрывается */
  .modal-backdrop.sheet { bottom: auto; top: var(--vv-top, 0px); height: min(var(--vv-h, 100dvh), 100dvh); }
  .modal-backdrop.sheet .modal { max-height: calc(min(var(--vv-h, 100dvh), 100dvh) - 12px - var(--sat)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@keyframes sheetUp { from { transform: translateY(40px); opacity: .4; } }
.sheet-handle { display: none; width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 2px auto 6px; flex: none; }
.menu-btn { display: none !important; }

/* ---------- пользователь ---------- */
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 11px; transition: background .12s; min-width: 0;
}
.user-chip:hover, .user-chip.active { background: var(--surface-2); }
.user-chip .user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-chip b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip.has-error small { color: var(--danger); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, #8b5cf6, var(--accent));
}
.avatar.xl { width: 64px; height: 64px; font-size: 22px; }
.avatar-btn {
  display: none; width: 36px; height: 36px; border-radius: 50%; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, #8b5cf6, var(--accent)); position: relative; flex: none;
}
.avatar-btn.has-error::after, .user-chip.has-error .avatar::after {
  content: ""; position: absolute; top: -1px; right: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); border: 2px solid var(--bg);
}
.user-chip .avatar { position: relative; }

/* ---------- нижняя панель (телефон) ---------- */
.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 55; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
  padding: 6px calc(6px + var(--sar)) calc(6px + var(--sab)) calc(6px + var(--sal)); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 4px; color: var(--text-3); font-size: 11px; font-weight: 600;
  position: relative; border-radius: 12px; -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 23px; height: 23px; stroke-width: 1.9; }
.tab.active { color: var(--accent-text); }
.tab em {
  position: absolute; top: 1px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; font-style: normal;
  font-size: 10.5px; line-height: 17px; text-align: center; background: var(--accent); color: #fff;
}
.tab em:empty { display: none; }
.tab em.alert { background: var(--danger); }
.tab-add {
  justify-self: center; width: 52px; height: 52px; border-radius: 17px; display: grid; place-items: center; color: #fff; margin-top: -18px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent);
  -webkit-tap-highlight-color: transparent; transition: transform .1s;
}
.tab-add:active { transform: scale(.94); }
.tab-add svg { width: 26px; height: 26px; stroke-width: 2.6; }

/* ---------- события календарей ---------- */
.events-block { display: flex; flex-direction: column; gap: 6px; padding: 8px 0 6px; }
.event {
  display: flex; gap: 10px; align-items: stretch; padding: 8px 10px 8px 8px; border-radius: 10px; cursor: pointer;
  background: color-mix(in srgb, var(--ev) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ev) 22%, transparent);
  transition: background .12s;
}
.event:hover { background: color-mix(in srgb, var(--ev) 15%, var(--surface)); }
.ev-bar { width: 4px; border-radius: 2px; background: var(--ev); flex: none; }
.ev-body { min-width: 0; flex: 1; }
.ev-title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; color: var(--text-3); margin-top: 1px; }
.ev-meta span { display: inline-flex; align-items: center; gap: 3px; min-width: 0; }
.ev-meta svg { width: 12px; height: 12px; }
.ev-time { color: color-mix(in srgb, var(--ev) 70%, var(--text)); font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-chip.ev { border-left-color: var(--ev); background: color-mix(in srgb, var(--ev) 14%, var(--surface)); }
.cal-chip.ev:hover { background: color-mix(in srgb, var(--ev) 22%, var(--surface)); }
.cal-chip .ev-ico { width: 12px; height: 12px; flex: none; color: var(--ev); margin-left: -1px; }
.upnext-item .ev-ico { width: 13px; height: 13px; flex: none; color: var(--ev); margin: 0 -2px 0 -2px; }
.mini-day .dots i.ev { border-radius: 1px; }
.ev-cal svg { color: var(--ev); }
.ev-modal-title { display: flex; align-items: center; gap: 10px; }
.ev-modal-title i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.ev-details > div { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.ev-details > div svg { color: var(--text-3); margin-top: 1px; }
.ev-details small { color: var(--text-3); }
.ev-details > div > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
/* окно события: высота ограничена экраном, заголовок и кнопки на месте, прокручивается только содержимое
   (раньше окно росло вместе с описанием: заголовок сверху, данные и кнопки уходили за нижний край экрана) */
.modal.ev-modal { display: flex; flex-direction: column; overflow: hidden; max-height: calc(100vh - 32px); max-height: min(760px, calc(100dvh - 32px)); }
.ev-modal .modal-head, .ev-modal .modal-foot { flex: none; }
.ev-modal .modal-head h3 { min-width: 0; overflow-wrap: anywhere; }
.ev-modal .modal-body { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.ev-modal .modal-foot { border-top: 1px solid var(--border); }
.ev-modal .modal-foot .btn { white-space: nowrap; }
@media (max-width: 860px) {
  .modal.ev-modal { overflow: hidden; max-height: calc(92vh - var(--sat)); max-height: min(92dvh, calc(100dvh - var(--sat) - 8px)); }
}
/* «Календари» в меню (календари подключений как списки) и страница календаря */
.nav-sub-head { padding: 6px 10px 2px 12px; font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.nav-item.cal-item { padding: 0 3px 0 0; gap: 0; }
.cal-item .cal-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; align-self: stretch; padding-left: 10px; color: inherit; }
.cal-item.off .cal-link { color: var(--text-3); }
.cal-item.off .dot { opacity: .35; }
.cal-eye { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--text-3); flex: none; }
.cal-eye:hover { background: var(--surface-3); color: var(--text); }
.cal-eye svg { width: 16px; height: 16px; }
.nav-item.cal-connect { width: 100%; color: var(--text-3); text-align: left; }
.nav-item.cal-connect svg { width: 16px; height: 16px; margin: 0 3px; }
.nav-item.cal-connect:hover { color: var(--accent-text); }
.calsrc-title { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.calsrc-title .dot { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.calsrc-head { padding: 12px 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.calsrc-row { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.calsrc-label { font-size: 13px; font-weight: 600; color: var(--text-3); }
.calsrc-hidden { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-2); }
.calsrc-hidden svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--text-3); }
.cal-swatches { gap: 6px; }
.cal-swatches .swatch { width: 28px; height: 28px; }
.cal-picker .cal-swatches { padding: 0 0 8px 30px; }
.cal-picker .cal-swatches .swatch { width: 24px; height: 24px; }
.pre { white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
/* узкая сетка месяца: задачи — сплошные полоски цвета приоритета, события — контурные цвета календаря */
@container (max-width: 640px) {
  .cal-chip.ev { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ev); }
  .cal-chip .ev-ico { display: none; }
}

/* ---------- вход ---------- */
body.auth-mode { overflow: auto; }
body.auth-mode .app, body.auth-mode .tabbar { display: none; }
.auth-root { min-height: 100dvh; padding-top: var(--sat); padding-bottom: var(--sab); }
.auth {
  min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 440px); gap: 56px; align-items: center; justify-content: center;
  padding: 32px 16px; background:
    radial-gradient(800px 400px at 15% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(600px 400px at 110% 110%, color-mix(in srgb, #ec4899 12%, transparent), transparent 70%), var(--bg);
}
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 30px 30px 24px; box-shadow: var(--shadow); }
.auth-card .brand { padding: 0 0 18px; }
.auth-card h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.auth-sub { margin: 0 0 18px; color: var(--text-2); }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .input { height: 44px; font-size: 15px; }
.auth-card .input-wrap .clear { top: 10px; }
.btn.block { width: 100%; justify-content: center; height: 46px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: default; }
.auth-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: -4px 0 -6px; }
.auth-more { margin: 2px 0 0; }
.auth-more > summary { cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 600; padding: 4px 0; list-style-position: inside; }
.auth-more[open] > summary { margin-bottom: 8px; }
.auth-server-state { display: block; min-height: 16px; margin-top: 4px; font-size: 12px; color: var(--text-3); }
.auth-server-state.ok { color: var(--success); }
.auth-server-state.bad { color: var(--danger); }
.auth-switch { margin-top: 16px; text-align: center; color: var(--text-2); font-size: 13.5px; }
.auth-switch button, .link-btn { color: var(--accent-text); font-weight: 600; }
.auth-switch button:hover, .link-btn:hover { text-decoration: underline; }
.auth-aside h3 { font-size: 22px; margin: 0 0 18px; letter-spacing: -.02em; }
.auth-aside ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-aside li { display: flex; gap: 14px; align-items: flex-start; color: var(--text-2); }
.auth-aside li svg { width: 22px; height: 22px; padding: 8px; box-sizing: content-box; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--accent); }
.auth-aside b { color: var(--text); }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text);
  font-size: 13px; margin-bottom: 12px;
}
.notice.subtle { background: var(--surface-2); color: var(--text-2); }
.notice.warn { background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.notice svg { width: 16px; height: 16px; margin-top: 1px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 480px); gap: 28px; align-content: start; padding-top: 28px; }
  .auth-card { padding: 24px 20px 20px; }
  .auth-aside { padding: 0 6px; }
}

/* ---------- личный кабинет ---------- */
.account { max-width: 920px; }
.acc-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 20px; margin-bottom: 14px; }
.acc-hero h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.acc-hero-text { min-width: 0; }
.acc-hero-text > div { overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); font-size: 11.5px; font-weight: 600; }
.acc-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.acc-stats div { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; text-align: center; min-width: 72px; }
.acc-stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.acc-stats span { font-size: 11.5px; color: var(--text-3); }
.acc-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.acc-tabs::-webkit-scrollbar { display: none; }
.acc-tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; font-weight: 600; color: var(--text-2); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.acc-tab svg { width: 16px; height: 16px; }
.acc-tab:hover { color: var(--text); }
.acc-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.acc-body { display: flex; flex-direction: column; gap: 14px; }
.acc-card { padding: 18px 20px; }
.acc-card h3 { margin: 0 0 14px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.acc-card h3 svg { width: 17px; height: 17px; color: var(--text-3); }
.acc-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.acc-card-head h3 { margin: 0; }
.acc-form { display: flex; flex-direction: column; gap: 14px; }
.acc-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.acc-actions.start { justify-content: flex-start; margin: 12px 0 4px; }
.acc-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 10px 2px 0; }
.acc-loading { display: flex; align-items: center; gap: 10px; color: var(--text-3); padding: 12px 0; }
.error-text { color: var(--danger); font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
.error-text svg { width: 14px; height: 14px; margin-top: 2px; }
.warn-text { color: var(--p2); font-size: 13px; background: color-mix(in srgb, var(--p2) 10%, transparent); padding: 10px 12px; border-radius: 10px; margin: 0; }
.warn-text a { text-decoration: underline; font-weight: 600; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { flex: 1; min-width: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.steps { margin: 0; padding-left: 20px; color: var(--text-2); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.steps a, .acc-card p a { color: var(--accent-text); font-weight: 600; }
code { background: var(--surface-2); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
details.howto { margin: -2px 0 12px; font-size: 13px; }
details.howto summary { cursor: pointer; color: var(--accent-text); font-weight: 600; margin-bottom: 8px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block;
  animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; cursor: pointer; }
.switch-row span { display: flex; flex-direction: column; min-width: 0; }
.switch-row small { color: var(--text-3); font-size: 12.5px; }
.switch {
  appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 12px; background: var(--surface-3); position: relative;
  flex: none; cursor: pointer; transition: background .15s; margin: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .18s cubic-bezier(.2, .8, .2, 1);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:disabled { opacity: .5; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap; flex: none;
}
.badge svg { width: 12px; height: 12px; stroke-width: 3; }
.badge.ok { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.badge.error { background: var(--danger-soft); color: var(--danger); }
.badge.syncing { background: var(--accent-soft); color: var(--accent-text); }
.badge .spinner { width: 10px; height: 10px; border-width: 1.5px; }

.integ-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); gap: 14px; }
.integ { padding: 16px 18px; display: flex; flex-direction: column; }
.integ-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.integ-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.integ-title small { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.integ-logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--surface-2); border: 1px solid var(--border); }
.integ-logo svg { width: 22px; height: 22px; }
.integ-logo.apple { background: #111; color: #fff; border-color: #111; }
.integ-logo.ics { color: #8b5cf6; }
.integ-logo.other { color: #f43f5e; }
.integ-status { font-size: 12.5px; margin-bottom: 4px; }
.integ .switch-row { border-top: 1px solid var(--border); }
.integ-foot { display: flex; gap: 8px; justify-content: flex-end; padding-top: 12px; margin-top: auto; border-top: 1px solid var(--border); }
.cal-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 0 0 10px; }
.cal-picker { display: flex; flex-direction: column; gap: 2px; padding: 0 0 10px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.check-row:hover { background: var(--surface-2); }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); }
.check-row i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.check-row small { color: var(--text-3); }
.push-target { padding: 0 0 10px; }
.connect p { margin: 0 0 12px; }

.sessions { display: flex; flex-direction: column; }
.session-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.session-row:first-child { border-top: 0; }
.session-row > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.session-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); flex: none; }

/* мобильные переопределения — после базовых правил компонентов */
@media (max-width: 860px) {
  .tabbar, .avatar-btn { display: grid; }
  .sheet-handle { display: block; }
  .avatar-btn[hidden] { display: none; }
  .toasts { top: calc(10px + var(--sat)); bottom: auto; }
  .acc-stats { gap: 6px; }
  .acc-stats div { min-width: 0; padding: 8px 4px; }
  .acc-stats b { font-size: 17px; }
  .acc-stats span { display: block; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-title .subtitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- мастер подключения календарей ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn.lg { height: 40px; padding: 0 16px; font-size: 14px; border-radius: 10px; }
.btn.outline { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent-text); justify-content: center; }
.btn.outline:hover { background: var(--accent-soft); border-color: var(--accent); }
.input.lg, .select.lg { height: 42px; font-size: 15px; border-radius: 10px; }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent); }
.field-help { color: var(--text-3); font-size: 12.5px; overflow-wrap: anywhere; }
.integ-logo.sm { width: 32px; height: 32px; border-radius: 10px; }
.integ-logo.sm svg { width: 18px; height: 18px; }
.integ-logo.xl { width: 56px; height: 56px; border-radius: 16px; }
.integ-logo.xl svg { width: 30px; height: 30px; }
.integ-logo.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.integ-logo.microsoft, .integ-logo.google, .integ-logo.nextcloud { background: #fff; border-color: var(--border); }
.integ-logo.yandex { background: #fff; border-color: var(--border); }
.integ-logo.fastmail { color: #fff; background: #2b5fd9; border-color: #2b5fd9; }
.integ-logo.other { color: #0ea5e9; }
.integ-logo.apple { background: #111; color: #fff; border-color: #111; }
:root[data-theme="dark"] .integ-logo.apple { background: #f2f2f5; color: #111; border-color: #f2f2f5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .integ-logo.apple { background: #f2f2f5; color: #111; border-color: #f2f2f5; } }

.connect-hub { padding: 18px 20px 20px; }
.connect-hub-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.connect-hub-head h3 { margin: 0 0 4px; font-size: 16px; }
.connect-hub-head p { margin: 0; color: var(--text-2); font-size: 13px; }
.provider-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.provider-tile {
  display: flex; align-items: center; gap: 12px; padding: 12px; min-height: 64px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); text-align: left; min-width: 0; transition: border-color .12s, box-shadow .12s, transform .08s;
}
.provider-tile:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow); }
.provider-tile:active { transform: translateY(1px); }
.provider-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 12px; }
.provider-tile-text { display: flex; flex-direction: column; min-width: 0; }
.provider-tile b { font-size: 13.5px; line-height: 1.25; }
.provider-tile small { color: var(--text-3); font-size: 12px; line-height: 1.3; margin-top: 2px; }
.provider-grid.in-wiz { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.badge.warn { background: color-mix(in srgb, var(--p2) 16%, transparent); color: var(--p2); }
.reauth-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 2px 0 8px; border-radius: 10px;
  background: color-mix(in srgb, var(--p2) 11%, var(--surface)); border: 1px solid color-mix(in srgb, var(--p2) 35%, transparent);
}
.reauth-bar > svg { width: 18px; height: 18px; color: var(--p2); }
.reauth-bar > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reauth-bar small { color: var(--text-2); font-size: 12.5px; }
.integ-status .link-btn { font-size: 12.5px; }

.wiz-backdrop { z-index: 95; }
.modal.wiz { max-width: 600px; display: flex; flex-direction: column; max-height: min(800px, calc(100dvh - 32px)); overflow: hidden; }
.wiz-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 4px; }
.wiz-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 17px; letter-spacing: -.01em; outline: none; overflow-wrap: anywhere; }
.wiz-steps { list-style: none; margin: 0; padding: 10px 20px 2px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wiz-steps li { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.wiz-steps li::before { content: ""; height: 4px; border-radius: 2px; background: var(--surface-3); transition: background .2s; }
.wiz-steps li span { display: inline-flex; align-items: center; gap: 4px; }
.wiz-steps li svg { width: 12px; height: 12px; stroke-width: 3; }
.wiz-steps li.done { color: var(--success); }
.wiz-steps li.done::before { background: var(--success); }
.wiz-steps li.current { color: var(--accent-text); }
.wiz-steps li.current::before { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.wiz-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.wiz-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.wiz-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.wiz-foot-left, .wiz-foot-right { display: flex; gap: 8px; align-items: center; }
.wiz-foot-right { margin-left: auto; }
.wiz-foot:has(.wiz-foot-left:empty):has(.wiz-foot-right:empty) { display: none; }
.wiz-lead { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.wiz a.link, .form-error a { color: var(--accent-text); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.wiz a.link .ext { width: 12px; height: 12px; margin-left: 2px; vertical-align: -1px; }
.wiz .muted.small { margin: 0; }
.wiz-hero { display: flex; gap: 16px; align-items: flex-start; }
.wiz-hero > div { min-width: 0; }
.wiz-hero h3 { margin: 2px 0 4px; font-size: 16px; line-height: 1.35; }
.wiz-hero p { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.5; }
.wiz-list { margin: 0; padding: 0; list-style: none; counter-reset: wl; display: flex; flex-direction: column; gap: 10px; }
.wiz-list li { counter-increment: wl; position: relative; padding: 1px 0 0 36px; min-height: 24px; font-size: 13.5px; color: var(--text); line-height: 1.5; }
.wiz-list li::before {
  content: counter(wl); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700;
}
.wiz .notice { margin: 0; }
.wiz .warn-text { display: flex; gap: 8px; align-items: flex-start; }
.wiz .warn-text svg { width: 15px; height: 15px; margin-top: 1px; flex: none; }
.suggest { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 12px; background: var(--accent-soft); animation: pop .2s cubic-bezier(.2, .8, .2, 1); }
.suggest > div { display: flex; flex-direction: column; min-width: 0; }
.suggest b { font-size: 14.5px; }
.suggest small { color: var(--text-2); font-size: 13px; }
.wiz-question { display: flex; flex-direction: column; gap: 4px; }
.wiz-question > b { font-size: 15px; }
.wiz-question > small { color: var(--text-3); font-size: 13px; margin-bottom: 6px; }
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); text-align: left; transition: border-color .12s, background .12s;
}
.option-btn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 50%, var(--surface)); }
.option-btn > span:not(.integ-logo) { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.option-btn small { color: var(--text-3); font-size: 12.5px; }
.option-btn .chev { color: var(--text-3); width: 16px; height: 16px; }
.alt-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--border-strong); }
.alt-card > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.alt-card small { color: var(--text-3); font-size: 12.5px; }
.form-error {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft);
  color: var(--danger); font-size: 13px; line-height: 1.45; animation: pop .18s ease-out;
}
.form-error > svg { width: 16px; height: 16px; margin-top: 1px; }
.form-error > div { min-width: 0; overflow-wrap: anywhere; }
.form-error-hint { color: var(--text); margin-top: 3px; }
.wiz-safe { display: flex; gap: 8px; align-items: flex-start; }
.wiz-safe svg { width: 14px; height: 14px; margin-top: 2px; }
.input-wrap .input.lg + .eye { top: 9px; }

.wiz-wait { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 18px 8px 6px; }
.wiz-wait b { font-size: 15.5px; }
.wiz-wait small { color: var(--text-2); font-size: 13px; max-width: 380px; line-height: 1.5; }
.wait-ring { position: relative; padding: 10px; margin-bottom: 6px; }
.wait-ring::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
.wait-ring .integ-logo { border-radius: 50%; }
.wiz-status { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.handoff-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); }
textarea.handoff-url { height: auto; min-height: 0; resize: none; font-size: 14px; line-height: 1.5; word-break: break-all; background: var(--surface); padding: 8px 10px; }
.handoff-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.setup-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.setup-steps > li { display: flex; gap: 12px; padding: 0 0 16px; position: relative; }
.setup-steps > li:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 30px; bottom: 4px; width: 2px; background: var(--border); }
.setup-num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; }
.setup-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }
.setup-text > b { color: var(--text); font-size: 14px; margin-top: 3px; }
.setup-text > div > .field, .setup-text > div > .warn-text { margin-top: 10px; }

.howto-group { display: flex; flex-direction: column; gap: 6px; }
details.howto-item { border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
details.howto-item summary { cursor: pointer; padding: 10px 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; list-style: none; }
details.howto-item summary::-webkit-details-marker { display: none; }
details.howto-item summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .15s; }
details.howto-item[open] summary::after { transform: rotate(225deg); }
details.howto-item summary svg { width: 16px; height: 16px; }
details.howto-item > div { padding: 0 12px 12px; }

.cal-choice { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: 12px; padding: 6px; max-height: 300px; overflow-y: auto; }
.check-row.lg { padding: 9px 8px; font-size: 14px; }
.check-row.lg small { margin-left: 4px; font-size: 12px; }
.check-row input:disabled + i { opacity: .5; }
.switch-row.boxed { padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; }

.wiz-success { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 24px 8px 12px; }
.wiz-success h3 { margin: 8px 0 0; font-size: 18px; }
.wiz-success p { margin: 0; color: var(--text-2); font-size: 13.5px; overflow-wrap: anywhere; }
.wiz-success small { color: var(--text-3); font-size: 12.5px; }
.success-art {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: var(--success); box-shadow: 0 0 0 10px color-mix(in srgb, var(--success) 14%, transparent); animation: pop .3s cubic-bezier(.2, .8, .2, 1.4);
}
.success-art svg { width: 36px; height: 36px; stroke-width: 3; }

@media (max-width: 1100px) { .provider-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .connect-hub { padding: 16px; }
  .connect-hub-head { flex-direction: column; align-items: stretch; }
  .connect-hub-head .btn { justify-content: center; height: 46px; }
  .provider-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .provider-tile { padding: 10px; gap: 10px; }
  .provider-tile .integ-logo { width: 34px; height: 34px; border-radius: 10px; }
  .provider-tile .integ-logo svg { width: 19px; height: 19px; }
  .reauth-bar { flex-wrap: wrap; }
  .integ-head .badge.warn { display: none; }
  .reauth-bar .btn { width: 100%; justify-content: center; height: 36px; }
  .modal.wiz {
    height: calc(100dvh - 10px - var(--sat)); max-height: none; overflow: hidden; padding-bottom: 0;
  }
  .wiz-head { padding: 4px 16px 2px; }
  .wiz-steps { padding: 8px 16px 2px; }
  .wiz-body { padding: 14px 16px 18px; }
  .wiz-foot { padding: 10px 16px calc(12px + var(--sab)); flex-wrap: wrap; }
  .wiz-foot-right { flex: 1; justify-content: flex-end; }
  .wiz-foot .btn { height: 44px; }
  .wiz-foot-right .btn.primary { flex: 1; justify-content: center; max-width: 320px; }
  .wiz-hero { gap: 12px; }
  .wiz-hero .integ-logo.xl { width: 44px; height: 44px; border-radius: 13px; }
  .wiz-hero .integ-logo.xl svg { width: 24px; height: 24px; }
  .hide-sm { display: none; }
  .input.lg, .select.lg { font-size: 16px; }
  .cal-choice { max-height: none; }
}

/* ---------- общие пространства ---------- */
.sidebar > .nav-section.spaces.no-spaces { order: 1; }
.sidebar > .sidebar-foot { order: 2; }
.sp-ico {
  --c: var(--accent); width: 22px; height: 22px; border-radius: 7px; display: inline-grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c);
}
.sp-ico svg { width: 14px; height: 14px; stroke-width: 2.2; }
.sp-ico .emoji { font-size: 13px; line-height: 1; }
.sp-ico.t-couple { --c: #ec4899; } .sp-ico.t-family { --c: #f59e0b; } .sp-ico.t-neighbors { --c: #14b8a6; }
.sp-ico.t-friends { --c: #0ea5e9; } .sp-ico.t-trip { --c: #8b5cf6; } .sp-ico.t-team { --c: #6366f1; }
.sp-ico.lg { width: 30px; height: 30px; border-radius: 9px; }
.sp-ico.lg svg { width: 18px; height: 18px; }
.sp-ico.xl { width: 56px; height: 56px; border-radius: 17px; }
.sp-ico.xl svg { width: 28px; height: 28px; stroke-width: 2; }
.sp-title { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.sp-title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mini-av {
  --c: var(--accent); width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--c); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; letter-spacing: 0;
  box-shadow: 0 0 0 2px var(--surface);
}
.mini-av.xs { width: 16px; height: 16px; font-size: 9px; box-shadow: none; }
.mini-av.lg { width: 38px; height: 38px; font-size: 15px; }

.nav-item.space-item { gap: 9px; }
.nav-item.space-item .sp-ico { margin: 0 -2px; }
.nav-item .sp-avs { display: inline-flex; flex: none; }
.nav-item .sp-avs .mini-av { margin-left: -4px; box-shadow: 0 0 0 2px var(--surface); }
.nav-item em.unread {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px;
  font-weight: 700; line-height: 18px; text-align: center;
}
.nav-item.sub { height: 32px; padding-left: 22px; font-size: 13.5px; }
.nav-item.sub .dot { width: 8px; height: 8px; }
.nav-item.space-add { width: 100%; color: var(--text-3); font-weight: 500; text-align: left; }
.nav-item.space-add svg { width: 16px; height: 16px; margin: 0 3px; }
.nav-item.space-add:hover { color: var(--accent-text); }

/* задача: ответственный и отметка общего списка */
.task-who { flex: none; display: grid; place-items: center; margin-top: 1px; }
.task-who.together { width: 22px; height: 22px; border-radius: 50%; color: var(--text-3); background: var(--surface-2); }
.task-who.together svg { width: 14px; height: 14px; }
.meta .tg, .crumb .tg { width: 12px; height: 12px; color: var(--text-3); margin-left: 2px; }
.crumb .tg { margin-left: 6px; }
.shared-mark { display: inline-grid; place-items: center; margin-left: 8px; color: var(--text-3); vertical-align: 1px; }
.shared-mark svg { width: 18px; height: 18px; }
.shared-note { display: flex; gap: 8px; align-items: center; margin: 0; }
.shared-note svg { width: 15px; height: 15px; }

/* «Сегодня»: фильтр и карточки */
.who-filter { display: flex; gap: 6px; margin: -6px 0 14px; flex-wrap: wrap; }
.who-filter .pill { height: 30px; border-radius: 15px; padding: 0 12px; }
.together-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; margin: -6px 0 16px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), color-mix(in srgb, var(--accent-2) 6%, var(--surface)));
  border-color: color-mix(in srgb, var(--accent) 18%, var(--border));
}
.together-art { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--accent); background: var(--accent-soft); }
.together-art svg { width: 20px; height: 20px; }
.together-card .sp-ico.together-art { width: 38px; height: 38px; border-radius: 12px; }
.together-card .sp-ico.together-art svg { width: 20px; height: 20px; }
.together-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.together-text b { font-size: 14px; }
.together-text small { color: var(--text-2); font-size: 12.5px; line-height: 1.4; }

.busy-card { margin: 0 0 20px; padding-bottom: 12px; }
.busy-card .card-head { padding-bottom: 6px; gap: 10px; }
.busy-card .card-head h3 { display: flex; align-items: center; gap: 8px; }
.busy-card .card-head h3 svg { width: 16px; height: 16px; color: var(--accent); }
.busy-rows { display: flex; flex-direction: column; gap: 8px; padding: 2px 16px 0; }
.busy-row { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 12px; align-items: center; }
.busy-who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.busy-who > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.busy-who b { font-size: 13px; }
.busy-who small { font-size: 11.5px; color: var(--success); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.busy-who small.is-busy { color: var(--p2); }
.busy-track { position: relative; height: 22px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bz { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; }
.bz.busy {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--text-3) 55%, transparent) 0 4px, color-mix(in srgb, var(--text-3) 35%, transparent) 4px 8px);
}
.bz.mine { background: color-mix(in srgb, var(--c) 45%, transparent); }
.bz.task { background: var(--c); }
.bz-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--danger); border-radius: 1px; }
.busy-row.scale { margin-top: -4px; }
.busy-scale { position: relative; height: 14px; font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.busy-scale span { position: absolute; transform: translateX(-50%); }
.busy-scale span:first-child { transform: none; }
.spinner.muted { color: var(--text-3); }

/* карточка задачи: кто делает */
.field-label-note { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.who-seg .pill.who { padding-left: 6px; }
.who-seg .pill.who svg { width: 15px; height: 15px; }
.switch-row.compact { padding: 6px 0 0; }
.switch-row.compact b { font-size: 13px; }
.who-hint { line-height: 1.5; }

/* мастер пространства и приглашение */
.modal.sp-wiz { max-width: 560px; }
.sp-wiz .modal-head { gap: 8px; }
.sp-wiz .modal-head h3 { flex: 1; min-width: 0; }
.tpl-tile {
  display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  text-align: left; min-width: 0; transition: border-color .12s, box-shadow .12s, transform .08s;
}
.tpl-tile:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow); }
.tpl-tile:active { transform: translateY(1px); }
.tpl-tile .sp-ico { width: 38px; height: 38px; border-radius: 12px; }
.tpl-tile .sp-ico svg { width: 20px; height: 20px; }
.tpl-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tpl-text b { font-size: 14px; }
.tpl-text small { color: var(--text-3); font-size: 12px; line-height: 1.35; }
.tpl-tile.featured { padding: 16px; border-color: color-mix(in srgb, #ec4899 30%, var(--border));
  background: linear-gradient(120deg, color-mix(in srgb, #ec4899 8%, var(--surface)), color-mix(in srgb, var(--accent) 7%, var(--surface))); }
.tpl-tile.featured b { font-size: 16px; }
.tpl-tile.featured small { color: var(--text-2); font-size: 13px; }
.tpl-tile .chev { color: var(--text-3); }
.tpl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tpl-lists { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tpl-lists i { font-style: normal; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }
.tpl-lists.big i { font-size: 12.5px; padding: 4px 10px; }
.invite-box { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 18px; align-items: start; }
.invite-qr { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; border-radius: 14px; background: #fff; border: 1px solid var(--border); }
.invite-qr small { color: #6b6c7c; font-size: 11.5px; }
svg.qr { width: 100%; height: auto; display: block; stroke: none; }
.invite-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.invite-side .btn.lg { justify-content: center; }

/* страница пространства */
.space-hero { padding: 16px; margin: 0 0 20px; display: flex; flex-direction: column; gap: 14px; }
.members { display: flex; flex-wrap: wrap; gap: 10px 26px; }
.member-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.member-chip > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.member-chip b { font-size: 14px; }
.member-chip small { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.member-chip small.is-busy { color: var(--p2); }
.st-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none; }
.st-dot.busy { background: var(--p2); }
.space-invite-cta { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 7%, var(--surface-2)); }
.space-invite-cta > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.space-invite-cta small { color: var(--text-2); font-size: 12.5px; }
.sec-link { display: inline-flex; align-items: center; gap: 8px; }
.sec-link:hover { color: var(--accent-text); }
.sec-link .dot { width: 9px; height: 9px; border-radius: 50%; }
.section-head h2 small svg { width: 12px; height: 12px; vertical-align: -1px; margin-right: 3px; }
.section-head .btn.ghost.sm svg { width: 14px; height: 14px; }
.add-row.more { color: var(--text-3); font-size: 13px; padding-left: 36px; }
.feed-card { padding-bottom: 8px; }
.feed-card .card-head h3 { display: flex; align-items: center; gap: 8px; }
.feed-card .card-head h3 svg { width: 15px; height: 15px; color: var(--text-3); }
.feed { padding: 0 8px; display: flex; flex-direction: column; }
.feed-day { font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 10px 8px 2px; }
.feed-item { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 8px; font-size: 13px; line-height: 1.4; }
.feed-item.link { cursor: pointer; }
.feed-item.link:hover { background: var(--surface-2); }
.feed-item > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.feed-item time { font-size: 11.5px; color: var(--text-3); }
.feed-more { margin: 4px 16px 6px; font-size: 13px; }
.sp-members-edit { display: flex; flex-direction: column; }
.sp-member-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.sp-member-row > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sp-member-row small { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.danger-row { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-top: 4px; border-top: 1px solid var(--border); padding-top: 14px; }

/* приглашение */
.join-wrap { display: grid; place-items: start center; padding: 24px 0; }
.join-card { max-width: 520px; width: 100%; padding: 30px 28px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.join-card h2 { margin: 6px 0 0; font-size: 21px; letter-spacing: -.01em; line-height: 1.3; }
.join-card p { margin: 0; color: var(--text-2); line-height: 1.5; }
.join-art { width: 56px; height: 56px; border-radius: 17px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.join-art.warn { background: color-mix(in srgb, var(--p2) 14%, transparent); color: var(--p2); }
.join-art svg { width: 28px; height: 28px; }
.join-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0 4px; }
.invite-notice { background: var(--accent-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.invite-notice svg { color: var(--accent); }

/* список покупок */
.shop .task.shop-item { align-items: center; padding: 12px 6px 12px 4px; }
.shop .task.shop-item .check { width: 28px; height: 28px; border-radius: 9px; margin: 0; }
.shop .task.shop-item .check svg { width: 16px; height: 16px; }
.shop .task.shop-item .task-title { font-size: 15.5px; }
.shop .task.shop-item.done .check { background: var(--success); border-color: var(--success); }
.shop.done-part { opacity: .75; }
.shop-done-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 18px 0 2px; padding: 0 2px 6px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-3); }

@container (max-width: 640px) {
  .busy-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .busy-row.scale > div:first-child { display: none; }
  .members { flex-direction: column; }
}
@media (max-width: 860px) {
  .together-card { flex-wrap: wrap; }
  .together-card .together-text { flex-basis: calc(100% - 90px); }
  .together-card .btn { order: 3; flex: 1; justify-content: center; height: 38px; }
  .invite-box { grid-template-columns: minmax(0, 1fr); }
  .invite-qr { width: 200px; justify-self: center; }
  .block-sm { width: 100%; }
  .tpl-grid { grid-template-columns: minmax(0, 1fr); }
  .shop .task.shop-item .check { width: 30px; height: 30px; }
  .join-card { padding: 24px 18px 18px; }
  .join-actions .btn { flex: 1; justify-content: center; height: 44px; }
  .space-invite-cta { flex-wrap: wrap; }
  .space-invite-cta .btn { width: 100%; justify-content: center; }
  .sidebar .nav-item.sub { height: 40px; font-size: 14.5px; padding-left: 24px; }
}
.nav-item .sp-ico, .nav-item .sp-avs, .nav-item .mini-av { flex: none; overflow: visible; }
.field > label.switch-row { font-size: 14px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text); }
.sp-member-row .btn.sm + .btn.sm { margin-left: -4px; }
@media (max-width: 860px) { .sp-member-row { flex-wrap: wrap; } .sp-member-row > div { flex-basis: calc(100% - 40px); } }

/* ---------- расходы (web/js/expenses.js) ---------- */
:root { --pos: #15803d; --neg: #d9480f; }
:root[data-theme="dark"] { --pos: #4ade80; --neg: #fb8a5c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --pos: #4ade80; --neg: #fb8a5c; } }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.emo { font-size: 14px; line-height: 1; }
.sp-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -4px 0 18px; overflow-x: auto; scrollbar-width: none; }
.sp-tabs::-webkit-scrollbar { display: none; }
.sp-tab { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; font-weight: 600; color: var(--text-2); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sp-tab svg { width: 16px; height: 16px; }
.sp-tab:hover { color: var(--text); }
.sp-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.sp-tab .exp-badge { margin-left: 2px; }
.exp-badge { font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 9px; line-height: 16px; white-space: nowrap;
  font-variant-numeric: tabular-nums; flex: none; }
.exp-badge.pos { background: color-mix(in srgb, var(--pos) 13%, transparent); color: var(--pos); }
.exp-badge.neg { background: color-mix(in srgb, var(--neg) 13%, transparent); color: var(--neg); }
.nav-item .exp-badge { margin-left: auto; }
.nav-item .exp-badge + .sp-avs, .nav-item .exp-badge + em.unread { margin-left: 4px; }

.exp-hero { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; padding: 18px; margin: 0 0 14px; flex-wrap: wrap;
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 6%, var(--surface)), var(--surface) 70%); }
.exp-hero-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 260px; }
.exp-hero-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.exp-big { font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.exp-big.pos { color: var(--pos); } .exp-big.neg { color: var(--neg); }
.exp-owes { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.exp-owe { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.exp-owe b { font-variant-numeric: tabular-nums; }
.exp-hero-sub { font-size: 12.5px; }
.exp-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.exp-hero-actions .btn.lg svg { width: 17px; height: 17px; }

.exp-filters { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.exp-fline { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 1px; }
.exp-fline::-webkit-scrollbar { display: none; }
.exp-fline .pill { height: 30px; border-radius: 15px; padding: 0 12px; flex: none; }
.exp-fline .pill .mini-av { margin-left: -5px; }

.exp-list { padding: 4px 0; margin-bottom: 20px; }
.exp-day + .exp-day { border-top: 1px solid var(--border); }
.exp-day-head { display: flex; justify-content: space-between; padding: 10px 16px 4px; font-size: 12px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.exp-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 16px; text-align: left; border-radius: 0; }
.exp-row:hover { background: var(--surface-2); }
.exp-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; font-size: 19px; line-height: 1;
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface)); }
.exp-ico.transfer { color: var(--accent); background: var(--accent-soft); }
.exp-ico.transfer svg { width: 18px; height: 18px; }
.exp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.exp-main b { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-main small, .exp-amt small { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-amt { display: flex; flex-direction: column; align-items: flex-end; flex: none; line-height: 1.3; font-variant-numeric: tabular-nums; max-width: 45%; }
.exp-amt b { font-size: 15px; font-weight: 700; white-space: nowrap; }
.exp-amt small.pos { color: var(--pos); } .exp-amt small.neg { color: var(--neg); }
.exp-more { display: block; margin: 6px auto 8px; font-size: 13px; }
.exp-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 28px 20px; }
.exp-empty small { color: var(--text-2); max-width: 420px; line-height: 1.45; margin-bottom: 6px; }
.exp-empty-art { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.exp-empty-art svg { width: 24px; height: 24px; }

.exp-pad { padding: 0 16px 14px; }
.exp-totals .card-head h3, .exp-members .card-head h3, .exp-io .card-head h3 { display: flex; align-items: center; gap: 8px; }
.exp-totals .card-head h3 svg, .exp-members .card-head h3 svg, .exp-io .card-head h3 svg { width: 15px; height: 15px; color: var(--text-3); }
.exp-total { font-size: 15px; font-variant-numeric: tabular-nums; }
.exp-sub-h { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin: 10px 0 8px; }
.exp-bars { display: flex; flex-direction: column; gap: 9px; }
.exp-bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: 13px; }
.exp-bar-label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.exp-bar-label > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-bar-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.exp-bar { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.exp-bar i { display: block; height: 100%; border-radius: 4px; background: var(--c); }
.exp-mem { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.exp-mem + .exp-mem { border-top: 1px solid var(--border); }
.exp-mem > div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.exp-mem small { font-size: 12px; color: var(--text-3); }
.exp-mem > b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.exp-io-body { padding: 0 16px 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.exp-io-body small { flex-basis: 100%; line-height: 1.4; }

/* форма */
.modal.exp-modal { max-width: 580px; display: flex; flex-direction: column; max-height: min(880px, calc(100dvh - 32px)); overflow: hidden; }
.modal.exp-modal > form, .modal.exp-modal > div { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.exp-modal .modal-body { overflow-y: auto; min-height: 0; }
.exp-modal .modal-foot { border-top: 1px solid var(--border); padding-top: 12px; }
.exp-kind .pill { flex: 1; justify-content: center; height: 32px; }
.exp-amount { position: relative; display: flex; align-items: center; }
.exp-amount-input.input { height: 58px; font-size: 32px; font-weight: 700; letter-spacing: -.01em; padding: 0 44px 0 14px; border-radius: 12px; font-variant-numeric: tabular-nums; }
.exp-cur { position: absolute; right: 14px; font-size: 24px; font-weight: 600; color: var(--text-3); pointer-events: none; }
.exp-calc { font-size: 13px; color: var(--text-3); min-height: 17px; font-variant-numeric: tabular-nums; }
.exp-calc.err { color: var(--danger); }
.exp-cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.exp-cat { display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px;
  font-weight: 500; color: var(--text-2); background: var(--surface); min-width: 0; white-space: nowrap; overflow: hidden; }
.exp-cat span { font-size: 16px; }
.exp-cat:hover { border-color: var(--border-strong); color: var(--text); }
.exp-cat.active { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.exp-payers { display: flex; flex-direction: column; gap: 6px; }
.exp-prow { display: grid; grid-template-columns: auto minmax(0, 1fr) 130px; align-items: center; gap: 8px; font-size: 14px; }
.exp-num.input { height: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.exp-payers-left { font-size: 12.5px; }
.exp-payers-left.ok { color: var(--pos); } .exp-payers-left.warn { color: var(--p2); }
.exp-modes .pill { flex: 1; justify-content: center; }
.exp-mode-hint { font-size: 12.5px; }
.exp-split { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.exp-srow { display: grid; grid-template-columns: minmax(0, 1fr) auto 112px; align-items: center; gap: 8px; padding: 6px 10px; min-height: 46px; }
.exp-srow + .exp-srow { border-top: 1px solid var(--border); }
.exp-srow .exp-num { width: 110px; }
.exp-srow.off .exp-check span { color: var(--text-3); }
.exp-srow:has(> output:nth-child(2)) { grid-template-columns: minmax(0, 1fr) 112px; }
.exp-check { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; cursor: pointer; }
.exp-check span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; margin: 0; }
.exp-x { display: none; }
.exp-share { text-align: right; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.exp-share.muted { font-weight: 400; font-size: 12.5px; }
.exp-split-status { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; min-height: 18px; }
.exp-split-status svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.exp-split-status.ok { color: var(--pos); }
.exp-split-status.err { color: var(--danger); font-weight: 500; }
.exp-cur-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; padding: 0 2px; }
.exp-cur-row .select { max-width: 240px; }
.exp-cur-row[hidden] { display: none; }

/* рассчитаться */
.exp-settle-lead { margin: 0; line-height: 1.45; }
.exp-settle-list { display: flex; flex-direction: column; gap: 8px; }
.exp-tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.exp-tr.mine { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.exp-tr-who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.exp-tr-who > span { display: flex; flex-direction: column; margin-left: 6px; min-width: 0; line-height: 1.3; }
.exp-tr-who small { color: var(--text-3); font-size: 12px; }
.exp-tr-arrow { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.exp-tr-amt { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.exp-tr-actions { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.exp-settled { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px 0; text-align: center; }
.exp-settled svg { width: 36px; height: 36px; color: var(--pos); padding: 8px; border-radius: 50%; background: color-mix(in srgb, var(--pos) 12%, transparent); box-sizing: content-box; }
.exp-settled small { color: var(--text-2); }

/* импорт */
.modal.exp-import { max-width: 720px; }
.exp-csv.input { min-height: 180px; font-size: 12.5px; white-space: pre; }
.exp-file { align-self: flex-start; cursor: pointer; }
.exp-map { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.exp-map-row { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.exp-map-row small { font-weight: 400; }
.exp-table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 10px; max-height: 180px; }
.exp-table-wrap.tall { max-height: min(420px, 50dvh); }
.exp-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.exp-table th, .exp-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.exp-table th { background: var(--surface-2); font-weight: 600; color: var(--text-2); position: sticky; top: 0; }
.exp-table td.num, .exp-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.exp-table td svg { width: 14px; height: 14px; vertical-align: -2px; }
.exp-table td.ok { color: var(--pos); } .exp-table td.err { color: var(--danger); }
.exp-table tr.bad td { white-space: normal; background: color-mix(in srgb, var(--danger) 5%, transparent); }
.exp-im-sum { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; font-weight: 600; }
.exp-im-sum span { display: inline-flex; align-items: center; gap: 6px; }
.exp-im-sum svg { width: 16px; height: 16px; }

@container (max-width: 640px) {
  .exp-hero-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .exp-hero-actions .btn.primary { grid-column: 1 / -1; }
  .exp-hero-actions .btn { justify-content: center; }
}
@media (max-width: 860px) {
  .sp-tabs { margin: 0 -16px 14px; padding: 0 16px; }
  .exp-hero { padding: 16px; }
  .exp-big { font-size: 24px; }
  .exp-row { padding: 10px 12px; }
  .exp-day-head { padding: 10px 12px 4px; }
  .modal.exp-modal { max-height: min(94dvh, calc(100dvh - var(--sat) - 8px)); border-radius: 22px 22px 0 0; }
  .exp-modal .modal-foot { padding-bottom: 14px; }
  .exp-modal .modal-foot .btn { height: 44px; flex: 1; justify-content: center; font-size: 15px; }
  .exp-modal .modal-foot .btn.left { flex: 0 0 auto; }
  .exp-modal .modal-foot .btn.danger span { display: none; }
  .exp-modal .input, .exp-modal .select { font-size: 16px; }
  .exp-modal .exp-amount-input.input { height: 66px; font-size: 38px; }
  .exp-modal .field-row.exp-row2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .exp-cats { display: flex; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px 2px; }
  .exp-cats::-webkit-scrollbar { display: none; }
  .exp-cat { height: 40px; font-size: 14px; flex: none; }
  .exp-num.input { height: 38px; }
  .exp-srow { grid-template-columns: minmax(0, 1fr) 96px 88px; padding: 6px 8px; }
  .exp-srow .exp-num { width: 96px; }
  .exp-srow:has(> output:nth-child(2)) { grid-template-columns: minmax(0, 1fr) 96px; }
  .exp-modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .exp-modes .pill { padding: 0 4px; height: 34px; }
  .exp-kind .pill { height: 36px; }
  .exp-who-seg .pill.who, .exp-modal .who-seg .pill.who { height: 36px; }
  .exp-map { grid-template-columns: minmax(0, 1fr); }
  .exp-tr-actions .btn { flex: 1; justify-content: center; height: 38px; }
}

/* iOS Safari увеличивает страницу при фокусе поля со шрифтом меньше 16px (и шапка/нижняя панель «уезжают»).
   На узких экранах все поля ввода — не меньше 16px: быстрый ввод (поле и подложка подсветки — одним размером),
   поиск, вход, кабинет, мастер, расходы. Крупные поля (сумма расхода, заголовок задачи) остаются крупными.
   Проверка — backend/tests/ui/test_ui.js («mobile: inputs ≥ 16px»). */
@media (max-width: 860px) {
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="hidden"], [type="button"], [type="submit"], [type="reset"], [type="image"], .exp-amount-input),
  select, textarea:not(.title), .qa-field, .day-panel .qa-field { font-size: 16px !important; }
}
/* предупреждение о долге при исключении/выходе: на телефоне кнопки не помещаются в строку — «Всё равно…» отдельной строкой */
@media (max-width: 860px) {
  .sp-balance-foot { flex-wrap: wrap; }
  .sp-balance-foot .btn { flex: 1; justify-content: center; height: 44px; }
  .sp-balance-foot .btn.left { flex-basis: 100%; order: 3; margin-right: 0; }
}

/* Ссылки на страницу скачивания /download (web/download.html): вход, кабинет, лист «Ещё» на телефоне; в приложении — скрыты */
.auth-dl { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; font-size: 13px; color: var(--text-3); text-decoration: none; }
.auth-dl svg { width: 15px; height: 15px; }
.auth-dl:hover { color: var(--accent-text); }
.nav-dl { display: none; }
@media (max-width: 860px) { .nav-dl { display: flex; } }
html.native-app .dl-link { display: none !important; }
