/* IB Задачи — оформление v6: индиго-акцент, карточки, ночная и дневная темы */
:root {
  --accent: #5b5bd6;
  --page: #f3f4f9; --card: #ffffff; --raised: #ecedf7;
  --line: rgba(20,24,36,.08); --line2: rgba(20,24,36,.34);
  --text: #141824; --hint: #5b6478; --soft: rgba(20,24,36,.05);
  --link: #4646c4;
  --c-new: #5b6478; --c-work: #a85f00; --c-done: #1b7f46; --c-danger: #c62f3b;
  --shadow: 0 8px 24px rgba(40,48,90,.07), 0 1px 2px rgba(40,48,90,.06);
  --ink: #14182b; --on-status: #ffffff;
  --radius: 24px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --page: #101522; --card: #181f31; --raised: #202a42;
  --line: rgba(255,255,255,.08); --line2: rgba(255,255,255,.28);
  --text: #edf0f7; --hint: #93a0b8; --soft: rgba(255,255,255,.06);
  --link: #a9abff;
  --c-new: #9aa7c2; --c-work: #ffb547; --c-done: #45d58f; --c-danger: #ff8383;
  --shadow: 0 0 0 1px rgba(255,255,255,.05);
  --on-status: #14182b;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--page); }
body {
  margin: 0; background: var(--page); color: var(--text);
  font: 16px/1.4 Onest, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 560px; margin: 0 auto; padding: 14px 20px calc(110px + env(safe-area-inset-bottom)); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
svg { flex: none; }
.ico { display: inline-block; vertical-align: -3px; }

/* ---------- шапка ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 0; }
.hello { font-size: 24px; line-height: 30px; font-weight: 700; letter-spacing: -.02em; }
.date { font-size: 13px; line-height: 18px; color: var(--hint); }
.sub { font-size: 13px; line-height: 18px; color: var(--hint); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 22px; background: var(--card); color: var(--text);
  box-shadow: var(--shadow); display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.bar { display: flex; align-items: center; gap: 12px; }
.bar .grow { flex: 1; min-width: 0; }
.bar h1 { margin: 0; font-size: 24px; line-height: 30px; letter-spacing: -.02em; }
.back { display: none; }

/* ---------- аватары ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%; color: var(--ink); font-size: 12px; font-weight: 700;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }

/* ---------- карточка-итог ---------- */
.hero {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 16px;
  margin-top: 16px; padding: 18px; border-radius: var(--radius); background: var(--accent); color: #fff;
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.07); }
.hero::before { width: 160px; height: 160px; right: -34px; top: -46px; }
.hero::after { width: 110px; height: 110px; right: 36px; bottom: -64px; }
.ring { position: relative; flex: none; width: 64px; height: 64px; }
.ring b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.hero-body { position: relative; min-width: 0; }
.hero-title { font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -.01em; }
.hero-sub { font-size: 13px; line-height: 18px; color: rgba(255,255,255,.9); }

/* ---------- вкладки, поиск, фильтры ---------- */
.tabs { display: flex; gap: 2px; margin-top: 14px; padding: 3px; background: var(--soft); border-radius: 16px; }
.tabs button {
  flex: 1; height: 44px; border: 0; border-radius: 13px; background: transparent; color: var(--hint);
  font-size: 15px; font-weight: 600;
}
.tabs button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.search { position: relative; margin-top: 10px; }
.search svg { position: absolute; left: 16px; top: 14px; color: var(--hint); }
.search input {
  width: 100%; height: 46px; padding: 0 14px 0 44px; border: 0; border-radius: 16px;
  background: var(--card); color: var(--text); font-size: 16px; box-shadow: var(--shadow);
}
.search input::placeholder { color: var(--hint); }
.filters { display: flex; gap: 5px; margin-top: 10px; }
.filters button {
  flex: 1 1 auto; height: 44px; padding: 0 8px; border: 0; border-radius: 22px;
  background: var(--card); color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; box-shadow: var(--shadow);
}
.filters button.active { background: var(--text); color: var(--page); font-weight: 700; box-shadow: none; }

/* ---------- карточки задач ---------- */
#list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.task-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 20px; }
.st-ico {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
}
.st-ico.new { background: color-mix(in srgb, var(--c-new) 16%, transparent); color: var(--c-new); }
.st-ico.in_progress { background: color-mix(in srgb, var(--c-work) 18%, transparent); color: var(--c-work); }
.st-ico.done { background: color-mix(in srgb, var(--c-done) 18%, transparent); color: var(--c-done); }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.task-title { font-size: 16px; line-height: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-card.done .task-title { color: var(--hint); text-decoration: line-through; }
.task-desc { font-size: 13px; line-height: 18px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.who { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; color: var(--hint); }
.who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; align-items: center; gap: 6px; flex: none; }
.chip-s {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px; border-radius: 13px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.chip-s.urgent, .chip-s.overdue { background: color-mix(in srgb, var(--c-danger) 16%, transparent); color: var(--c-danger); }
.chip-s.due-today { background: color-mix(in srgb, var(--c-work) 18%, transparent); color: var(--c-work); }
.chip-s.plain { padding: 0 4px; font-weight: 500; color: var(--hint); }

.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 24px; text-align: center; color: var(--hint); font-size: 14px; }
.empty b { font-size: 18px; line-height: 24px; color: var(--text); }
.skeleton { height: 86px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); animation: pulse 1.2s ease-in-out infinite; }
.skeleton.tall { height: 260px; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- кнопка «Новая задача» ---------- */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 5;
  bottom: calc(18px + env(safe-area-inset-bottom)); width: min(520px, calc(100% - 40px)); height: 56px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 20px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 700;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border: 0; border-radius: 16px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700;
}
.btn.big { width: 100%; height: 54px; margin-top: 10px; border-radius: 18px; font-size: 16px; background: var(--c-done); color: var(--on-status); }
.btn.big.reopen { background: var(--soft); color: var(--text); }
.btn.secondary { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.btn.danger { background: color-mix(in srgb, var(--c-danger) 12%, transparent); color: var(--c-danger); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }
.row.small { margin-top: 12px; }
.note { margin-top: 12px; font-size: 13px; color: var(--hint); text-align: center; }

/* ---------- карточка задачи ---------- */
.task-full { position: relative; overflow: hidden; margin-top: 14px; padding: 22px 18px 18px; }
.task-full::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 5px; background: var(--c-new); }
.task-full.in_progress::before { background: var(--c-work); }
.task-full.done::before { background: var(--c-done); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 14px;
  font-size: 13px; font-weight: 700;
}
.badge.new { background: color-mix(in srgb, var(--c-new) 16%, transparent); color: var(--c-new); }
.badge.in_progress { background: color-mix(in srgb, var(--c-work) 18%, transparent); color: var(--c-work); }
.badge.done { background: color-mix(in srgb, var(--c-done) 18%, transparent); color: var(--c-done); }
.badge.urgent { background: color-mix(in srgb, var(--c-danger) 16%, transparent); color: var(--c-danger); }
.task-full h1 { margin: 12px 0 0; font-size: 24px; line-height: 30px; font-weight: 700; letter-spacing: -.02em; overflow-wrap: anywhere; }
.description { margin-top: 8px; font-size: 15px; line-height: 22px; color: var(--hint); white-space: pre-wrap; overflow-wrap: anywhere; }
.status-switch { display: flex; gap: 2px; margin-top: 18px; padding: 3px; background: var(--soft); border-radius: 16px; }
.status-switch button {
  flex: 1; height: 44px; border: 0; border-radius: 13px; background: transparent; color: var(--hint);
  font-size: 14px; font-weight: 600;
}
.status-switch button.active { color: var(--on-status); font-weight: 700; }
.status-switch button.new.active { background: var(--c-new); }
.status-switch button.in_progress.active { background: var(--c-work); }
.status-switch button.done.active { background: var(--c-done); }
.status-switch button:disabled { cursor: default; opacity: .75; }

.facts { margin: 12px 0 0; padding: 0 14px; border-radius: 20px; background: var(--soft); }
.fact { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.fact + .fact { border-top: 1px solid var(--line); }
.fact > span { flex: 1; font-size: 14px; color: var(--hint); }
.fact > div { font-size: 15px; font-weight: 600; text-align: right; }
.person { display: flex; align-items: center; gap: 8px; }
.fact .overdue { color: var(--c-danger); font-weight: 700; }
.fact .due-today { color: var(--c-work); font-weight: 700; }

.overdue { color: var(--c-danger); }

/* вложения */
.atts { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { width: 88px; height: 88px; object-fit: cover; border-radius: 14px; background: var(--soft); cursor: zoom-in; }
.file { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px; border-radius: 16px; background: var(--soft); }
.file-icon {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 10px; background: #5b6478; color: #fff; font-size: 12px; font-weight: 800;
}
.file-icon.xls { background: #1b7f45; }
.file-icon.doc { background: #2b5fc7; }
.file-icon.pdf { background: #c62f3b; font-size: 10px; }
.file-icon.zip { background: #8a5a14; font-size: 10px; }
.file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 12px; color: var(--hint); }
.add-file {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; margin-top: 12px;
  border: 1.5px dashed var(--line2); border-radius: 16px; color: var(--link); font-size: 14px; font-weight: 600; cursor: pointer;
}
.add-file:focus-within { outline: 2px solid var(--link); outline-offset: 2px; }
.picked-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.picked { display: inline-flex; align-items: center; gap: 2px; height: 40px; padding: 0 4px 0 14px; border-radius: 20px; background: var(--soft); font-size: 13px; font-weight: 500; }
.picked button { width: 36px; height: 36px; border: 0; background: none; color: var(--hint); font-size: 20px; }

h2 { margin: 22px 4px 8px; font-size: 13px; line-height: 18px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--hint); }

/* история и комментарии */
.timeline { padding: 6px 16px; }
.tl-item { display: flex; gap: 10px; padding: 12px 0; font-size: 14px; line-height: 20px; }
.tl-item + .tl-item { border-top: 1px solid var(--line); }
.tl-item.event { align-items: center; color: var(--hint); }
.tl-item.event b { color: var(--text); font-weight: 600; }
.tl-time { margin-left: 6px; font-size: 12px; white-space: nowrap; }
.tl-body { flex: 1; min-width: 0; }
.tl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tl-head .tl-time { color: var(--hint); }
.bubble { margin-top: 4px; padding: 10px 14px; border-radius: 6px 18px 18px 18px; background: var(--soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.act { font-weight: 700; }
.act.in_progress { color: var(--c-work); }
.act.done { color: var(--c-done); }
.act.new, .act.reopened { color: var(--c-new); }

/* поле комментария */
.comment-form {
  position: sticky; bottom: calc(14px + env(safe-area-inset-bottom)); margin-top: 14px; padding: 6px;
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow), 0 8px 24px rgba(0,0,0,.12);
}
.comment-form .picked-list { margin: 4px 8px 6px; }
.comment-row { display: flex; align-items: flex-end; gap: 4px; }
.comment-row textarea {
  flex: 1; min-width: 0; height: 44px; max-height: 160px; padding: 11px 4px; border: 0; background: none;
  color: var(--text); font-size: 16px; line-height: 22px; resize: none; outline: none;
}
.comment-row textarea::placeholder { color: var(--hint); }
.attach, .send {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 22px; display: inline-flex; align-items: center; justify-content: center;
}
.attach { background: none; color: var(--hint); cursor: pointer; }
.send { background: var(--accent); color: #fff; }
.send:disabled { opacity: .5; }

/* ---------- сотрудники ---------- */
.team-list { display: flex; flex-direction: column; gap: 10px; }
.member { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.member.inactive { background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.member .avatar { width: 48px; height: 48px; font-size: 16px; }
.member.inactive .avatar { filter: grayscale(1); opacity: .7; }
.member-body { flex: 1; min-width: 0; }
.member-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 17px; line-height: 24px; font-weight: 700; }
.role { padding: 2px 9px; border-radius: 10px; background: color-mix(in srgb, var(--link) 18%, transparent); color: var(--link); font-size: 11px; font-weight: 700; }
.member-sub { font-size: 13px; line-height: 18px; color: var(--hint); }
.member-sub .overdue { font-weight: 700; }
.member-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { height: 44px; padding: 0 16px; border: 0; border-radius: 22px; background: var(--soft); color: var(--text); font-size: 14px; font-weight: 600; }
.chip.danger { background: color-mix(in srgb, var(--c-danger) 12%, transparent); color: var(--c-danger); }
.chip.ok { background: var(--c-done); color: var(--on-status); font-weight: 700; }
.watch-list { display: flex; flex-wrap: wrap; gap: 8px; }
.watch-list .chip.active { background: var(--accent); color: #fff; }
.watch-hint { margin: -2px 4px 0; font-size: 13px; line-height: 18px; color: var(--hint); }
.people { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.me-label { font-size: 12px; color: var(--hint); }
.hint { margin: 18px 12px 0; text-align: center; font-size: 13px; line-height: 18px; color: var(--hint); }

/* ---------- окно «Новая задача» ---------- */
dialog {
  width: 100%; max-width: 560px; max-height: 100%; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 28px 28px 0 0; background: var(--page); color: var(--text);
}
dialog::backdrop { background: rgba(8,10,20,.55); }
#task-form { display: flex; flex-direction: column; gap: 10px; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }
#task-form h1 { margin: 0 0 4px; font-size: 24px; line-height: 30px; letter-spacing: -.02em; }
#task-form label:not(.toggle):not(.add-file) {
  margin: 6px 4px -4px; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--hint);
}
#task-form input:not([type=checkbox]):not([type=file]), #task-form select, #task-form textarea {
  width: 100%; min-height: 50px; padding: 0 16px; border: 0; border-radius: 18px;
  background: var(--card); color: var(--text); font-size: 16px; box-shadow: var(--shadow);
}
#task-form textarea { min-height: 96px; padding: 12px 16px; line-height: 22px; resize: none; }
#task-form input::placeholder, #task-form textarea::placeholder { color: var(--hint); }
.toggle {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 16px; border-radius: 20px;
  background: var(--card); box-shadow: var(--shadow); cursor: pointer; font-size: 16px; font-weight: 700;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .t-ico { flex: none; width: 40px; height: 40px; border-radius: 14px; background: var(--soft); color: var(--hint); display: inline-flex; align-items: center; justify-content: center; }
.toggle .t-text { flex: 1; }
.toggle .t-text small { display: block; font-size: 13px; line-height: 18px; font-weight: 400; color: var(--hint); }
.toggle-track { position: relative; flex: none; width: 46px; height: 28px; border-radius: 14px; background: var(--line2); transition: background .15s; }
.toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked ~ .toggle-track { background: var(--c-danger); }
.toggle input:checked ~ .toggle-track::after { transform: translateX(18px); }
.toggle input:checked ~ .t-ico { background: var(--c-danger); color: var(--on-status); }
.toggle input:focus-visible ~ .toggle-track { outline: 2px solid var(--link); outline-offset: 2px; }
#task-form .row { margin-top: 6px; }
#task-form .row .btn { height: 56px; border-radius: 20px; font-size: 16px; }
#task-form .row .btn:last-child { flex: 2; box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- прочее ---------- */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 20; padding: 10px 18px; border-radius: 20px; background: var(--text); color: var(--page); font-size: 14px; font-weight: 600; }
.lightbox { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.92); }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-open { position: absolute; right: 16px; top: calc(16px + env(safe-area-inset-top)); display: inline-flex; align-items: center; height: 44px; padding: 0 18px; border-radius: 22px; background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.bar-title { flex: 1; font-size: 16px; line-height: 22px; font-weight: 600; }
.bar .icon-btn:last-child:not(:first-child) { margin-left: auto; }
.bar .grow + .icon-btn { margin-left: auto; }
