:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1c2230;
  --muted: #687083;
  --line: #dde1e8;
  --accent: #2f6fde;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecfc;
  --todo: #6b7486;
  --todo-soft: #eceef2;
  --doing: #c46a00;
  --doing-soft: #fff1dc;
  --done: #1e8a4c;
  --done-soft: #ddf3e6;
  --danger: #c93636;
  --danger-soft: #fbe5e5;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1c2029;
    --surface-2: #262b36;
    --text: #e9ecf2;
    --muted: #98a0b2;
    --line: #323846;
    --accent: #6c9bff;
    --accent-ink: #0d1424;
    --accent-soft: #24324f;
    --todo: #a4abba;
    --todo-soft: #2a2f3a;
    --doing: #ffb35c;
    --doing-soft: #3d2e1a;
    --done: #5fd08f;
    --done-soft: #1c3527;
    --danger: #ff7a7a;
    --danger-soft: #3d2020;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.grow { flex: 1; }
.center { min-height: 70vh; display: grid; place-content: center; text-align: center; gap: 16px; padding: 24px; }

/* ---------- Шапка ---------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px;
  min-height: 56px; padding: 6px 8px 6px 16px;
  padding-top: max(6px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.bar-title {
  flex: 1; margin: 0; font-size: 20px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: transparent; color: var(--muted);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.small { width: 36px; height: 36px; font-size: 15px; }
.icon-btn.danger { color: var(--danger); }

.ro-banner {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; background: var(--accent-soft); color: var(--accent); font-size: 15px; font-weight: 600;
}
.note-banner {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 12px;
  background: var(--doing-soft); color: var(--text); font-size: 14px;
}

.page { max-width: 720px; margin: 0 auto; padding: 16px; }
.page.tasks { padding-bottom: 110px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 18px; border: 0; border-radius: 12px;
  font-weight: 600; text-decoration: none; background: var(--surface-2); color: var(--text);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn.left { justify-content: flex-start; }
.btn:active { filter: brightness(.94); }
.btn.back { padding-left: 4px; color: var(--accent); }
.link { border: 0; background: none; color: var(--accent); padding: 6px 4px; font-size: 15px; font-weight: 600; }
.link.danger { color: var(--danger); }

.input {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
}
.input:focus, .title-input:focus, .note-text:focus, .list-title:focus, .item-text:focus {
  outline: none; border-color: var(--accent);
}

/* ---------- Главная ---------- */
.panel {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px; display: grid; gap: 12px;
}
.panel h2 { margin: 0; font-size: 19px; }
.panel p { margin: 0; }
.row-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 52px; padding: 8px 4px; border-top: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-weight: 550;
}
.row-link:first-of-type { border-top: 0; }
.row-link .small { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; }

/* ---------- Вкладки статусов ---------- */
.tabs {
  position: sticky; top: 56px; z-index: 4;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 10px 12px; background: var(--bg);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  min-height: 58px; padding: 6px 4px; border: 2px solid transparent; border-radius: 12px;
  background: var(--surface); color: var(--muted); font-weight: 600; font-size: 15px; box-shadow: var(--shadow);
}
.tab b { font-size: 19px; line-height: 1.2; }
.tab.on.st-todo { border-color: var(--todo); color: var(--text); background: var(--todo-soft); }
.tab.on.st-doing { border-color: var(--doing); color: var(--doing); background: var(--doing-soft); }
.tab.on.st-done { border-color: var(--done); color: var(--done); background: var(--done-soft); }

/* ---------- Чипы ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll-x { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 12px 6px; }
.chips.scroll-x::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 7px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font-size: 15px; font-weight: 550;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.add { border-style: dashed; color: var(--accent); }
.chip:disabled { opacity: 1; }
.filters .chip { min-height: 36px; padding: 5px 13px; }

/* ---------- Карточки задач ---------- */
.task {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; padding: 14px 12px 14px 16px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer;
}
.task:active { filter: brightness(.97); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 17.5px; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 14px; }
.meta:empty { display: none; }
.pill { padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cnt { color: var(--muted); padding: 2px 0; }
.due { padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.due.overdue { background: var(--danger-soft); color: var(--danger); }
.due.today { background: var(--doing-soft); color: var(--doing); }
.due.soon { background: var(--doing-soft); color: var(--doing); }
.step {
  flex: none; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 0;
  font-size: 14.5px; font-weight: 650; max-width: 112px;
}
.step.to-doing { background: var(--doing-soft); color: var(--doing); }
.step.to-done { background: var(--done-soft); color: var(--done); }
.step.to-todo { background: var(--surface-2); color: var(--muted); }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

.fab {
  position: fixed; right: 16px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 6;   /* выше плашки хостинга в правом нижнем углу */
  min-height: 58px; padding: 0 24px; border: 0; border-radius: 18px;
  background: var(--accent); color: var(--accent-ink); font-size: 18px; font-weight: 700;
  box-shadow: 0 3px 10px rgba(20, 30, 50, .28), 0 1px 3px rgba(20, 30, 50, .2);
}

/* ---------- Карточка задачи (экран) ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 10; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateY(16px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet .page { padding-bottom: 60px; }
.title-input {
  width: 100%; resize: none; field-sizing: content; min-height: 56px;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); font-size: 21px; font-weight: 650; line-height: 1.3;
}
.title-ro { margin: 4px 0 8px; font-size: 22px; overflow-wrap: anywhere; }
.field { margin-top: 18px; display: grid; gap: 8px; }
.label { font-size: 14px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.value { font-size: 17px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg-btn {
  min-height: 50px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface); color: var(--muted); font-weight: 650; font-size: 15.5px;
}
.seg-btn.on.st-todo { border-color: var(--todo); background: var(--todo-soft); color: var(--text); }
.seg-btn.on.st-doing { border-color: var(--doing); background: var(--doing-soft); color: var(--doing); }
.seg-btn.on.st-done { border-color: var(--done); background: var(--done-soft); color: var(--done); }
.seg-btn:disabled:not(.on) { opacity: .55; }
.due-row { display: flex; gap: 8px; }
.input.date { flex: 1; }

.block { margin-top: 26px; display: grid; gap: 10px; }
.block h3 { margin: 0; font-size: 18px; }
.block p { margin: 0; }

/* Списки */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 6px 6px 12px; }
.list-head { display: flex; align-items: center; gap: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.list-title {
  flex: 1; min-width: 0; min-height: 44px; padding: 6px 8px; margin-left: -8px;
  border: 1.5px solid transparent; border-radius: 10px; background: transparent; font-weight: 650; font-size: 17px;
}
div.list-title { display: flex; align-items: center; }
.item { display: flex; align-items: center; gap: 8px; min-height: 48px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.check { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--done); }
.item-text {
  flex: 1; min-width: 0; min-height: 42px; padding: 6px 8px;
  border: 1.5px solid transparent; border-radius: 10px; background: transparent;
}
span.item-text { display: flex; align-items: center; }
.item.done .item-text { text-decoration: line-through; color: var(--muted); }
.item.add .plus { width: 24px; text-align: center; color: var(--accent); font-weight: 700; }
.item.add .item-text::placeholder { color: var(--accent); opacity: .8; }

/* Заметки */
.note { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.note-text {
  width: 100%; resize: vertical; field-sizing: content; min-height: 72px;
  padding: 8px 10px; border: 1.5px solid transparent; border-radius: 10px; background: transparent; line-height: 1.45;
}
.note-text.ro { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 0; }
.note-meta { display: flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 13.5px; color: var(--muted); }
.note-meta .link { margin-left: auto; font-size: 14px; }

/* Файлы */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.file {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow);
}
.thumb { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 100%; height: 100%; padding: 8px; color: var(--text); text-decoration: none; text-align: center;
}
.file-icon { font-size: 30px; }
.file-name { font-size: 12.5px; overflow-wrap: anywhere; line-height: 1.25; max-height: 3.75em; overflow: hidden; }
.file.uploading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--muted); }
.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Окна ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(10, 14, 22, .45); animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  display: grid; gap: 12px; padding: 22px 18px max(18px, env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 20px 20px 0 0;
}
@media (min-width: 600px) { .backdrop { align-items: center; } .modal { border-radius: 20px; } }
.modal h2 { margin: 0; font-size: 21px; }
.modal p { margin: 0; }
.stack { display: grid; gap: 8px; }
.share-opt { display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.share-title { font-weight: 650; }
.link-box {
  padding: 8px 10px; border-radius: 10px; background: var(--surface); font-size: 13px;
  font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; color: var(--muted);
}
.row2 { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.people { display: grid; }
.person { display: flex; align-items: center; gap: 6px; min-height: 50px; border-bottom: 1px solid var(--line); }
.person > span { flex: 1; font-weight: 550; }

.viewer {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column;
  background: #000; animation: fade .15s ease-out;
}
.viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.viewer-bar {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
}

#toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 40; transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px;
  background: #222937; color: #fff; font-size: 15px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Язык ---------- */
.seg-btn.plain.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.seg.lang .seg-btn { min-height: 46px; }
.modal .label { margin-top: 4px; }

/* ---------- Исполнители ---------- */
.assignees { display: grid; gap: 6px; }
.assignee { padding: 10px 14px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.a-name { font-weight: 650; }
.a-note { margin-top: 2px; font-size: 14.5px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.picks { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; }
.pick {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px 14px; text-align: left;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface);
}
.pick.on { border-color: var(--accent); background: var(--accent-soft); }
.tick {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; margin-top: 1px;
  border: 2px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--accent-ink); font-weight: 800;
}
.pick.on .tick { border-color: var(--accent); background: var(--accent); }
.pick-body { display: grid; gap: 2px; min-width: 0; }
.pick-body b { font-size: 17px; }
.pick-body small { font-size: 14px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.person-main { flex: 1; min-width: 0; display: grid; padding: 6px 0; }
.p-name { font-weight: 600; }
.p-note { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.person { align-items: flex-start; min-height: 54px; }
.input.area { min-height: 84px; resize: vertical; line-height: 1.4; }

/* ---------- Подтверждение ---------- */
.confirm-text { font-size: 19px; line-height: 1.35; overflow-wrap: anywhere; }
.btn.danger-solid { background: var(--danger); color: #fff; }

/* ---------- Миниатюры ссылок ---------- */
.pvs { display: grid; gap: 8px; padding: 4px 4px 6px; }
.pv {
  display: flex; overflow: hidden; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--text); text-decoration: none;
}
.pv-img { flex: none; width: 96px; height: 96px; object-fit: cover; background: var(--line); }
.pv-body { display: grid; align-content: center; gap: 2px; min-width: 0; padding: 8px 12px; }
.pv-site { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-title { font-weight: 650; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pv-desc { font-size: 13.5px; color: var(--muted); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.pv-plain { background: var(--surface-2); }
.pv-plain .pv-desc { -webkit-line-clamp: 1; }
.pv-loading { opacity: .6; }

/* Исполнители в задаче: строка с кнопкой «снять» */
.assignee { display: flex; align-items: flex-start; gap: 6px; padding-right: 6px; }
.a-main { flex: 1; min-width: 0; }
.assignee .icon-btn { margin-top: -4px; }

/* Исполнители в задаче: компактные плашки */
.as-chip {
  display: inline-flex; align-items: center; max-width: 100%;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent); overflow: hidden;
}
.as-name { min-height: 40px; padding: 6px 6px 6px 14px; border: 0; background: transparent; color: inherit; font-weight: 650; font-size: 15.5px; text-align: left; overflow-wrap: anywhere; }
.as-chip:not(:has(.as-x)) .as-name { padding-right: 14px; }
.as-i { font-size: 13px; opacity: .75; }
.as-x { min-width: 40px; min-height: 40px; border: 0; background: transparent; color: inherit; font-size: 14px; opacity: .7; }
.as-x:active, .as-name:active { background: rgba(47, 111, 222, .18); }
.info-note { margin: 0; font-size: 17px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Кнопки добавления: компактные плашки */
.pill-add {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-height: 40px; padding: 6px 14px; border: 0; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 15.5px; font-weight: 650; cursor: pointer;
}
.pill-add:active { filter: brightness(.94); }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.block-head h3 { margin: 0; }
.person-main { border: 0; background: transparent; text-align: left; cursor: pointer; border-radius: 10px; }
.person-main:active { background: var(--surface-2); }

/* ---------- Офлайн-режим ---------- */
.sync-banner {
  margin: 0; padding: 9px 16px; font-size: 14.5px; line-height: 1.35; text-align: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.sync-banner.off { background: var(--doing-soft); color: var(--doing); }
.file.pending img { opacity: .6; }
.file-wait {
  position: absolute; top: 6px; right: 6px; z-index: 1; padding: 2px 6px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; line-height: 1.3; pointer-events: none;
}

/* ---------- Удаление и выгрузка проекта ---------- */
.btn:disabled { opacity: .45; cursor: default; }
.plain-text { margin: 0; font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; }
.center-spin { display: grid; place-items: center; padding: 10px 0 4px; }

/* Кнопка перевода задачи в другой статус: контурная, чтобы не походить на значок статуса */
.step.to-doing, .step.to-done, .step.to-todo { background: transparent; border: 2px solid currentColor; font-size: 14px; line-height: 1.2; max-width: 132px; }

/* ---------- Переключатель проектов в заголовке ---------- */
.bar-title .caret { color: var(--muted); font-size: .8em; }
.projects { display: grid; max-height: 38vh; overflow-y: auto; }
button.row-link { width: 100%; background: transparent; border: 0; border-top: 1px solid var(--line); font: inherit; text-align: left; cursor: pointer; }
.row-link.cur { color: var(--accent); font-weight: 700; }
