:root {
  --bg: #f4f3ef;
  --dot: #d9d6cc;
  --ink: #17171a;
  --muted: #6b6a66;
  --line: #e3e0d8;
  --card: #ffffff;
  --accent: #1d4ed8;
  --danger: #c0392b;
  --frame: #ffffff;
  --frame-head: #17171a;
  --col: #faf9f6;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  --s-yellow: #fff1a8; --s-pink: #ffd3dd; --s-blue: #cfe6ff; --s-green: #d4f2cf;
  --s-purple: #e5dbff; --s-orange: #ffdcb8; --s-gray: #ecebe6; --s-red: #ffc9c2;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- вход ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(var(--dot) 1px, transparent 1px) 0 0 / 22px 22px, var(--bg); }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.error { color: var(--danger); min-height: 1em; margin: 0; font-size: 13px; }

/* ---------- шапка ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand.big { font-size: 20px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background:
  linear-gradient(#ffd84d,#ffd84d) 4px 4px / 6px 6px no-repeat,
  linear-gradient(#90d0ff,#90d0ff) 12px 4px / 6px 6px no-repeat,
  linear-gradient(#a6e3a1,#a6e3a1) 4px 12px / 14px 6px no-repeat, #111; }
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 0 14px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.tools { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tools::-webkit-scrollbar { display: none; }
.right { display: flex; align-items: center; gap: 8px; position: relative; }
.sep { width: 1px; height: 22px; background: var(--line); flex: none; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 12px; cursor: pointer; white-space: nowrap; font-size: 14px; }
.btn:hover { background: #f7f6f2; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #333; }
.btn.danger { color: var(--danger); }
.btn.icon { padding: 7px 10px; min-width: 36px; }
#zoom-label { min-width: 58px; font-variant-numeric: tabular-nums; }
.zoom { display: flex; gap: 4px; }
select#jump, #search { border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; background: #fff; font-size: 14px; }
select#jump { max-width: 220px; }
#search { width: 190px; }
.presence { display: flex; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: #17171a; color: #fff; border: 2px solid #fff; margin-left: -6px; }
.menu { position: absolute; right: 0; top: 46px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  min-width: 220px; padding: 6px; display: grid; }
.menu button { text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: #f4f3ef; }
.menu-head { padding: 8px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* ---------- холст ---------- */
.viewport { position: fixed; inset: 56px 0 0 0; overflow: hidden; cursor: grab; touch-action: none;
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.2px); background-size: 24px 24px; }
.viewport.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.el { position: absolute; user-select: none; }
.el.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.el.dim { opacity: .25; }

/* спринт */
.frame { background: var(--frame); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.frame-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); cursor: move; }
.frame-title { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.frame-meta { margin-top: 4px; color: var(--muted); font-size: 14px; }
.frame-goal { margin-top: 6px; font-size: 14px; line-height: 1.4; max-width: 900px; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: #eee; color: #444; }
.badge.planned { background: #eef2ff; color: #3730a3; }
.badge.active { background: #fff4d6; color: #8a5a00; }
.badge.done { background: #dcfce7; color: #166534; }
.frame-cols { flex: 1; display: grid; gap: 10px; padding: 12px; }
.frame-col { background: var(--col); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; }
.frame-col h4 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; display: flex; justify-content: space-between; }
.frame.backlog .frame-col { border-style: solid; }

/* стикер */
.sticky { width: 220px; min-height: 120px; border-radius: 6px; padding: 12px 12px 10px; box-shadow: 0 1px 1px rgba(0,0,0,.08), 0 6px 14px rgba(0,0,0,.08);
  cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.sticky:hover { box-shadow: 0 2px 2px rgba(0,0,0,.08), 0 10px 22px rgba(0,0,0,.12); }
.sticky .t { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.sticky .d { font-size: 12.5px; line-height: 1.35; color: #3d3c39; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sticky .f { margin-top: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 11.5px; color: #4b4a46; }
.chip { background: rgba(255,255,255,.65); border-radius: 999px; padding: 2px 7px; font-weight: 500; }
.chip.prio-high { background: #fff; color: var(--danger); }
.chip.key { font-family: ui-monospace, monospace; }
.sticky.st-done .t { text-decoration: line-through; text-decoration-color: rgba(0,0,0,.35); }
.c-yellow { background: var(--s-yellow); } .c-pink { background: var(--s-pink); } .c-blue { background: var(--s-blue); }
.c-green { background: var(--s-green); } .c-purple { background: var(--s-purple); } .c-orange { background: var(--s-orange); }
.c-gray { background: var(--s-gray); } .c-red { background: var(--s-red); }

/* заметка */
.note { background: #fffdf5; border: 1px solid #ece6cf; border-radius: 14px; box-shadow: var(--shadow); padding: 18px 20px; cursor: pointer; overflow: hidden; display: flex; flex-direction: column; }
.note .nt { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 8px; }
.note .nb { font-size: 14px; line-height: 1.5; overflow: hidden; flex: 1; }
.note .nb h1, .note .nb h2, .note .nb h3 { font-size: 15px; margin: 10px 0 4px; }
.note .nb p { margin: 4px 0; }
.note .nb ul { margin: 4px 0; padding-left: 18px; }
.note .nb code { background: #f2efe4; padding: 0 4px; border-radius: 4px; font-size: 13px; }
.resize { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,.25) 50%, rgba(0,0,0,.25) 60%, transparent 60%, transparent 70%, rgba(0,0,0,.25) 70%, rgba(0,0,0,.25) 80%, transparent 80%); }

/* ---------- панель деталей ---------- */
.panel { position: fixed; top: 56px; right: 0; bottom: 0; width: min(460px, 100%); z-index: 15; background: #fff; border-left: 1px solid var(--line);
  box-shadow: -8px 0 30px rgba(0,0,0,.06); display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head .kind { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); flex: 1; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 14px; align-content: start; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; width: 100%; }
.field textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
.field input.title { font-size: 18px; font-weight: 600; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.colors { display: flex; gap: 6px; flex-wrap: wrap; }
.colors button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.colors button.on { border-color: var(--ink); }
.meta { font-size: 12px; color: var(--muted); line-height: 1.5; }
.panel-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: space-between; }

/* ---------- модалка и уведомления ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(20,20,20,.35); display: grid; place-items: center; padding: 16px; }
.modal-card { width: min(520px, 100%); max-height: 86vh; overflow-y: auto; background: #fff; border-radius: 16px; padding: 22px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.modal-card h3 { margin: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-card ul { margin: 0; padding-left: 18px; line-height: 1.6; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; }

@media (max-width: 760px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .brand { font-size: 0; gap: 0; }
  #search, .zoom, .presence { display: none; }
  select#jump { max-width: 130px; }
}
