/* Темы: светлая по умолчанию, тёмная — по системной настройке или по выбору
   пользователя (data-theme на <html>, выставляется до отрисовки в index.html). */
:root {
  color-scheme: light;
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --column: #e8eaf0;          /* подложка колонки темнее карточек — они «лежат» сверху */
  --card: #ffffff;
  --card-border: #d9dde6;
  --card-border-hover: #b3b9c8;
  --border: #e3e5ec;
  --text: #1c1f2b;
  --muted: #6b7280;
  --accent: #6366f1;
  --accent-soft: #eef0ff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 1px 6px rgba(20, 24, 40, .05);
  --shadow-card: 0 1px 2px rgba(20, 24, 40, .06), 0 2px 6px rgba(20, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(20, 24, 40, .18);
  --radius: 10px;
  --col-backlog: #9ca3af;
  --col-todo: #3b82f6;
  --col-doing: #f59e0b;
  --col-done: #22c55e;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161d;
  --surface: #1d2029;
  --surface-2: #232734;
  --column: #1a1c24;
  --card: #262a36;
  --card-border: #363b4b;
  --card-border-hover: #4d5468;
  --border: #2e3240;
  --text: #e6e7ee;
  --muted: #9298a8;
  --accent: #818cf8;
  --accent-soft: #2a2d4a;
  --danger: #f87171;
  --danger-soft: #3f1d1d;
  --warn: #fbbf24;
  --warn-soft: #3d2f0f;
  --ok: #4ade80;
  --ok-soft: #14321f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 6px rgba(0, 0, 0, .25);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14161d;
    --surface: #1d2029;
    --surface-2: #232734;
    --column: #1a1c24;
    --card: #262a36;
    --card-border: #363b4b;
    --card-border-hover: #4d5468;
    --border: #2e3240;
    --text: #e6e7ee;
    --muted: #9298a8;
    --accent: #818cf8;
    --accent-soft: #2a2d4a;
    --danger: #f87171;
    --danger-soft: #3f1d1d;
    --warn: #fbbf24;
    --warn-soft: #3d2f0f;
    --ok: #4ade80;
    --ok-soft: #14321f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 6px rgba(0, 0, 0, .25);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
input:not([type]), input[type="text"], input[type="search"], input[type="password"], input[type="date"], textarea, select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 4px 8px; font-size: 13px; }
.grow { flex: 1; }

/* ---------- auth ---------- */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 360px; background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 28px; display: flex; flex-direction: column; gap: 12px;
}
.auth-logo {
  width: 48px; height: 48px; border-radius: 12px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 26px; font-weight: 700; margin-bottom: 4px;
}
.auth-card h1 { margin: 0 0 6px; font-size: 22px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.auth-card input { padding: 9px 11px; }
.auth-error { color: var(--danger); font-size: 13px; min-height: 18px; }
.auth-toggle { text-align: center; font-size: 13px; }

/* ---------- layout ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 15px;
}
.nav { display: flex; gap: 2px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#search { width: 220px; }
.avatar-btn { border: 0; padding: 0; background: none; }

.avatar {
  width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; text-transform: uppercase; flex-shrink: 0;
  border: 2px solid var(--surface); letter-spacing: .3px; overflow: hidden;
}
.avatar.lg { width: 34px; height: 34px; font-size: 13px; }
.avatar.xl { width: 96px; height: 96px; font-size: 34px; border-width: 3px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.avatar.inactive { opacity: .4; }
.avatars { display: flex; }
.avatars .avatar + .avatar { margin-left: -8px; }

.filters {
  display: flex; align-items: center; gap: 6px; padding: 8px 16px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.filters-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 3px 10px; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip .avatar { width: 18px; height: 18px; font-size: 9px; border: 0; }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.stats b { color: var(--text); }
.stats .overdue b { color: var(--danger); }

main { flex: 1; overflow: auto; }

/* ---------- board ---------- */
.board {
  display: grid; grid-template-columns: repeat(4, minmax(260px, 1fr)); gap: 14px;
  padding: 14px 16px; min-height: 100%; align-items: start;
}
.column {
  background: var(--column); border-radius: 12px; border: 1px solid var(--border);
  display: flex; flex-direction: column; max-height: calc(100vh - 140px); min-height: 200px;
}
.column.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; font-weight: 600;
}
.col-dot { width: 8px; height: 8px; border-radius: 50%; }
.col-count { color: var(--muted); font-weight: 500; font-size: 13px; }
.col-head .btn { margin-left: auto; padding: 1px 8px; }
.col-hint { font-size: 12px; color: var(--muted); padding: 0 12px 6px; }
.quick-add { padding: 0 8px 4px; position: relative; }
.quick-add input { width: 100%; background: var(--surface); }
.quick-add-hint {
  position: absolute; left: 8px; right: 8px; top: 100%; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg);
  padding: 6px 10px; font-size: 12px; color: var(--muted); margin-top: -4px;
}
.quick-add-hint code { background: var(--surface-2); padding: 0 4px; border-radius: 4px; }
/* Сверху 4px запаса: приподнятая при наведении карточка и её тень не обрезаются краем прокрутки. */
.cards { padding: 4px 8px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 40px; flex: 1; }
.cards:empty::after {
  content: "Пусто"; color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0;
}

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-card);
  padding: 10px 12px 10px 14px; cursor: pointer; position: relative; border: 1px solid var(--card-border);
  user-select: none; transition: border-color .12s, box-shadow .12s, transform .12s;
}
/* Тень компактная — помещается в поля колонки и не срезается по бокам. */
.card:hover { border-color: var(--card-border-hover); box-shadow: var(--shadow-card), 0 4px 12px rgba(0, 0, 0, .18); transform: translateY(-1px); }
.board.is-dragging .card { transition: none; }
.board.is-dragging .card:hover { transform: none; box-shadow: var(--shadow-card); }
.card.dragging { opacity: .4; }
.card::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px;
  background: transparent;
}
.card.p-high::before { background: var(--warn); }
.card.p-urgent::before { background: var(--danger); }
.card.p-low { opacity: .85; }
.card.done .card-title { color: var(--muted); text-decoration: line-through; }
.card-title { font-weight: 500; word-break: break-word; }
.card-title.untitled { font-weight: 400; color: var(--text); white-space: pre-line; }
.card-title.untitled.empty { color: var(--muted); font-style: italic; }
.card-desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-meta { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; min-height: 20px; }
.card-meta .avatars { margin-left: auto; }
/* Теги: цвет приходит инлайном в --tag */
.tag-pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; line-height: 1.6;
  text-transform: none; letter-spacing: 0;
  padding: 1px 8px; border-radius: 999px; white-space: nowrap; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
  color: var(--tag); border: 1px solid color-mix(in srgb, var(--tag) 45%, transparent);
  background: color-mix(in srgb, var(--tag) 14%, transparent);
}
.tag-pill[data-tag-off] { cursor: pointer; }
.tag-pill[data-tag-off]::after { content: "×"; opacity: .6; font-size: 13px; }
.tag-pill[data-tag-off]:hover { background: color-mix(in srgb, var(--tag) 28%, transparent); }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-list:not(:empty) { margin-bottom: 6px; }
.chip.tag-chip.active { background: color-mix(in srgb, var(--tag) 16%, transparent); border-color: var(--tag); color: var(--tag); }
.tag-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tag); }
.tag-color { width: 34px; height: 28px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 2px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.tag.due-over { background: var(--danger-soft); color: var(--danger); border-color: transparent; font-weight: 600; }
.tag.due-today { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 600; }
.tag.due-soon { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.urgent { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.high { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.progress { width: 100%; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 2px; transition: width .2s; }
.progress.full > div { background: var(--ok); }

.empty-board {
  padding: 60px 20px; text-align: center; color: var(--muted);
}

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 20, .45); }
.modal-card {
  position: relative; width: 100%; max-width: 860px; background: var(--surface); border-radius: 14px;
  box-shadow: var(--shadow-lg); display: grid; grid-template-columns: 1fr 250px; overflow: hidden;
  animation: pop .15s ease-out;
}
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.modal-main { padding: 22px 24px; min-width: 0; }
.modal-side { background: var(--surface-2); border-left: 1px solid var(--border); padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.modal-side label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .3px; }
.modal-side select, .modal-side input[type="date"] { width: 100%; font-size: 14px; text-transform: none; letter-spacing: 0; }
.modal-side .btn { justify-content: center; }
.modal-close { position: absolute; top: 10px; right: 10px; border: 0; background: none; font-size: 20px; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.title-input {
  width: 100%; border: 0; background: transparent; font-size: 20px; font-weight: 600; padding: 4px 0;
  outline: none; border-radius: 6px;
}
.title-input:focus { background: var(--surface-2); padding: 4px 8px; }
.desc-input {
  width: 100%; border: 0; background: transparent; padding: 6px 0; resize: none; min-height: 60px;
  outline: none; line-height: 1.5; border-radius: 6px;
}
.desc-input:focus { background: var(--surface-2); padding: 6px 8px; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.section-title .grow { flex: 1; }
.checklist { display: flex; flex-direction: column; gap: 2px; }
.check-item { display: flex; align-items: flex-start; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.check-item.dragging { opacity: .4; }
.ci-handle {
  flex-shrink: 0; cursor: grab; color: var(--muted); opacity: .35; user-select: none;
  font-size: 13px; letter-spacing: -2px; line-height: 1; padding: 6px 2px 0; touch-action: none;
}
.check-item:hover .ci-handle { opacity: 1; }
.ci-handle:active { cursor: grabbing; }
.check-item:hover { background: var(--surface-2); }
.check-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; margin: 4px 0 0; }
/* textarea вместо input: длинный пункт переносится на следующие строки, высота — по тексту. */
.check-item .ci-title {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 2px 4px; outline: none; border-radius: 4px;
  resize: none; overflow: hidden; line-height: 1.45; font: inherit; color: inherit; word-break: break-word;
  field-sizing: content;  /* современные браузеры подгоняют высоту сами; JS — для остальных */
}
.check-item .ci-title:focus { background: var(--surface); }
.check-item.done .ci-title { color: var(--muted); text-decoration: line-through; }
.check-item .ci-del { opacity: 0; border: 0; background: none; color: var(--muted); padding: 2px 6px; border-radius: 4px; flex-shrink: 0; }
.check-item:hover .ci-del { opacity: 1; }
.check-item .ci-del:hover { color: var(--danger); background: var(--danger-soft); }
.check-add { display: flex; gap: 6px; margin-top: 6px; }
.check-add input { flex: 1; }
.assignee-list { display: flex; flex-wrap: wrap; gap: 6px; }
.assignee-list .chip { text-transform: none; letter-spacing: 0; }
.meta-line { font-size: 12px; color: var(--muted); margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.saved-indicator { font-size: 12px; color: var(--muted); }
.saved-indicator.saving { color: var(--warn); }

.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { display: flex; gap: 10px; }
.comment-body { flex: 1; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; word-break: break-word; }
.comment-head { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-bottom: 2px; }
.comment-head b { color: var(--text); }
.comment-head button { margin-left: auto; border: 0; background: none; color: var(--muted); padding: 0 4px; }
.comment-head button:hover { color: var(--danger); }
.comment-add { display: flex; gap: 8px; margin-top: 10px; align-items: flex-start; }
.comment-add textarea { flex: 1; min-height: 38px; resize: vertical; }

/* ---------- lists (archive / team) ---------- */
.page { max-width: 900px; margin: 0 auto; padding: 20px 16px; }
.page h2 { margin: 0 0 14px; font-size: 20px; display: flex; align-items: center; gap: 12px; }
.page-title { margin: 0 0 18px; font-size: 24px; }
.page h2 .grow { flex: 1; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--radius);
  padding: 10px 14px; box-shadow: var(--shadow);
}
.row .row-main { flex: 1; min-width: 0; }
.row .row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row.clickable { cursor: pointer; }
.row.clickable { border: 1px solid transparent; transition: border-color .12s, background .12s; }
.row.clickable:hover { border-color: var(--card-border-hover); }
.row-chevron { font-size: 22px; line-height: 1; color: var(--muted); padding: 0 4px; }
.row.clickable:hover .row-chevron { color: var(--accent); }
.row .actions { display: flex; gap: 6px; flex-shrink: 0; }
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
/* min-width только текстовым полям — раньше он растягивал и чекбокс «админ» на 140px. */
.form-inline input:not([type="checkbox"]) { min-width: 140px; flex: 1; }
.check-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; user-select: none;
}
.check-chip:hover { color: var(--text); }
.check-chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.check-chip input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge.gray { background: var(--surface-2); color: var(--muted); }

/* ---------- menu ---------- */
.menu {
  position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; display: flex; flex-direction: column;
}
.menu button, .menu .menu-item { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; display: flex; gap: 8px; align-items: center; }
.menu button:hover { background: var(--surface-2); }
.menu .sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu .who { padding: 6px 10px; font-size: 12px; color: var(--muted); }
.menu.tag-menu { max-height: 60vh; overflow-y: auto; min-width: 220px; }
.menu.tag-menu button { gap: 8px; }
.menu.tag-menu button.on { color: var(--tag); font-weight: 600; }
.menu.tag-menu button.unused { opacity: .55; }
.menu .menu-count { font-size: 12px; color: var(--muted); }
#tag-filter-btn { gap: 5px; }
#tag-filter-btn b { color: inherit; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 13px; display: flex; gap: 12px; align-items: center;
}
.toast button { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0; }
.toast.error { background: var(--danger); color: #fff; }

kbd { font: 11px/1 ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 2px 5px; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(4, 280px); }
  main { overflow-x: auto; }
}
@media (max-width: 720px) {
  .topbar { gap: 10px; padding: 8px 12px; flex-wrap: wrap; }
  .brand-name { display: none; }
  #search { width: 130px; }
  .nav a { padding: 6px 8px; }
  .filters { padding: 6px 12px; }
  .stats { display: none; }
  .board { grid-template-columns: repeat(4, 85vw); padding: 10px 12px; gap: 10px; }
  .column { max-height: none; }
  .modal { padding: 0; }
  .modal-card { grid-template-columns: 1fr; border-radius: 0; min-height: 100%; }
  .modal-side { border-left: 0; border-top: 1px solid var(--border); }
}

/* ---------- кнопка темы, «+ Задача ▾», шаблоны ---------- */
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 17px; height: 17px; }
.split-btn { display: inline-flex; }
.split-btn #btn-new { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-btn #btn-tpl {
  border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 7px 9px;
  border-left: 1px solid rgba(255, 255, 255, .28);
}
.menu.tpl-menu { min-width: 280px; max-width: 360px; max-height: 70vh; overflow-y: auto; }
.menu.tpl-menu button { gap: 10px; }
.menu.tpl-menu .menu-count { white-space: nowrap; }
.from-template {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  color: var(--accent); margin-bottom: 6px;
}
.field-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin: 6px 0 4px; }
.field-label input { font-size: 14px; }
.modal-side input[type="number"] { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 14px; text-transform: none; letter-spacing: 0; }
.row-sub .tag-pill { vertical-align: middle; }

/* ---------- фото профиля ---------- */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.av-pick { display: flex; align-items: center; gap: 20px; }
.av-pick-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.av-crop { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.crop-box {
  position: relative; width: 240px; height: 240px; border-radius: 12px; overflow: hidden;
  background: var(--surface-2); cursor: grab; touch-action: none;
}
.crop-box:active { cursor: grabbing; }
.crop-box canvas { display: block; }
/* Всё, что за пределами круга, затемнено — так видно, что попадёт в аватар. */
.crop-box::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 200px rgba(10, 12, 20, .55); outline: 2px solid rgba(255, 255, 255, .7); outline-offset: -1px;
}
.crop-zoom { display: flex; align-items: center; gap: 10px; color: var(--muted); width: 240px; }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.modal-card.drop-hover { outline: 2px dashed var(--accent); outline-offset: -8px; }

/* ---------- карточка пользователя ---------- */
.modal-card.narrow { max-width: 540px; }
.profile-head .row-title { font-weight: 600; }
.profile-head .row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.uc-fields { display: grid; gap: 12px; }
.inline-field { display: flex; gap: 8px; }
.inline-field input { flex: 1; min-width: 0; }
.switches { display: flex; flex-direction: column; gap: 2px; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
}
.switch-row:hover { background: var(--surface-2); }
.switch-row.disabled { cursor: default; opacity: .55; }
.switch-row.disabled:hover { background: none; }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-text b { font-weight: 500; }
.switch-text span { font-size: 12px; color: var(--muted); }
/* Переключатель вместо стандартной галочки. */
.switch {
  appearance: none; -webkit-appearance: none; flex-shrink: 0; margin: 0; cursor: inherit;
  width: 38px; height: 22px; border-radius: 999px; position: relative;
  background: color-mix(in srgb, var(--muted) 45%, transparent);  /* заметна и на светлом, и на тёмном */
  transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
