:root {
  --bg: #EDF0EA;
  --surface: #FFFFFF;
  --surface-2: #F6F8F4;
  --ink: #18262B;
  --muted: #5E6B6A;
  --line: #D5DBD2;
  --accent: #1E5E58;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCE9E4;
  --red: #D62839;
  --red-soft: #FBE3E5;
  --yellow: #F0B323;
  --yellow-soft: #FDF1D3;
  --calm: #B9CFC0;
  --focus: #2F7DE1;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --display: "Unbounded", system-ui, sans-serif;
  --text: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 14px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #174A45; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn svg { width: 16px; height: 16px; flex: none; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--radius-s); padding: 10px 12px;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.55; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: var(--accent); color: #EAF3EF; padding: 48px 56px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.logo { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; font: 700 20px var(--display); letter-spacing: -.01em; color: inherit; text-decoration: none; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: currentColor; display: grid; place-items: center; }
.logo-mark svg { width: 18px; height: 18px; }
.auth-hero .logo-mark { background: #EAF3EF; color: var(--accent); }
.auth-hero h1 { font: 700 clamp(28px, 3.4vw, 44px)/1.12 var(--display); margin: 0; max-width: 14ch; letter-spacing: -.02em; }
.auth-hero p { margin: 16px 0 0; max-width: 42ch; color: #C6DCD3; font-size: 16px; }
.auth-map { max-width: 460px; aspect-ratio: 800 / 440; border-radius: var(--radius-m); overflow: hidden; background: #151a20; }
.hero-frame { width: 100%; height: 100%; border: 0; display: block; pointer-events: none; }
.auth-map-caption { font-size: 13px; color: #A9C7BC; margin-top: 10px; }

.auth-form-wrap { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.tabs { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 999px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.auth-card h2 { font: 600 22px var(--display); margin: 6px 0 0; letter-spacing: -.01em; }
.form-error { color: var(--red); font-size: 14px; min-height: 1.5em; margin: 0; }
.auth-card form { display: grid; gap: 14px; }
.auth-card .btn.primary { justify-content: center; padding: 12px; font-size: 15px; }

/* ---------- shell ---------- */
.shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 20; flex: none;
}
.topbar .logo { color: var(--accent); }
.topbar .logo-mark svg { color: #fff; }
.topbar .spacer { flex: 1; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 4px 6px 4px 4px; border-radius: 999px; font-weight: 600; }
.user-btn:hover { background: var(--accent-soft); }

.avatar {
  --c: var(--accent);
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--c); color: #fff; letter-spacing: 0;
}
.avatar.empty { background: transparent; border: 1.5px dashed #9AA6A3; color: var(--muted); }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }


.body { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.muted { color: var(--muted); font-size: 13px; }

/* ---------- board ---------- */
.main { flex: 1; padding: 16px 24px 20px; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.board-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.board-head h1 { font: 600 22px var(--display); margin: 0; letter-spacing: -.01em; }
.filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .avatar { width: 18px; height: 18px; font-size: 9px; }

/* Дошка займає весь екран: колонки тягнуться донизу, задачі гортаються всередині колонки */
.board { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.col-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin: 0 -6px; padding: 2px 6px 4px; }
/* остання колонка: місце під мапою тривог, щоб її не закривали картки */
.col:last-child .col-list { padding-bottom: 200px; }
.col.drop { border-color: var(--accent); background: var(--accent-soft); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 4px; }
.col-head h3 { font: 600 13px var(--display); margin: 0; letter-spacing: 0; }
.col-head .count { color: var(--muted); font-size: 13px; font-weight: 600; }
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.col[data-status="todo"] .dot { background: #8C9A96; }
.col[data-status="progress"] .dot { background: #3B5BA5; }
.col[data-status="review"] .dot { background: var(--yellow); }
.col[data-status="done"] .dot { background: #2F7D32; }

.quick-add { display: grid; gap: 6px; }
.quick-add textarea {
  width: 100%; resize: none; border: 1px dashed #A9B5B0; background: transparent; border-radius: var(--radius-m);
  padding: 9px 12px; min-height: 40px; line-height: 1.4; overflow: hidden;
}
.quick-add textarea:focus { border-style: solid; border-color: var(--accent); background: var(--surface); outline: none; }
.quick-add .row { display: none; align-items: center; gap: 6px; }
.quick-add:focus-within .row, .quick-add.has-text .row { display: flex; }
.quick-add .row .hint { flex: 1; font-size: 12px; color: var(--muted); }
.empty-hint { font-size: 13px; color: var(--muted); padding: 8px 4px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 10px 12px; display: grid; gap: 8px; cursor: pointer; position: relative;
}
.card:hover { border-color: #9FB0AA; }
.card.dragging { opacity: .5; }
.card.prio-high { border-left: 4px solid var(--red); padding-left: 9px; }
.card.prio-low .card-title { color: var(--muted); }
.card-title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.col[data-status="done"] .card-title { text-decoration: line-through; text-decoration-color: #9AA6A3; color: var(--muted); }
.card-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.card-meta .grow { flex: 1; }
.card-meta svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.card-meta .overdue { color: var(--red); font-weight: 700; }
.assignee-btn { border: 0; background: none; padding: 2px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink); }
.assignee-btn:hover { background: var(--accent-soft); }

.popover {
  position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: 0 12px 32px rgba(24, 38, 43, .16); padding: 6px; min-width: 200px; max-height: 320px; overflow: auto;
}
.popover button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 8px 10px; border-radius: var(--radius-s); text-align: left; font-weight: 500; }
.popover button:hover, .popover button.current { background: var(--accent-soft); }

/* ---------- task dialog ---------- */
dialog { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(24, 38, 43, .45); }
.task-dlg { width: min(980px, calc(100vw - 32px)); margin: 4vh auto; }
.task-box { background: var(--surface); border-radius: var(--radius-l); display: grid; grid-template-columns: 1fr 260px; max-height: 92vh; overflow: hidden; }
.task-main { padding: 24px 28px; overflow: auto; display: grid; gap: 18px; align-content: start; }
.task-side { background: var(--surface-2); border-left: 1px solid var(--line); padding: 24px 20px; display: grid; gap: 14px; align-content: start; overflow: auto; }
.task-top { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.task-top .spacer { flex: 1; }
.icon-btn { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--accent-soft); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.title-input { font: 600 22px/1.3 var(--display); letter-spacing: -.01em; border: 1px solid transparent; border-radius: var(--radius-s); padding: 4px 6px; margin: -4px -6px; width: calc(100% + 12px); resize: none; background: transparent; overflow: hidden; }
.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--accent); outline: none; }
.section-title { font: 600 14px var(--display); margin: 0; display: flex; align-items: center; gap: 10px; }
.section-title .save-state { font: 500 12px var(--text); color: var(--muted); }

.ai-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ai-bar .btn { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.ai-bar .btn:hover { border-color: var(--accent); }
.ai-result { border: 1px solid var(--accent); background: #F3F8F6; border-radius: var(--radius-m); padding: 14px 16px; display: grid; gap: 10px; }
.ai-result header { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; color: var(--accent); }
.ai-result .text { white-space: pre-wrap; line-height: 1.6; }
.ai-result .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-loading { display: flex; align-items: center; gap: 10px; color: var(--accent); font-weight: 600; font-size: 14px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.comments { display: grid; gap: 14px; }
.comment { display: grid; grid-template-columns: 28px 1fr; gap: 10px; }
.comment .who { font-weight: 700; font-size: 14px; }
.comment .when { color: var(--muted); font-size: 12px; font-weight: 500; margin-left: 6px; }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.comment-form { display: grid; gap: 8px; }
.comment-form .textarea { min-height: 72px; }
.comment-form .row { display: flex; justify-content: flex-end; }

/* ---------- карта районів ---------- */

.alert-widget { position: fixed; right: 20px; bottom: 20px; z-index: 30; }
.alert-widget:empty { display: none; }
.aw {
  display: grid; gap: 6px; width: 230px; padding: 8px 8px 10px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
  box-shadow: 0 10px 30px rgba(24, 38, 43, .18);
}
.aw { position: relative; --mw: 212px; --s: .265; }
.aw:hover { border-color: var(--ink); }
/* iframe alerts.in.ua рендериться в 800×440 (мапа вписується по висоті) і зменшується до ширини віджета */
.aw-map { display: block; width: var(--mw); height: calc(var(--mw) * 440 / 800); border-radius: var(--radius-m); overflow: hidden; background: #151a20; }
.aw-frame { width: 800px; height: 440px; border: 0; transform: scale(var(--s)); transform-origin: 0 0; pointer-events: none; display: block; }
.aw-hit { position: absolute; inset: 0; border: 0; background: transparent; border-radius: inherit; cursor: pointer; }
.aw-text { display: grid; padding: 0 4px; line-height: 1.3; }
.aw-text strong { font-size: 14px; }
.aw-text span { font-size: 13px; color: var(--muted); font-weight: 600; }

.picker-dlg { width: min(1000px, calc(100vw - 32px)); margin: 4vh auto; }
.picker-box { background: var(--surface); border-radius: var(--radius-l); padding: 20px 24px 24px; display: grid; grid-auto-rows: max-content; gap: 14px; min-width: 0; max-height: 92vh; overflow: auto; }
.picker-head { display: flex; align-items: center; justify-content: space-between; }
.picker-head h2 { font: 600 20px var(--display); margin: 0; }
.picker-aiu { height: min(58vh, 540px); flex: none; border-radius: var(--radius-m); overflow: hidden; background: #151a20; }
.picker-frame { width: 100%; height: 100%; border: 0; display: block; }
.picker-aiu-note { margin-top: -6px; }
.picker-aiu-note a { color: var(--accent); font-weight: 600; }
.picker-sub { font: 600 16px var(--display); margin: 6px 0 0; }
.note { margin: 0; }
.note:empty { display: none; }

/* ---------- команда ---------- */
.team-dlg { width: min(780px, calc(100vw - 32px)); }
.team-list { display: grid; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.team-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 160px 104px; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.team-row:first-child { border-top: 0; }
.team-who { display: grid; min-width: 0; }
.team-who strong { font-size: 15px; }
.team-who .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-role { padding: 7px 10px; }
.team-del { justify-content: center; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 100;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); }

.loading-screen { min-height: 100vh; display: grid; place-items: center; color: var(--muted); font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
  .col:last-child .col-list { padding-bottom: 4px; }
  .col:nth-child(2) .col-list, .col:last-child .col-list { padding-bottom: 190px; }
}
@media (max-width: 760px) {
  .shell { height: auto; min-height: 100vh; overflow: visible; }
  .board { display: flex; flex-direction: column; }
  .col-list { overflow: visible; }
  .col:nth-child(2) .col-list, .col:last-child .col-list { padding-bottom: 4px; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 16px; gap: 20px; }
  .auth-hero h1 { font-size: 26px; }
  .auth-map { max-width: 300px; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .topbar .logo { font-size: 15px; gap: 8px; }
  .topbar .btn .label-long { display: none; }
  .user-btn .name { display: none; }
  .main { padding: 16px 16px 120px; }
  .aw { width: 168px; padding: 6px 6px 8px; gap: 4px; --mw: 156px; --s: .195; }
  .picker-aiu { height: 62vh; }
  .aw-text strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .aw-text span { font-size: 12px; }
  .alert-widget { right: 12px; bottom: 12px; }
  #toast { bottom: auto; top: 12px; }
  .team-row { grid-template-columns: 32px minmax(0, 1fr); }
  .team-role, .team-del, .team-del-placeholder { grid-column: 2; }
  .team-del { justify-self: start; }
  .picker-dlg { width: 100vw; margin: auto 0 0; }
  .picker-box { border-radius: var(--radius-l) var(--radius-l) 0 0; padding: 16px; max-height: 94vh; }
  .board { grid-template-columns: 1fr; overflow: visible; }
  .task-dlg { width: 100vw; margin: 0; }
  .task-box { grid-template-columns: 1fr; max-height: 100vh; height: 100vh; border-radius: 0; overflow: auto; }
  .task-main { overflow: visible; padding: 16px; }
  .task-side { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 16px; grid-template-columns: 1fr 1fr; }
  .task-side .full { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- вкладки «Дошка / Архів» ---------- */
[hidden] { display: none !important; }
.view-tabs { display: flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-left: 12px; }
.view-tabs a { padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted); text-decoration: none; }
.view-tabs a:hover { color: var(--ink); }
.view-tabs a[aria-current="page"] { background: var(--ink); color: #fff; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.delete-hint { margin-left: auto; font-size: 12px; color: var(--muted); max-width: 30ch; line-height: 1.35; text-align: right; }
@media (hover: none) { .delete-hint { display: none; } }

/* ---------- перейменування на картці ---------- */
.card-title { padding-right: 22px; }
.card-edit {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: var(--surface); color: var(--muted); display: grid; place-items: center; opacity: 0; transition: opacity .15s;
}
.card-edit svg { width: 15px; height: 15px; }
.card:hover .card-edit, .card:focus-within .card-edit { opacity: 1; }
.card-edit:hover { background: var(--accent-soft); color: var(--ink); }
@media (hover: none) { .card-edit { opacity: .7; } }
.card-title-input {
  width: 100%; resize: none; overflow: hidden; font: 600 15px/1.35 var(--text); border: 1px solid var(--accent);
  border-radius: var(--radius-s); padding: 4px 6px; margin: -5px -7px -5px; box-shadow: 0 0 0 3px var(--accent-soft); outline: none;
}
.title-wrap { display: flex; align-items: flex-start; gap: 6px; }
.title-wrap .title-input { flex: 1; width: auto; margin: -4px 0 -4px -6px; }
.title-input { cursor: text; }

/* ---------- архів ---------- */
.arch-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.arch-tools .select { width: auto; min-width: 180px; }
.arch-search { position: relative; flex: 1; min-width: 220px; }
.arch-search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.arch-search .input { padding-left: 36px; }
.arch-list { flex: 1; min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.arch-row {
  display: grid; grid-template-columns: 56px minmax(0, 2.6fr) 136px minmax(0, 1.3fr) 118px 150px 112px;
  gap: 12px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 14px; cursor: pointer;
}
.arch-row:hover { background: var(--surface-2); }
.arch-head { position: sticky; top: 0; z-index: 1; background: var(--surface-2); border-top: 0; font-size: 12px; font-weight: 700; color: var(--muted); cursor: default; }
.arch-row.is-deleted { cursor: default; }
.arch-row.is-deleted .a-title { color: var(--muted); text-decoration: line-through; text-decoration-color: #A9B5B0; }
.a-id { color: var(--muted); font-size: 13px; }
.a-title { font-weight: 600; overflow-wrap: anywhere; display: flex; align-items: center; gap: 10px; }
.a-cmt { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: 12px; font-weight: 600; flex: none; }
.a-cmt svg { width: 13px; height: 13px; }
.a-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.a-who > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-date { color: var(--muted); font-size: 13px; }
.a-lbl { display: none; }
.a-act { text-align: right; }
.a-act .btn { padding: 5px 12px; font-size: 13px; }
.arch-empty { padding: 32px 16px; text-align: center; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.st-todo { background: #E6EAE7; color: #44514D; }
.pill.st-progress { background: #E1E7F5; color: #2C4686; }
.pill.st-review { background: var(--yellow-soft); color: #7A5600; }
.pill.st-done { background: #DDEEDD; color: #22602A; }
.pill.st-deleted { background: var(--red-soft); color: #A21D2C; }

/* ---------- кошик для видалення жестом ---------- */
body.trash-dragging, body.trash-dragging * { user-select: none; cursor: grabbing !important; }
.card.ghosted { opacity: .35; }
.card-ghost {
  position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; margin: 0;
  box-shadow: 0 18px 40px rgba(24, 38, 43, .25); transition: border-color .15s, opacity .15s, scale .18s ease;
}
.card-ghost.over-trash { border-color: var(--red); opacity: .55; scale: .45; }
.card-ghost.returning { transition: transform .25s ease-out; }
.card-ghost.falling { transition: transform .42s cubic-bezier(.55, 0, .8, .4), opacity .42s; opacity: 0; }
.card-ghost .card-edit { display: none; }

.trash {
  position: fixed; left: 50%; bottom: 28px; z-index: 210; display: grid; justify-items: center; gap: 10px;
  transform: translate(-50%, 180%); transition: transform .38s cubic-bezier(.34, 1.56, .64, 1); pointer-events: none;
}
.trash.show { transform: translate(-50%, 0); }
.trash-label {
  background: var(--ink); color: #fff; font-weight: 600; font-size: 13px; padding: 6px 14px; border-radius: 999px;
  box-shadow: 0 8px 20px rgba(24, 38, 43, .2); white-space: nowrap; transition: background .15s;
}
.trash-can {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--ink); border: 2px dashed #9AA6A3;
  box-shadow: 0 12px 30px rgba(24, 38, 43, .22); transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), background .15s, color .15s, border-color .15s;
}
.trash-can svg { width: 34px; height: 34px; overflow: visible; }
.trash-can .lid { transform-box: fill-box; transform-origin: 0% 100%; transition: transform .2s ease; }
.trash.show .trash-can .lid { animation: lid-bob 1.4s ease-in-out infinite; }
.trash.hot .trash-can { transform: scale(1.18); background: var(--red); color: #fff; border: 2px solid var(--red); }
.trash.hot .trash-can .lid { animation: none; transform: translate(-1px, -2px) rotate(-28deg); }
.trash.hot .trash-label { background: var(--red); }
.trash.gulp .trash-can { animation: gulp .45s ease; }
.trash.gulp .trash-can .lid { animation: none; transform: none; }
@keyframes lid-bob { 0%, 100% { transform: rotate(0); } 50% { transform: translateY(-1.5px) rotate(-8deg); } }
@keyframes gulp { 0% { transform: scale(1.18); } 40% { transform: scale(.88); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }

#toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding-right: 8px; }
#toast button { border: 0; background: #fff; color: var(--ink); font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 999px; }

@media (max-width: 1000px) {
  .arch-row { grid-template-columns: 48px minmax(0, 1fr) 128px 112px; }
  .arch-row > :nth-child(5), .arch-row > :nth-child(6) { display: none; }
  .arch-row > .a-act:empty { display: none; }
}
@media (max-width: 760px) {
  .view-tabs { margin-left: 4px; }
  .view-tabs a { padding: 5px 10px; font-size: 13px; }
  .topbar .logo { font-size: 0; gap: 0; }
  .arch-list { overflow: visible; }
  .arch-head { display: none; }
  .arch-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 12px 14px; }
  .arch-row > * { grid-column: 1 / -1; }
  .arch-row > .a-id { display: none; }
  .arch-row > :nth-child(5), .arch-row > :nth-child(6) { display: block; }
  .a-lbl { display: inline; }
  .a-act { text-align: left; }
  .arch-tools > label { flex: 1 1 140px; }
  .arch-tools .select { width: 100%; min-width: 0; }
}

/* ---------- покращення опису: список змін ---------- */
.ai-bar .muted { flex: 1; min-width: 200px; }
.changes { font-size: 13px; color: var(--muted); }
.changes summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.changes ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 2px; }
.ai-result header svg { width: 16px; height: 16px; flex: none; }
.task-main .textarea[name=description] { max-height: 55vh; overflow-y: auto; }

/* =====================================================================
   Плавні анімації взаємодії.
   Рух лише у відповідь на дії людини (відкрити, перетягнути, додати) —
   плюс один короткий вхід дошки при завантаженні. prefers-reduced-motion вимикає все.
   ===================================================================== */
:root {
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --t-fast: .16s;
  --t-med: .26s;
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- кнопки, чипи, іконки: м'яка реакція на наведення й натискання ---- */
.btn, .chip, .icon-btn, .user-btn, .assignee-btn, .link-btn, .tabs button, .popover button, .card-edit, #toast button {
  transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease, color var(--t-fast) ease,
    transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) ease, opacity var(--t-fast) ease;
}
.btn:active, .chip:active, .icon-btn:active, .user-btn:active, .tabs button:active, #toast button:active { transform: scale(.96); }
.btn.primary:hover { box-shadow: 0 6px 16px rgba(30, 94, 88, .25); }
.input, .select, .textarea { transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease; }

/* ---- картки ---- */
.card {
  transition: border-color var(--t-fast) ease, box-shadow var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out), opacity var(--t-fast) ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(24, 38, 43, .08); }
.card:active { transform: translateY(0) scale(.99); box-shadow: none; }
.card.dragging, .card.ghosted { transform: none; box-shadow: none; }

/* ---- колонки: підсвічування під час перетягування ---- */
.col { transition: background-color var(--t-med) ease, border-color var(--t-med) ease, box-shadow var(--t-med) ease; }
.col.drop { box-shadow: inset 0 0 0 2px var(--accent); }

/* ---- швидке додавання: рядок із кнопкою плавно розкривається ---- */
.quick-add .row {
  display: flex; max-height: 0; opacity: 0; visibility: hidden; overflow: hidden;
  transition: max-height var(--t-med) var(--ease-out), opacity var(--t-fast) ease, visibility 0s linear var(--t-med);
}
.quick-add:focus-within .row, .quick-add.has-text .row {
  max-height: 60px; opacity: 1; visibility: visible; transition-delay: 0s;
}
.quick-add textarea { transition: border-color var(--t-fast) ease, background-color var(--t-fast) ease, height var(--t-fast) ease; }

/* ---- діалоги: поява й зникнення (фон затемнюється плавно) ---- */
dialog {
  opacity: 0; transform: translateY(14px) scale(.985);
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out),
    overlay var(--t-med) allow-discrete, display var(--t-med) allow-discrete;
}
dialog[open] { opacity: 1; transform: none; }
@starting-style { dialog[open] { opacity: 0; transform: translateY(14px) scale(.985); } }
dialog::backdrop {
  background: rgba(24, 38, 43, 0);
  transition: background-color var(--t-med) ease, overlay var(--t-med) allow-discrete, display var(--t-med) allow-discrete;
}
dialog[open]::backdrop { background: rgba(24, 38, 43, .45); }
@starting-style { dialog[open]::backdrop { background: rgba(24, 38, 43, 0); } }

/* ---- спливні меню, панелі, нові записи ---- */
.popover { animation: pop-in var(--t-fast) var(--ease-out); transform-origin: top left; }
.ai-result { animation: rise var(--t-med) var(--ease-out); }
.changes ul { animation: fade-in var(--t-med) ease; }
.team-row { transition: background-color var(--t-fast) ease; }
.team-row:hover { background: var(--surface-2); }
.arch-row { transition: background-color var(--t-fast) ease; }
.form-error:not(:empty) { animation: rise var(--t-fast) var(--ease-out); }

/* ---- вкладки «Дошка / Архів»: активний фон плавно переїжджає ---- */
.view-tabs { position: relative; isolation: isolate; }
.view-tabs::before {
  content: ""; position: absolute; z-index: -1; top: 3px; bottom: 3px; left: 0;
  width: var(--tab-w, 0); transform: translateX(var(--tab-x, 0)); border-radius: 999px; background: var(--ink);
  transition: transform .32s var(--ease-spring), width .32s var(--ease-spring);
}
.view-tabs a { transition: color var(--t-med) ease; }
.view-tabs.ready a[aria-current="page"] { background: transparent; color: #fff; }
.view-enter { animation: rise var(--t-med) var(--ease-out); }

/* ---- вхід дошки при завантаженні: колонки з'являються по черзі ---- */
.board.intro .col { animation: rise .42s var(--ease-out) both; }
.board.intro .col:nth-child(2) { animation-delay: .05s; }
.board.intro .col:nth-child(3) { animation-delay: .1s; }
.board.intro .col:nth-child(4) { animation-delay: .15s; }
.loading-screen { animation: fade-in .4s ease .15s both; }
.auth-card form { animation: rise var(--t-med) var(--ease-out); }
.alert-widget .aw { transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) ease, border-color var(--t-fast) ease; }
.alert-widget .aw:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(24, 38, 43, .22); }

/* ---- спливне повідомлення: пружний вхід ---- */
#toast { transition: opacity .22s ease, transform .32s var(--ease-spring); }

/* ---- мобільні: вікна виїжджають знизу як шторка ---- */
@media (max-width: 760px) {
  .picker-dlg, .task-dlg { transform: translateY(40px); }
  .picker-dlg[open], .task-dlg[open] { transform: none; }
  @starting-style { .picker-dlg[open], .task-dlg[open] { transform: translateY(40px); opacity: 0; } }
  .card:hover { transform: none; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card:hover, .alert-widget .aw:hover { transform: none; }
}

/* привид картки під час жесту видалення йде точно за курсором — без загальної анімації карток */
.card.card-ghost { transition: border-color .15s, opacity .15s, scale .18s ease; }
.card.card-ghost.returning { transition: transform .25s ease-out; }
.card.card-ghost.falling { transition: transform .42s cubic-bezier(.55, 0, .8, .4), opacity .42s; }
/* ---------- індикатор складності на картці: 1–3 заповнені риски ---------- */
.diff { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.diff i { width: 3px; border-radius: 2px; background: #CBD3CE; }
.diff i:nth-child(1) { height: 5px; } .diff i:nth-child(2) { height: 8px; } .diff i:nth-child(3) { height: 11px; }
.diff.d-easy i:nth-child(1), .diff.d-medium i:nth-child(-n+2), .diff.d-hard i { background: var(--muted); }


/* ---------- заявки до команди ---------- */
.user-btn { position: relative; }
.req-badge {
  position: absolute; top: -2px; left: 20px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--surface); animation: pop-in .3s var(--ease-spring);
}
.req-count { margin-left: auto; background: var(--red-soft); color: #A21D2C; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.popover button .req-count { margin-left: auto; }
.team-requests { display: grid; background: #FFF8EC; border-bottom: 1px solid var(--line); }
.team-requests .picker-sub, .team-members-title { display: flex; align-items: center; gap: 8px; margin: 0; padding: 12px 14px 4px; font-size: 14px; }
.team-row.is-pending { grid-template-columns: 32px minmax(0, 1fr) auto auto; border-top: 0; }
.team-row.is-pending .btn { padding: 6px 12px; font-size: 13px; }
.auth-note { margin: -6px 0 0; line-height: 1.5; }

.pending-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.pending-card {
  max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 32px 28px; display: grid; gap: 12px; justify-items: start; animation: rise .4s var(--ease-out);
}
.pending-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.pending-card h1 { font: 600 22px var(--display); margin: 4px 0 0; }
.pending-card p { margin: 0; line-height: 1.55; }
@media (max-width: 760px) {
  .team-row.is-pending { grid-template-columns: 32px minmax(0, 1fr); }
  .team-row.is-pending .btn { grid-column: 2; justify-self: start; }
}
