/* ============================================================
   Задачи — оформление
   Тёмная тема по умолчанию. Светлая — только по выбору
   (или при data-theme="auto" — по системной настройке).
   ============================================================ */

:root {
  /* палитра — тёмная */
  --bg:            #0e0e12;
  --bg-sunk:       #0b0b0f;
  --surface:       #16161d;
  --surface-2:     #1d1d26;
  --hover:         rgba(255, 255, 255, 0.045);
  --hover-strong:  rgba(255, 255, 255, 0.075);

  --text:          #ecebf2;
  --text-2:        #9c9aa8;
  --text-3:        #64626f;

  --line:          rgba(255, 255, 255, 0.07);
  --line-2:        rgba(255, 255, 255, 0.13);

  --accent:        #8b7cf6;
  --accent-text:   #a79bff;
  --accent-soft:   rgba(139, 124, 246, 0.14);
  --accent-faint:  rgba(139, 124, 246, 0.055);
  --accent-ring:   rgba(139, 124, 246, 0.42);
  --on-accent:     #0e0e12;

  --danger:        #d9736f;
  --danger-soft:   rgba(217, 115, 111, 0.11);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px -8px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 24px 60px -16px rgba(0, 0, 0, 0.7), 0 4px 12px rgba(0, 0, 0, 0.4);

  /* сетка 8px */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;

  --r1: 8px; --r2: 12px; --r3: 16px; --r4: 20px;

  --dur: 170ms;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
          system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --topbar-h: 68px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  color-scheme: dark;
}

/* --- светлая тема --- */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="light"],
:root[data-theme="auto"] {
  --bg:            #fbfbfd;
  --bg-sunk:       #f3f3f6;
  --surface:       #ffffff;
  --surface-2:     #ffffff;
  --hover:         rgba(10, 10, 20, 0.035);
  --hover-strong:  rgba(10, 10, 20, 0.06);

  --text:          #1b1a22;
  --text-2:        #63616f;
  --text-3:        #93919e;

  --line:          rgba(10, 10, 25, 0.08);
  --line-2:        rgba(10, 10, 25, 0.16);

  --accent:        #6250e4;
  --accent-text:   #5a48dd;
  --accent-soft:   rgba(98, 80, 228, 0.11);
  --accent-faint:  rgba(98, 80, 228, 0.045);
  --accent-ring:   rgba(98, 80, 228, 0.4);
  --on-accent:     #ffffff;

  --danger:        #c4544f;
  --danger-soft:   rgba(196, 84, 79, 0.09);

  --shadow-1: 0 1px 2px rgba(20, 20, 40, 0.06);
  --shadow-2: 0 8px 24px -10px rgba(20, 20, 40, 0.18), 0 1px 3px rgba(20, 20, 40, 0.07);
  --shadow-3: 0 24px 60px -18px rgba(20, 20, 40, 0.3), 0 3px 10px rgba(20, 20, 40, 0.1);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] { color-scheme: light; }
}
@media (prefers-color-scheme: dark) {
  /* при auto и тёмной системе возвращаем тёмные значения */
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #0e0e12; --bg-sunk: #0b0b0f; --surface: #16161d; --surface-2: #1d1d26;
    --hover: rgba(255,255,255,.045); --hover-strong: rgba(255,255,255,.075);
    --text: #ecebf2; --text-2: #9c9aa8; --text-3: #64626f;
    --line: rgba(255,255,255,.07); --line-2: rgba(255,255,255,.13);
    --accent: #8b7cf6; --accent-text: #a79bff; --accent-soft: rgba(139,124,246,.14);
    --accent-faint: rgba(139,124,246,.055); --accent-ring: rgba(139,124,246,.42);
    --on-accent: #0e0e12;
    --danger: #d9736f; --danger-soft: rgba(217,115,111,.11);
  }
}

/* ============================================================
   база
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: var(--r1);
}

.skip {
  position: fixed;
  top: -60px; left: var(--s4);
  z-index: 100;
  background: var(--surface);
  color: var(--text);
  padding: var(--s2) var(--s3);
  border-radius: var(--r1);
  text-decoration: none;
  transition: top var(--dur) var(--ease);
}
.skip:focus { top: calc(var(--safe-t) + var(--s2)); }

.icon { display: inline-flex; align-items: center; justify-content: center; }
.icon svg { display: block; }

.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ============================================================
   каркас
   ============================================================ */

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 max(var(--s5), var(--safe-l)) 0 max(var(--s5), var(--safe-r));
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- верхняя панель ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  min-height: var(--topbar-h);
  padding: calc(var(--safe-t) + var(--s5)) 0 var(--s3);
  background: linear-gradient(var(--bg) 62%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
}

.head-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.head-title h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.head-title .sub {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: var(--s1);
  flex: none;
}

.iconbtn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.iconbtn:hover { background: var(--hover); color: var(--text); }
.iconbtn:active { transform: scale(0.94); }
.iconbtn.is-armed { background: var(--accent-soft); color: var(--accent-text); }
.iconbtn[hidden] { display: none; }

.ghostbtn {
  height: 34px;
  padding: 0 var(--s3);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ghostbtn:hover { background: var(--hover); color: var(--text); }
.ghostbtn:active { transform: scale(0.97); }

.spacer-s { width: var(--s2); }

/* ============================================================
   просрочено
   ============================================================ */

.overdue-slot { flex: none; }
body[data-view="day"] .overdue { max-width: 640px; margin-inline: auto; }

.overdue {
  margin: 0 0 var(--s4);
  border-radius: var(--r2);
  background: var(--danger-soft);
  overflow: hidden;
}

.overdue-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  font-size: 13.5px;
  color: var(--danger);
  text-align: left;
}
.overdue-head .toggle {
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: inherit;
  min-height: 28px;
}
.overdue-head .chev {
  transition: transform var(--dur) var(--ease);
  opacity: 0.8;
}
.overdue[data-open="true"] .overdue-head .chev { transform: rotate(90deg); }
.overdue-head .grow { flex: 1; }
.overdue-head .all {
  font-size: 12.5px;
  color: var(--danger);
  opacity: 0.85;
  padding: 2px var(--s2);
  border-radius: var(--r1);
}
.overdue-head .all:hover { background: var(--danger-soft); opacity: 1; }

.overdue-body { padding: 0 var(--s2) 6px; }
.overdue-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 3px var(--s2) 3px var(--s3);
  border-radius: var(--r1);
  font-size: 13.5px;
}
.overdue-row:hover { background: var(--hover); }
.overdue-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overdue-row .when { font-size: 12.5px; color: var(--text-3); flex: none; }
.overdue-row .move {
  flex: none;
  font-size: 12.5px;
  color: var(--accent-text);
  padding: 3px var(--s2);
  border-radius: var(--r1);
  min-height: 28px;
}
.overdue-row .move:hover { background: var(--accent-soft); }

/* ============================================================
   неделя (десктоп)
   ============================================================ */

.main { flex: 1; display: flex; flex-direction: column; padding-bottom: var(--s7); }
.main > * { width: 100%; }   /* main — flex-колонка, детям нужна полная ширина */

.week {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: stretch;
  border-top: 1px solid var(--line);
}

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 320px;
  padding: 0 var(--s1) var(--s5);
  border-left: 1px solid var(--line);
  transition: background var(--dur) var(--ease);
}
.col:first-child { border-left: 0; }
.col[data-today="true"] { background: var(--accent-faint); }
.col[data-past="true"] .col-body { opacity: 0.55; }
.col.drop-target { background: var(--accent-soft); }

.col-head {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  width: 100%;
  padding: var(--s3) var(--s2) var(--s2);
  text-align: left;
  border-radius: var(--r1);
  transition: background var(--dur) var(--ease);
}
.col-head:hover { background: var(--hover); }
.col-head .dow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  font-weight: 500;
}
.col-head .num {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-2);
}
.col[data-today="true"] .col-head .num { color: var(--accent-text); font-weight: 650; }
.col[data-today="true"] .col-head .dow { color: var(--accent-text); opacity: 0.85; }

.col-body { display: flex; flex-direction: column; gap: 1px; }

.col-add {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  width: 100%;
  min-height: 40px;
  flex: 1;
  border-radius: var(--r1);
  color: var(--text-3);
  text-align: left;
  padding: var(--s2);
  font-size: 13.5px;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.col:hover .col-add { opacity: 1; }
.col-add:hover { color: var(--text-2); }   /* кликабельна вся пустая область, но подсветки нет */
.col-add:focus-visible { opacity: 1; }
.col-add .plus { margin-right: 6px; }

.empty-day {
  padding: var(--s2);
  font-size: 13px;
  color: var(--text-3);
  opacity: 0.75;
}

/* ============================================================
   строка задачи
   ============================================================ */

.task {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: 7px var(--s2) 7px 6px;
  border-radius: 10px;
  touch-action: pan-y;
  transition: background var(--dur) var(--ease), opacity var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.task:hover { background: var(--hover); }
.task.is-now { background: var(--accent-faint); }
.task.is-now:hover { background: var(--accent-soft); }
.task.is-dragging { opacity: 0.28; }
.task.swiping { transition: none; }

.check {
  position: relative;
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
              color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.check:hover { border-color: var(--accent); }
.check svg { width: 12px; height: 12px; stroke-width: 2.2; }

.task-main { flex: 1; min-width: 0; }
.task-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1px 6px;
  min-width: 0;
}
.task-title {
  /* min-content не даёт разрывать слова, flex-basis: 0 — уйти на вторую строку без нужды */
  flex: 1 1 0;
  min-width: min-content;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: break-word;   /* переносим по словам, слова не рвём */
  word-break: normal;
  hyphens: none;
  transition: color var(--dur) var(--ease);
}
.task-meta {
  flex: none;
  margin-left: auto;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}
.task-time {
  flex: none;
  font-size: 12.5px;
  color: var(--text-2);
  letter-spacing: -0.01em;
}
.bang {
  flex: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--accent-text);
}
.bang[data-p="2"] { color: var(--danger); }
.task-repeat { flex: none; color: var(--text-3); transform: translateY(2px); }
.task-desc {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.nowdot {
  flex: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-1px);
  animation: pulse 2.4s var(--ease) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1;   box-shadow: 0 0 0 0 var(--accent-soft); }
  50%      { opacity: 0.55; box-shadow: 0 0 0 5px transparent; }
}

.more {
  flex: none;
  width: 26px; height: 26px;
  border-radius: var(--r1);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.task:hover .more, .more:focus-visible { opacity: 1; }
.more:hover { background: var(--hover-strong); color: var(--text); }

/* выполнено */
.task[data-done="true"] .check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.task[data-done="true"] .task-title {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: var(--text-3);
  text-decoration-thickness: 1px;
}
.task[data-done="true"] .task-time,
.task[data-done="true"] .bang,
.task[data-done="true"] .task-desc { color: var(--text-3); }
.task[data-done="true"] .bang { opacity: 0.5; }

/* анимация завершения */
.task.completing .check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  animation: pop 260ms var(--ease);
}
@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.28); }
  100% { transform: scale(1); }
}
.task.completing .task-title { color: var(--text-3); }

/* ============================================================
   день (десктоп)
   ============================================================ */

.day {
  max-width: 640px;
  margin: 0 auto;
  padding-top: var(--s2);
}
.day-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s3);
}
.day-head .dh-title { flex: 1; min-width: 0; }
.day-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.day-head .dh-sub { font-size: 13px; color: var(--text-2); }
.day[data-today="true"] .day-head h2 { color: var(--accent-text); }

.day .task { padding: var(--s3) var(--s3) var(--s3) var(--s2); border-radius: var(--r2); }
.day .task-title { font-size: 16px; }
.day .task-time { font-size: 14px; }
.day .check { width: 22px; height: 22px; margin-top: 0; }
.day .col-body { gap: 2px; }
.day .more { opacity: 0; }

.day-add {
  margin-top: var(--s2);
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3);
  border-radius: var(--r2);
  color: var(--text-3);
  font-size: 14.5px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.day-add:hover { background: var(--hover); color: var(--text-2); }

/* зум между видами */
@keyframes zoom-in  { from { opacity: 0; transform: scale(0.975); } to { opacity: 1; transform: none; } }
@keyframes zoom-out { from { opacity: 0; transform: scale(1.02);  } to { opacity: 1; transform: none; } }
@keyframes slide-x  { from { opacity: 0; transform: translateX(var(--dx, 0)); } to { opacity: 1; transform: none; } }
.main[data-anim="in"]  > * { animation: zoom-in 190ms var(--ease); }
.main[data-anim="out"] > * { animation: zoom-out 190ms var(--ease); }
.main[data-anim="next"] > *, .main[data-anim="prev"] > * { animation: slide-x 190ms var(--ease); }
.main[data-anim="next"] { --dx: 14px; }
.main[data-anim="prev"] { --dx: -14px; }

/* ============================================================
   мобильный вид
   ============================================================ */

.strip-wrap {
  position: sticky;
  top: calc(var(--topbar-h) + var(--safe-t));
  z-index: 10;
  background: var(--bg);
  padding-bottom: var(--s2);
  margin: 0 calc(-1 * var(--s3));
  padding-left: var(--s3);
  padding-right: var(--s3);
}
.strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  touch-action: pan-y;
}
.pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: var(--s2) 0 6px;
  border-radius: var(--r2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.pill .p-dow {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.pill .p-num { font-size: 16px; font-weight: 500; color: var(--text-2); line-height: 1; }
.pill[data-today="true"] .p-num { color: var(--accent-text); font-weight: 650; }
.pill[data-selected="true"] { background: var(--hover-strong); }
.pill[data-selected="true"] .p-num { color: var(--text); }
.pill[data-selected="true"][data-today="true"] { background: var(--accent-soft); }
.pill[data-selected="true"][data-today="true"] .p-num { color: var(--accent-text); }
.pill.drop-target { background: var(--accent-soft); }
.pill[data-past="true"] { opacity: 0.55; }

.dots { display: flex; gap: 3px; height: 4px; align-items: center; }
.dots i {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-3);
  display: block;
}
.dots i[data-imp="true"] { background: var(--danger); }
.pill[data-selected="true"] .dots i { background: var(--text-2); }

.mobile-day { padding-top: var(--s2); }
.mobile-day .day-title {
  font-size: 15px;
  font-weight: 600;
  padding: var(--s3) var(--s2) var(--s2);
  letter-spacing: -0.01em;
}
.mobile-day .day-title span { color: var(--text-3); font-weight: 400; margin-left: 6px; }
.mobile-day .task { padding: var(--s3) var(--s2); min-height: 44px; border-radius: var(--r2); }
.mobile-day .task-title { font-size: 15.5px; }
/* пальцевые зоны ≥ 44px: сам кружок остаётся маленьким, область нажатия шире */
.mobile-day .check { width: 26px; height: 26px; }
.mobile-day .check::after { content: ""; position: absolute; inset: -9px; }
.mobile-day .more { opacity: 1; width: 44px; height: 44px; margin: -5px -5px -5px 0; }

.fab {
  position: fixed;
  right: calc(var(--s4) + var(--safe-r));
  bottom: calc(var(--s4) + var(--safe-b));
  z-index: 30;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-2);
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.fab:active { transform: scale(0.92); }
.fab svg { width: 24px; height: 24px; stroke-width: 2; }

body[data-view="mobile"] .fab { display: inline-flex; }
body[data-view="mobile"] .app { padding-left: max(var(--s3), var(--safe-l)); padding-right: max(var(--s3), var(--safe-r)); }
body[data-view="mobile"] .main { padding-bottom: calc(96px + var(--safe-b)); }
body[data-view="mobile"] .topbar { padding-top: calc(var(--safe-t) + var(--s3)); align-items: center; }
body[data-view="mobile"] .head-title h1 { font-size: 18px; }

/* ============================================================
   карточка задачи (модалка / шторка)
   ============================================================ */

.sheet {
  position: fixed;
  inset: 0;
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: var(--text);
}
.sheet:not([open]) { display: none; }
.sheet::backdrop {
  background: rgba(6, 6, 10, 0.55);
  backdrop-filter: blur(3px);
}
:root[data-theme="light"] .sheet::backdrop { background: rgba(30, 30, 50, 0.28); }

.sheet-inner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r4);
  box-shadow: var(--shadow-3);
  padding: var(--s5);
  max-height: min(86vh, 760px);
  overflow-y: auto;
  animation: sheet-pop 190ms var(--ease);
}
@keyframes sheet-pop {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

body[data-view="mobile"] .sheet-inner {
  left: 0; top: auto; bottom: 0;
  transform: none;
  width: 100%;
  max-width: none;
  border-radius: var(--r4) var(--r4) 0 0;
  border-left: 0; border-right: 0; border-bottom: 0;
  padding: var(--s4) var(--s4) calc(var(--s4) + var(--safe-b));
  max-height: 92vh;
  animation: sheet-up 220ms var(--ease);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

.grabber {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--line-2);
  margin: 0 auto var(--s3);
  display: none;
}
body[data-view="mobile"] .grabber { display: block; }

.field { margin-bottom: var(--s3); }
.field:last-of-type { margin-bottom: 0; }

.label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 6px;
}

.input, .textarea {
  width: 100%;
  background: var(--bg-sunk);
  border: 1px solid transparent;
  border-radius: var(--r2);
  padding: 11px var(--s3);
  font-size: 15px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .textarea:focus { border-color: var(--accent-ring); outline: none; }
.input.title-input {
  font-size: 17px;
  padding: var(--s3);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding-left: 0; padding-right: 0;
}
.input.title-input:focus { border-bottom-color: var(--accent); }
.textarea { resize: vertical; min-height: 68px; line-height: 1.5; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s2); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 6px 0 10px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12.5px;
  white-space: nowrap;
  animation: chip-in 160ms var(--ease);
}
@keyframes chip-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }
.chip .x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  opacity: 0.65;
}
.chip .x:hover { opacity: 1; background: var(--accent-soft); }
.chip svg { width: 10px; height: 10px; stroke-width: 2; }

.linkbtn {
  font-size: 13.5px;
  color: var(--text-2);
  padding: 6px 0;
  transition: color var(--dur) var(--ease);
}
.linkbtn:hover { color: var(--accent-text); }

.seg {
  display: inline-flex;
  background: var(--bg-sunk);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  min-width: 52px;
  height: 30px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-1); }
.seg button[data-p="1"][aria-pressed="true"] { color: var(--accent-text); }
.seg button[data-p="2"][aria-pressed="true"] { color: var(--danger); }
.seg button b { font-weight: 700; letter-spacing: -0.05em; }

.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.row .grow { flex: 1; }

.datechips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--s2); }
.tinychip {
  height: 28px;
  padding: 0 10px;
  border-radius: 14px;
  background: var(--bg-sunk);
  color: var(--text-2);
  font-size: 12.5px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tinychip:hover { background: var(--hover-strong); color: var(--text); }
.tinychip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }

input[type="date"], input[type="time"] {
  background: var(--bg-sunk);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px var(--s3);
  font-size: 14.5px;
  min-height: 40px;
  font-variant-numeric: tabular-nums;
}
input[type="date"]:focus, input[type="time"]:focus { border-color: var(--accent-ring); }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(0.75); }

.switch {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: 10px 0;
  font-size: 14.5px;
  text-align: left;
}
.switch .track {
  flex: none;
  width: 42px; height: 25px;
  border-radius: 13px;
  background: var(--line-2);
  position: relative;
  transition: background var(--dur) var(--ease);
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease);
}
.switch[aria-pressed="true"] .track { background: var(--accent); }
.switch[aria-pressed="true"] .track::after { transform: translateX(17px); }

.sheet-sep { height: 1px; background: var(--line); margin: var(--s4) 0; }

.sheet-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s5);
}
.sheet-actions .grow { flex: 1; }

.btn {
  height: 38px;
  padding: 0 var(--s4);
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 500;
  transition: background var(--dur) var(--ease), opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.45; cursor: default; }
.btn-quiet { color: var(--text-2); }
.btn-quiet:hover { background: var(--hover); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }

body[data-view="mobile"] .btn { height: 44px; }
body[data-view="mobile"] .sheet-actions .btn-primary { flex: 1; }

/* ============================================================
   контекстное меню задачи
   ============================================================ */

.menu-layer { position: fixed; inset: 0; z-index: 60; }
.menu {
  position: absolute;
  min-width: 190px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  box-shadow: var(--shadow-3);
  padding: var(--s1);
  animation: menu-in 140ms var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r1);
  font-size: 14px;
  text-align: left;
  color: var(--text);
  transition: background var(--dur) var(--ease);
}
.menu button:hover { background: var(--hover-strong); }
.menu button .icon { color: var(--text-3); }
.menu button.danger, .menu button.danger .icon { color: var(--danger); }
.menu .sep { height: 1px; background: var(--line); margin: var(--s1) 0; }

body[data-view="mobile"] .menu-layer {
  background: rgba(6, 6, 10, 0.45);
  animation: fade-in 160ms var(--ease);
}
:root[data-theme="light"] body[data-view="mobile"] .menu-layer { background: rgba(30, 30, 50, 0.25); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.menu-title {
  padding: 10px 12px 6px;
  font-size: 12.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: none;
}
body[data-view="mobile"] .menu-title { display: block; }

body[data-view="mobile"] .menu {
  left: var(--s3) !important;
  right: var(--s3);
  top: auto !important;
  bottom: calc(var(--s3) + var(--safe-b));
  width: auto;
  min-width: 0;
  padding: 6px;
  animation: menu-up 180ms var(--ease);
}
@keyframes menu-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
body[data-view="mobile"] .menu button { padding: 13px 12px; font-size: 15.5px; min-height: 48px; }

/* ============================================================
   перетаскивание
   ============================================================ */

body.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.drag-ghost {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
  box-shadow: var(--shadow-3);
  opacity: 0.97;
  transform-origin: 12px 12px;
  animation: lift 140ms var(--ease) forwards;
}
@keyframes lift { from { transform: scale(1); } to { transform: scale(1.03) rotate(-0.6deg); } }
.drag-ghost .more { display: none; }

.drop-line {
  height: 2px;
  margin: 1px 6px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0.85;
}

/* ============================================================
   тосты и связь
   ============================================================ */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--s5) + var(--safe-b));
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
body[data-view="mobile"] .toasts { bottom: calc(88px + var(--safe-b)); }

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px var(--s3) 10px var(--s4);
  border-radius: 999px;
  box-shadow: var(--shadow-3);
  font-size: 13.5px;
  animation: toast-in 200ms var(--ease);
}
.toast.out { animation: toast-out 160ms var(--ease) forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
.toast button {
  color: var(--accent-text);
  font-size: 13.5px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--r1);
}
.toast button:hover { background: var(--accent-soft); }
.toast.error { border-color: var(--danger-soft); }
.toast.error .dotm { color: var(--danger); }

.conn {
  position: fixed;
  z-index: 70;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--safe-t) + var(--s2));
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12.5px;
  padding: 5px var(--s3);
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  animation: toast-in 200ms var(--ease);
}
.conn[hidden] { display: none; }

/* ============================================================
   меньше движения
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
