/* ============================================================
   Задачи — оформление
   Календарная сетка в духе Google Calendar, сдержанно (Things 3 / Linear).
   Тёмная тема по умолчанию. Светлая — по выбору
   (или при data-theme="auto" — по системной настройке).
   ============================================================ */

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

  --text:          #ecebf2;
  --text-2:        #a09eac;
  --text-3:        #6b6977;

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

  --accent:        #8b7cf6;
  --accent-text:   #aca1ff;
  --accent-soft:   rgba(139, 124, 246, 0.15);
  --accent-faint:  rgba(139, 124, 246, 0.055);
  --accent-ring:   rgba(139, 124, 246, 0.45);
  --on-accent:     #0e0e12;

  --danger:        #e07b76;
  --danger-soft:   rgba(224, 123, 118, 0.1);

  /* календарь */
  --cal-bg:        #0e0e12;
  --grid-line:     rgba(255, 255, 255, 0.068);
  --grid-half:     rgba(255, 255, 255, 0.028);
  --today-tint:    rgba(139, 124, 246, 0.03);
  --ev-mix:        23%;
  --ev-text:       #e8e3ff;
  --ev-done-bg:    rgba(255, 255, 255, 0.04);
  --ev-edge:       rgba(14, 14, 18, 0.9);
  --top-shade:     rgba(0, 0, 0, 0.55);
  /* текст на задачах гостей: их цвет, подмешанный к белому (тёмная) или к почти чёрному (светлая) */
  --guest-ink:     #ffffff;
  --guest-ink-mix: 24%;

  --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.75), 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-drag: 0 14px 30px -8px rgba(0, 0, 0, 0.7), 0 3px 8px rgba(0, 0, 0, 0.45);

  /* сетка 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;

  --rail: 60px;
  --col-pad: 10px;          /* свободная полоска справа в колонке — чтобы было куда нажать */
  --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);

  /* производные цвета блоков: одна акцентная краска разной плотности */
  --ev-bg:        color-mix(in srgb, var(--accent) var(--ev-mix), var(--cal-bg));
  --ev-bg-hover:  color-mix(in srgb, var(--accent) calc(var(--ev-mix) + 7%), var(--cal-bg));
  --ev-bg-strong: color-mix(in srgb, var(--accent) calc(var(--ev-mix) + 15%), var(--cal-bg));
  --chip-bg:      color-mix(in srgb, var(--accent) calc(var(--ev-mix) - 5%), var(--cal-bg));
  --pt-bg:        color-mix(in srgb, var(--accent) calc(var(--ev-mix) - 7%), var(--cal-bg));

  color-scheme: dark;
}

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

  --text:          #1b1a22;
  --text-2:        #5f5d6b;
  --text-3:        #8f8d9b;

  --line:          rgba(10, 10, 30, 0.08);
  --line-2:        rgba(10, 10, 30, 0.15);

  --accent:        #6250e4;
  --accent-text:   #5140d6;
  --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.08);

  --cal-bg:        #fbfbfd;
  --grid-line:     rgba(20, 20, 50, 0.085);
  --grid-half:     rgba(20, 20, 50, 0.035);
  --today-tint:    rgba(98, 80, 228, 0.025);
  --ev-mix:        14%;
  --ev-text:       #2a1f78;
  --ev-done-bg:    rgba(20, 20, 50, 0.04);
  --ev-edge:       rgba(255, 255, 255, 0.95);
  --top-shade:     rgba(20, 20, 50, 0.12);
  --guest-ink:     #17151f;
  --guest-ink-mix: 52%;

  --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);
  --shadow-drag: 0 14px 30px -10px rgba(40, 30, 110, 0.35), 0 2px 6px rgba(20, 20, 40, 0.12);
}
@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: #0a0a0d; --surface: #16161d; --surface-2: #1c1c25;
    --hover: rgba(255,255,255,.045); --hover-strong: rgba(255,255,255,.08);
    --text: #ecebf2; --text-2: #a09eac; --text-3: #6b6977;
    --line: rgba(255,255,255,.07); --line-2: rgba(255,255,255,.14);
    --accent: #8b7cf6; --accent-text: #aca1ff; --accent-soft: rgba(139,124,246,.15);
    --accent-faint: rgba(139,124,246,.055); --accent-ring: rgba(139,124,246,.45);
    --on-accent: #0e0e12;
    --danger: #e07b76; --danger-soft: rgba(224,123,118,.1);
    --cal-bg: #0e0e12; --grid-line: rgba(255,255,255,.068); --grid-half: rgba(255,255,255,.028);
    --today-tint: rgba(139,124,246,.03); --ev-mix: 23%; --ev-text: #e8e3ff;
    --ev-done-bg: rgba(255,255,255,.04); --ev-edge: rgba(14,14,18,.9); --top-shade: rgba(0,0,0,.55);
    --guest-ink: #ffffff; --guest-ink-mix: 24%;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 8px 24px -8px rgba(0,0,0,.6), 0 2px 6px rgba(0,0,0,.35);
    --shadow-3: 0 24px 60px -16px rgba(0,0,0,.75), 0 4px 14px rgba(0,0,0,.45);
    --shadow-drag: 0 14px 30px -8px rgba(0,0,0,.7), 0 3px 8px rgba(0,0,0,.45);
  }
}

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

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
/* страница-календарь не прокручивается целиком: прокручивается только сетка */
body:has(> .app) { overflow: hidden; }

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 {
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 0 max(var(--s5), var(--safe-r)) 0 max(var(--s4), var(--safe-l));
  display: flex;
  flex-direction: column;
}

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

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  min-height: 64px;
  padding: calc(var(--safe-t) + 14px) 0 12px;
}

.head-left {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
}

.head-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.head-title h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.head-title .sub {
  font-size: 13.5px;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

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

.nav { display: flex; gap: 0; }

.iconbtn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  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-strong); color: var(--text); }
.iconbtn:active { transform: scale(0.94); }
.iconbtn[hidden] { display: none; }

.todaybtn {
  height: 34px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.todaybtn:hover { background: var(--hover); border-color: var(--text-3); }
.todaybtn:active { transform: scale(0.97); }

.viewseg {
  display: inline-flex;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}
.viewseg button {
  height: 28px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.viewseg button:hover { color: var(--text); }
.viewseg button[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--line);
}

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

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

.overdue-slot { flex: none; }

.overdue {
  margin: 0 0 var(--s2) var(--rail);
  border-radius: var(--r2);
  background: color-mix(in srgb, var(--danger) 7%, transparent);
  overflow: hidden;
}

.overdue-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 3px var(--s2) 3px var(--s3);
  font-size: 13px;
  color: var(--danger);
  text-align: left;
}
.overdue-head .toggle {
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: inherit;
  min-height: 28px;
  font-weight: 500;
}
.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: 3px var(--s2);
  border-radius: var(--r1);
}
.overdue-head .all:hover { background: var(--danger-soft); opacity: 1; }

.overdue-body {
  padding: 0 var(--s2) 6px;
  max-height: 124px;
  overflow-y: auto;
}
.overdue-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 2px var(--s2) 2px 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;
  text-align: left;
  padding: 3px 0;
}
.overdue-row .bang { color: var(--danger); font-weight: 700; }
.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;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--s3);
}
.main:focus { outline: none; }

.cal {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--cal-bg);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.cal-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.cal-scroll::-webkit-scrollbar { width: 10px; }
.cal-scroll::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 10px;
  border: 3px solid var(--cal-bg);
}
.cal-scroll::-webkit-scrollbar-track { background: transparent; }

.cal-top {
  position: sticky;
  top: 0;
  z-index: 12;
  background: var(--cal-bg);
  box-shadow: 0 1px 0 var(--line), 0 10px 14px -14px var(--top-shade);
}

.cal-head, .cal-allday, .cal-body {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
}
.days {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  min-width: 0;
}

.rail-cell { min-width: 0; }

/* ---------- шапка дней ---------- */

.tz {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 10px 8px 0;
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.dh {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 8px;
  min-width: 0;
  border-radius: 0;
  cursor: pointer;
}
.dh-dow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.dh-num {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 450;
  letter-spacing: -0.02em;
  color: var(--text);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.dh:hover .dh-num { background: var(--hover-strong); }
.dh[data-past="true"] .dh-num { color: var(--text-2); }
.dh[data-today="true"] .dh-dow { color: var(--accent-text); }
.dh[data-today="true"] .dh-num,
.dh[data-today="true"]:hover .dh-num {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.cal[data-mode="day"] .dh {
  flex-direction: row;
  justify-content: flex-start;
  gap: 10px;
  padding-left: 14px;
  cursor: default;
}
.cal[data-mode="day"] .dh:hover .dh-num { background: none; }
.cal[data-mode="day"] .dh[data-today="true"] .dh-num { background: var(--accent); }

/* ---------- полоса «без времени» ---------- */

.cal-allday { min-height: 32px; }
.cal-allday .days { align-items: start; }
.cal-allday[data-open="true"] .days {
  max-height: 34vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.ad-label {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 7px 8px 0 0;
}
.ad-caption {
  font-size: 10px;
  line-height: 1.15;
  color: var(--text-3);
  text-align: right;
  letter-spacing: 0.02em;
  max-width: 44px;
}
.ad-toggle {
  width: 26px;
  height: 22px;
  border-radius: 7px;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ad-toggle:hover { background: var(--hover-strong); color: var(--text); }

.adc {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  min-height: 32px;
  height: 100%;
  padding: 4px var(--col-pad) 5px 3px;
  box-shadow: inset 1px 0 0 var(--grid-line);
  transition: background var(--dur) var(--ease);
}
.adc[data-today="true"] { background: var(--today-tint); }
.adc.drop-target { background: var(--accent-faint); }

.chip-ad {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  min-width: 0;
  padding: 0 7px 0 4px;
  border-radius: 6px;
  background: var(--chip-bg);
  color: var(--ev-text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.chip-ad:hover { background: var(--ev-bg-hover); }
.chip-ad .t {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-ad .rep { flex: none; opacity: 0.55; }
.chip-ad[data-p="2"] { background: var(--ev-bg-strong); }
.chip-ad[data-done="true"] { background: var(--ev-done-bg); color: var(--text-3); }
.chip-ad[data-done="true"] .t { text-decoration: line-through; text-decoration-thickness: 1px; }
.chip-ad.draft {
  background: var(--accent);
  color: var(--on-accent);
  padding-left: 8px;
  box-shadow: var(--shadow-2);
}

.ad-more {
  align-self: flex-start;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ad-more:hover { background: var(--hover-strong); color: var(--text); }
.ad-empty {
  font-size: 12.5px;
  color: var(--text-3);
  padding: 3px 2px;
  opacity: 0.8;
}

/* ---------- часы ---------- */

.cal-body { position: relative; }

.rail { position: relative; }
.rail::after {
  /* короткие засечки часов у края шкалы */
  content: "";
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 6px;
  background: repeating-linear-gradient(to bottom, var(--grid-line) 0 1px, transparent 1px var(--hour));
}
.hr {
  position: absolute;
  right: 11px;
  transform: translateY(-50%);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.01em;
  line-height: 1;
}
.hr-hidden { visibility: hidden; }
.now-tag {
  position: absolute;
  right: 5px;
  z-index: 2;
  transform: translateY(-50%);
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.2;
  box-shadow: 0 0 0 3px var(--cal-bg);
}

.cols {
  position: relative;
  background-image: repeating-linear-gradient(to bottom,
    var(--grid-line) 0 1px,
    transparent 1px calc(var(--hour) / 2),
    var(--grid-half) calc(var(--hour) / 2) calc(var(--hour) / 2 + 1px),
    transparent calc(var(--hour) / 2 + 1px) var(--hour));
}

.dc {
  position: relative;
  min-width: 0;
  box-shadow: inset 1px 0 0 var(--grid-line);
}
.dc[data-today="true"] { background: var(--today-tint); }

/* ---------- линия «сейчас» ---------- */

.now {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  margin-top: -1px;
  background: var(--accent);
  z-index: 8;
  pointer-events: none;
  box-shadow: 0 0 0 0.5px var(--ev-edge);
}
.now::before {
  content: "";
  position: absolute;
  left: -6px;
  top: -5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--cal-bg);
}
.now-week {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: var(--accent);
  opacity: 0.3;
  z-index: 1;
  pointer-events: none;
}

/* ---------- блоки с длительностью ---------- */

.ev {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 4px 6px 4px 11px;
  border-radius: 7px;
  background: var(--ev-bg);
  color: var(--ev-text);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--ev-edge);
  transition: background var(--dur) var(--ease), opacity var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.ev::before {
  content: "";
  position: absolute;
  left: 3px; top: 3px; bottom: 3px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.ev:hover { background: var(--ev-bg-hover); }
.ev[data-p="2"] { background: var(--ev-bg-strong); }

.ev-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.ev-title {
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ev-inline {
  display: none;
  flex: none;
  font-size: 11.5px;
  font-weight: 450;
  opacity: 0.72;
}
.ev-inline::before { content: ", "; }
.ev[data-size="s"] .ev-title + .ev-inline { margin-left: -5px; }   /* запятая сразу после названия */
.ev-time {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
  font-size: 11.5px;
  line-height: 15px;
  opacity: 0.74;
  white-space: nowrap;
  overflow: hidden;
}
.ev-time .rep { opacity: 0.8; }
.ev-desc { display: none; }

.ev .bang, .pt .bang, .chip-ad .bang {
  flex: none;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.06em;
  color: var(--accent-text);
}
:root[data-theme="light"] .ev .bang { color: var(--accent); }

/* узкие блоки (много пересечений): сначала прячем время и галочку, название важнее */
.ev, .pt { container-type: inline-size; }
@container (max-width: 100px) {
  .ev .ev-check { display: none; }
  .ev-row { gap: 3px; }
}
@container (max-width: 74px) {
  .ev-inline, .ev-time { display: none !important; }
}
@container (max-width: 110px) {
  .pt-time { display: none; }
}
@container (max-width: 70px) {
  .pt-chip .ev-check { display: none; }
}

/* низкий блок — одна строка «Название, 15:00» */
.ev[data-size="s"] { justify-content: center; padding-top: 0; padding-bottom: 0; }
.ev[data-size="s"] .ev-title { flex: 0 1 auto; }
.ev[data-size="s"] .ev-inline { display: inline; }
.ev[data-size="s"] .ev-time { display: none; }
.ev[data-size="s"] .ev-check { width: 12px; height: 12px; }
/* высокий блок — название в несколько строк и описание */
.ev[data-size="l"] .ev-row { align-items: flex-start; }
.ev[data-size="l"] .ev-row .ev-check { margin-top: 1.5px; }
.ev[data-size="l"] .ev-title {
  white-space: normal;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--lines, 2);
}
.ev[data-size="l"] .ev-desc {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 15px;
  opacity: 0.6;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ручка длительности (низ блока) */
.ev-resize {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 8px;
  cursor: ns-resize;
  touch-action: none;
}
.ev-resize::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 18px;
  height: 3px;
  margin-left: -9px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
@media (hover: hover) {
  .ev:hover .ev-resize::after { opacity: 0.45; }
}

/* ---------- точка во времени (без длительности) ---------- */

.pt {
  position: absolute;
  z-index: 3;
  height: 0;
  cursor: pointer;
}
.pt-line {
  position: absolute;
  left: 4px; right: 0;
  top: -0.75px;
  height: 1.5px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0.6;
  pointer-events: none;
}
.pt-dot {
  position: absolute;
  left: -1px;
  top: -4.5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--cal-bg);
}
.pt-chip {
  position: absolute;
  left: 5px;
  top: 3px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100% - 5px);
  height: 21px;
  padding: 0 7px 0 5px;
  border-radius: 2px 7px 7px 7px;
  background: var(--pt-bg);
  color: var(--ev-text);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 0 0 1px var(--ev-edge);
  transition: background var(--dur) var(--ease);
}
.pt:hover { z-index: 24 !important; }
.pt:hover .pt-chip { background: var(--ev-bg-hover); }
.pt[data-p="2"] .pt-chip { background: var(--ev-bg-strong); }
.pt-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.pt-time {
  flex: none;
  font-size: 11px;
  opacity: 0.7;
}
.pt-grip {
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 30px;
  height: 12px;
  margin-left: -15px;
  cursor: ns-resize;
  touch-action: none;
  display: none;
}
.pt-grip::after {
  content: "";
  position: absolute;
  left: 7px; right: 7px;
  top: 5px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.8;
}
@media (hover: hover) {
  .pt:hover .pt-grip { display: block; }
}

/* ---------- галочка «выполнено» на блоке ---------- */

.ev-check {
  position: relative;
  flex: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  opacity: 0.6;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.ev-check::after { content: ""; position: absolute; inset: -6px; }   /* зона нажатия больше самого кружка */
.ev-check svg { width: 9px; height: 9px; stroke-width: 2.4; opacity: 0; }
.ev-check:hover { opacity: 1; }
.ev-check:hover svg { opacity: 0.55; }

/* выполнено */
.ev[data-done="true"], .pt[data-done="true"] .pt-chip {
  background: var(--ev-done-bg);
  color: var(--text-3);
}
.ev[data-done="true"]::before { background: var(--line-2); }
.pt[data-done="true"] .pt-dot, .pt[data-done="true"] .pt-line { background: var(--text-3); }
.ev[data-done="true"] .ev-title,
.pt[data-done="true"] .pt-title,
.chip-ad[data-done="true"] .t {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  font-weight: 500;
}
[data-done="true"] > .ev-row .ev-check,
[data-done="true"] .pt-chip .ev-check,
.chip-ad[data-done="true"] .ev-check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  opacity: 0.9;
}
[data-done="true"] .ev-check svg { opacity: 1; }
[data-done="true"] .bang { color: var(--text-3) !important; }

.completing .ev-check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  opacity: 1;
  animation: pop 260ms var(--ease);
}
.completing .ev-check svg { opacity: 1; }
@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

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

body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
body.is-dragging { user-select: none; -webkit-user-select: none; }

.is-source { opacity: 0.32; }
.is-optimistic { opacity: 0.7; }

.ev.ghost, .pt.ghost, .chip-ad.ghost {
  z-index: 30;
  pointer-events: none;
}
.ev.ghost, .pt.ghost { transition: top 70ms var(--ease), height 70ms var(--ease); }
.ev.ghost {
  background: var(--ev-bg-strong);
  box-shadow: var(--shadow-drag), 0 0 0 1.5px var(--accent);
}
.pt.ghost .pt-chip { background: var(--ev-bg-strong); box-shadow: var(--shadow-drag), 0 0 0 1.5px var(--accent); }
.chip-ad.ghost { background: var(--ev-bg-strong); box-shadow: var(--shadow-drag), 0 0 0 1.5px var(--accent); }

.ev.is-resizing {
  z-index: 30 !important;
  background: var(--ev-bg-strong);
  box-shadow: var(--shadow-drag), 0 0 0 1.5px var(--accent);
}

/* новая задача (черновик до сохранения) */
.ev.draft {
  z-index: 25;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-2);
  pointer-events: none;
}
.ev.draft::before { display: none; }
.ev.draft .ev-check, .pt.draft .ev-check, .draft .ev-resize, .draft .pt-grip { display: none; }
.ev.draft { padding-left: 8px; }
.pt.draft { z-index: 25; pointer-events: none; }
.pt.draft .pt-chip { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-2); }
.ev.ghost-new { opacity: 0.92; }

/* выбранный пальцем блок: видна ручка длительности */
.ev.is-selected, .pt.is-selected .pt-chip, .chip-ad.is-selected {
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-2);
}
.ev.is-selected, .pt.is-selected { z-index: 26 !important; }

.dragtip {
  position: fixed;
  z-index: 210;
  pointer-events: none;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-2);
}

/* ---------- переходы между неделями / днями ---------- */

@keyframes zoom-in  { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes zoom-out { from { opacity: 0; transform: scale(1.012); } 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"] .cal  { animation: zoom-in 200ms var(--ease); }
.main[data-anim="out"] .cal { animation: zoom-out 200ms var(--ease); }
.main[data-anim="next"] .days, .main[data-anim="prev"] .days { animation: slide-x 210ms var(--ease); }
.main[data-anim="next"] { --dx: 18px; }
.main[data-anim="prev"] { --dx: -18px; }
body.is-swiping .cal .days { transition: none; }

/* ============================================================
   быстрое создание (окно у слота)
   ============================================================ */

.pop {
  position: fixed;
  z-index: 55;
  width: 330px;
  padding: 12px 12px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-3);
  animation: pop-in 150ms var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(0.98); } to { opacity: 1; transform: none; } }
.pop-input {
  width: 100%;
  border: 0;
  border-bottom: 1.5px solid var(--line);
  background: transparent;
  padding: 6px 2px 9px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  outline: none;
  transition: border-color var(--dur) var(--ease);
}
.pop-input::placeholder { color: var(--text-3); font-weight: 400; }
.pop-input:focus { border-bottom-color: var(--accent); }
.pop-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 2px 2px;
  font-size: 13px;
  color: var(--text-2);
}
.pop-meta .icon { color: var(--text-3); }
.pop-actions {
  display: flex;
  align-items: center;
  gap: var(--s1);
  margin-top: 12px;
}
.pop-actions .grow { flex: 1; }

/* ============================================================
   телефон
   ============================================================ */

.strip-wrap {
  flex: none;
  padding: 0 0 6px;
}
.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;
  gap: 3px;
  padding: 4px 0 3px;
  border-radius: var(--r2);
}
.pill .p-dow {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}
.pill .p-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.pill[data-past="true"] .p-num { color: var(--text-2); }
.pill[data-today="true"] .p-num { color: var(--accent-text); font-weight: 650; }
.pill[data-today="true"] .p-dow { color: var(--accent-text); }
.pill[data-selected="true"] .p-num { background: var(--hover-strong); color: var(--text); font-weight: 600; }
.pill[data-selected="true"][data-today="true"] .p-num { background: var(--accent); color: var(--on-accent); }

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

.dbadge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1px;
  padding: 6px 0 6px;
}
.dbadge .dh-num { width: auto; height: auto; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.dbadge[data-today="true"] .dh-dow,
.dbadge[data-today="true"] .dh-num { color: var(--accent-text); }

.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: 18px;
  background: var(--accent);
  color: var(--on-accent);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-2), 0 6px 20px -6px var(--accent-ring);
  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"] {
  --rail: 48px;
  --col-pad: 14px;
}
body[data-view="mobile"] .fab { display: inline-flex; }
body[data-view="mobile"] .app {
  padding-left: max(var(--s2), var(--safe-l));
  padding-right: max(var(--s2), var(--safe-r));
}
body[data-view="mobile"] .topbar {
  min-height: 52px;
  padding: calc(var(--safe-t) + 10px) var(--s2) 6px;
}
body[data-view="mobile"] .head-title h1 { font-size: 22px; letter-spacing: -0.025em; }
body[data-view="mobile"] .todaybtn { height: 32px; padding: 0 13px; }
body[data-view="mobile"] .overdue { margin-left: var(--s1); margin-right: var(--s1); }
body[data-view="mobile"] .main { padding-bottom: 0; }
body[data-view="mobile"] .cal-body { margin-bottom: calc(92px + var(--safe-b)); }
body[data-view="mobile"] .hr { right: 8px; font-size: 10.5px; }
body[data-view="mobile"] .adc { padding: 5px var(--col-pad) 6px 4px; gap: 3px; box-shadow: none; }
body[data-view="mobile"] .dc { box-shadow: none; }
body[data-view="mobile"] .dc[data-today="true"],
body[data-view="mobile"] .adc[data-today="true"] { background: none; }   /* на телефоне колонка одна — подсветка не нужна */
body[data-view="mobile"] .chip-ad { height: 28px; font-size: 13.5px; padding: 0 9px 0 6px; border-radius: 7px; gap: 7px; }
body[data-view="mobile"] .chip-ad .ev-check { width: 15px; height: 15px; }
body[data-view="mobile"] .ad-more { height: 24px; font-size: 12.5px; }
body[data-view="mobile"] .ev-title { font-size: 13.5px; line-height: 17px; }
body[data-view="mobile"] .ev-time { font-size: 12px; }
body[data-view="mobile"] .ev-check { width: 15px; height: 15px; }
body[data-view="mobile"] .ev-check::after { inset: -10px; }
body[data-view="mobile"] .pt-chip { height: 25px; font-size: 13px; padding: 0 9px 0 6px; gap: 6px; }
body[data-view="mobile"] .pop {
  left: max(10px, var(--safe-l));
  right: max(10px, var(--safe-r));
  top: calc(var(--safe-t) + 8px);
  width: auto;
}
body[data-view="mobile"] .pop-input { font-size: 17px; }

/* на сенсорных экранах ручки длительности видны только у выбранного (долгим нажатием) блока */
@media (hover: none) {
  .ev-resize { display: none; }
  .ev.is-selected .ev-resize { display: block; height: 22px; }
  .ev.is-selected .ev-resize::after {
    opacity: 1;
    width: 22px; height: 5px;
    margin-left: -11px;
    bottom: 4px;
    border-radius: 3px;
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--ev-edge);
  }
  .pt.is-selected .pt-grip { display: block; width: 44px; height: 22px; margin-left: -22px; bottom: -20px; }
  .pt.is-selected .pt-grip::after { left: 11px; right: 11px; top: 8px; height: 5px; border-radius: 3px; }
}

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

.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(480px, 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(88vh, 780px);
  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(--s4); }
.field:last-of-type { margin-bottom: 0; }
.field-inline { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.field-inline .label { margin: 0; }

.label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 8px;
}
.label-sub { margin-top: var(--s4); text-transform: none; letter-spacing: 0; font-size: 12.5px; }

.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: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: var(--s2) 0 var(--s3);
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--line);
  border-radius: 0;
}
.input.title-input:focus { border-bottom-color: var(--accent); }
.textarea { resize: vertical; min-height: 68px; line-height: 1.5; }
body[data-view="mobile"] .textarea { font-size: 16px; }   /* iOS не приближает поле при фокусе */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s2); }
.chips:empty { display: none; }
.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;
  font-weight: 500;
  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: 4px 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), 0 0 0 1px var(--line); }
.seg button[data-p="1"][aria-pressed="true"],
.seg button[data-p="2"][aria-pressed="true"] { color: var(--accent-text); }
.seg button b { font-weight: 800; letter-spacing: -0.05em; }

.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.row .grow { flex: 1; }
.when-row { gap: 6px; }
.when-sep { font-size: 13.5px; color: var(--text-3); padding: 0 2px; }
.when-sep:empty { display: none; }

.datechips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tinychip {
  height: 28px;
  padding: 0 11px;
  border-radius: 14px;
  background: var(--bg-sunk);
  color: var(--text-2);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow 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); box-shadow: inset 0 0 0 1px var(--accent-ring); }
.durchips { margin-top: 0; }

input[type="date"], input[type="time"] {
  background: var(--bg-sunk);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  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); }
body[data-view="mobile"] input[type="date"],
body[data-view="mobile"] input[type="time"] { font-size: 16px; }
body[data-view="mobile"] .when-row input[type="date"] { flex: 1 0 100%; }

/* поле времени (24 часа) и список с шагом 15 минут */
.tf {
  width: 74px;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--bg-sunk);
  font-size: 14.5px;
  text-align: center;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tf::placeholder { color: var(--text-3); }
.tf:hover { background: var(--hover-strong); }
.tf:focus { border-color: var(--accent-ring); outline: none; background: var(--bg-sunk); }
body[data-view="mobile"] .tf { font-size: 16px; width: 80px; }

.tf-list {
  position: fixed;
  z-index: 5;
  width: 188px;
  max-height: 232px;
  overflow-y: auto;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  scrollbar-width: thin;
  animation: menu-in 120ms var(--ease);
}
.tf-opt {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  text-align: left;
  color: var(--text);
}
.tf-opt:hover { background: var(--hover-strong); }
.tf-opt[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.tf-hint { font-size: 12px; color: var(--text-3); font-weight: 400; }

.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), filter var(--dur) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn-s { height: 32px; padding: 0 13px; font-size: 13.5px; border-radius: 9px; }
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.4; cursor: default; filter: none; }
.btn-quiet { color: var(--text-2); }
.btn-quiet:hover { background: var(--hover-strong); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }

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

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

.menu-layer { position: fixed; inset: 0; z-index: 60; }
.menu-layer[hidden] { display: none; }
.menu {
  position: absolute;
  min-width: 200px;
  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: 8px 10px;
  border-radius: var(--r1);
  font-size: 14px;
  text-align: left;
  color: var(--text);
  transition: background var(--dur) var(--ease);
}
.menu button:hover, .menu button:focus-visible { background: var(--hover-strong); outline: none; }
.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; }

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

.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: 600;
  padding: 2px 6px;
  border-radius: var(--r1);
}
.toast button:hover { background: var(--accent-soft); }
.toast.error { border-color: var(--danger-soft); 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; }

/* ============================================================
   гости: задачи в цвете того, кто их добавил
   ============================================================ */

/* на элементе задачи гостя --tc = его цвет. Перекрашиваем «акцент» только внутри
   этого элемента: полоска слева, заливка, точка, галочка, ручки — всё берёт его цвет. */
.by-guest {
  --accent: var(--tc);
  --accent-text: color-mix(in srgb, var(--tc) 72%, var(--text));
  --ev-text: color-mix(in srgb, var(--tc) var(--guest-ink-mix), var(--guest-ink));
  --ev-bg:        color-mix(in srgb, var(--tc) var(--ev-mix), var(--cal-bg));
  --ev-bg-hover:  color-mix(in srgb, var(--tc) calc(var(--ev-mix) + 7%), var(--cal-bg));
  --ev-bg-strong: color-mix(in srgb, var(--tc) calc(var(--ev-mix) + 15%), var(--cal-bg));
  --chip-bg:      color-mix(in srgb, var(--tc) calc(var(--ev-mix) - 5%), var(--cal-bg));
  --pt-bg:        color-mix(in srgb, var(--tc) calc(var(--ev-mix) - 7%), var(--cal-bg));
}
:root[data-theme="light"] .by-guest .bang { color: var(--accent-text); }

/* подпись с именем на блоке */
.ev-who, .pt-who, .chip-ad .who {
  flex: none;
  min-width: 0;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent-text);
}
.ev-time .ev-range { flex: none; }
.ev-time .ev-who { margin-left: auto; padding-left: 6px; flex: 0 1 auto; max-width: none; }
.ev-time .ev-who::before { content: none; }
.ev-who-s { display: none; margin-left: auto; padding-left: 4px; }
.ev[data-size="s"] .ev-who-s { display: inline; }
.pt-who { opacity: 0.95; }
.chip-ad .who { margin-left: 2px; }
.chip-ad { container-type: inline-size; }
@container (max-width: 100px) {
  .ev-who { display: none !important; }
}
@container (max-width: 160px) {
  .chip-ad .who { display: none !important; }
}
/* в одной строке имя не должно съедать название: на узких блоках его прячем (цвет остаётся),
   а у точки гостя сначала уходит время — его и так видно по положению на сетке */
@container (max-width: 210px) {
  .ev-who-s, .pt-who { display: none !important; }
}
@container (max-width: 320px) {
  .pt.by-guest .pt-time { display: none; }
}
.draft .ev-who, .draft .pt-who { display: none !important; }
[data-done="true"] .ev-who, [data-done="true"] .pt-who, .chip-ad[data-done="true"] .who { color: var(--text-3); }

/* выполненные задачи гостя: полоска слева остаётся его цвета, но приглушённо */
.ev.by-guest[data-done="true"]::before { background: color-mix(in srgb, var(--tc) 45%, var(--line-2)); }

/* кружок «выполнено» на чужой задаче — только для вида */
.ev-check.is-static { pointer-events: none; opacity: 0.35; }
[data-done="true"] .ev-check.is-static { opacity: 0.6; }

/* чужие задачи у гостя: курсор-указатель вместо «можно тянуть» */
.ev[data-ro="true"], .pt[data-ro="true"], .chip-ad[data-ro="true"] { cursor: default; }

/* точка цвета (легенда, список «Просрочено», карточка) */
.who-dot, .lg-dot {
  flex: none;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tc, var(--accent));
}
.overdue-row .who {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 34%;
  font-size: 12px;
  color: var(--accent-text);
}
.overdue-row .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overdue-row.by-guest .move { color: var(--accent-text); }
.overdue-row .move-none { flex: none; width: 1px; min-height: 28px; }

/* легенда: тихо, в шапке (десктоп) или под полосой дней (телефон) */
.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: var(--s3);
  font-size: 12px;
  color: var(--text-3);
  min-width: 0;
  overflow: hidden;
}
.lg-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; min-width: 0; }
.lg-name { overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.strip-wrap .legend {
  justify-content: center;
  flex-wrap: wrap;
  row-gap: 2px;
  margin: 6px 0 0;
  font-size: 11.5px;
}

/* кто вошёл (гость) */
.me {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin-left: var(--s2);
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.me b { font-weight: 600; color: var(--text-2); }
.me-out {
  padding: 4px 8px;
  border-radius: var(--r1);
  color: var(--text-2);
  font-size: 12.5px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.me-out:hover { background: var(--hover-strong); color: var(--text); }
.me-dot {
  width: 30px;
  height: 30px;
  margin-left: 2px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 650;
  background: color-mix(in srgb, var(--tc) 22%, var(--bg));
  color: color-mix(in srgb, var(--tc) var(--guest-ink-mix), var(--guest-ink));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tc) 70%, transparent);
  transition: transform var(--dur) var(--ease);
}
.me-dot:active { transform: scale(0.94); }
a.iconbtn { text-decoration: none; }
.menu-note {
  padding: 8px 10px 6px;
  font-size: 13px;
  color: var(--text-3);
}
.menu-note b { color: var(--text); font-weight: 600; }

/* строка «Добавлено: Катя» в карточке задачи */
.sheet-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 var(--s2);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent-text);
}

/* карточка чужой задачи (только посмотреть) */
.ro-title {
  margin: 2px 0 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.ro-title[data-done="true"] { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--text-2); }
.ro-desc {
  margin: var(--s2) 0 0;
  color: var(--text-2);
  font-size: 14.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ro-facts { display: flex; flex-direction: column; gap: 10px; }
.ro-fact { display: flex; align-items: center; gap: 10px; font-size: 14.5px; }
.ro-fact .icon { color: var(--text-3); width: 16px; }
.ro-bang { width: 16px; text-align: center; font-weight: 800; letter-spacing: -0.06em; color: var(--accent-text); }
body[data-view="mobile"] .sheet-ro .sheet-actions .btn { flex: 1; background: var(--hover-strong); color: var(--text); }
.ro-note {
  margin: var(--s4) 0 0;
  padding: 10px var(--s3);
  border-radius: var(--r2);
  background: var(--bg-sunk);
  color: var(--text-2);
  font-size: 13.5px;
}

/* ============================================================
   «Люди и доступ» (/admin)
   ============================================================ */

.adm-page { min-height: 100%; height: auto; }
.adm {
  max-width: 620px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + var(--s5)) max(var(--s4), var(--safe-r)) calc(var(--s7) + var(--safe-b)) max(var(--s4), var(--safe-l));
}
.adm-head { margin-bottom: var(--s5); }
.adm-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 var(--s4) -6px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.adm-back:hover { background: var(--hover-strong); color: var(--text); }
.adm-head h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.adm-lead { margin: var(--s2) 0 0; color: var(--text-2); font-size: 14.5px; max-width: 34em; }
.adm-sec { margin-top: var(--s6); }
.adm-h2 {
  margin: 0 0 var(--s3);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}
.adm-muted, .adm-empty { color: var(--text-3); font-size: 14.5px; margin: 0; }
.adm-empty { padding: var(--s4); border-radius: var(--r3); background: var(--surface); }
.adm-note { margin: 0 0 var(--s3); color: var(--text-3); font-size: 13px; }

/* список людей */
.plist { display: flex; flex-direction: column; gap: var(--s2); }
.person {
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  overflow: hidden;
  transition: box-shadow var(--dur) var(--ease);
}
.person[data-open="true"] { box-shadow: 0 0 0 1px var(--line-2); }
.p-head { display: flex; align-items: center; gap: var(--s2); padding-right: var(--s3); }
.p-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 14px 0 14px var(--s4);
  text-align: left;
  border-radius: var(--r3) 0 0 var(--r3);
}
.p-dot {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--tc);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 22%, transparent);
}
.p-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.p-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-sub { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-sub .tg.on { color: var(--text-2); }
.p-sub .off { color: var(--danger); }
.person[data-active="false"] .p-name { color: var(--text-2); }
.person[data-active="false"] .p-dot { opacity: 0.45; }
.p-chev { flex: none; color: var(--text-3); padding: 0 var(--s2); transition: transform var(--dur) var(--ease); }
.person[data-open="true"] .p-chev { transform: rotate(180deg); }

/* переключатель «доступ вкл/выкл» */
.toggle { flex: none; padding: 8px 2px; }
.toggle .track {
  display: block;
  width: 42px; height: 25px;
  border-radius: 13px;
  background: var(--line-2);
  position: relative;
  transition: background var(--dur) var(--ease);
}
.toggle .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);
}
.toggle[aria-checked="true"] .track { background: var(--accent); }
.toggle[aria-checked="true"] .track::after { transform: translateX(17px); }

.p-edit { padding: var(--s2) var(--s4) var(--s4); border-top: 1px solid var(--line); animation: fade-in 160ms var(--ease); }
.p-edit > .label:first-child { margin-top: var(--s3); }
.label-gap { margin-top: var(--s4); }
.p-save { display: flex; justify-content: flex-end; margin-top: var(--s3); }
.p-links { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* мягкая кнопка (вторичная) */
.btn-soft {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-sunk);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn-soft:hover { background: var(--hover-strong); }
.btn-soft .icon { color: var(--text-2); }
.btn-soft.is-done, .btn-soft.is-done .icon { color: var(--accent-text); }

/* цвета */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--sw);
  color: #fff;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.swatch:hover { transform: scale(1.07); }
.swatch .icon { opacity: 0; transition: opacity var(--dur) var(--ease); }
.swatch .icon svg { stroke-width: 2.4; filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.5)); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw); }
.swatch[aria-checked="true"] .icon { opacity: 1; }
.swatch-custom { background: conic-gradient(#ff5f6d, #ffc371, #3ecf8e, #22c3d6, #4d8dff, #c77dff, #ff5fa2, #ff5f6d); }
.swatch-custom[aria-checked="true"] { background: var(--sw); }
.swatch-custom input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
}
.swatch-custom:focus-within { outline: 2px solid var(--accent-ring); outline-offset: 3px; }

/* форма «добавить» */
.addform {
  padding: var(--s4);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}
.add-actions { display: flex; justify-content: flex-end; margin-top: var(--s4); }

/* окно со ссылками / подтверждением */
.adm-dialog { width: min(520px, calc(100vw - 32px)); }
.dlg-person {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--s2);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
}
.dlg-person .p-dot { width: 10px; height: 10px; box-shadow: none; }
.dlg-title { margin: 0 0 var(--s2); font-size: 20px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.25; }
.dlg-text { margin: 0; color: var(--text-2); font-size: 14.5px; }
.dlg-warn {
  margin: var(--s3) 0 0;
  padding: 10px var(--s3);
  border-radius: var(--r2);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  color: var(--text);
  font-size: 13.5px;
}
.dlg-warn b { color: var(--danger); font-weight: 600; }
.dlg-once { margin: var(--s2) 0 0; color: var(--text-3); font-size: 13px; }
.lk { margin-top: var(--s4); }
.lk-url, .lk-msg {
  padding: 10px var(--s3);
  border-radius: var(--r2);
  background: var(--bg-sunk);
  font-size: 13.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
}
.lk-url { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; color: var(--text); }
.lk-msg { white-space: pre-wrap; user-select: text; -webkit-user-select: text; color: var(--text-2); }
.lk-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.lk-none { margin: 0; padding: 10px var(--s3); border-radius: var(--r2); background: var(--bg-sunk); color: var(--text-2); font-size: 13.5px; }

body.adm-page[data-view="mobile"] .adm-head h1 { font-size: 24px; }
body.adm-page[data-view="mobile"] .p-links .btn { flex: 1 1 100%; justify-content: center; height: 44px; }
body.adm-page[data-view="mobile"] .add-actions .btn { flex: 1; height: 46px; }
body.adm-page[data-view="mobile"] .input { font-size: 16px; }
body.adm-page[data-view="mobile"] .lk-actions .btn { flex: 1; justify-content: center; height: 40px; }
body.adm-page[data-view="mobile"] .sheet-actions .grow { display: none; }
body.adm-page[data-view="mobile"] .toasts { bottom: calc(var(--s5) + var(--safe-b)); }
body.adm-page[data-view="mobile"] .swatches { gap: 12px; }
body.adm-page[data-view="mobile"] .swatch { width: 34px; height: 34px; }

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

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