/* Оформление сайта TaskMaster. Цвета заданы переменными; тему выбирает атрибут data-theme на <html> (см. theme.js).
   Пары «текст/фон» проверены на контраст не ниже WCAG AA (4.5:1 для текста, 3:1 для границ полей и значков). */
:root {
  color-scheme: light;
  --bg: #f4f6fb; --card: #ffffff; --text: #141b2b; --muted: #556178; --line: #dfe4ed; --ctl: #7b879c;
  --accent: #2563eb; --accent-ink: #1e4fd0; --accent-soft: #e6edff; --on-accent: #ffffff;
  --bad: #c4223b; --bad-soft: #fde7eb; --warn: #8a5300; --warn-soft: #fff1d1; --ok: #12753f; --ok-soft: #dcf5e6;
  --chip: #e8ebf2; --hover: #f0f3f9;
  --toast-bg: #1b2333; --toast-text: #ffffff; --toast-action: #a9c6ff;
  --shadow: 0 1px 2px rgba(20, 27, 43, .05), 0 4px 16px rgba(20, 27, 43, .06);
  --shadow-lg: 0 8px 28px rgba(20, 27, 43, .22);
  --scrim: rgba(14, 18, 28, .5);
  --radius: 16px; --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); --tabbar-h: 64px;
  --side: 0px;
  --p0: #2563eb; --p1: #0f766e; --p2: #7c3aed; --p3: #c2410c; --p4: #be185d; --p5: #15803d; --p6: #4f46e5; --p7: #475569;
}
/* Мини-приложение: отступы безопасных зон приходят от Telegram (--tg-*), выреза и шапки Telegram не касаемся. */
:root[data-platform="telegram"] {
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
}
:root[data-platform="telegram"] .theme-toggle { display: none; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1218; --card: #171d27; --text: #e9eef6; --muted: #9ba7ba; --line: #273040; --ctl: #6f7c92;
  --accent: #6c9cff; --accent-ink: #9bbcff; --accent-soft: #1b2a47; --on-accent: #0a1020;
  --bad: #ff7a8e; --bad-soft: #3a1d25; --warn: #f3be5c; --warn-soft: #372c14; --ok: #4cc38a; --ok-soft: #14342a;
  --chip: #252d3b; --hover: #1e2532;
  --toast-bg: #e9eef6; --toast-text: #101623; --toast-action: #1e4fd0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, .6);
  --scrim: rgba(0, 0, 0, .62);
}
/* без JavaScript атрибута нет: тогда следуем системной теме */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0e1218; --card: #171d27; --text: #e9eef6; --muted: #9ba7ba; --line: #273040; --ctl: #6f7c92;
    --accent: #6c9cff; --accent-ink: #9bbcff; --accent-soft: #1b2a47; --on-accent: #0a1020;
    --bad: #ff7a8e; --bad-soft: #3a1d25; --warn: #f3be5c; --warn-soft: #372c14; --ok: #4cc38a; --ok-soft: #14342a;
    --chip: #252d3b; --hover: #1e2532;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.boot { padding: 48px 16px; text-align: center; color: var(--muted); }
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 16px; height: 16px; }
.ico.xs { width: 12px; height: 12px; }

/* ---------- каркас ---------- */
.shell { max-width: 760px; margin: 0 auto; min-height: 100vh; padding: 0 16px calc(var(--safe-bottom) + var(--tabbar-h) + 96px); }
.topbar {
  position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 10px; min-height: 60px;
  padding: calc(var(--safe-top) + 8px) 0 8px; background: var(--bg);
}
.topbar h1 { font-size: 28px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .iconbtn { box-shadow: none; border-color: transparent; background: var(--chip); }
.topbar .iconbtn:hover { background: var(--hover); border-color: var(--line); }
.btn.back { padding-left: 6px; border-color: transparent; background: none; color: var(--accent-ink); }
.btn.back:hover { background: var(--accent-soft); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.off { background: var(--warn-soft); color: var(--warn); }
.iconbtn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--text); box-shadow: var(--shadow);
  transition: background-color .15s, border-color .15s;
}
.iconbtn:hover { background: var(--hover); border-color: var(--ctl); }
.banner { margin: 8px 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: 14px; font-weight: 500; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner button { margin-left: 8px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom);
}
.tabbar .inner { display: flex; width: 100%; max-width: 760px; padding: 0 8px; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px 8px;
  border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 500; position: relative;
}
.tab .pillbg { display: grid; place-items: center; width: 52px; height: 28px; border-radius: 14px; transition: background-color .15s; }
.tab.active { color: var(--accent-ink); font-weight: 700; }
.tab.active .pillbg { background: var(--accent-soft); }
.tab .dot { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: var(--card); font-size: 11px; font-weight: 700; line-height: 18px; padding: 0 5px; }

/* ---------- карточки и строки ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line);
  width: 100%; background: none; text-align: left;
}
.row:last-child { border-bottom: 0; }
button.row { transition: background-color .12s; }
button.row:hover { background: var(--hover); }
button.row:active { background: var(--accent-soft); }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 600; overflow-wrap: break-word; }
.sub { color: var(--muted); font-size: 13px; line-height: 1.4; }
.chev { color: var(--muted); }
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; line-height: 1.3; padding: 3px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.muted { background: var(--chip); color: var(--muted); }
.section { margin: 24px 4px 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.section.bad { color: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; font-size: 15px; }
.card .empty { padding: 28px 16px; }

/* главный экран «Задачи»: фильтры и группы по сроку */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 2px -16px 4px; padding: 4px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 18px;
  border: 1px solid transparent; background: var(--chip); color: var(--muted); font-size: 14px; font-weight: 600; transition: background-color .12s, color .12s;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--text); color: var(--card); }
.chip .n { font-weight: 700; opacity: .85; }
.chip .n::before { content: "· "; }
.group { margin-top: 18px; }
.group-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 6px; }
.group-h .gt { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.group-h.bad .gt { color: var(--bad); }
.link { border: 0; background: none; padding: 4px 2px; color: var(--accent-ink); font-weight: 700; font-size: 14px; }
.link:hover { text-decoration: underline; }
.row-more { display: block; width: 100%; padding: 12px 16px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--accent-ink); font-weight: 700; font-size: 14px; text-align: left; }
.row-more:hover { background: var(--hover); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat b { display: block; font-size: 24px; line-height: 1.1; font-weight: 700; letter-spacing: -.01em; }
.stat span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.bad b { color: var(--bad); }
.stat.accent b { color: var(--accent-ink); }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 17px; }
.avatar .ico { width: 20px; height: 20px; }
.avatar.inbox { background: var(--chip); color: var(--muted); }
/* цвет проекта: аватар и точка в строке задачи */
.pc0 { --pc: var(--p0); } .pc1 { --pc: var(--p1); } .pc2 { --pc: var(--p2); } .pc3 { --pc: var(--p3); }
.pc4 { --pc: var(--p4); } .pc5 { --pc: var(--p5); } .pc6 { --pc: var(--p6); } .pc7 { --pc: var(--p7); }
.avatar[class*="pc"] { background: var(--pc); color: #ffffff; }
.clamp2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.row .badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; flex: none; max-width: 50%; }

/* строка проекта: основная кнопка, быстрые действия (видны при наведении и фокусе) и «⋯» */
.row.proj { padding: 0; gap: 0; position: relative; transition: background-color .12s; }
.row.proj::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: transparent; }
.row.proj.prio-high::before { background: var(--bad); }
.row.proj.dragging { opacity: .55; }
.row.proj.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.row.proj.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.pinmark { color: var(--accent-ink); flex: none; display: inline-flex; align-self: center; }
.pinmark .ico { width: 14px; height: 14px; }
.pbar { display: flex; gap: 8px; align-items: center; margin: 4px 0 6px; }
.pbar input[type=search] { flex: 1; min-height: 42px; }
.psub { display: flex; flex-wrap: wrap; column-gap: 8px; margin-top: 1px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.psub .bad { color: var(--bad); font-weight: 700; }
.psub .shared { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.pcount { flex: none; min-width: 20px; margin-right: 6px; text-align: right; font-size: 14px; font-weight: 700; color: var(--muted); }
.pfold { margin-top: 12px; }
.pfold-h { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 50px; padding: 12px 16px; border: 0; background: none; color: var(--text); font-weight: 600; text-align: left; }
.pfold-h:hover { background: var(--hover); }
.pfold-h + * { border-top: 1px solid var(--line); }
.pfold .row.proj { border-top: 1px solid var(--line); border-bottom: 0; }
.pfold .empty { padding: 18px 16px; font-size: 14px; }
.row.proj:hover, .row.proj:focus-within { background: var(--hover); }
.rowmain { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 14px 4px 14px 16px; border: 0; background: none; text-align: left; }
.rowmain:active { background: var(--accent-soft); }
.rowmain:focus-visible { outline-offset: -2px; border-radius: var(--radius-sm); }
.row.proj > .rowmain:last-child { padding-right: 16px; }
.tline { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.tline .title { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--muted); }
.peek .pk { padding: 2px 7px; margin-right: 4px; border-radius: 6px; background: var(--hover); }
.peek .pk.bad { color: var(--bad); }
.peek .pk .w { opacity: .8; }
.peek .mark { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; border: 1.5px solid var(--bad); vertical-align: 1px; }
.peek .pmore { font-weight: 600; }
.peek .pmore.narrow { display: none; }
.more { display: grid; place-items: center; width: 40px; height: 40px; flex: none; margin: 0 8px 0 2px; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--muted); transition: background-color .12s, color .12s; }
.more:hover, .more[aria-expanded="true"] { background: var(--chip); color: var(--text); }
.iconbtn.more { margin: 0; border-radius: 50%; background: var(--card); color: var(--text); }
.iconbtn.more:hover, .iconbtn.more[aria-expanded="true"] { background: var(--hover); }
.ico.dots { stroke-width: 3.2; }
.toolbtn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; padding: 0; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); transition: background-color .12s, border-color .12s, color .12s;
}
.toolbtn:hover { border-color: var(--ctl); background: var(--hover); }
.toolbtn.danger { color: var(--bad); }
.toolbtn.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.toolbtn.ok { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.toolbtn.ok:hover { filter: brightness(1.07); background: var(--accent); }
.toolbtn:disabled { opacity: .5; cursor: default; }
.row-tools, .head-tools { display: none; gap: 4px; align-items: center; }
@media (hover: hover) and (pointer: fine) {
  .row-tools {
    display: flex; position: absolute; top: 50%; right: 50px; transform: translateY(-50%); padding: 4px 4px 4px 44px;
    background: linear-gradient(to right, transparent, var(--hover) 40px); opacity: 0; pointer-events: none; transition: opacity .12s;
  }
  .row.proj:hover .row-tools, .row.proj:focus-within .row-tools { opacity: 1; pointer-events: auto; }
  .row.proj > .row-tools:nth-last-child(1) { right: 8px; }
}
@media (hover: hover) and (pointer: fine) and (min-width: 640px) {
  .head-tools { display: flex; }
}
.row.renaming { padding: 8px 8px 8px 16px; background: var(--hover); }
.rename { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.rename input[type=text] { flex: 1; min-width: 0; min-height: 40px; padding: 8px 12px; font-weight: 600; }
.topbar .rename input[type=text] { font-size: 18px; }

/* предпросмотр задач проекта при наведении: полупрозрачная карточка, мышь проходит сквозь неё к кнопкам */
.ppv {
  position: fixed; top: 0; left: 0; z-index: 15; width: 360px; max-width: calc(100vw - 16px); padding: 12px 14px 10px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); box-shadow: var(--shadow-lg);
  pointer-events: none; opacity: 0; transform: translateY(-4px); transition: opacity .14s, transform .14s;
}
.ppv.show { opacity: 1; transform: none; pointer-events: auto; }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) and (background: color-mix(in srgb, red 50%, transparent)) {
  .ppv {
    background: color-mix(in srgb, var(--card) 78%, transparent); border-color: color-mix(in srgb, var(--line) 80%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  }
}
.ppv-head { display: flex; flex-direction: column; gap: 1px; margin-bottom: 8px; }
.ppv-head b { font-size: 14px; overflow-wrap: anywhere; }
.ppv-head span { font-size: 12px; color: var(--muted); font-weight: 500; }
.ppv-list { list-style: none; margin: 0; padding: 0; }
.ppv-note { font-size: 13px; color: var(--muted); margin: -2px 0 8px; white-space: pre-line; overflow-wrap: anywhere; }
.pnote-box { margin: 0 0 12px; }
.pnote { width: 100%; resize: vertical; min-height: 56px; line-height: 1.45; }
.pnote-meta { margin-top: 4px; font-size: 12px; }
.ppv-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; line-height: 1.3; border-top: 1px solid var(--line); }
.ppv-item .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ppv-item.bad .t { color: var(--bad); font-weight: 600; }
.ppv-item.pending { opacity: .75; }
.ppv-item .badge { font-size: 11px; padding: 2px 7px; }
.ppv-item .mark { width: 7px; height: 7px; flex: none; border-radius: 50%; border: 1.5px solid var(--ctl); }
.ppv-item .mark.high { border-color: var(--bad); }
.ppv-item .mark.bad { background: var(--bad); border-color: var(--bad); }
.ppv-empty { font-size: 13px; color: var(--muted); padding: 6px 0 4px; border-top: 1px solid var(--line); }
.ppv-more { font-size: 12px; font-weight: 600; color: var(--accent-ink); padding-top: 6px; border-top: 1px solid var(--line); }
.ppv-act { pointer-events: auto; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
@media (hover: none), (pointer: coarse) { .ppv { display: none; } }

/* меню «⋯» на компьютере и лист действий на телефоне */
.menu-wrap { position: fixed; inset: 0; z-index: 25; }
.menu {
  position: fixed; top: 0; right: 8px; min-width: 240px; max-width: min(340px, calc(100vw - 16px)); padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.menu .mh { padding: 6px 10px 8px; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: none; text-align: left; font-size: 15px; font-weight: 500; color: var(--text); }
.mi:hover, .mi:focus-visible { background: var(--hover); }
.mi:focus-visible { outline-offset: -2px; }
.mi .ico { color: var(--muted); }
.mi.danger, .mi.danger .ico { color: var(--bad); }
.mi.danger:hover { background: var(--bad-soft); }
.mi:disabled { opacity: .6; cursor: default; background: none; }
.mi .hint { font-size: 12px; color: var(--muted); font-weight: 500; }
.mi.on { background: var(--accent-soft); color: var(--accent-ink); }
.menu .sep, .menulist .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menulist { padding: 6px; }
.menulist .mi { padding: 14px 12px; font-size: 16px; min-height: 52px; }

/* шапка проекта: длинное название читается целиком (две строки, по нажатию — всё) */
.topbar.proj { flex-wrap: wrap; row-gap: 6px; }
.topbar.proj > .btn:first-child { margin-right: auto; }
.topbar .ptitle { order: 5; flex: 1 0 100%; min-width: 0; }
.topbar h1.ptitle { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; font-size: 22px; line-height: 1.25; }
.topbar h1.ptitle.long { cursor: pointer; border-radius: 6px; }
.topbar h1.ptitle.full { display: block; -webkit-line-clamp: unset; line-clamp: none; }
.listbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.listbar .count { flex: 1; min-width: 120px; font-size: 13px; color: var(--muted); font-weight: 500; }
select.small { width: auto; min-height: 34px; padding: 4px 10px; font-size: 14px; border-radius: 10px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: var(--card); }
.btn.danger.solid:hover { filter: brightness(1.07); background: var(--bad); }
.btn.danger.solid:disabled { filter: none; }
.seg { margin: 0 0 6px; }
.note { margin: 10px 0; line-height: 1.45; }
.note.muted { color: var(--muted); font-size: 14px; }

/* ---------- задачи: плотная строка 52–56 px, свойства одной строкой ---------- */
.task { display: flex; gap: 12px; align-items: center; min-height: 54px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--card); position: relative; transition: background-color .12s; }
.task:last-child { border-bottom: 0; }
.task:hover { background: var(--hover); }
.task::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: transparent; }
.task.prio-high::before { background: var(--bad); }
.task.done::before { background: transparent; }
.task .check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ctl); background: transparent; flex: none; margin-top: 0; padding: 0;
  display: grid; place-items: center; color: var(--on-accent); transition: background-color .12s, border-color .12s;
}
.task .check:hover { border-color: var(--accent); }
.task.prio-high .check { border-color: var(--bad); }
.task .check .ico { width: 16px; height: 16px; stroke-width: 3; }
.task.done .check { background: var(--ok); border-color: var(--ok); color: var(--card); }
.task.done .ttl { text-decoration: line-through; color: var(--muted); }
.task .body { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; margin: 0; }
.task .ttl { overflow-wrap: anywhere; font-size: 16px; line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.task .meta { display: flex; align-items: center; gap: 10px; margin-top: 2px; font-size: 13px; line-height: 1.35; color: var(--muted); white-space: nowrap; overflow: hidden; }
.task .meta > * { flex: none; }
.task .meta > .pdot { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.when { font-size: 13px; font-weight: 500; color: var(--muted); }
.when.bad { color: var(--bad); font-weight: 700; }
.when.today { color: var(--accent-ink); font-weight: 700; }
.pdot { display: inline-block; white-space: nowrap; }
.pdot i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; vertical-align: 1px; border-radius: 50%; background: var(--pc, var(--ctl)); }
.pdot.inbox i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ctl); }
.who { font-weight: 500; }
.pend { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font-weight: 600; }

/* ---------- кнопки и формы ---------- */
.fab {
  position: fixed; right: max(18px, calc(50% - 362px - var(--side) / 2)); bottom: calc(var(--safe-bottom) + 84px);
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; box-shadow: var(--shadow-lg); z-index: 7; transition: transform .12s;
}
.fab:active { transform: scale(.94); }
.fab .ico { width: 26px; height: 26px; stroke-width: 2.4; }
.fabs { position: fixed; right: max(18px, calc(50% - 362px - var(--side) / 2)); bottom: calc(var(--safe-bottom) + 84px); z-index: 7; display: flex; align-items: center; gap: 12px; }
.fabs .fab { position: static; }
.fab.project { background: var(--ok); }
.fab.small { width: 46px; height: 46px; }
.fab.small .ico { width: 22px; height: 22px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--ctl); background: var(--card); color: var(--text); border-radius: 12px; font-weight: 600; font-size: 15px;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.field { display: block; margin: 16px 0; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--ctl); border-radius: 12px; background: var(--card); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 92px; resize: vertical; line-height: 1.4; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.inline { display: flex; gap: 8px; }
.inline input { min-width: 0; }
.quick { margin: 12px 0; }

/* ---------- карточка задачи и создание ---------- */
.sheet-wrap { position: fixed; inset: 0; background: var(--scrim); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 94vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 18px 16px calc(var(--safe-bottom) + 24px); border: 1px solid var(--line); border-bottom: 0; box-shadow: var(--shadow-lg); overscroll-behavior: contain; }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--ctl); opacity: .5; margin: -6px auto 12px; }
.sheet h2 { font-size: 20px; line-height: 1.25; margin: 4px 0 8px; overflow-wrap: anywhere; letter-spacing: -.01em; }
.sheet .head { display: flex; align-items: flex-start; gap: 8px; }
.sheet .head h2 { flex: 1; }
.sheet .field:first-of-type { margin-top: 8px; }

.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--safe-bottom) + var(--tabbar-h) + 72px); max-width: 520px; margin: 0 auto; z-index: 30;
  background: var(--toast-bg); color: var(--toast-text); padding: 12px 16px; border-radius: 14px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow-lg);
}
.toast span { flex: 1; font-size: 14px; font-weight: 500; }
.toast button { background: none; border: 0; color: var(--toast-action); font-weight: 700; padding: 4px 6px; }

/* ---------- строка ввода задачи: внизу на телефоне, над списком на компьютере ---------- */
.composer {
  position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + var(--tabbar-h)); z-index: 7; padding: 8px 12px;
  background: var(--bg); border-top: 1px solid var(--line);
}
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .composer { background: color-mix(in srgb, var(--bg) 90%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
}
.composer > * { max-width: 736px; margin-left: auto; margin-right: auto; }
.composer.inline { position: static; padding: 0; margin: 10px 0; background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
.cbox {
  display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 12px; border: 1px solid var(--ctl); border-radius: 16px;
  background: var(--card); box-shadow: var(--shadow); transition: border-color .12s, box-shadow .12s;
}
.cbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cplus { display: grid; color: var(--muted); }
.cbox input.cinput { flex: 1; min-width: 0; min-height: 40px; padding: 8px 6px; border: 0; background: none; box-shadow: none; font-size: 16px; }
.cbox input.cinput:focus { box-shadow: none; }
.cbtn, .csend { display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--muted); }
.cbtn:hover, .cbtn.on { background: var(--chip); color: var(--text); }
.csend { background: var(--accent); color: var(--on-accent); }
.csend:disabled { background: var(--chip); color: var(--muted); }
.cchips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 2px 0; }
.cchip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-height: 30px; padding: 4px 8px 4px 10px; border: 0; border-radius: 15px;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; font-weight: 600;
}
.cchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cchip.warn { background: var(--warn-soft); color: var(--warn); }
.cchip.muted { background: var(--chip); color: var(--muted); padding-right: 10px; }
.cmore { display: grid; gap: 12px; margin-top: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); max-height: 52vh; overflow: auto; }
.crow { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 10px; }
.crow > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.crow select { min-height: 40px; padding: 6px 10px; }
.picker { display: grid; gap: 8px; }
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-row .chip { min-height: 34px; padding: 4px 12px; }
.picker .chip.on { background: var(--accent); color: var(--on-accent); }
.pick-row input.pick-native { width: auto; max-width: 220px; min-height: 40px; }

/* ---------- карточка задачи ---------- */
.tcard { position: relative; }
.chead { display: flex; align-items: center; gap: 8px; margin: -4px 0 8px; }
.chead .ctl { flex: 1; text-align: center; font-weight: 700; }
.chead .btn.back { min-width: 92px; justify-content: flex-start; }
.iconbtn.plain { box-shadow: none; border-color: transparent; background: none; margin-left: 52px; }
.cmenu { position: absolute; top: 44px; right: 0; z-index: 3; min-width: 250px; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); }
.cmenu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.chero { display: flex; gap: 12px; align-items: flex-start; }
.ccheck {
  display: grid; place-items: center; flex: none; width: 30px; height: 30px; margin-top: 3px; padding: 0; border: 2px solid var(--ctl); border-radius: 50%;
  background: none; color: var(--on-accent); transition: border-color .12s, background-color .12s;
}
.ccheck:hover { border-color: var(--accent); }
.ccheck.done { background: var(--ok); border-color: var(--ok); }
.ccheck .ico { width: 18px; height: 18px; stroke-width: 3; }
textarea.ctitle {
  display: block; width: 100%; min-height: 0; padding: 2px 4px; margin-left: -4px; border: 0; border-radius: 8px; background: none; resize: none;
  font-size: 22px; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; overflow-wrap: anywhere; field-sizing: content; box-shadow: none;
}
textarea.ctitle:focus { background: var(--card); box-shadow: 0 0 0 2px var(--accent-soft); }
.csub { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2px; font-size: 13px; color: var(--muted); }
.cflags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0 42px; }
.flag {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 4px 11px; border: 1px solid var(--line); border-radius: 15px;
  background: none; color: var(--muted); font-size: 13px; font-weight: 600;
}
.flag:hover { color: var(--text); }
.flag.on { border-color: transparent; background: var(--bad-soft); color: var(--bad); }
.flag.on.sun { background: var(--warn-soft); color: var(--warn); }
.flag.muted { border-style: dashed; }
.props { margin-top: 14px; }
.prow {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 10px 14px; border: 0;
  border-bottom: 1px solid var(--line); background: none; color: var(--text); text-align: left; font-size: 16px;
}
.props > :last-child { border-bottom: 0; }
.prow:hover { background: var(--hover); }
.prow:disabled, .prow.off { opacity: .6; cursor: default; background: none; }
.prow:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.pic { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 9px; color: #fff; }
.pic.due { background: #dc2626; }
.pic.rem { background: #b45309; }
.pic.proj { background: var(--pc, #475569); }
.pic.proj.inbox { background: #475569; }
.pic.who { background: #7c3aed; }
.plabel { flex: 1; font-weight: 500; }
.pval { max-width: 58%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; text-align: right; }
.pval.accent { color: var(--accent-ink); }
.pval.bad { color: var(--bad); }
.pval.muted { color: var(--muted); font-weight: 500; }
.prow > .ico { color: var(--muted); }
.prow select.pselect { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; }
.pbody { padding: 10px 14px 14px; border-bottom: 1px solid var(--line); background: var(--bg); }
.cadders { display: flex; gap: 8px; margin: 12px 0 4px; }
.cadd {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; padding: 6px 10px; border: 1px dashed var(--ctl); border-radius: 12px;
  background: none; color: var(--accent-ink); font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden;
}
.cadd:hover { background: var(--accent-soft); }
.cblock .section { margin-top: 18px; }
.cblock textarea { min-height: 72px; }
.addrow { margin-top: 8px; }
.addrow .btn { flex: none; white-space: nowrap; }
.sublist label.sr { cursor: pointer; }
.chint { margin: 16px 2px 4px; font-size: 13px; color: var(--muted); }
.cfoot { position: sticky; bottom: -24px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px -16px -24px; padding: 10px 16px 24px; background: var(--bg); border-top: 1px solid var(--line); }
.cfoot > :only-child { grid-column: 1 / -1; }
.cfoot .btn { min-height: 50px; font-size: 16px; }
@media (max-width: 520px) { .cfoot { grid-template-columns: minmax(0, 1fr); } .cfoot .btn.primary { order: 2; } }
:root[data-platform="telegram"] .cfoot { padding-bottom: calc(var(--safe-bottom) + 12px); }

/* своё окно подтверждения вместо системного */
.dlg-wrap { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; background: var(--scrim); }
.dlg { width: 100%; max-width: 400px; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow-lg); }
.dlg h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: -.01em; }
.dlg p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.dlg .actions { justify-content: flex-end; margin: 18px 0 0; }

/* ---------- вход ---------- */
.login { max-width: 420px; margin: 0 auto; padding: calc(var(--safe-top) + 56px) 20px 32px; }
.login .logo { width: 56px; height: 56px; display: block; border-radius: 14px; margin-bottom: 16px; }
.login h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.02em; }
.login .btn { width: 100%; margin: 6px 0; padding: 12px; justify-content: flex-start; }
.login .corner { position: absolute; top: calc(var(--safe-top) + 14px); right: 16px; }
.err { color: var(--bad); margin: 8px 0; font-size: 14px; font-weight: 500; }

/* ---------- списки внутри карточки ---------- */
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); flex: none; }
.kv span:last-child { text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.sublist .sr { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.sublist .sr:last-child { border-bottom: 0; }
.sublist .sr.done span { text-decoration: line-through; color: var(--muted); }
.comment { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment b { font-size: 13px; color: var(--muted); font-weight: 600; }
.comment p { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- календарь ---------- */
.shell.wide { max-width: 1180px; }
.stat.ok b { color: var(--ok); }
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 10px; }
.cal-nav { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cal-label { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; min-width: 150px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--chip); border: 1px solid var(--line); }
.cal-seg button { border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 14px; padding: 6px 12px; border-radius: 9px; min-height: 32px; transition: background-color .12s, color .12s; }
.cal-seg button:hover { color: var(--text); }
.cal-seg button.on { background: var(--card); color: var(--accent-ink); box-shadow: var(--shadow); }
.cal-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 4px; }
.cal-filters select { width: auto; min-width: 200px; max-width: 100%; flex: 1 1 200px; min-height: 40px; padding: 6px 12px; }
.cal .stats { margin: 10px 0 4px; }
.cal .stat { background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.cal-layout { display: grid; gap: 16px; align-items: start; }
.cal-month { padding: 8px; margin-top: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.cal-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 54px; padding: 6px 2px;
  border: 1px solid transparent; border-radius: 12px; background: none; color: var(--text); text-align: center; overflow: hidden;
  transition: background-color .12s, border-color .12s;
}
.cal-cell:hover { background: var(--hover); }
.cal-cell .num { font-weight: 600; font-size: 15px; line-height: 24px; min-width: 26px; height: 24px; border-radius: 12px; }
.cal-cell.we .num { color: var(--muted); }
.cal-cell.out { opacity: .45; }
.cal-cell.today .num { background: var(--accent); color: var(--on-accent); }
.cal-cell.sel { background: var(--accent-soft); border-color: var(--accent); }
.cal-cell .cnt { position: absolute; top: 4px; right: 5px; font-size: 11px; font-weight: 700; color: var(--accent-ink); display: none; }
.cal-cell .cnt.od { color: var(--bad); }
.cal-cell .dots { display: flex; gap: 3px; justify-content: center; }
.cal-cell .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal-cell .dots i.hi { background: var(--warn); }
.cal-cell .dots i.od { background: var(--bad); }
.cal-cell .dots i.dn { background: var(--ok); }
.cal-cell .chips { display: none; }
.cal-cell { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* подсказка дня в месяце: тот же вид, что у предпросмотра проекта, но по задачам можно нажать */
.ppv.cal-pop { pointer-events: auto; overflow-y: auto; overscroll-behavior: contain; }
.ppv.cal-pop:not([hidden]) { display: block; }
.cal-pop-item { width: 100%; border: 0; border-top: 1px solid var(--line); background: none; color: inherit; font-family: inherit; text-align: left; cursor: pointer; border-radius: 0; }
.cal-pop-item:hover, .cal-pop-item:focus-visible { background: var(--hover); }
.cal-pop-item .tm { flex: none; width: 66px; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-pop-item .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; line-height: 1.3; }
.cal-pop-item .pj { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-pop-item.done .t { text-decoration: line-through; color: var(--muted); }
.cal-pop-more { display: block; width: 100%; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; font-family: inherit; }
.cal-side { margin-top: 12px; }
.cal-dayhead { display: flex; align-items: center; gap: 12px; padding: 4px 4px 0; }
.cal-dayhead .title { font-size: 17px; }
.cal-side .quick { margin: 10px 0 8px; }
.cal-toggle { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; text-align: left; }
.cal-toggle:hover { color: var(--text); }
.cal-hint { color: var(--muted); font-size: 13px; margin: 12px 4px; }
.cal-year { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.cal-mini { margin: 0; padding: 10px; }
.cal-mini.now { border-color: var(--accent); }
.cal-mini-head { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; padding: 2px 2px 8px; text-align: left; border-radius: 8px; }
.cal-mini-head .title { flex: 1; }
.cal-mini-head:hover .title { color: var(--accent-ink); }
.cal-mini-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal-mini-grid .wd { text-align: center; font-size: 10px; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.cal-mini-grid .d { border: 0; padding: 0; height: 24px; border-radius: 6px; background: none; color: var(--muted); font-size: 11px; font-weight: 500; }
.cal-mini-grid .d:hover { outline: 1px solid var(--ctl); }
.cal-mini-grid .d.lv1 { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.cal-mini-grid .d.lv2 { background: var(--accent-soft); color: var(--accent-ink); font-weight: 800; box-shadow: inset 0 -3px 0 var(--accent); }
.cal-mini-grid .d.lv3 { background: var(--accent); color: var(--on-accent); font-weight: 800; }
.cal-mini-grid .d.od { box-shadow: inset 0 0 0 2px var(--bad); }
.cal-mini-grid .d.today { outline: 2px solid var(--accent); outline-offset: -2px; color: var(--text); font-weight: 800; }
.cal-mini-grid .d.sel { text-decoration: underline; text-underline-offset: 2px; }

@media (min-width: 640px) {
  .cal-year { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cal-cell { min-height: 64px; }
}
@media (min-width: 900px) {
  .cal-cell { min-height: 92px; align-items: stretch; text-align: left; padding: 6px; }
  .cal-cell .num { align-self: flex-start; text-align: center; padding: 0 4px; }
  .cal-cell .cnt { display: block; }
  .cal-cell .dots { display: none; }
  .cal-cell .chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .cal-chip { display: block; font-size: 11px; line-height: 1.35; padding: 1px 5px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
  .cal-chip.od { background: var(--bad-soft); color: var(--bad); }
  .cal-chip.dn { background: var(--ok-soft); color: var(--ok); text-decoration: line-through; }
  .cal-cell .cal-more { font-size: 11px; color: var(--muted); font-weight: 600; padding-left: 5px; }
  .cal-year { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1240px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr) 360px; }
  .cal-side { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
}
@media (max-width: 520px) {
  .cal-bar { flex-direction: column; align-items: stretch; }
  .cal-bar .cal-seg { align-self: stretch; }
  .cal-bar .cal-seg button, .cal-filters .cal-seg button { flex: 1; }
  .cal-filters .cal-seg { width: 100%; }
  .cal-nav .cal-label { flex: 1; min-width: 0; font-size: 17px; }
  .cal-cell { min-height: 50px; padding: 5px 0; border-radius: 10px; }
  .cal-cell .num { font-size: 14px; }
  .cal-month { padding: 4px; }
  .cal-grid { gap: 2px; }
}

/* ---------- широкие экраны: боковое меню ---------- */
@media (min-width: 640px) {
  .sheet-wrap { align-items: center; padding: 24px; }
  .sheet { border-radius: 22px; max-height: 88vh; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
  .sheet::before { display: none; }
}
@media (min-width: 900px) {
  :root { --side: 232px; }
  #app { padding-left: var(--side); }
  .shell { padding-bottom: 48px; }
  .tabbar { right: auto; top: 0; width: var(--side); flex-direction: column; justify-content: flex-start; border-top: 0; border-right: 1px solid var(--line); padding: 20px 12px; }
  .tabbar::before { content: "TaskMaster"; display: block; font-weight: 800; font-size: 20px; letter-spacing: -.02em; padding: 4px 12px 18px; }
  .tabbar .inner { flex-direction: column; gap: 4px; max-width: none; padding: 0; }
  .tab { flex: none; flex-direction: row; gap: 12px; padding: 11px 12px; border-radius: 12px; font-size: 15px; text-align: left; }
  .tab:hover { background: var(--hover); }
  .tab.active { background: var(--accent-soft); }
  .tab .pillbg { width: auto; height: auto; }
  .tab.active .pillbg { background: none; }
  .tab .dot { position: static; margin-left: auto; }
  .fab, .fabs { bottom: 32px; }
  .composer { position: static; padding: 0; margin: 4px 0 12px; background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .composer > * { max-width: none; }
  .toast { left: calc(var(--side) + 12px); bottom: 24px; }
  .sheet-wrap { padding-left: calc(var(--side) + 24px); }
}
@media (max-width: 520px) {
  .rowmain { flex-wrap: wrap; row-gap: 8px; }
  .rowmain .grow { flex-basis: calc(100% - 100px); }
  .rowmain .badges { order: 3; flex-basis: 100%; max-width: none; justify-content: flex-start; padding-left: 52px; }
  .rowmain .badges:empty { display: none; }
  .tline { display: block; }
  .peek { display: block; margin-top: 3px; }
  .peek .pk:nth-of-type(n+3), .peek .pmore.wide { display: none; }
  .peek .pmore.narrow { display: inline; }
  .row.proj .more { margin-right: 4px; }
}
@media (max-width: 380px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .topbar h1 { font-size: 21px; }
  .stats { gap: 6px; }
  .stat { padding: 8px 10px; }
  .row { padding: 12px; }
  .task { padding: 11px 12px; }
  .inline { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- свайпы по строке и выбор нескольких ---------- */
.task { touch-action: pan-y; -webkit-touch-callout: none; }
.task .body, .task .check { transition: transform .18s ease; }
.task.swiping { overflow: hidden; }
.task.swiping .body, .task.swiping .check { transform: translateX(var(--dx, 0)); transition: none; }
.task.swiping::after { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; padding: 0 18px; font-weight: 700; font-size: 14px; pointer-events: none; }
.task.swipe-r { background: var(--ok-soft); }
.task.swipe-r::after { content: "✓ Готово"; left: 0; color: var(--ok); }
.task.swipe-l { background: var(--accent-soft); }
.task.swipe-l::after { content: "Завтра →"; right: 0; color: var(--accent-ink); }
.task.swipe-r.armed { background: var(--ok); }
.task.swipe-r.armed::after { color: var(--card); }
.task.swipe-l.armed { background: var(--accent); }
.task.swipe-l.armed::after { color: var(--on-accent); }
.task.selecting { user-select: none; -webkit-user-select: none; }
.task.picked { background: var(--accent-soft); }
.task .check.pick { border-radius: 7px; }
.task.picked .check.pick { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.selbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + var(--tabbar-h)); z-index: 9; margin: 0 auto; max-width: 760px;
  background: var(--card); border-top: 1px solid var(--line); box-shadow: var(--shadow-lg); padding: 8px 12px; display: grid; gap: 8px;
}
.selbar .sel-row { display: flex; align-items: center; gap: 8px; }
.selbar .sel-n { flex: 1; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selbar .sel-acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.selbar .sel-acts .btn { min-height: 44px; padding: 4px 8px; }
.selbar .sel-panel { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.task.selecting.done { opacity: .55; }
.task.selecting.done .check.pick { background: none; border-color: var(--line); }
.selbar .sel-panel.list { max-height: 34vh; overflow: auto; }
.pick-cal, .tri-b.cal { position: relative; overflow: hidden; }
.pick-over { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; min-height: 0; }
body:has(.selbar) .composer { display: none; }

/* ---------- разбор просрочки ---------- */
.triage { max-width: 560px; margin: 0 auto; padding-bottom: 12px; }
.tri-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; }
.tri-pos { color: var(--muted); font-size: 14px; font-weight: 600; }
.tri-bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin: 4px 0 10px; }
.tri-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .2s; }
.tri-card { padding: 16px; }
.tri-late { color: var(--bad); font-weight: 700; font-size: 14px; }
.tri-title { font-size: 21px; line-height: 1.25; margin: 6px 0 6px; overflow-wrap: anywhere; letter-spacing: -.01em; }
.tri-card .meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 13px; }
.tri-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.tri-b { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.tri-b:hover { background: var(--hover); }
.tri-b.ok { background: var(--ok); border-color: var(--ok); color: var(--card); }
.tri-foot { display: grid; gap: 8px; margin-top: 12px; }
.tri-foot .btn { min-height: 50px; font-size: 16px; }
.tri-done { padding: 24px 16px; text-align: center; }
.tri-done .tri-ok { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 8px; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.tri-done .tri-ok .ico { width: 28px; height: 28px; stroke-width: 3; }
.tri-done .actions { justify-content: center; }

/* ---------- мини-приложение: нативные кнопки Telegram заменяют свои ---------- */
html.tg-main .tcard .cfoot .primary, html.tg-main .tri-foot .skip, html.tg-main .tri-done .tri-exit { display: none; }
html.tg-second .tcard .cfoot .later { display: none; }
html.tg-back .topbar .btn.back, html.tg-back .chead .btn.back { display: none; }
html.tg-main.tg-second .tcard .cfoot, html.tg-main .tcard .cfoot:not(:has(.later)) { display: none; }
[data-platform="telegram"] .sheet { max-height: min(94vh, calc(var(--tg-viewport-stable-height, 100vh) - 12px)); }
