:root {
  color-scheme: light dark;
  --bg: light-dark(#f3f4f8, #111318);
  --surface: light-dark(#ffffff, #1b1e26);
  --soft: light-dark(#eceef4, #252935);
  --border: light-dark(#e0e3ec, #303544);
  --text: light-dark(#1a1d29, #e8eaf2);
  --muted: light-dark(#5d6377, #9ca3b8);
  --accent: light-dark(#4f5bd5, #8e99ff);
  --on-accent: light-dark(#ffffff, #12142a);
  --danger: light-dark(#c2303a, #ff8088);
  --warn: light-dark(#8a5a00, #e8b04e);
  --ok: light-dark(#1b7a49, #62d296);
  --shadow: 0 8px 30px rgb(0 0 0 / .18);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 14px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 13px; margin: 8px 0 0; color: var(--muted); }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
input, textarea { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
ul { list-style: none; margin: 0; padding: 0; }
.muted { color: var(--muted); font-size: 12px; }
.danger-text { color: var(--danger) !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.logo { display: flex; margin-right: 8px; }
.top a { padding: 6px 12px; border-radius: 8px; white-space: nowrap; font-weight: 600; color: var(--muted); }
.top a:hover { background: var(--soft); }
.top a.on { background: var(--soft); color: var(--text); }
.badge { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; text-align: center; }
.me { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; }
.me:hover { background: var(--soft); }

main { padding: 16px; }
main section { margin-bottom: 24px; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.people { margin-left: auto; display: flex; flex-wrap: wrap; gap: 2px; }
.person { padding: 3px; border-radius: 50%; border: 2px solid transparent; }
.person.on { border-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.board { display: grid; grid-template-columns: repeat(4, minmax(270px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; padding-bottom: 12px; scroll-snap-type: x proximity; }
.column { background: var(--soft); border-radius: 14px; padding: 10px; min-height: 240px; margin: 0 !important; scroll-snap-align: start; border: 2px dashed transparent; }
.column.over { border-color: var(--accent); }
.column > .quick { margin-bottom: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.card { position: relative; display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; min-width: 0; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card.is-late { border-left: 3px solid var(--danger); }
.card.off { opacity: .6; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.card-title { font-weight: 600; overflow-wrap: anywhere; }
.card-title:hover { color: var(--accent); }
/* без меток над названием флажок встаёт в одну строку с ним */
.card-top:has(> .crumbs:empty) { position: absolute; top: 12px; right: 10px; }
.card-top:has(> .crumbs:empty) + .card-title { padding-right: 30px; }
.flag { color: var(--muted); opacity: .45; min-width: 24px; text-align: center; }
.flag:hover, .flag.on { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 3px 10px 3px 6px; border-radius: 20px; background: var(--soft); font-size: 12px; border: 1px solid transparent; }
.chip:hover { border-color: var(--accent); }
.chip.ghost { background: none; border: 1px dashed var(--border); color: var(--muted); }
.chip.late, .tag.late, .tag.danger, .mini.late { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }
.chip.soon, .tag.soon, .tag.warn, .mini.soon { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.eye { font-weight: 700; color: var(--ok); padding-left: 3px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; background: var(--soft); font-size: 12px; overflow-wrap: anywhere; }

.ava { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%; font-size: 10px; font-weight: 700; color: #fff; background: var(--tone); }
.ava.empty { background: var(--soft); color: var(--muted); }
.c0 { --tone: #4f5bd5; } .c1 { --tone: #0f7f8c; } .c2 { --tone: #a4478f; }
.c3 { --tone: #b25a16; } .c4 { --tone: #2f7d46; } .c5 { --tone: #7a52c7; }
.tag[class*=" c"] { background: color-mix(in srgb, var(--tone) 18%, transparent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 5px 14px; border-radius: 8px; background: var(--soft); font-weight: 600; font-size: 13px; }
.btn:hover { filter: brightness(.95); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ok { background: var(--ok); color: light-dark(#fff, #0c1f15); }
.btn.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.btn.quiet { background: none; color: var(--muted); font-weight: 400; padding-inline: 8px; }
.btn.quiet:hover { background: var(--soft); }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card-actions:empty { display: none; }
.right { margin-left: auto; }

progress { appearance: none; width: 100%; height: 5px; border: 0; border-radius: 3px; overflow: hidden; background: var(--soft); }
progress::-webkit-progress-bar { background: var(--soft); }
progress::-webkit-progress-value { background: var(--ok); }
progress::-moz-progress-bar { background: var(--ok); }
.progress { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; min-height: 24px; }
.progress span { white-space: nowrap; }

.subs { display: flex; flex-direction: column; gap: 4px; }
.sub { border-top: 1px solid var(--border); padding-top: 4px; }
.sub-title { display: flex; gap: 8px; align-items: baseline; width: 100%; overflow-wrap: anywhere; }
.sub.done .sub-title span { text-decoration: line-through; color: var(--muted); }
.sub-meta { display: flex; gap: 6px; align-items: center; padding-left: 16px; }
.mini { display: inline-flex; align-items: center; min-height: 28px; border-radius: 6px; padding: 2px 4px; font-size: 12px; }
.mini:hover { background: var(--soft); }
.mini.ghost { color: var(--muted); }
.mini.act { margin-left: auto; color: var(--accent); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--muted); }
.s-work { background: var(--accent); } .s-review { background: var(--warn); } .s-done { background: var(--ok); }
.count { color: var(--muted); font-weight: 400; }

.project { border-top: 4px solid var(--tone); }
.project strong { font-size: 16px; overflow-wrap: anywhere; }
.new-card { border-style: dashed; }
.person-row { display: flex; gap: 10px; align-items: center; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px 16px; color: var(--muted); }

.shade { position: fixed; inset: 0; z-index: 10; background: rgb(0 0 0 / .35); }
.panel { position: fixed; z-index: 11; top: 0; right: 0; bottom: 0; width: min(600px, 100%); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 32px; background: var(--surface); box-shadow: var(--shadow); }
.panel > * { flex: none; }
.title-input { font-size: 20px; font-weight: 600; border-color: transparent; resize: none; }
.title-input:hover { border-color: var(--border); }
.feed { display: flex; flex-direction: column; gap: 8px; }
.comment { display: flex; gap: 8px; }
.comment p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.log { padding-left: 30px; }

.popover { position: fixed; z-index: 20; width: 250px; max-height: min(420px, 90vh); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.popover form { display: flex; flex-direction: column; gap: 8px; }
.popover > * { flex: none; }
.pop-title { font-size: 12px; font-weight: 700; color: var(--muted); padding: 2px 6px; }
.option { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 8px; border-radius: 7px; }
.option:hover, .option.on { background: var(--soft); }

.login { width: min(340px, calc(100% - 32px)); margin: 12vh auto; padding: 28px; align-items: stretch; text-align: center; }
.login img { align-self: center; }

#toast { position: fixed; z-index: 30; bottom: 20px; left: 50%; translate: -50% 0; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .15s; }
#toast.show { opacity: 1; }
body.offline::after { content: "Нет связи с сервером"; position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; padding: 6px; text-align: center; background: var(--danger); color: #fff; }

@media (max-width: 700px) {
  main { padding: 10px; }
  .top { padding: 6px 8px; }
  .top a { padding: 8px; }
  .logo, .me span { display: none; }
  .board { grid-template-columns: repeat(4, 85vw); }
  .grid { grid-template-columns: 1fr; }
  .people { margin-left: 0; }
  .btn, .option { min-height: 40px; }
  input, textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.list { display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
.list p { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.top { scrollbar-width: none; }
@media (max-width: 700px) { .top { gap: 0; } .top a { font-size: 13px; padding-inline: 6px; } }
.nest-zone { display: none; position: absolute; left: 6px; right: 6px; bottom: 6px; height: 44px; align-items: center; justify-content: center; border: 2px dashed var(--accent); border-radius: 8px; background: var(--surface); color: var(--accent); font-weight: 600; font-size: 13px; }
.nest-zone.ready { display: flex; }
.nest-zone.over { background: var(--accent); color: var(--on-accent); }
.tools { display: inline-flex; margin-left: auto; }
.tool { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; color: var(--muted); }
.tool:hover { background: var(--soft); color: var(--text); }
.tool.danger:hover { color: var(--danger); }
.tool:disabled { opacity: .4; }
.card-edit { font-weight: 600; resize: none; }
.card-top:has(> .crumbs:empty) + .card-edit { padding-right: 32px; }
@media (hover: hover) { .tool { opacity: .55; } .card:hover .tool, .tool:focus-visible { opacity: 1; } }
@media (max-width: 700px) { .tool { width: 40px; height: 40px; } }

.compact { gap: 6px; padding: 8px 10px; }
.project.compact { border-top-width: 3px; }
.p-work { background: var(--accent); } .p-pause { background: var(--muted); }
.p-review { background: var(--warn); } .p-done { background: var(--ok); }
.board.lanes { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(260px, 320px); }
.queue-row { display: flex; gap: 8px; align-items: baseline; }
.num { display: inline-grid; place-items: center; flex: none; min-width: 22px; height: 22px; border-radius: 6px; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 700; }
.numbered { display: flex; flex-direction: column; gap: 4px; }
.numbered > .num { align-self: flex-start; background: var(--surface); }
.card.before { box-shadow: 0 -5px 0 -1px var(--accent); }
.card.after { box-shadow: 0 5px 0 -1px var(--accent); }
.list.wide { max-width: 760px; }
.team { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 24px; align-items: start; }
.team aside { display: flex; flex-direction: column; gap: 12px; padding-right: 24px; border-right: 1px solid var(--border); }
.card.mine { border-color: var(--accent); }
.mine .row { flex-wrap: wrap; }
.mine .row input { flex: 1; min-width: 150px; }
.people-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 700px) {
  .board.lanes { grid-auto-columns: 85vw; }
  .team { grid-template-columns: 1fr; }
  .team aside { padding-right: 0; border-right: 0; }
}
.add-typical { align-self: flex-start; flex: none; }
.column > .add-typical { margin-bottom: 8px; }
.option { overflow-wrap: anywhere; }
.option:disabled { opacity: .5; }
.avas { display: inline-flex; }
.avas .ava + .ava { margin-left: -7px; box-shadow: 0 0 0 2px var(--surface); }
.check { margin-left: auto; color: var(--ok); }
