/* «Задачи» — mobile-first. Светлая и тёмная тема по настройке системы. */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #ededf1;
  --border: #e2e2e8;
  --text: #17171c;
  --muted: #6b6b76;
  --accent: #6d3ee8;
  --accent-soft: #eee8ff;
  --on-accent: #ffffff;
  --danger: #dc3b40;
  --warn: #e08a00;
  --ok: #1f9d55;

  --radius: 16px;
  --radius-sm: 10px;
  --tap: 44px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .05);

  color-scheme: light dark;
  accent-color: var(--accent);
}

/* Тёмная тема: по системе (если в настройках не выбрана светлая) или выбрана явно.
   Набор цветов повторён дважды — у CSS нет способа сослаться на один блок из двух условий. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111114;
    --surface: #1b1b20;
    --surface-2: #26262d;
    --border: #2e2e36;
    --text: #f2f2f6;
    --muted: #9b9ba8;
    --accent: #9b7bff;
    --accent-soft: #2a2346;
    --on-accent: #140b30;
    --danger: #ff6b6f;
    --warn: #ffb020;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #111114;
  --surface: #1b1b20;
  --surface-2: #26262d;
  --border: #2e2e36;
  --text: #f2f2f6;
  --muted: #9b9ba8;
  --accent: #9b7bff;
  --accent-soft: #2a2346;
  --on-accent: #140b30;
  --danger: #ff6b6f;
  --warn: #ffb020;
  --shadow: none;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: clip; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.icon { width: 22px; height: 22px; flex: none; }

/* --- Каркас --------------------------------------------------------------- */

.sidebar { display: none; }
.page { min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  min-height: 56px; padding: env(safe-area-inset-top, 0px) 12px 0 16px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.topbar h1 {
  flex: 1; min-width: 0; font-size: 24px; font-weight: 750; letter-spacing: -0.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .back { margin-left: -10px; }
.topbar-avatar { display: grid; place-items: center; width: var(--tap); height: var(--tap); }
.topbar-avatar .avatar { --size: 32px; font-size: 13px; }

main {
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + var(--safe-bottom) + 28px);
}

.bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; align-items: center;
  height: calc(var(--nav-h) + var(--safe-bottom)); padding: 0 4px var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--border);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 100%; font-size: 11px; font-weight: 600; color: var(--muted);
}
.bottomnav a[aria-current="page"] { color: var(--accent); }
.nav-add { border: 0; background: none; padding: 0 8px; cursor: pointer; }
.nav-icon { position: relative; display: inline-flex; }
.dot-badge {
  position: absolute; top: -1px; right: -3px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--surface);
}
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: auto; padding: 0 6px;
  border-radius: 10px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700;
}
.nav-add .icon-wrap {
  display: grid; place-items: center; width: 56px; height: 40px; border-radius: 20px;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform .1s ease;
}
.nav-add:active .icon-wrap { transform: scale(.94); }
.nav-add .icon { width: 26px; height: 26px; }

/* --- Кнопки и поля -------------------------------------------------------- */

.icon-btn {
  display: inline-grid; place-items: center; flex: none; width: var(--tap); height: var(--tap);
  border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.is-active { color: var(--accent); background: var(--accent-soft); }
.icon-btn.accent { background: var(--accent); color: var(--on-accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: transform .08s ease, background .15s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn .icon { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 14px; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .field > .label, .field > legend {
  display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.field > legend { margin-bottom: 6px; }
.field > label .icon { width: 16px; height: 16px; }

.input,
.field input:not([type=radio]):not([type=checkbox]),
.field select, .field textarea,
.task-form input[type=date], .task-form input[type=time], .switch-row select {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 16px; /* 16px — iOS не зумит поле */
}
.field textarea { resize: vertical; min-height: 72px; field-sizing: content; max-height: 40dvh; }
.field select, .switch-row select { appearance: none; padding-right: 32px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; }
input:user-invalid { border-color: var(--danger) !important; }
.error-msg { display: none; color: var(--danger); font-size: 14px; }
input:user-invalid ~ .error-msg { display: block; }
.errorlist { margin: 0; padding: 0; list-style: none; color: var(--danger); font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); }
.field .hint { margin-top: -2px; }

.password { position: relative; }
.password input { padding-right: 52px !important; }
.password .icon-btn { position: absolute; right: 2px; top: 50%; translate: 0 -50%; color: var(--muted); }
.password .icon-btn[aria-pressed="true"] { color: var(--accent); }

.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.notice.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }

/* Чипы-переключатели: раздел, ответственные, отметки */
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; inset: 0; opacity: 0; margin: 0; pointer-events: none; }
.choice > span {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: 14px; font-weight: 600; cursor: pointer; user-select: none;
  transition: background .15s ease, border-color .15s ease;
}
.choice > span .icon { width: 18px; height: 18px; color: var(--c, var(--muted)); }
.choice input:checked + span {
  border-color: var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 13%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--c, var(--accent));
}
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice.person > span { padding-left: 5px; }
.choice.person .avatar { --size: 30px; }

.pill {
  min-height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.pill[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Переключатель (role="switch") */
input[role="switch"] {
  appearance: none; flex: none; position: relative; width: 50px; height: 30px; margin: 0;
  border-radius: 15px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
  transition: background .2s ease;
}
input[role="switch"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: translate .2s ease;
}
input[role="switch"]:checked { background: var(--ok); border-color: var(--ok); }
input[role="switch"]:checked::after { translate: 20px 0; }

.avatar {
  --size: 26px;
  display: inline-grid; place-items: center; flex: none; width: var(--size); height: var(--size); border-radius: 50%;
  background: var(--av, var(--accent)); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em;
}

/* --- Фильтры (в шапке) ---------------------------------------------------- */

/* Чипы разделов — второй строкой шапки, прокручиваются вбок от края до края */
.chips {
  order: 10; display: flex; gap: 6px; flex: 0 0 calc(100% + 28px); min-width: 0;
  margin: 0 -12px 0 -16px; padding: 2px 12px 10px 16px;
  overflow-x: auto; scrollbar-width: none;
  mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.chip[aria-current] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip .icon { width: 17px; height: 17px; color: var(--muted); }
.who { flex: none; }
.chip-select { padding-right: 4px; }
.chip-select select {
  appearance: none; border: 0; background: transparent; font-weight: 600; font-size: 14px;
  padding: 0 22px 0 0; cursor: pointer; max-width: 120px; field-sizing: content; text-overflow: ellipsis;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 4px center / 14px;
}
.list-search { margin: 4px 0; }
.list-search .input { border-radius: 999px; min-height: 40px; }

/* --- Список задач --------------------------------------------------------- */

.group { margin-top: 20px; }
.group-title {
  display: flex; align-items: baseline; gap: 8px; margin: 0 4px 8px;
  font-size: 15px; font-weight: 700;
}
.group-title .sub { font-weight: 500; color: var(--muted); font-size: 14px; }
.group-title .count { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.group-overdue .group-title { color: var(--danger); }
.done-group summary { cursor: pointer; list-style: none; color: var(--muted); }
.done-group summary::-webkit-details-marker { display: none; }
.done-group summary::before { content: "›"; display: inline-block; transition: rotate .15s ease; font-size: 18px; line-height: 1; }
.done-group[open] summary::before { rotate: 90deg; }

.tasks {
  margin: 0; padding: 0; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.task {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  padding-right: 12px; border-top: 1px solid var(--border);
}
.task:first-child { border-top: 0; }
.task:hover { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }

.check {
  display: grid; place-items: center; width: 50px; align-self: stretch; min-height: 52px;
  border: 0; background: none; padding: 0; cursor: pointer; color: var(--c);
}
.check .icon {
  width: 24px; height: 24px; padding: 4px; border-radius: 50%;
  border: 2px solid var(--c); color: transparent; stroke-width: 3;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.check:hover .icon { color: color-mix(in srgb, var(--c) 55%, transparent); }
.check:active .icon { transform: scale(.88); }
.is-done .check .icon { background: var(--c); color: #fff; }
.is-virtual .check .icon { border: 0; padding: 0; width: 20px; height: 20px; color: var(--c); stroke-width: 2; opacity: .7; }

.task-main { display: grid; gap: 3px; min-width: 0; padding: 12px 8px 12px 0; }
.task-title { font-weight: 550; overflow-wrap: anywhere; }
.task-title .flag { display: inline-flex; vertical-align: -2px; margin-right: 4px; color: var(--warn); }
.task-title .flag .icon { width: 16px; height: 16px; }
.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; font-size: 13px; color: var(--muted); }
.task-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.task-meta .icon { width: 14px; height: 14px; }
.task-cat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.hide-cat .task-cat { display: none; }
.when.overdue { color: var(--danger); font-weight: 600; }
.avatars { display: flex; }
.avatars .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatars .avatar + .avatar { margin-left: -7px; }

.empty { display: grid; justify-items: center; gap: 12px; padding: 56px 16px; text-align: center; color: var(--muted); }
.empty .icon { width: 44px; height: 44px; stroke-width: 1.5; }

/* --- Календарь ------------------------------------------------------------ */

.calendar { display: grid; gap: 18px; margin-top: 4px; }
.month-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.month-head h2 { flex: 1; font-size: 19px; font-weight: 750; }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays span { padding: 4px 0; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.weekdays .weekend { color: color-mix(in srgb, var(--danger) 75%, var(--muted)); }
.grid { gap: 2px; }

.day {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 0; min-height: 54px; padding: 5px 2px; border-radius: 12px;
}
.day:hover { background: var(--surface-2); }
.day .num {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.day.red .num { color: var(--danger); }
.day.outside { opacity: .38; }
.day.selected { background: var(--surface); box-shadow: inset 0 0 0 2px var(--accent); }
.day.today .num { background: var(--accent); color: var(--on-accent); }
.dots { display: flex; gap: 3px; height: 6px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.dots i.done { opacity: .35; }
.day-tasks, .hol-name { display: none; }

.day-panel { min-width: 0; }
.day-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.day-head > div { flex: 1; min-width: 0; }
.day-head h2 { font-size: 18px; font-weight: 700; }
.holiday-name { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 14px; font-weight: 600; color: var(--danger); }
.holiday-name .icon { width: 16px; height: 16px; }
.day-empty { padding: 22px 16px; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; color: var(--muted); font-size: 14px; }

/* --- Шторка с задачей ----------------------------------------------------- */

dialog.sheet {
  width: 100%; max-width: 560px; max-height: 94dvh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--text);
  box-shadow: 0 -8px 40px rgb(0 0 0 / .2);
}
dialog.sheet:modal { overscroll-behavior: contain; }
dialog.sheet::backdrop { background: rgb(0 0 0 / .45); overflow: hidden; overscroll-behavior: contain; }
dialog.sheet[open] { animation: sheet-in .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet-in { from { translate: 0 60px; opacity: 0; } }

.task-form { padding: 0 16px calc(12px + var(--safe-bottom)); }
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px;
  margin: 0 -16px 4px; padding: 14px 8px 6px 16px; background: var(--surface);
}
.sheet-head h2 { flex: 1; font-size: 18px; font-weight: 700; }
.sheet-head::before {   /* «ручка» шторки */
  content: ""; position: absolute; top: 6px; left: 50%; translate: -50% 0;
  width: 38px; height: 4px; border-radius: 2px; background: var(--border);
}
.task-form .title-input {
  border: 0 !important; border-bottom: 1px solid var(--border) !important; border-radius: 0 !important;
  padding: 8px 0 !important; background: transparent !important;
  font-size: 21px !important; font-weight: 650;
}
.task-form .title-input:focus-visible { outline: 0; border-bottom-color: var(--accent) !important; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-2 > .field { margin-bottom: 0; }
.when-hint { margin: 6px 0 16px; }
.task-form > .choice-row { margin-bottom: 6px; }
.sheet-foot {
  position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 8px;
  margin: 14px -16px 0; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--border);
}
.sheet-foot .btn-primary { margin-left: auto; min-width: 140px; }
.task-form .meta { margin-top: 10px; font-size: 12px; color: var(--muted); text-align: center; }
.panel .task-form { padding: 0; }
.panel .sheet-foot { margin: 14px 0 0; padding: 12px 0 0; }

/* --- Настройки, вход ------------------------------------------------------ */

.panel {
  margin-top: 14px; padding: 18px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.panel h2 { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.panel > .hint { margin: -6px 0 12px; }
.settings > .btn-block { margin-top: 14px; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--border); cursor: pointer;
}
.switch-row > span, .switch-row > label { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch-row > span .icon, .switch-row > label .icon { color: var(--muted); }
.switch-row b { display: block; font-weight: 600; }
.switch-row small { display: block; font-size: 13px; color: var(--muted); }
.switch-row select { width: auto; min-width: 150px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.panel h2 .count { margin-left: 4px; color: var(--muted); font-size: 14px; font-weight: 600; }
.page-hint { margin: 4px 4px 12px; }

/* Проекты */
.project-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px;
  padding-right: 8px; border-top: 1px solid var(--border);
}
.project-row:first-child { border-top: 0; }
.project-main { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px; }
.project-icon {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: color-mix(in srgb, var(--c) 15%, var(--surface)); color: var(--c);
}
.project-text { display: grid; gap: 2px; min-width: 0; }
.project-list .empty { padding: 32px 16px; }
.add-project { margin-top: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch, .icon-choice { position: relative; }
.swatch input, .icon-choice input { position: absolute; inset: 0; margin: 0; opacity: 0; pointer-events: none; }
.swatch > span {
  display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); cursor: pointer;
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / .08);
}
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); }
.swatch input:focus-visible + span, .icon-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 4px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-choice > span {
  display: grid; place-items: center; height: 44px; border: 1px solid var(--border); border-radius: 12px;
  color: var(--muted); cursor: pointer;
}
.icon-choice input:checked + span { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.delete-project {
  margin: 0 16px 16px; padding: 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border));
}
.panel .delete-project { margin: 14px 0 0; }
.delete-project h3 { font-size: 16px; margin-bottom: 8px; }
.delete-project .btn { margin-top: 10px; }
.radio-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; font-size: 15px; cursor: pointer; }
.radio-row select { min-height: 36px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }

/* Друзья */
.inline-form { display: flex; gap: 8px; margin-bottom: 8px; }
.inline-form .input { flex: 1; min-width: 0; }
.people { margin: 0; padding: 0; list-style: none; }
.people li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.people li:first-child { border-top: 0; }
.people .avatar { --size: 36px; font-size: 13px; }
.person-text { display: grid; flex: 1; min-width: 0; }
.person-text b { font-weight: 600; }
.person-text small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.sub-field { margin: 0 0 6px 34px; }
.sub-field.field { margin-bottom: 14px; }
.link { color: var(--accent); font-weight: 600; }
.tg-nick { margin: 16px 0 6px; }
.at-input { position: relative; }
.at-input > span { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.at-input input { padding-left: 32px !important; }

.segmented { display: flex; gap: 4px; padding: 4px; margin-bottom: 10px; border-radius: 999px; background: var(--surface-2); }
.segmented label { flex: 1; position: relative; min-width: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border-radius: 999px;
  font-size: 14px; font-weight: 650; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.segmented span .icon { width: 18px; height: 18px; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .15); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.tg-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.tg-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ok); }
.telegram .hint { margin-bottom: 12px; }

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth .logo { width: 64px; height: 64px; margin: 0 auto 14px; }
.auth h1 { text-align: center; font-size: 26px; font-weight: 750; margin-bottom: 22px; }
.auth-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 20px; margin-top: 18px; font-size: 15px; }
.auth-links a { color: var(--accent); font-weight: 600; }
.auth .empty .btn { margin-top: 4px; }

/* --- Уведомления ---------------------------------------------------------- */

.toasts {
  position: fixed; left: 16px; right: 16px; z-index: 60; display: grid; gap: 8px; justify-items: center;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px); pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg);
  font-size: 15px; font-weight: 600; box-shadow: 0 6px 24px rgb(0 0 0 / .25);
  animation: toast 3.4s ease forwards;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast {
  0% { opacity: 0; translate: 0 8px; }
  8%, 85% { opacity: 1; translate: 0 0; }
  100% { opacity: 0; }
}

/* --- Планшет и компьютер -------------------------------------------------- */

@media (min-width: 640px) {
  dialog.sheet { margin: auto; border-radius: 22px; max-height: 90dvh; }
  dialog.sheet[open] { animation-name: dialog-in; }
  .sheet-head::before { display: none; }
  @keyframes dialog-in { from { scale: .96; opacity: 0; } }
}

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 6px; padding: 18px 14px;
    background: var(--surface); border-right: 1px solid var(--border);
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-size: 19px; font-weight: 750; }
  .sidebar > .btn { margin-bottom: 10px; }
  .side-nav { display: grid; gap: 2px; }
  .side-nav a {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px;
    border-radius: 10px; font-weight: 550; color: var(--text);
  }
  .side-nav a:hover { background: var(--surface-2); }
  .side-nav a[aria-current] { background: var(--accent-soft); color: var(--accent); }
  .side-nav .icon { width: 20px; height: 20px; color: var(--muted); }
  .side-nav a[aria-current] .icon { color: var(--accent); }
  .side-nav .cat-icon { display: grid; }
  .side-nav .cat-icon .icon { color: var(--c); }
  .side-nav .count { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .side-label {
    display: flex; align-items: center; justify-content: space-between; margin: 16px 2px 4px 10px;
    font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  }
  .side-label a[aria-current] { color: var(--accent); }
  .side-add { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; }
  .side-add:hover { background: var(--surface-2); color: var(--text); }
  .side-add .icon { width: 16px; height: 16px; }
  .side-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-user {
    display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 8px 10px;
    border-radius: 12px; font-weight: 600;
  }
  .side-user span:not(.avatar) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-user .icon { width: 20px; height: 20px; color: var(--muted); }
  .side-user:hover, .side-user[aria-current] { background: var(--surface-2); }
  .side-user .avatar { --size: 32px; font-size: 13px; }

  .bottomnav, .topbar-avatar, .topbar .chips { display: none; }
  .topbar { padding: 0 24px; min-height: 68px; }
  main { padding: 0 24px 48px; }
  main.wide { max-width: 1280px; }
  .toasts { left: auto; right: 24px; bottom: 24px; justify-items: end; }

  .calendar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; gap: 24px; }
  .grid {
    gap: 1px; overflow: hidden; border-radius: var(--radius);
    background: var(--border); border: 1px solid var(--border); box-shadow: var(--shadow);
  }
  .day {
    align-items: stretch; gap: 3px; min-height: 118px; padding: 6px; border-radius: 0; background: var(--surface);
  }
  .day:hover { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
  .day.outside { opacity: 1; background: color-mix(in srgb, var(--bg) 70%, var(--surface)); }
  .day.outside .num, .day.outside .day-tasks { opacity: .45; }
  .day.selected { box-shadow: inset 0 0 0 2px var(--accent); background: var(--surface); }
  .day .num { width: 28px; height: 28px; font-size: 14px; }
  .dots { display: none; }
  .hol-name { display: block; font-size: 11px; line-height: 1.25; color: var(--danger); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .day-tasks { display: grid; gap: 2px; min-width: 0; }
  .cal-task {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: 1px 6px; border-radius: 5px; font-size: 12px; line-height: 1.5;
    background: color-mix(in srgb, var(--c) 14%, var(--surface)); box-shadow: inset 3px 0 0 var(--c);
  }
  .cal-task b { font-weight: 650; }
  .cal-task.done { opacity: .5; text-decoration: line-through; }
  .more { padding: 0 6px; font-size: 12px; color: var(--muted); }
  .day-panel { position: sticky; top: 84px; }
  .month-head { margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; }
}
