:root {
  color-scheme: dark light;
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --border: #2d3a4f;
  --chip-active-bg: #1e3355;
  --overlay: rgba(0, 0, 0, 0.55);
  --fab-shadow: rgba(0, 0, 0, 0.35);
  --a: #ff5c5c;
  --b: #ffb020;
  --c: #f0d030;
  --ok: #3dd68c;
  --prio-a-bg: #4a1520;
  --prio-b-bg: #3d2a10;
  --prio-c-bg: #3a3410;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface2: #eef1f6;
  --text: #1a2332;
  --muted: #5c6b80;
  --accent: #2563eb;
  --border: #d8dee8;
  --chip-active-bg: #dbeafe;
  --overlay: rgba(15, 20, 25, 0.4);
  --fab-shadow: rgba(0, 0, 0, 0.18);
  --prio-a-bg: #fde8e8;
  --prio-b-bg: #fff3e0;
  --prio-c-bg: #fff9e0;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface2: #eef1f6;
    --text: #1a2332;
    --muted: #5c6b80;
    --accent: #2563eb;
    --border: #d8dee8;
    --chip-active-bg: #dbeafe;
    --overlay: rgba(15, 20, 25, 0.4);
    --fab-shadow: rgba(0, 0, 0, 0.18);
    --prio-a-bg: #fde8e8;
    --prio-b-bg: #fff3e0;
    --prio-c-bg: #fff9e0;
  }
}

[data-theme="dark"] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.login-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.login-card h1 {
  margin: 0;
}

#app-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ИИ: экран ровно во viewport — скролл только внутри колонок */
body:has(#ai-view:not(.hidden)) {
  overflow: hidden;
}
#app-screen:has(#ai-view:not(.hidden)) {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.app-content {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.app-views {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

/* Полноэкранные панели (ИИ): скролл только внутри колонок, не у .app-views */
.app-views:has(#ai-view:not(.hidden)) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.task-detail-sidebar {
  width: 0;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  transition: width 0.18s ease;
}

.task-detail-sidebar.open {
  width: min(440px, 46vw);
  border-left: 1px solid var(--border);
}

.task-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.task-detail-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.detail-save-status {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.detail-save-status.ok {
  color: var(--ok);
}

.detail-save-status.error {
  color: var(--a);
}

.detail-panel-actions {
  justify-content: flex-start;
}

.task-detail-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 0;
  line-height: 1.35;
  word-break: break-word;
  white-space: normal;
}

.detail-close-btn {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.task-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 20px;
}

.detail-meta-block {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 0.85rem;
}

.detail-meta-dl {
  margin: 0;
}

.detail-meta-row {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}

.detail-meta-row:last-child {
  border-bottom: none;
}

.detail-meta-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.detail-meta-row dd {
  margin: 0;
  word-break: break-word;
}

.task-item.selected {
  border-color: var(--accent);
  background: var(--chip-active-bg);
}

@media (max-width: 768px) {
  .app-content {
    position: relative;
  }

  .task-detail-sidebar.open {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(100%, 420px);
    z-index: 15;
    box-shadow: -6px 0 24px var(--fab-shadow);
  }
}

.top-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-left h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.link-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
}

.link-btn:hover {
  color: var(--text);
  background: var(--surface2);
}
.link-btn.disabled {
  cursor: default;
  opacity: 0.6;
}
.link-btn.disabled:hover {
  color: var(--muted);
  background: transparent;
}
.link-btn.active {
  color: var(--text);
  background: var(--surface2);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.icon-btn:hover {
  border-color: var(--accent);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Меню «три полоски» справа: редкие разделы (OKR, суфлёр, тема) не занимают шапку */
.header-menu {
  position: relative;
}

.burger-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.header-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 240px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.header-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
}

.header-menu-item:hover {
  color: var(--text);
  background: var(--surface2);
}

.header-menu-item.active {
  color: var(--text);
  background: var(--surface2);
}

.header-menu-item svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

.header-menu-item .contract-badge {
  margin-left: auto;
}

.header-menu-sep {
  height: 1px;
  margin: 4px 2px;
  background: var(--border);
}

.settings-layout {
  display: flex;
  min-height: calc(100vh - 52px);
}

.settings-main {
  display: flex;
  flex: 1;
  min-width: 0;
}

.settings-projects-content {
  max-width: 720px;
}

.settings-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

.project-access-project-label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.92rem;
}

.project-access-project-label select {
  display: block;
  margin-top: 6px;
  width: 100%;
  max-width: 360px;
}

.project-access-table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
}

.project-access-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.project-access-table th,
.project-access-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.project-access-table th:not(:first-child),
.project-access-table td.project-access-check {
  text-align: center;
  width: 120px;
}

.project-access-table tbody tr:hover {
  background: var(--surface2);
}

.project-access-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 0;
}

.settings-nav-item {
  display: block;
  padding: 10px 16px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}

.settings-nav-item:hover,
.settings-nav-item.active {
  color: var(--text);
  background: var(--surface2);
}

.settings-list-pane {
  flex: 1;
  min-width: 0;
  padding: 16px;
  overflow-y: auto;
}

.settings-detail-pane {
  width: 34%;
  min-width: 260px;
  max-width: 400px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 16px;
  overflow-y: auto;
}

.settings-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.settings-list-header h2 {
  margin: 0;
  font-size: 1rem;
}

.settings-users-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-user-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}

.settings-user-item:hover {
  border-color: var(--accent);
}

.settings-user-item.selected {
  border-color: var(--accent);
  background: var(--chip-active-bg);
}

.settings-user-item strong {
  font-size: 0.95rem;
}

.settings-user-item span {
  font-size: 0.8rem;
  color: var(--muted);
}

.settings-form label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 10px 0 4px;
}

.settings-form input,
.settings-form select {
  width: 100%;
}

.settings-form h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.user-danger-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.user-danger-actions button {
  width: auto;
  margin: 0;
}

.settings-user-item.is-inactive {
  opacity: 0.65;
}

.settings-user-item .user-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.72rem;
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  vertical-align: middle;
}

.settings-user-item .user-badge.off {
  color: #c0392b;
  border-color: color-mix(in srgb, #c0392b 40%, var(--border));
}

.muted-field {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 12px 0;
}

#tasks-view .toolbar {
  padding: 10px 16px 0;
}

#tasks-view .status-bar {
  padding: 0 16px;
}

#tasks-view main {
  max-width: none;
  margin: 0;
  padding: 8px 16px 80px;
}

/* Открытая карточка прибивает экран к окну: слева свой скролл, справа свой.
   Без этого страница скроллится целиком — спустился по списку, открыл задачу,
   и верх карточки уехал за экран (17.09.2026). `min-height: 100vh` у #app-screen
   для этого и не годится: он растёт вместе с содержимым. */
body:has(.app-content.task-detail-open) { overflow: hidden; }
#app-screen:has(.app-content.task-detail-open) { height: 100vh; min-height: 0; }

.app-content.task-detail-open #tasks-view main {
  max-width: 900px;
  margin: 0 auto;
}

/* Дерево центрировать нельзя. Ограничение в 900px придумано для плоского
   списка — там узкая колонка читается лучше. У дерева справа шкала дат, и
   поля по краям съедают её, а сами строки уезжают к середине экрана
   (17.09.2026). Дерево занимает всю ширину независимо от карточки. */
.app-content.task-detail-open #tasks-view main:has(#task-tree-wrap:not(.hidden)) {
  max-width: none;
  margin: 0;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 4px;
  transition: border-color 0.15s;
}

.task-item:hover {
  border-color: var(--accent);
}

.task-done-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  /* Удержание ✓ открывает меню переноса — без лупы и выделения на iOS. */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.task-done-btn:hover {
  border-color: var(--a);
  color: var(--a);
  background: var(--prio-a-bg);
}

.task-line {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.35;
}

.task-id {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.task-prio {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
}

.task-prio.prio-A { color: var(--a); }
.task-prio.prio-B { color: var(--b); }
.task-prio.prio-C { color: var(--c); }
.task-prio.prio-D { color: var(--muted); }

.task-est {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.task-title {
  flex: 1 1 120px;
  min-width: 0;
  word-break: break-word;
}

.task-tail {
  flex: 1 1 100%;
  font-size: 0.75rem;
  color: var(--muted);
}

@media (min-width: 480px) {
  .task-tail {
    flex: 0 1 auto;
    margin-left: auto;
    text-align: right;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.login-card .hint {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 0.9rem;
}

.login-card label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 10px 0 4px;
}

.login-card input {
  width: 100%;
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--text);
  background: var(--surface2);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.remember-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0 !important;
  font-size: 0.9rem !important;
  color: var(--text) !important;
  cursor: pointer;
  user-select: none;
}

.remember-row input {
  width: auto !important;
  margin: 0;
  accent-color: var(--accent);
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 16px;
}

.admin-user-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.admin-user-row .tag {
  color: var(--accent);
}

.admin-user-row .muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-create label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 8px 0 4px;
}

.admin-create input,
.admin-create select {
  width: 100%;
}

.admin-card {
  max-width: 520px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

select,
input,
textarea,
button {
  font: inherit;
}

select,
input,
textarea {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
}

button.secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  background: #c0392b;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--chip-active-bg);
}

.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 16px 0 8px;
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 16px;
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* legacy panel — удалён, оставлены общие panel-actions */

.events {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.event {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.create-form {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
}

.create-form.open {
  display: block;
}

.create-form label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 8px 0 4px;
}

.create-form input,
.create-form select,
.create-form textarea {
  width: 100%;
}

.detail-form label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 10px 0 4px;
}

.detail-form input,
.detail-form select,
.detail-form textarea {
  width: 100%;
}

.detail-form textarea {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
  line-height: 1.45;
}

.tag-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  position: relative;
}

.tag-field:focus-within {
  border-color: var(--accent);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip-active-bg);
  font-size: 0.85rem;
  max-width: 100%;
}

.tag-chip.phantom {
  border: 1px dashed var(--muted);
}

.tag-chip button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 1rem;
  line-height: 1;
}

.tag-field-input {
  flex: 1;
  min-width: 120px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  padding: 2px 0;
}

.tag-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px var(--fab-shadow);
  max-height: 180px;
  overflow-y: auto;
}

.tag-suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.tag-suggest-item:hover,
.tag-suggest-item.active {
  background: var(--surface2);
}

.tag-suggest-item .muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.detail-form .panel-actions {
  margin-top: 16px;
}

.detail-form .panel-actions button[type="submit"] {
  flex: 1;
  min-width: 120px;
}

.status-bar {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 8px;
}

.status-bar.error {
  color: var(--a);
}

.gamification-badge {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--chip-bg, rgba(0, 0, 0, 0.06));
  white-space: nowrap;
  cursor: pointer;
}

.gamification-badge:hover {
  color: var(--fg, inherit);
}

/* --- Профиль навыков ------------------------------------------------- */

.skills-subhead {
  margin: 18px 0 8px;
  font-size: 0.9rem;
}

.skills-branches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
  align-items: start;
}

.skill-row {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
}

.skill-row--focus {
  border-color: #d4a017;
  background: rgba(212, 160, 23, 0.07);
}

.skill-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
}

.skill-level {
  color: var(--muted);
  white-space: nowrap;
}

.skill-bar {
  margin: 6px 0 4px;
  height: 6px;
  border-radius: 999px;
  background: var(--chip-bg, rgba(0, 0, 0, 0.08));
  overflow: hidden;
}

.skill-bar-fill {
  height: 100%;
  background: #1a7f37;
}

.skill-hint {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Подветки внутри ветки: свой уровень, но XP берётся из ветки */
.skill-subs {
  list-style: none;
  margin: 4px 0 0;
  padding: 0 0 0 10px;
  border-left: 2px solid var(--border, #d8dee4);
}

/* Сетка, а не space-between: колонки выстраиваются друг под другом
   независимо от длины названия подветки. */
.skill-sub {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: baseline;
  column-gap: 10px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--muted);
  padding: 1px 0;
}

.skill-sub-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-sub-level,
.skill-sub-xp,
.skill-sub-share {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

/* Ширины фиксируем по самому длинному правдоподобному значению,
   иначе колонки съезжают от строки к строке. */
.skill-sub-level {
  min-width: 3.4em;
}

.skill-sub-xp {
  min-width: 4.6em;
}

.skill-sub-share {
  min-width: 2.6em;
  opacity: 0.75;
}

.skills-achievements {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.achievement {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--chip-bg, rgba(0, 0, 0, 0.06));
  color: var(--muted);
}

.achievement--earned {
  background: rgba(26, 127, 55, 0.12);
  color: inherit;
}

.achievement-progress {
  font-size: 0.7rem;
  opacity: 0.75;
}

.skills-events {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 340px;
  overflow-y: auto;
}

.skill-event {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.8rem;
  padding: 3px 0;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
}

.skill-event-xp {
  font-weight: 600;
  min-width: 44px;
}

.skill-event-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-bonus {
  color: #b8860b;
  white-space: nowrap;
}

.skill-event-branch,
.skill-event-date {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.xp-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 10px 16px;
  border-radius: 10px;
  background: #1a7f37;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  max-width: min(92vw, 420px);
  text-align: center;
}

.xp-toast.level-up {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
}

.xp-toast.hidden {
  display: none;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: 0 4px 16px var(--fab-shadow);
}

.boot-loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 480px) {
  header { padding: 10px 12px; }
  main { padding: 10px 12px 72px; }
}

/* OKR */
.okr-block {
  margin: 0 16px 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 20vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.okr-compact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.okr-compact-head h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
}

.okr-filter-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
}

.okr-compact-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.okr-obj-compact {
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.okr-obj-compact:last-child {
  border-bottom: none;
}

.okr-obj-compact-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.okr-o-title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
}

.okr-kr-lines {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.okr-kr-line {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--muted);
}

.tasks-status {
  margin: 0 0 8px;
  min-height: 1.2em;
}

main .tasks-status:empty {
  display: none;
}

.okr-kr-code {
  font-weight: 600;
  color: var(--text);
  min-width: 22px;
}

.okr-kr-pct {
  min-width: 28px;
  text-align: right;
  font-size: 0.68rem;
}

.okr-kr-mini-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.okr-progress-mini {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  height: 4px;
  flex: none;
}

.okr-proj-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  font-size: 0.9rem;
  flex-shrink: 0;
  line-height: 1;
}

.okr-proj-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--chip-active-bg);
  color: var(--accent);
  white-space: nowrap;
}

.okr-proj-personal {
  color: var(--muted);
  background: var(--surface2);
}

.okr-owner-badge {
  font-size: 0.72rem;
  color: var(--muted);
}

.okr-obj-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.okr-obj-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.okr-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn.danger-icon:hover {
  color: var(--a);
}

.okr-objective {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.okr-objective h3 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  font-weight: 600;
}

.okr-hint {
  margin: 0 0 10px;
  font-size: 0.8rem;
}

.okr-layers-hint {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.okr-layers-hint summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.okr-edit-card {
  max-width: 420px;
}

.okr-kr-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.okr-kr {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.okr-kr-child {
  margin-left: 16px;
  padding-left: 8px;
  border-left: 2px solid var(--accent);
}

.okr-kr-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.okr-kr-title {
  font-size: 0.9rem;
  margin: 2px 0;
}

.okr-target {
  font-size: 0.8rem;
  color: var(--muted);
}

.okr-owner {
  font-size: 0.75rem;
  color: var(--muted);
}

.okr-progress {
  position: relative;
  flex: 1;
  min-width: 80px;
  max-width: 140px;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}

.okr-progress-fill {
  height: 100%;
  background: var(--ok);
  border-radius: 4px;
  transition: width 0.2s;
}

.okr-progress span {
  position: absolute;
  right: 0;
  top: -16px;
  font-size: 0.7rem;
  color: var(--muted);
}

.okr-warn {
  font-size: 0.8rem;
  color: var(--b);
  margin: 4px 0;
}

.okr-page {
  display: grid;
  gap: 16px;
  padding: 12px 16px 80px;
}

@media (min-width: 900px) {
  .okr-page {
    grid-template-columns: 1fr 1.2fr;
    align-items: start;
  }
}

.okr-guidelines {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.okr-rules {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
  margin: 0;
}

.okr-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.okr-toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.okr-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.okr-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.okr-create-panel {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.okr-create-panel summary {
  cursor: pointer;
  font-weight: 600;
}

.okr-slider {
  width: 100%;
  max-width: 200px;
  margin-top: 4px;
}

/* ── Шаблонные поля (PHASE8) ── */
.tpl-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.tpl-field label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.tpl-field input,
.tpl-field select,
.tpl-field textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 5px 8px;
}

.tpl-field textarea {
  resize: vertical;
  min-height: 56px;
}

#detail-template-fields,
#create-template-fields {
  margin-top: 4px;
}

/* ── Планировщик дня (PHASE10) ── */
.plan-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 16px 20px;
}

.plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.plan-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.plan-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.plan-controls input[type="number"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 3px 6px;
  font-size: 0.85rem;
}

.plan-wip-warning {
  background: rgba(255, 176, 32, 0.12);
  border: 1px solid rgba(255, 176, 32, 0.4);
  border-radius: 8px;
  color: var(--b);
  padding: 8px 12px;
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.plan-section {
  margin-bottom: 16px;
}

.okr-suggest-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 4px 0 8px;
  line-height: 1.4;
}

.plan-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.plan-kr-tag {
  font-size: 0.75rem;
  background: rgba(61, 139, 253, 0.15);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 4px;
}

.plan-badge {
  display: inline-block;
  font-size: 0.72rem;
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 4px;
  font-weight: 600;
}

.plan-badge.overdue {
  background: rgba(255, 92, 92, 0.2);
  color: var(--a);
}

.plan-badge.due-today {
  background: rgba(255, 176, 32, 0.2);
  color: var(--b);
}

.plan-badge.due-tomorrow {
  background: rgba(240, 208, 48, 0.15);
  color: var(--c);
}

/* ── «Сегодня»: режимы «Набор задач» и «План по времени» ── */
.plan-container--wide { max-width: 1400px; }

.plan-modes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.plan-resend-btn { margin-left: auto; }
.plan-add-btn { margin-left: auto; }
.plan-add-btn ~ .plan-resend-btn { margin-left: 0; }
.plan-add-flag { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-size: 0.85rem; }
.plan-day-flash { font-size: 0.8rem; }

/* Новая задача прямо в план дня — строка под режимами */
.plan-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.plan-add-form.hidden { display: none; }
.plan-add-form input { flex: 1 1 260px; min-width: 0; }
.plan-add-form select { flex: 0 1 200px; min-width: 0; }

.plan-day-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.plan-day-split--timeline { grid-template-columns: minmax(0, 11fr) minmax(0, 9fr); }

.plan-day-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.plan-day-panel-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.plan-day-count { color: var(--text); }
.plan-day-hint { font-weight: 400; font-size: 0.78rem; margin-left: 6px; }
.plan-day-hint.is-error { color: var(--b); }
.plan-day-panel-body {
  padding: 8px;
  overflow-y: auto;
  max-height: calc(100vh - 230px);
  min-height: 240px;
}

.plan-day-list-zone { min-height: 60px; }
.plan-day-list { list-style: none; margin: 0; padding: 0; }
.plan-day-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 4px;
  user-select: none;
}
.plan-day-item:hover { border-color: var(--accent); }
.plan-day-item.dragging, .plan-day-tree-row.dragging { opacity: 0.35; }
.plan-day-num {
  flex-shrink: 0;
  min-width: 1.6em;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.plan-day-line {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.35;
}
.plan-day-slot-badge {
  font-size: 0.72rem;
  color: var(--accent);
  background: rgba(61, 139, 253, 0.12);
  border-radius: 4px;
  padding: 1px 5px;
}
.dp-handle {
  flex-shrink: 0;
  color: var(--muted);
  cursor: grab;
  letter-spacing: -2px;
  padding: 4px 2px;
  touch-action: none;
}
.plan-day-dragging, .plan-day-dragging * { cursor: grabbing !important; }
.dp-remove {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.dp-remove:hover { border-color: var(--border); color: var(--text); }
.plan-day-placeholder {
  height: 34px;
  margin-bottom: 4px;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgba(61, 139, 253, 0.08);
}
.plan-day-empty {
  color: var(--muted);
  text-align: center;
  padding: 18px 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
}
.plan-day-extra { margin-top: 10px; font-size: 0.85rem; color: var(--muted); }
.plan-day-extra summary { cursor: pointer; padding: 4px 0; }
.plan-day-mini { list-style: none; margin: 4px 0 0; padding: 0; }
.plan-day-mini li { display: flex; align-items: center; gap: 6px; padding: 3px 4px; }
.plan-day-mini .task-title { color: var(--muted); }
.plan-day-mini--dropped button { padding: 2px 8px; font-size: 0.78rem; }
.plan-day-note { font-size: 0.75rem; color: var(--muted); }

.plan-day-tree-group {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 8px 4px 4px;
}
/* Поток внутри сферы в панели «Все задачи»: тот же заголовок, но тише и с
   отступом — иначе два уровня группировки читаются как один. */
/* Снимок дня разошёлся с сообщением в чате — номера там врут. Полоса сверху,
   а не тихая строчка: по этим номерам человек закрывает задачи. */
.plan-day-desync {
  margin: 0 0 8px; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--stream-warn); color: var(--stream-warn);
  font-size: 12px; line-height: 1.4;
}
.plan-day-tree-group--sub {
  font-weight: 500;
  padding-top: 4px;
  text-transform: none;
  opacity: 0.85;
}
.plan-day-tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding-right: 6px;
  border-radius: 5px;
  font-size: 0.88rem;
  user-select: none;
  cursor: grab;
}
.plan-day-tree-row:hover { background: var(--surface2); }
.plan-day-tree-row:hover .tree-add { opacity: 1; }
.plan-day-tree-row .tree-title { flex: 1; min-width: 0; cursor: pointer; }
.plan-day-tree-row.in-plan { cursor: default; }
.plan-day-tree-row.in-plan .tree-title { color: var(--muted); }
.plan-day-in-plan { font-size: 0.75rem; color: var(--ok); white-space: nowrap; }
.dp-cancel-task {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
}
.plan-day-tree-row:hover .dp-cancel-task, .dp-cancel-task:focus { opacity: 1; }
.dp-cancel-task:hover { color: var(--a); border-color: var(--a); background: var(--prio-a-bg); }

.plan-day-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  max-width: 280px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  box-shadow: 0 6px 20px var(--fab-shadow);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Календарь дня: сетка по 20 минут, блоки позиционируются абсолютно. */
.plan-day-allday {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px 0;
}
.plan-day-allday-chip {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.plan-day-cal { --gutter: 48px; position: relative; }
.plan-day-cal-line {
  position: absolute;
  left: var(--gutter);
  right: 0;
  border-top: 1px dotted var(--border);
}
.plan-day-cal-line.is-hour { border-top-style: solid; }
.plan-day-cal-off {
  position: absolute;
  left: var(--gutter);
  right: 0;
  background: var(--bg);
  opacity: 0.7;
  pointer-events: none;
}
.plan-day-cal-line span {
  position: absolute;
  left: calc(-1 * var(--gutter));
  top: -0.6em;
  width: calc(var(--gutter) - 6px);
  text-align: right;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.plan-day-cal-now {
  position: absolute;
  left: calc(var(--gutter) - 4px);
  right: 0;
  border-top: 2px solid var(--a);
  z-index: 3;
  pointer-events: none;
}
.plan-day-cal-block, .plan-day-task-block {
  position: absolute;
  left: calc(var(--gutter) + (100% - var(--gutter) - 4px) * var(--lane) / var(--lanes));
  width: calc((100% - var(--gutter) - 4px) / var(--lanes) - 3px);
  margin-top: 1px;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.78rem;
  line-height: 1.25;
  overflow: hidden;
  box-sizing: border-box;
}
.plan-day-cal-block {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  color: var(--muted);
  z-index: 1;
}
.plan-day-cal-block.is-personal {
  background: repeating-linear-gradient(135deg, var(--surface2) 0 6px, transparent 6px 12px);
}
.plan-day-cal-block.is-absorbed { opacity: 0.55; }
.plan-day-task-block {
  background: var(--chip-active-bg);
  border: 1px solid var(--accent);
  border-left: 3px solid var(--accent);
  color: var(--text);
  z-index: 2;
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: flex;
  flex-direction: column;
}
.plan-day-task-block.dragging { box-shadow: 0 6px 20px var(--fab-shadow); z-index: 4; }
.plan-day-task-block.is-leaving { opacity: 0.4; }
.plan-day-task-block.is-done .plan-day-task-title { text-decoration: line-through; color: var(--muted); }
.plan-day-task-time { font-size: 0.7rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.plan-day-task-title { overflow: hidden; text-overflow: ellipsis; }
.dp-unschedule {
  position: absolute;
  top: 1px;
  right: 2px;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 0 2px;
  opacity: 0;
}
.plan-day-task-block:hover .dp-unschedule { opacity: 1; }
.dp-resize {
  position: absolute;
  left: 0;
  right: 0;
  height: 7px;
  cursor: ns-resize;
}
.dp-resize--top { top: -2px; }
.dp-resize--bottom { bottom: -2px; }
.plan-day-cal-preview {
  border-style: dashed;
  opacity: 0.8;
  pointer-events: none;
  z-index: 4;
  font-size: 0.72rem;
  color: var(--accent);
}

@media (hover: none) {
  .dp-unschedule, .plan-day-tree-row .tree-add, .dp-cancel-task { opacity: 1; }
}

@media (max-width: 768px) {
  .plan-day-split, .plan-day-split--timeline { grid-template-columns: minmax(0, 1fr); }
  .plan-day-panel-body { max-height: 48vh; min-height: 160px; }
  .plan-resend-btn, .plan-add-btn { margin-left: 0; }
}

/* ── Поля дат и OKR KR в детали задачи ── */
.detail-dates-row {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  align-items: center;
  gap: 6px 8px;
  margin: 6px 0 2px;
}
.detail-dates-row label { font-size: 0.78rem; color: var(--text-muted, #888); white-space: nowrap; margin: 0; }
.detail-dates-row input { padding: 4px 6px; border-radius: 6px; font-size: 0.85rem; }
.detail-tags-row {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  align-items: center;
  gap: 6px 8px;
  margin: 6px 0 2px;
}
.detail-tags-row label { font-size: 0.78rem; color: var(--text-muted, #888); white-space: nowrap; margin: 0; }
.detail-tags-row select { padding: 4px 6px; border-radius: 6px; font-size: 0.85rem; }
.muted-label { font-size: 0.78rem; color: var(--text-muted, #888); }

/* ── Блокеры (PHASE11) ── */
.blocker-info {
  font-size: 0.85rem;
  padding: 5px 8px;
  border-radius: 6px;
  margin-top: 6px;
  background: rgba(255, 92, 92, 0.08);
  border: 1px solid rgba(255, 92, 92, 0.2);
  color: var(--text);
}

.blocker-info a.blocker-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.blocker-info a.blocker-link:hover {
  opacity: 0.8;
}

/* ── Чек-лист карточки: лёгкие пункты и подзадачи одним деревом ── */
.detail-checklist-block { margin-top: 4px; }
.detail-checklist-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted, #888);
  margin-bottom: 4px;
}
.detail-checklist-progress { font-variant-numeric: tabular-nums; }
.detail-checklist-tree { display: flex; flex-direction: column; }
.checklist-node { display: flex; flex-direction: column; }
.checklist-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 2px;
  border-radius: 5px;
}
.checklist-row:hover { background: var(--surface2, rgba(127,127,127,0.08)); }
.checklist-row.is-task .checklist-title { cursor: pointer; }
.checklist-row.is-task .checklist-title:hover { text-decoration: underline; }
.checklist-twist {
  flex: 0 0 auto;
  width: 14px;
  text-align: center;
  color: var(--text-muted, #888);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 10px;
  padding: 0;
}
.checklist-twist-spacer { flex: 0 0 auto; width: 14px; }
/* Круглый чек-бокс — как в Планфиксе, а не квадратный браузерный.
   Селектор с двумя классами нужен, чтобы перебить «.detail-form input { width: 100% }» —
   у него тоже один класс, но ещё и тип-селектор input, и по правилам специфичности
   он выигрывает у одноклассового «.checklist-check» на этом третьем разряде. */
.checklist-row .checklist-check {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin: 0;
  border: 1.5px solid var(--border, #ccc);
  border-radius: 50%;
  background: var(--surface, #fff);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
}
.checklist-check:hover { border-color: var(--accent); }
.checklist-check:checked {
  background: var(--ok, #2fa86a);
  border-color: var(--ok, #2fa86a);
}
.checklist-check:checked::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(40deg) translate(-1px, -1px);
}
.checklist-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
  outline: none;
}
.checklist-title[contenteditable="true"] {
  background: var(--surface, #fff);
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--accent);
  padding: 0 2px;
}
.checklist-row.is-done .checklist-title { color: var(--text-muted, #888); text-decoration: line-through; }
.checklist-add-sub, .checklist-menu-btn {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-muted, #888);
  cursor: pointer;
  opacity: 0;
}
.checklist-row:hover .checklist-add-sub,
.checklist-row:hover .checklist-menu-btn,
.checklist-add-sub:focus, .checklist-menu-btn:focus { opacity: 1; }
.checklist-add-sub:hover, .checklist-menu-btn:hover { background: var(--surface2, rgba(127,127,127,0.15)); color: var(--text); }
.checklist-children { margin-left: 22px; }
.checklist-menu {
  position: absolute;
  z-index: 20;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 160px;
  padding: 4px;
}
.checklist-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border: none;
  background: none;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}
.checklist-menu button:hover { background: var(--surface2, rgba(127,127,127,0.12)); }
.checklist-menu button.danger { color: var(--a, #e5484d); }
/* Строка добавления — как пустой пункт списка, а не отдельная форма в рамке. */
.detail-checklist-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 2px;
  margin-top: 2px;
}
.detail-checklist-add-row::before {
  content: "";
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  border: 1.5px dashed var(--border, #ccc);
  border-radius: 50%;
}
.detail-checklist-add-row input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: none;
  padding: 2px 0;
  font-size: 0.85rem;
  background: none;
  color: var(--text);
}
.detail-checklist-add-row input:focus { outline: none; }
.detail-checklist-add-row input::placeholder { color: var(--text-muted, #888); }


/* --- Аудио с диктофона --- */
.audio-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

/* --- Документы / текст (на странице Аудио) --- */
.docs-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.docs-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.88rem;
}
.docs-tab:hover { border-color: var(--accent); }
.docs-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.docs-pane { margin-bottom: 12px; }
.docs-url-input { width: 100%; box-sizing: border-box; }
.docs-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  line-height: 1.45;
  resize: vertical;
  min-height: 140px;
}
.docs-textarea:focus { outline: none; border-color: var(--accent); }
.docs-kind-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-right: 6px;
}
.docs-content-preview {
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.45;
  max-height: 50vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
}
.audio-header h2 { margin: 0 0 4px; }
.audio-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 16px;
}
.audio-form { margin-bottom: 24px; }
/* Ряд «загрузка файла + запись с микрофона» */
.audio-source-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}
.audio-drop {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.audio-drop:hover,
.audio-drop.dragover {
  border-color: var(--accent);
  background: var(--surface2);
}
.audio-drop-icon { font-size: 1.6rem; }
.audio-drop-text { margin-top: 4px; font-weight: 600; }
.audio-drop-sub { margin-top: 3px; color: var(--muted); font-size: 0.8rem; }
.audio-picked {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  word-break: break-all;
}

.picked-files { list-style: none; margin: 0; padding: 0; }
.picked-files li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}
.picked-file-name { flex: 1; min-width: 0; }
.picked-file-rm {
  flex: 0 0 auto;
  padding: 0 6px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}
.picked-file-rm:hover { color: var(--danger, #c0392b); }
.picked-files-plan {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  word-break: normal;
}

/* Блок записи СЛЕВА от зоны загрузки — кнопка-иконка микрофона */
.audio-record {
  flex: 0 0 104px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
}
.audio-record-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-height: 100%;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.audio-record-btn:hover { border-color: var(--accent); color: var(--accent); }
.audio-mic-icon { display: block; }
.audio-record-label { font-size: 0.8rem; font-weight: 600; }
.audio-record-btn.recording {
  border-color: #e5484d;
  background: rgba(229, 72, 77, 0.10);
  color: #e5484d;
}
.audio-record-btn.recording .audio-mic-icon {
  animation: audio-rec-pulse 1.1s ease-in-out infinite;
}
@keyframes audio-rec-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.9); }
}
.audio-record-time {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.95rem;
  color: #e5484d;
  flex: 0 0 auto;
}
.audio-record-cancel {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
}
.audio-record-cancel:hover { border-color: #e5484d; color: #e5484d; }

/* Эквалайзер уровня микрофона — вертикальные полоски */
.audio-record-eq {
  flex: 1 1 auto;
  min-width: 60px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 34px;
}
.audio-record-eq > span {
  flex: 1 1 0;
  min-width: 2px;
  height: 8%;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, #e5484d 0%, #d29922 45%, #3fb950 100%);
  transition: height .07s linear;
}

/* Во время записи строка становится горизонтальной, зона загрузки прячется */
.audio-source-row.recording .audio-drop { display: none; }
.audio-source-row.recording .audio-record {
  flex: 1 1 100%;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid #e5484d;
  border-radius: 12px;
  background: rgba(229, 72, 77, 0.06);
}
.audio-source-row.recording .audio-record-btn {
  flex: 0 0 auto;
  flex-direction: row;
  width: auto;
  min-height: 0;
  gap: 8px;
  padding: 9px 16px;
  border-color: #e5484d;
  background: #e5484d;
  color: #fff;
}
.audio-source-row.recording .audio-record-btn:hover { color: #fff; }

/* Проект + тип записи + заметка в одну строку */
.audio-meta-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.audio-input {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  font-size: 0.88rem;
  height: 38px;
}
.audio-input:focus { outline: none; border-color: var(--accent); }
.audio-input:hover { border-color: var(--accent); }
/* селекты: убираем нативный вид, рисуем свою стрелку — видно, что кликабельно */
select.audio-input {
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b9cb3' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
#audio-project, #audio-type { flex: 1 1 0; }
#audio-note { flex: 1.6 1 0; }
/* пустой селект выглядит как placeholder */
select.audio-input.is-placeholder { color: var(--muted); }
@media (max-width: 640px) {
  .audio-source-row { flex-direction: column; }
  .audio-record { flex-basis: auto; }
  .audio-meta-row { flex-wrap: wrap; }
  #audio-note { flex-basis: 100%; }
}
/* Подробность FollowUp: 1-5, по умолчанию 4 */
.audio-detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.audio-detail-label {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}
.audio-detail-levels {
  display: flex;
  gap: 4px;
}
.audio-detail-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.audio-detail-btn:hover { border-color: var(--accent); color: inherit; }
.audio-detail-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.audio-d-comment { margin-top: 12px; }
.audio-comment-input {
  width: 100%;
  resize: vertical;
  font: inherit;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  box-sizing: border-box;
}
.audio-d-classify { margin-top: 12px; }
.audio-tasks-accordion { margin-top: 12px; }
.audio-tasks-accordion > summary {
  cursor: pointer;
  list-style: none;
}
.audio-tasks-accordion > summary::-webkit-details-marker { display: none; }
.audio-tasks-accordion > summary::before { content: "▸ "; }
.audio-tasks-accordion[open] > summary::before { content: "▾ "; }
.audio-speakers {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.audio-speakers-input { width: 64px; height: 30px; padding: 0 6px; box-sizing: border-box; }
@media (max-width: 640px) {
  .audio-detail-row { flex-wrap: wrap; }
  .audio-speakers { margin-left: 0; }
}

.audio-list { list-style: none; margin: 8px 0 0; padding: 0; }
.audio-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 8px;
}
.audio-item-name { font-weight: 600; word-break: break-all; }
.audio-item-meta { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.audio-empty { color: var(--muted); padding: 12px 0; }

/* --- Индикатор долгой операции: кольцо + счётчик секунд ---------------------
   Перегенерация FollowUp идёт 3-6 минут, раскладка знания — минуты. Без живого
   счётчика человек через 15 секунд решает, что кнопка не сработала. */
.busy-line { display: inline-flex; align-items: center; gap: 6px; }
.busy-spinner {
  width: 11px; height: 11px; flex: none;
  border: 2px solid var(--border, #ccc);
  border-top-color: var(--accent, #3b6ef5);
  border-radius: 50%;
  animation: busy-spin 0.8s linear infinite;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .busy-spinner { animation-duration: 2.4s; }
}
.audio-followup-error {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 4px;
  border-left: 2px solid #e5484d;
  padding-left: 8px;
}

/* --- Zoom: модалка со списком облачных записей --- */
.zoom-modal-card { width: min(640px, 100%); }
.zoom-list { max-height: 50vh; overflow-y: auto; }
.zoom-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.zoom-item .audio-item-main { min-width: 0; }
.zoom-item .audio-item-title { font-weight: 600; }
.zoom-item .audio-item-sub { font-size: 0.82rem; margin-top: 2px; }
.zoom-item.zoom-item-done { opacity: 0.65; }

.audio-progress { margin-top: 12px; }
.audio-progress-track {
  height: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.audio-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .12s linear;
}
.audio-progress-text {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* --- Аудио: статусы обработки и транскрипт --- */
.audio-item-row { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; }
.audio-item-left { min-width: 0; }
.audio-badge {
  flex: none;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid var(--border);
}
.audio-badge-pending    { color: var(--muted); }
.audio-badge-processing { color: var(--accent); border-color: var(--accent); }
.audio-badge-done       { color: #1a7f37; border-color: #1a7f3766; }
.audio-badge-failed     { color: #b3261e; border-color: #b3261e66; }
/* «не разбираем» — осознанный исход, поэтому приглушённый, а не тревожный */
.audio-badge-muted      { color: var(--muted); border-style: dashed; }
.audio-item-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.audio-item-progress { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.audio-item-progress-track {
  flex: 1;
  height: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.audio-item-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width .3s ease;
}
.audio-item-progress-text { flex: none; font-size: 0.78rem; color: var(--muted); }
.audio-item-error { margin-top: 4px; font-size: 0.82rem; color: #b3261e; word-break: break-word; }
.audio-transcript {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 340px;
  overflow-y: auto;
  font-family: inherit;
}
@media (prefers-color-scheme: dark) {
  .audio-badge-done { color: #4ac26b; }
  .audio-badge-failed { color: #ff7b72; }
}

/* --- Аудио: классификация (тип/проект) --- */
.audio-item-class { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.audio-chip {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.audio-item-summary { margin-top: 4px; font-size: 0.85rem; color: var(--text); }

/* --- Аудио: шаг 4 (FollowUp) и содержание --- */
.audio-item-file { font-size: 0.78rem; color: var(--muted); margin-top: 2px; word-break: break-all; }
.audio-followup {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 420px;
  overflow-y: auto;
}
.audio-fu-download { display: inline-block; margin-bottom: 8px; }
.audio-fu-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* --- Аудио v2: сжатый аплоад, кликабельная карточка, сайдбар --- */
.audio-container { padding: 12px 16px; }
.audio-drop { padding: 12px 16px; }
.audio-drop-icon { font-size: 1.3rem; }
.audio-drop-text { margin-top: 2px; font-size: 0.9rem; }
.audio-drop-sub { margin-top: 2px; }
.audio-form { margin-bottom: 16px; }

.audio-item-clickable { cursor: pointer; transition: border-color .12s; }
.audio-item-clickable:hover { border-color: var(--accent); }

.audio-detail-sidebar .task-detail-body { padding: 12px 14px; overflow-y: auto; }
.audio-d-summary { font-size: 0.95rem; color: var(--text); margin: 0 0 8px; font-weight: 600; }
.audio-d-actions { margin: 10px 0; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.audio-d-followup { font-size: 0.9rem; line-height: 1.55; }
.audio-d-followup h3 { font-size: 1.05rem; margin: 10px 0 4px; }
.audio-d-followup h4 { font-size: 0.95rem; margin: 12px 0 4px; color: var(--accent); }
.audio-d-followup h5 { font-size: 0.9rem; margin: 8px 0 3px; }
.audio-d-followup p { margin: 4px 0; }
.audio-d-followup ul { margin: 4px 0 8px; padding-left: 20px; }
.audio-d-followup ul.md-tasks { list-style: none; padding-left: 0; }
.audio-d-followup ul.md-tasks li { margin: 3px 0; }

/* --- Аудио: утверждение задач --- */
.audio-tasks { margin-top: 14px; }
.audio-tasks-rows { display: flex; flex-direction: column; gap: 6px; }
.audio-task-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; }
.audio-task-title { min-width: 0; }
.audio-task-assignee, .audio-task-priority { max-width: 130px; }
.audio-tasks-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.audio-tasks-submit { padding: 5px 12px; }

/* --- Аудио: ресайз сайдбара --- */
.audio-detail-sidebar { position: relative; }
.audio-detail-sidebar.open { width: var(--audio-sidebar-w, min(460px, 46vw)); }
.audio-resize-handle { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 6; }
.audio-resize-handle:hover { background: var(--accent); opacity: 0.5; }
body.resizing-x { cursor: col-resize; user-select: none; }

/* --- База знаний: навигация --- */
.knowledge-container { max-width: 820px; margin: 0 auto; padding: 12px 16px; }
.knowledge-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.knowledge-tabs { display: flex; gap: 6px; }
.knowledge-content {
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  padding: 16px 20px; line-height: 1.6; font-size: 0.95rem; overflow-x: auto;
}
.knowledge-content h2 { font-size: 1.08rem; margin: 14px 0 5px; color: var(--accent); font-weight: 650; }
.knowledge-content h3 { font-size: 0.98rem; margin: 10px 0 4px; font-weight: 600; }
.knowledge-content h4 { font-size: 0.92rem; margin: 10px 0 4px; color: var(--muted); }
.knowledge-content p { margin: 6px 0 8px; line-height: 1.55; }
.knowledge-content ul, .knowledge-content ol { margin: 5px 0 10px; padding-left: 22px; }
.knowledge-content ul.md-tasks { list-style: none; padding-left: 0; }
.knowledge-content hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.knowledge-content code { background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-size: 0.88em; }
.knowledge-content pre.md-code { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.knowledge-content pre.md-code code { background: none; padding: 0; }
.knowledge-content a { color: var(--accent); text-decoration: none; }
.knowledge-content a:hover { text-decoration: underline; }
.knowledge-content blockquote {
  margin: 8px 0 12px;
  padding: 6px 10px;
  border-left: 3px solid var(--accent);
  background: var(--surface2);
  color: var(--muted);
  border-radius: 0 6px 6px 0;
  font-size: 0.84rem;
  line-height: 1.45;
}
.knowledge-content blockquote p { margin: 3px 0; font-size: inherit; }
.knowledge-content table.md-table { width: 100%; border-collapse: collapse; margin: 10px 0 14px; font-size: 0.88rem; display: block; overflow-x: auto; }
.knowledge-content table.md-table th, .knowledge-content table.md-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.knowledge-content table.md-table th { background: var(--surface2); font-weight: 600; white-space: nowrap; }
.knowledge-content table.md-table tr:nth-child(even) td { background: color-mix(in srgb, var(--surface2) 40%, transparent); }

/* Предложение спрятать найденные в тексте секреты */
.wiki-secret-hints {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid #e0a800;
  border-radius: 8px;
  background: var(--surface2);
}
.wiki-secret-hints .wiki-secret-list li { border-bottom: none; padding: 3px 0; }
.wiki-secret-hints label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

/* Панель закрытых значений страницы */
.wiki-secrets { margin-top: 18px; }
.wiki-secret-list { list-style: none; padding: 0; margin: 8px 0 10px; }
.wiki-secret-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.wiki-secret-title { font-weight: 600; }
.wiki-secret-head { display: flex; align-items: center; gap: 8px; }
.icon-round-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface2);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.icon-round-btn:hover { color: var(--text); border-color: var(--muted); }
.icon-round-btn[disabled] { opacity: 0.5; cursor: default; }
.wiki-secret-ref { font-size: 0.82rem; }
.danger-link { color: var(--danger, #c0392b); font-size: 0.82rem; }
.wiki-secret-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
}
.wiki-secret-form input { min-width: 180px; }

/* Маркер машинного блока: читателю не показываем, в редакторе — тонкая подпись,
   чтобы человек видел границы генерируемого куска и не писал внутрь. */
.knowledge-content .md-auto-marker { display: none; }
.wiki-visual-editor .md-auto-marker {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.55;
  margin: 6px 0;
  user-select: none;
}

/* Закрытое значение: скрытый текст как в Telegram — значение приходит по клику */
.md-secret {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: baseline;
}
.md-secret-btn {
  font: inherit;
  font-size: 0.85em;
  line-height: 1.2;
  padding: 1px 7px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
}
.md-secret-btn:hover { color: var(--text); border-style: solid; }
.md-secret-btn[disabled] { opacity: 0.6; cursor: default; }
.md-secret-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface2);
  border-radius: 5px;
  padding: 1px 6px;
  user-select: all;
}

/* Встроенное видео: компактный 16:9 ≈ 7 строк текста */
.wiki-video {
  display: inline-block;
  vertical-align: top;
  margin: 8px 12px 10px 0;
  max-width: 100%;
}
.wiki-video-shell {
  position: relative;
  height: calc(1.55em * 7);
  width: calc(1.55em * 7 * 16 / 9);
  max-width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #14181f;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.wiki-video-poster {
  position: absolute;
  inset: 0;
  background: center / cover no-repeat #1b2230;
  transition: opacity .2s ease;
}
.wiki-video-el {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.wiki-video-embed {
  border: 0;
  object-fit: unset;
}
.wiki-video-gdrive .wiki-video-poster { opacity: 0; }
.wiki-video-bar .wiki-video-open {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--accent);
  text-decoration: none;
  line-height: 1.3;
}
.wiki-video-bar .wiki-video-open:hover { text-decoration: underline; }
.wiki-video-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 2.2rem;
  height: 2.2rem;
  border: none;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 2px;
}
.wiki-video-play:hover { background: rgba(0,0,0,.72); }
.wiki-video-status {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 4px 6px;
  font-size: 0.68rem;
  line-height: 1.2;
  color: rgba(255,255,255,.88);
  background: linear-gradient(transparent, rgba(0,0,0,.55));
  z-index: 1;
  pointer-events: none;
  text-align: center;
}
.wiki-video-playing .wiki-video-poster { opacity: 0; }
.wiki-video-playing .wiki-video-status { display: none; }
.wiki-video-bar {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  flex-wrap: wrap;
}
.wiki-video-bar button {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  line-height: 1.3;
}
.wiki-video-bar button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.wiki-video-bar .wiki-video-fs { margin-left: auto; }
.wiki-video-error .wiki-video-shell { outline: 1px solid #c45; }
.wiki-visual-editor .wiki-video-shell { cursor: default; opacity: 0.92; }
.wiki-visual-editor .wiki-video-play { display: none; }

/* --- Issue reports (модерация репортов об ошибках) --- */
.issues-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.issues-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.issue-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.issue-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.issue-card-head .issue-id { font-weight: 600; color: var(--muted); }
.issue-card-head select { font-size: 0.82rem; padding: 2px 6px; border-radius: 5px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.issue-card-head .issue-author { font-size: 0.82rem; }
.issue-card-head .issue-date { font-size: 0.76rem; margin-left: auto; }
.issue-body { margin: 8px 0; white-space: pre-wrap; word-break: break-word; }
.issue-ctx { font-size: 0.76rem; word-break: break-all; margin-bottom: 8px; }
.issue-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.issue-foot .issue-note { flex: 1; min-width: 160px; padding: 4px 8px; border-radius: 5px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); font-size: 0.82rem; }

/* --- База знаний v2: вкладки проектов/страниц, редактор --- */
.knowledge-projects { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.knowledge-proj-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.knowledge-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.knowledge-pages { display: flex; flex-wrap: wrap; gap: 6px; }
.knowledge-page-tab.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.knowledge-actions { display: flex; gap: 4px; }
.knowledge-editor { display: flex; flex-direction: column; gap: 8px; }
#knowledge-textarea { width: 100%; min-height: 55vh; resize: vertical; font-family: ui-monospace, monospace; font-size: 0.88rem; line-height: 1.5; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.knowledge-editor-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wiki-archive-btn { margin-left: auto; }

/* --- База знаний: вики (Obsidian-lite) --- */
.knowledge-container.wiki { max-width: none; width: 100%; margin: 0; padding: 12px 20px 24px; box-sizing: border-box; }
.wiki-layout { display: flex; gap: 16px; align-items: flex-start; }
.wiki-notes { flex: 0 0 280px; max-height: calc(100vh - 120px); overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 8px; position: sticky; top: 8px; }
.wiki-notes-head { display: flex; gap: 6px; margin-bottom: 6px; position: sticky; top: 0; background: var(--surface); z-index: 1; padding-bottom: 4px; }
#wiki-search { flex: 1; min-width: 0; }
#wiki-lint-btn { position: relative; }
.lint-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 0.65rem; line-height: 16px; text-align: center; font-weight: 600;
}
.wiki-note-list { list-style: none; margin: 0; padding: 0; }
.wiki-note-group { margin: 0 0 6px; }
.wiki-note-group-label { cursor: pointer; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding: 4px 6px; user-select: none; list-style: none; }
.wiki-note-group-label::-webkit-details-marker { display: none; }
.wiki-note-group-list { list-style: none; margin: 0; padding: 0 0 4px; }
.wiki-note-item { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 0.88rem; line-height: 1.25; }
.wiki-note-item.wiki-note-draft { font-style: italic; color: var(--muted); }
.wiki-note-item.wiki-note-deleted { text-decoration: line-through; opacity: 0.55; font-style: normal; }
.wiki-note-item.wiki-note-deprecated { opacity: 0.55; font-style: italic; }
.wiki-note-item:hover { background: var(--surface2); }
.wiki-note-item.active { background: var(--accent); color: #fff; }
.wiki-note-item.active.wiki-note-draft { color: #fff; font-style: italic; }
.wiki-note-item.active.wiki-note-deleted { color: #fff; text-decoration: line-through; opacity: 0.9; }
.wiki-tree-folder { list-style: none; margin: 2px 0; }
.wiki-folder-head { display: flex; align-items: center; gap: 0; width: 100%; padding: 2px 8px; border-radius: 6px; color: var(--muted); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; text-align: left; }
.wiki-folder-head:hover { background: var(--surface2); color: var(--text); }
.wiki-folder-head.active { background: var(--accent); color: #fff; }
.wiki-folder-head.active .wiki-folder-name,
.wiki-folder-head.active .wiki-folder-toggle { color: #fff; }
/* Треугольник сдвинут в гуттер отрицательным margin, чтобы название раздела
   начиналось на той же вертикали, что и текст обычной заметки (см. .wiki-note-item). */
.wiki-folder-toggle { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 16px; height: 16px; margin-left: -16px; padding: 0; border: none; border-radius: 4px; background: transparent; color: inherit; font-size: 0.65rem; cursor: pointer; transition: transform 0.15s; }
.wiki-folder-toggle:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.wiki-folder-collapsed .wiki-folder-toggle { transform: rotate(-90deg); }
.wiki-folder-name { flex: 1; min-width: 0; padding: 4px 6px 4px 0; border: none; border-radius: 4px; background: transparent; color: inherit; font: inherit; font-weight: 600; letter-spacing: 0.02em; cursor: pointer; text-align: left; }
.wiki-folder-name:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.wiki-folder-collapsed .wiki-tree-children { display: none; }
.wiki-tree-children { padding-left: 8px; border-left: 1px solid var(--border); margin-left: 6px; }
.wiki-tree-children .wiki-note-item { font-size: 0.84rem; padding: 5px 8px; }
.wiki-note-snippet { font-size: 0.78rem; color: var(--muted); }
.wiki-note-item.active .wiki-note-snippet { color: rgba(255,255,255,0.85); }
.wiki-main { flex: 1; min-width: 0; }
.wiki-main-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.wiki-title-row { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.wiki-title-block { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.wiki-main-head h2 { margin: 0; font-size: 1.2rem; line-height: 1.3; }
.wiki-back-btn { flex-shrink: 0; font-size: 1.1rem; font-weight: 600; line-height: 1; }
.wiki-status-badge {
  display: inline-block; flex-shrink: 0;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); text-transform: none;
}
.wiki-status-draft { color: #a67c00; border-color: color-mix(in srgb, #e6b800 45%, var(--border)); background: color-mix(in srgb, #e6b800 12%, var(--surface)); }
.wiki-status-published { color: #1f7a3f; border-color: color-mix(in srgb, #2ecc71 40%, var(--border)); background: color-mix(in srgb, #2ecc71 12%, var(--surface)); }
.wiki-status-review { color: #1a5fb4; border-color: color-mix(in srgb, #3584e4 40%, var(--border)); background: color-mix(in srgb, #3584e4 12%, var(--surface)); }
.wiki-status-deleted { color: #a51d2a; border-color: color-mix(in srgb, #c01c28 40%, var(--border)); background: color-mix(in srgb, #c01c28 12%, var(--surface)); text-decoration: line-through; }
.wiki-main-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.wiki-main-actions .icon-btn.active { background: var(--accent); color: #fff; }
.wiki-history-panel {
  flex: 0 0 300px;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 8px;
  position: sticky;
  top: 8px;
}
.wiki-history-panel.hidden { display: none; }
.wiki-ai-panel {
  flex: 0 0 390px;
  min-width: 0;    /* не давать содержимому (длинным репликам чата) раздвигать панель шире базовой */
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 0;
  max-height: calc(100vh - 24px);
  position: sticky;
  top: 8px;
  z-index: 4;
  border-left: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
  box-shadow: -6px 0 18px color-mix(in srgb, var(--text) 10%, transparent);
  transition: flex-basis .18s ease, box-shadow .18s ease, margin .18s ease;
}
.wiki-ai-panel:not(.is-collapsed) {
  flex-direction: column;
}
.wiki-ai-panel.is-collapsed {
  flex: 0 0 28px;
  margin-left: -16px;   /* съесть gap у .wiki-layout */
  margin-right: -20px;  /* съесть padding у .knowledge-container.wiki */
  border-left: none;
  background: transparent;
  box-shadow: none;
}
.wiki-ai-panel.hidden { display: none; }
.wiki-ai-panel.is-collapsed .wiki-ai-panel-body { display: none; }
.wiki-ai-rail-tab {
  flex: 0 0 28px;
  width: 28px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  padding: 10px 0;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: .06em;
  font-size: 0.78rem;
  font-weight: 600;
  align-self: center;
  min-height: 7.5rem;
  box-shadow: -2px 0 8px color-mix(in srgb, var(--text) 8%, transparent);
}
.wiki-ai-rail-tab:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--text);
}
.wiki-ai-panel.is-collapsed .wiki-ai-rail-tab {
  border-radius: 8px 0 0 8px;
  height: auto;
  align-self: center;
}
.wiki-ai-panel:not(.is-collapsed) .wiki-ai-rail-tab {
  /* в открытом виде — не боковой рельс, а горизонтальная подпись сверху, над «Чаты · Знания» */
  flex: 0 0 auto;
  width: 100%;
  writing-mode: horizontal-tb;
  transform: none;
  align-self: stretch;
  min-height: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  box-shadow: none;
  text-align: left;
  padding: 5px 10px;
  background: color-mix(in srgb, var(--surface) 88%, var(--bg));
  color: var(--muted);
}
.wiki-ai-panel-body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.wiki-ai-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); gap: 8px; }
.wiki-ai-chat-list { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--border); max-height: 9.5rem; overflow: auto; }
.wiki-ai-chat-list li { padding: 6px 10px; cursor: pointer; border-left: 3px solid transparent; font-size: 0.85rem; }
.wiki-ai-chat-list li:hover { background: var(--surface2); }
.wiki-ai-chat-list li.active { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); border-left-color: var(--muted); font-weight: 600; }
.wiki-ai-main-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wiki-ai-main-host .ai-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wiki-history-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.wiki-history-list {
  flex: 1;
  overflow-y: auto;
  font-size: 0.82rem;
  min-height: 80px;
}
.wiki-history-item {
  display: block; width: 100%;
  text-align: left;
  border: none; border-radius: 6px;
  background: transparent; color: var(--text);
  padding: 7px 8px; margin: 0 0 4px; cursor: pointer;
}
.wiki-history-item:hover { background: var(--surface2); }
.wiki-history-item.active { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.wiki-history-msg { display: block; font-size: 0.84rem; line-height: 1.3; margin-bottom: 2px; }
.wiki-history-meta { display: block; font-size: 0.72rem; color: var(--muted); }
/* Правка не рукой человека — видно в списке, до открытия diff */
.wiki-history-actor {
  font-size: 0.66rem;
  padding: 1px 5px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.wiki-history-preview {
  margin-top: 8px;
  max-height: 42vh;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  font-size: 0.86rem;
}
.wiki-history-rev-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 8px;
}
@media (max-width: 1100px) {
  .wiki-history-panel { flex-basis: 260px; }
}
@media (max-width: 900px) {
  .wiki-history-panel {
    position: fixed; right: 8px; top: 60px; bottom: 8px;
    width: min(92vw, 340px); z-index: 40;
    box-shadow: 0 8px 28px rgba(0,0,0,.18);
  }
}
.wiki-meta-fields {
  display: grid;
  grid-template-columns: 110px 160px 1fr;
  gap: 10px;
  margin-bottom: 4px;
}
.wiki-template-banner {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--accent, #5b7cfa);
  background: color-mix(in srgb, var(--accent, #5b7cfa) 10%, transparent);
}
.wiki-meta-field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.78rem; color: var(--muted);
}
.wiki-meta-field input,
.wiki-meta-field select {
  width: 100%;
  font-size: 0.9rem;
  color: var(--text);
}
.wiki-edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 4px 0 8px;
}
.wiki-mode-tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface2);
}
.wiki-mode-tab {
  border: none;
  margin: 0;
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.84rem;
  width: auto;
}
.wiki-mode-tab.active {
  background: var(--accent);
  color: #fff;
}
.wiki-visual-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.wiki-visual-tools button {
  width: auto;
  margin: 0;
  min-width: 32px;
  padding: 4px 8px;
  font-size: 0.78rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}
.wiki-visual-tools button:hover { border-color: var(--accent); }
.wiki-visual-tools button[data-cmd="bold"] { font-weight: 700; }
.wiki-visual-editor {
  min-height: 42vh;
  max-height: 70vh;
  overflow-y: auto;
  outline: none;
  cursor: text;
}
.wiki-visual-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.wiki-visual-editor .wikilink { cursor: text; }
#wiki-textarea.hidden,
.wiki-visual-editor.hidden,
.wiki-visual-tools.hidden { display: none !important; }
@media (max-width: 720px) {
  .wiki-meta-fields { grid-template-columns: 1fr 1fr; }
  .wiki-meta-title { grid-column: 1 / -1; }
}
.wiki-content { min-height: 38vh; }
.wiki-lint-actions { display: flex; gap: 8px; margin: 0 0 12px; }
a.wikilink { color: var(--accent); cursor: pointer; text-decoration: none; border-bottom: 1px dashed var(--accent); }
a.wikilink:hover { border-bottom-style: solid; }
.wiki-backlinks { margin-top: 16px; }
.wiki-backlink-list { list-style: none; padding-left: 0; }
.wiki-backlink-list li { margin: 3px 0; }
#wiki-textarea { width: 100%; min-height: 55vh; resize: vertical; font-family: ui-monospace, monospace; font-size: 0.88rem; line-height: 1.5; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
@media (max-width: 720px) { .wiki-layout { flex-direction: column; } .wiki-notes { flex-basis: auto; width: 100%; } }

.groups-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
  max-height: 240px;
  overflow-y: auto;
}
.group-detail {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.group-detail h4 { margin: 16px 0 8px; font-size: 0.95rem; }

.wiki-ctx-menu {
  position: fixed;
  z-index: 1200;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 4px;
}
.wiki-ctx-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.wiki-ctx-item:hover { background: var(--surface2); }

/* Меню по удержанию ✓ в «Сегодня»: перенести или отменить. */
.done-menu { max-width: min(320px, calc(100vw - 16px)); }
.done-menu .wiki-ctx-item { padding: 10px 12px; font-size: 0.95rem; }
.done-menu-title {
  padding: 6px 12px 8px;
  font-size: 0.8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.done-menu-date { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.done-menu-date input { font-size: 0.85rem; max-width: 150px; }
.done-menu-danger { color: var(--danger, #d64545); }

.wiki-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.wiki-modal.hidden { display: none !important; }
.wiki-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}
.wiki-modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}
.wiki-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.wiki-modal-header h3 { margin: 0; font-size: 1.05rem; }

/* Файл в базу знаний: форма загрузки (📎) и панель файла на странице-карточке */
.wiki-file-modal-card { width: min(620px, 100%); max-height: min(92vh, 860px); }
.wiki-file-form { display: flex; flex-direction: column; gap: 10px; }
.wiki-file-form .audio-picked { margin-top: 0; }
.wiki-file-modes {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px 8px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wiki-file-modes legend { padding: 0 4px; font-size: 0.85rem; color: var(--muted); }
.wiki-file-mode { display: flex; gap: 8px; align-items: flex-start; font-size: 0.9rem; cursor: pointer; }
.wiki-file-mode input { margin-top: 3px; }
.wiki-file-mode input:disabled + span { opacity: 0.5; }
.wiki-file-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
/* Форма — колонка: база 180px у поля в ней ушла бы в ВЫСОТУ (было: провалы под
   «Названием» и «Комментарием», форма в 1000px и срок хранения за краем экрана).
   Растягиваем поля только по ширине и только внутри строки. */
.wiki-file-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 0;
}
.wiki-file-row > .wiki-file-field { flex: 1 1 180px; }
.wiki-file-row > .wiki-file-number { flex: 0 1 130px; }
.wiki-file-field input, .wiki-file-field select, .wiki-file-field textarea {
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
  min-height: 38px;
}
.wiki-file-field textarea { min-height: 0; resize: vertical; }
.wiki-file-row > .wiki-file-ttl-field { flex: 0 1 200px; }
.wiki-file-ttl-note { flex: 1 1 200px; align-self: flex-end; padding-bottom: 9px; font-size: 0.82rem; }
.wiki-file-ttl-note.warn { color: #d97706; }
.wiki-file-describe { margin: 0; }
.wiki-file-form .settings-hint { margin: 0; }
.wiki-file-form .audio-drop { padding: 12px; }
.wiki-file-form.picked .audio-drop { padding: 6px 12px; }
.wiki-file-form.picked .audio-drop-sub { display: none; }
/* кнопки всегда на виду, даже если окно пришлось прокрутить */
.wiki-file-actions {
  position: sticky;
  bottom: -16px;
  background: var(--surface);
  padding: 10px 0 4px;
  margin: 0;
  z-index: 1;
}

.wiki-file-panel {
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wiki-file-panel.expiring { border-color: #d97706; }
.wiki-file-panel.deleted { opacity: 0.8; }
.wiki-file-panel-head { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; word-break: break-word; }
.wiki-file-panel-term { font-size: 0.85rem; color: var(--muted); }
.wiki-file-panel.expiring .wiki-file-panel-term { color: #d97706; }
.wiki-file-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.wiki-file-panel-actions button, .wiki-file-panel-actions select { padding: 5px 10px; font-size: 0.85rem; }
.wiki-file-panel-actions a {
  display: inline-block;
  padding: 5px 10px;
  font-size: 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.wiki-file-panel-actions a:hover { border-color: var(--accent); }
.wiki-file-frame {
  width: 100%;
  height: 75vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 0.92rem;
}

.academy-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 16px 40px;
}
.academy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.academy-header h2 { margin: 0; }
.academy-header-actions { display: flex; gap: 8px; }

/* «Обновления недели»: страница × группы-чипы, рассылка в бот */
.academy-digest-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0 12px; }
.academy-digest-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  word-break: break-word;
}
.academy-digest-item-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.academy-digest-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.academy-digest-chip {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.8rem;
  font-weight: 400;
}
.academy-digest-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.academy-digest-rest { margin: 10px 0; }
.academy-digest-rest summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.academy-digest-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.academy-digest-foot .muted-field { flex: 1 1 240px; }
.academy-digest-sent { color: var(--muted); }
.academy-course-cards {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.academy-course-card {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
}
.academy-course-card:hover { border-color: var(--accent); }
.academy-course-item { display: grid; }
.academy-course-item:has(.academy-continue-btn) .academy-course-card {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.academy-continue-btn {
  text-align: left;
  border-radius: 0 0 10px 10px;
  padding: 10px 14px;
}
.academy-course-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.academy-progress {
  position: relative;
  height: 18px;
  background: var(--surface2);
  border-radius: 9px;
  overflow: hidden;
  margin-bottom: 6px;
}
.academy-progress-fill {
  height: 100%;
  background: color-mix(in srgb, var(--accent) 70%, transparent);
}
.academy-progress span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}
.academy-back-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.academy-lesson-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.academy-lesson-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.academy-lesson-row:hover:not(:disabled) { border-color: var(--accent); }
.academy-lesson-row:disabled,
.academy-lesson-locked { opacity: 0.55; cursor: not-allowed; }
.academy-lesson-pos {
  font-weight: 600;
  color: var(--muted);
}
.academy-lesson-body { margin: 14px 0; min-height: 20vh; }
.academy-lesson-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}
.academy-error-report {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  max-width: 560px;
}
.academy-error-report-label {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.academy-error-report textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 3.2em;
  resize: vertical;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.academy-error-report-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}
.academy-errors-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}
.academy-errors-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.academy-error-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface);
}
.academy-error-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.academy-error-card-meta { margin: 6px 0 8px; line-height: 1.35; }
.academy-error-quote {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: var(--surface2);
  font-size: 0.92rem;
  white-space: pre-wrap;
}
.academy-error-card label {
  display: block;
  margin: 8px 0;
  font-size: 0.88rem;
}
.academy-error-card select,
.academy-error-card textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  box-sizing: border-box;
}
#wiki-error-modal textarea {
  width: 100%;
  box-sizing: border-box;
  margin: 8px 0 12px;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}
.academy-relearn-banner {
  background: color-mix(in srgb, #c47a00 18%, var(--surface));
  border: 1px solid color-mix(in srgb, #c47a00 40%, var(--border));
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.academy-show-changes-btn {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  border: 1px solid var(--accent);
  color: var(--text);
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.academy-show-changes-btn:hover {
  background: color-mix(in srgb, var(--accent) 32%, var(--surface));
}
.academy-diff-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  max-height: 55vh;
  overflow: auto;
  background: var(--surface);
}
.academy-diff-box.academy-diff-rich {
  font-family: inherit;
  font-size: inherit;
  white-space: normal;
}
.academy-diff-view { display: flex; flex-direction: column; gap: 16px; }
.academy-diff-heading {
  margin: 0 0 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.academy-diff-section.academy-diff-added {
  border-left: 3px solid #0a6b3c;
  padding-left: 12px;
}
.academy-diff-section.academy-diff-removed {
  border-left: 3px solid #b33;
  padding-left: 12px;
}
.academy-diff-section.academy-diff-removed .academy-diff-body {
  opacity: 0.88;
}
.academy-diff-section.academy-diff-removed .academy-diff-body :is(p, li, h1, h2, h3, td, th) {
  text-decoration: line-through;
  color: color-mix(in srgb, #b33 55%, var(--text));
}
.academy-diff-del {
  text-decoration: line-through;
  color: #b33;
  background: color-mix(in srgb, #b33 12%, transparent);
}
.academy-diff-ins {
  color: #0a6b3c;
  background: color-mix(in srgb, #0a6b3c 12%, transparent);
  text-decoration: none;
}
.academy-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.academy-tabs .active {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
}
.academy-relearn-list,
.academy-updates-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.academy-relearn-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px;
}
.academy-relearn-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}
.academy-actor {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.academy-actor-ai { border-color: #b98900; color: #b98900; }
.academy-actor-script { border-color: var(--muted); color: var(--muted); }
.academy-relearn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.academy-relearn-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}
.academy-q {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface);
}
.academy-q-stem { margin-bottom: 10px; }
.academy-choices { display: flex; flex-direction: column; gap: 6px; }
.academy-choice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
}
.academy-choice:hover { background: var(--surface2); }
.academy-manage-form { max-width: 560px; }
.academy-groups-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 12px 0;
}
.academy-draft-warn {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #c4a35a;
  background: rgba(196, 163, 90, 0.12);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.35;
}
.academy-lesson-builder { margin: 12px 0; }
.academy-lesson-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.academy-lesson-add-row input { flex: 1; }
.academy-suggest {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  max-height: 320px;
  overflow: auto;
  margin-top: 4px;
  font-size: 0.8rem;
}
.academy-suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 5px 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.25;
}
.academy-suggest-item strong { font-size: 0.8rem; font-weight: 600; }
.academy-suggest-item .muted-field { font-size: 0.72rem; }
.academy-suggest-item:hover { background: var(--surface2); }
.academy-suggest-empty { padding: 8px; color: var(--muted); font-size: 0.8rem; }

.academy-manage-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.academy-manage-list-head h4 { margin: 0; }
.academy-plus-btn {
  font-size: 1.25rem;
  line-height: 1;
  width: 36px;
  height: 36px;
}
.academy-manage-list { list-style: none; padding: 0; margin: 8px 0 16px; }
.academy-manage-course { margin: 0 0 6px; }
.academy-manage-course-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}
.academy-manage-course.active .academy-manage-course-btn,
.academy-manage-course-btn:hover {
  border-color: var(--accent);
}
.academy-manage-course-title {
  display: block;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.academy-manage-course-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
#academy-next-quiz:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.academy-picked-lessons { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.academy-picked-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
}
.academy-picked-main { display: flex; gap: 10px; align-items: flex-start; }
.academy-picked-actions { display: flex; gap: 2px; }
.academy-q-badge {
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.academy-q-badge.off { opacity: 0.45; background: var(--surface2); }
.academy-q-edit {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--surface);
}
.danger-icon { color: #b33; }
.wiki-img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 8px 0;
  display: block;
}
.wiki-subscribers {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.wiki-subs-head { font-weight: 600; margin-bottom: 8px; }
.wiki-subs-list { list-style: none; padding: 0; margin: 0; }
.wiki-subs-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.wiki-history-rev-actions { display: flex; gap: 8px; margin: 8px 0; }

/* Аккордеоны markdown: `##> Заголовок` → <details class="md-fold"> */
.md-fold {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 10px 0;
  background: transparent;
}
.md-fold > summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--accent);
  padding: 8px 12px;
  list-style: none;
  user-select: none;
}
.md-fold > summary::-webkit-details-marker { display: none; }
.md-fold > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.md-fold[open] > summary::before { transform: rotate(90deg); }
.md-fold > .md-fold-body { padding: 0 12px 10px; }
.md-fold .md-fold { margin: 8px 0; }

/* Публичная страница шаринга (public.html) */
body.public-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.public-container {
  min-height: 40vh;
}

.public-password-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  margin: 60px auto 0;
  text-align: center;
}

.public-password-form input[type="password"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.md-video-note {
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
}

/* --- Модуль «ИИ-задачи» --- */
/* Независимый скролл: левый список и лента сообщений — каждый свой overflow */
#ai-view:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ai-layout {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  gap: 12px;
  overflow: hidden;
}
.ai-chats {
  width: 280px;
  flex: 0 0 280px;
  align-self: stretch;
  border-right: 1px solid var(--border, #ddd);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  padding: 8px;
}
.ai-chats-toolbar { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-chats-toolbar .btn { flex: 1; min-width: 0; font-size: 13px; padding: 6px 8px; }
.ai-chat-tree { margin-top: 6px; }
.ai-chat-list { list-style: none; padding: 0; margin: 4px 0; }
.ai-folder { margin: 4px 0 8px; border-radius: 8px; }
.ai-folder-summary {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  position: relative;
  user-select: none;
}
.ai-folder-summary::-webkit-details-marker { display: none; }
.ai-folder-summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 11px;
  width: 12px;
}
.ai-folder[open] > .ai-folder-summary::before { content: "▾"; }
.ai-folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-folder-count { flex: none; font-size: 11px; font-weight: 500; color: var(--muted); }
.ai-folder .ai-chat-list { margin-left: 8px; }
.ai-folder-empty { padding: 4px 8px; font-size: 12px; color: var(--muted); }
.ai-chat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: default;
  font-size: 14px;
  position: relative;
}
.ai-chat-item:hover { background: var(--hover, #eef); }
.ai-chat-item.active { background: var(--accent-soft, #e5ecff); font-weight: 600; }
.ai-chat-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.ai-chat-rel {
  flex: none;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ai-chat-more {
  flex: none;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0 4px;
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
  cursor: pointer;
}
.ai-chat-more:hover { color: var(--text); background: var(--surface2, #eee); }
.ai-chat-menu {
  display: none;
  position: absolute;
  right: 4px;
  top: 100%;
  z-index: 5;
  min-width: 140px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface, #fff);
  box-shadow: 0 4px 16px var(--fab-shadow, rgba(0,0,0,.15));
}
.ai-chat-menu.open {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 60vh;
  overflow-y: auto;
}
.ai-chat-menu button {
  background: transparent;
  color: var(--text);
  border: none;
  text-align: left;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
}
.ai-chat-menu button:hover { background: var(--surface2, #eee); }
/* Секция-список внутри меню (выбор папки) — вместо prompt «введите номер». */
.ai-menu-sep {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 6px 8px 2px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}
.ai-menu-sep:empty { padding: 0; margin-top: 4px; }
.ai-chat-menu .ai-menu-opt {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-chat-menu .ai-menu-opt.active { color: var(--accent, #36c); font-weight: 500; }
/* Галочка слева: справа её съедает ellipsis у длинных «Папка · проект». */
.ai-chat-menu .ai-menu-opt.active::before { content: "✓ "; }
.ai-folder-badge {
  flex: none;
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 6px;
  color: var(--accent, #36c);
  background: color-mix(in srgb, var(--accent, #36c) 14%, transparent);
}
.ai-modal-back {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .35);
}
.ai-modal {
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface, #fff);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
.ai-modal-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.ai-modal label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}
.ai-modal input,
.ai-modal select,
.ai-modal textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg, #fff);
  border: 1px solid var(--border, #ccc);
  border-radius: 8px;
  padding: 7px 8px;
}
.ai-modal textarea { resize: vertical; min-height: 72px; }
.ai-modal-hint { font-size: 11px; color: var(--muted); line-height: 1.35; }
.ai-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.ai-search-row { margin-top: 8px; }
.ai-search-input {
  width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg, #fff); color: inherit;
}
.ai-search-results { margin-top: 8px; }
.ai-search-results.hidden { display: none; }
.ai-search-empty { padding: 8px 4px; font-size: 13px; opacity: .7; }
.ai-search-count { padding: 2px 4px 6px; font-size: 12px; opacity: .7; }
.ai-search-snippet {
  padding: 0 8px 6px 8px; margin: -4px 0 4px; font-size: 12px; line-height: 1.35;
  opacity: .75; word-break: break-word;
}
.ai-search-badge {
  display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px;
  font-size: 11px; background: var(--accent-soft, #e5ecff); opacity: .85;
}
.ai-archive-wrap { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 6px; }
.ai-archive-wrap.empty { display: none; }
.ai-archive-summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 8px;
  user-select: none;
}
.ai-context-ring {
  flex: none;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  border-radius: 50%;
}
.ai-context-ring .ai-ring-track { stroke: var(--border, #ccc); }
.ai-context-ring .ai-ring-primary {
  stroke: hsl(var(--ai-ring-hue, 120) 45% 55%);
  stroke-dasharray: 0 88;
  transition: stroke-dasharray .25s ease, stroke .25s ease;
}
.ai-context-ring .ai-ring-overflow {
  stroke: #c0392b;
  stroke-dasharray: 0 88;
  opacity: 0.95;
  transition: stroke-dasharray .25s ease;
}
.ai-context-ring.warn { box-shadow: 0 0 0 2px color-mix(in srgb, #e6b800 45%, transparent); }
.ai-context-ring.overflow .ai-ring-primary { opacity: 0.85; }
.ai-model-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  text-align: left;
  max-width: 8.5rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 8px;
  cursor: pointer;
}
.ai-model-label:hover { border-color: var(--border, #ccc); background: var(--surface2, #f2f2f2); }
.ai-model-label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.ai-model-caret {
  flex: none;
  font-size: 9px;
  line-height: 1;
  color: var(--muted);
  opacity: 0.9;
}
.ai-model-label:hover .ai-model-label-text,
.ai-model-label:hover .ai-model-caret {
  color: var(--text);
}
/* Меню якорится к .ai-compose (не к кнопке): кнопка модели теперь в середине
   нижней панели, и от неё меню вылезало бы за узкий рельс «Знаний». */
.ai-model-wrap { position: static; max-width: 8.5rem; display: inline-flex; }
.ai-model-menu {
  position: absolute;
  left: 10px;
  bottom: calc(100% + 6px);
  min-width: min(17rem, calc(100% - 20px));
  max-width: min(24rem, calc(100% - 20px));
  max-height: min(26rem, 60vh);
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px var(--fab-shadow, rgba(0,0,0,.25));
  z-index: 40;
  padding: 6px;
}
.ai-model-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}
.ai-model-item-name {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-model-item:hover:not(:disabled) { background: var(--surface2); }
.ai-model-item.active .ai-model-item-name { color: var(--accent); }
.ai-model-item.disabled, .ai-model-item:disabled { opacity: .45; cursor: not-allowed; }
.ai-model-item-meta {
  color: var(--muted);
  white-space: nowrap;
  font-size: 11px;
  flex: none;
}
.ai-model-sep {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 8px 8px 4px;
}
.ai-limit-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 12px 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, #e6b800 18%, var(--surface));
  border: 1px solid color-mix(in srgb, #e6b800 40%, transparent);
  color: var(--text);
  font-size: 12px;
}
.ai-limit-banner.hidden { display: none; }
.ai-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  overflow: hidden;
}
.ai-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
}
.ai-status,
.ai-compose {
  flex-shrink: 0;
}
.ai-msg { margin: 10px 0; padding: 10px 12px; border-radius: 12px; max-width: 85%; }
.ai-msg-body { white-space: pre-wrap; word-wrap: break-word; }
.ai-msg-user { background: var(--accent-soft, #e5ecff); margin-left: auto; }
.ai-msg-assistant { background: var(--panel, #f6f6f6); }
/* Узкая панель «Знания» — экономим горизонталь: меньше отступов, реплики шире,
   расстояние между «моей» и «ИИ» стороной уменьшено. */
.wiki-ai-panel .ai-messages { padding: 8px; }
.wiki-ai-panel .ai-msg { margin: 8px 0; padding: 8px 10px; max-width: 94%; }
/* Ответ по неполным данным: агент упёрся в лимит шагов. Без пометки такой
   ответ выглядит как обычный, и человек принимает его за полный. */
.ai-truncated {
  font-size: 12px;
  margin-top: 6px;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--danger, #c0392b);
  color: var(--danger, #c0392b);
  background: color-mix(in srgb, var(--danger, #c0392b) 8%, transparent);
  line-height: 1.35;
}
.ai-degraded {
  font-size: 12px;
  margin-top: 6px;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--muted, #8a8a8a);
  color: var(--muted, #8a8a8a);
  line-height: 1.35;
}
.ai-sources {
  font-size: 12px;
  opacity: .85;
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 0;
  max-width: 100%;
  line-height: 1.35;
}
.ai-sources:not(.expanded) {
  white-space: nowrap;
  overflow: hidden;
}
.ai-sources.expanded {
  flex-wrap: wrap;
  white-space: normal;
}
.ai-sources-label { flex: none; opacity: .75; }
.ai-sources-body {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-sources.expanded .ai-sources-body { overflow: visible; }
.ai-sources a.ai-source-link { color: var(--accent); }
.ai-sources-toggle {
  display: inline;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 0 0 0 2px;
  cursor: pointer;
  font-weight: 500;
  vertical-align: baseline;
}
.ai-sources-toggle:hover { color: var(--accent); }
.ai-plan { margin-top: 10px; padding: 10px; border: 1px dashed var(--border, #bbb); border-radius: 10px; }
.ai-plan-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.ai-step { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; font-size: 14px; cursor: pointer; }
.ai-step-num {
  flex: 0 0 auto;
  min-width: 1.4em;
  color: var(--muted, #888);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.ai-step-text { white-space: pre-wrap; flex: 1; min-width: 0; }

/* Раскрывашка «что запишем» под шагом плана: текст правки, а не только имя страницы */
.ai-step-item { border-bottom: 1px solid rgba(128,128,128,.12); }
.ai-step-item:last-child { border-bottom: 0; }
.ai-step-diff { margin: 0 0 6px 30px; font-size: 13px; }
.ai-step-diff > summary { cursor: pointer; color: var(--muted, #888); font-size: 12px;
  padding: 2px 0; user-select: none; }
.ai-step-diff > summary:hover { color: var(--fg, #222); }

/* Строка под шагом плана: раскрывашка «что запишем» слева, исполнитель
   задачи справа от неё — видно и правится без раскрытия деталей. */
.ai-step-meta { display: flex; align-items: center; flex-wrap: wrap;
  justify-content: space-between; gap: 4px 12px; margin: 0 0 6px 30px; }
.ai-step-meta .ai-step-diff { margin: 0; flex: 1 1 auto; min-width: 0; }
.ai-step-assignee { display: flex; align-items: center; gap: 4px; flex: 0 0 auto;
  font-size: 12px; color: var(--muted, #888); }
.ai-step-assignee-cap { white-space: nowrap; }
.ai-step-assignee-select { font-size: 12px; max-width: 160px; }
.ai-diff-heading { color: var(--muted, #888); font-size: 12px; margin: 4px 0; }
.ai-diff { margin: 4px 0; border-left: 3px solid transparent; padding-left: 8px; }
.ai-diff-cap { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted, #888); margin-bottom: 2px; }
.ai-diff pre { margin: 0; white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto; font-size: 13px; line-height: 1.45;
  background: rgba(128,128,128,.06); padding: 6px 8px; border-radius: 4px; }
.ai-diff-add { border-left-color: #3fa45b; }
.ai-diff-add pre { background: rgba(63,164,91,.10); }
.ai-diff-del { border-left-color: #d1544f; }
.ai-diff-del pre { background: rgba(209,84,79,.10); }
.ai-diff-del pre { text-decoration: line-through; text-decoration-color: rgba(209,84,79,.5); }
.ai-diff-info { border-left-color: rgba(128,128,128,.4); }
.ai-step-error { color: #b00020; }
.ai-step-done { color: #0a7a2f; }
.ai-plan-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.ai-exec-btn { margin-top: 0; }
.ai-cancel-btn {
  margin-top: 0;
  background: transparent;
  color: var(--text, #222);
  border: 1px solid var(--border, #bbb);
}
.ai-cancel-btn:hover { border-color: var(--muted, #888); }
.ai-plan-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted, #888);
  line-height: 1.35;
}
.ai-clarify {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border, #bbb);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface2, #f4f4f4) 70%, transparent);
}
.ai-clarify-done { opacity: 0.75; }
.ai-clarify-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.ai-clarify-q { margin-bottom: 12px; }
.ai-clarify-prompt { font-size: 14px; margin-bottom: 6px; }
.ai-clarify-options { display: flex; flex-direction: column; gap: 4px; }
.ai-clarify-opt {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 14px;
  cursor: pointer;
}
.ai-clarify-text {
  width: 100%;
  margin-top: 6px;
  box-sizing: border-box;
  resize: vertical;
  font: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border, #bbb);
  background: var(--surface, #fff);
  color: inherit;
}
.ai-clarify-submit { margin-top: 4px; }
.ai-status { padding: 4px 12px; font-size: 13px; opacity: .8; min-height: 20px; }
.ai-status.error { color: #b00020; opacity: 1; }
.ai-status-thinking {
  opacity: 1;
  color: var(--muted, #666);
  font-variant-numeric: tabular-nums;
}
.ai-msg-pending { opacity: .92; }
.ai-msg-assistant { position: relative; }
.ai-msg-body :is(p, ul, ol) { margin: 0.35em 0; }
.ai-msg-body :is(ul, ol) { padding-left: 1.25em; }
.ai-msg-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.ai-msg-body code {
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface2, #eee) 80%, transparent);
}
.ai-msg-body pre.md-code {
  overflow-x: auto;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface2, #eee);
  font-size: 0.85em;
}
.ai-msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  opacity: 0.55;
  transition: opacity .15s ease;
}
.ai-msg-assistant:hover .ai-msg-actions,
.ai-msg-actions:focus-within { opacity: 1; }
.ai-copy-btn {
  background: transparent;
  color: var(--muted, #666);
  border: 1px solid var(--border, #ccc);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
}
.ai-copy-btn:hover { color: var(--text); border-color: var(--accent); }
.ai-copy-btn.copied { color: var(--ok, #0a7a2f); border-color: var(--ok, #0a7a2f); }
.ai-compose {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border, #ddd);
  align-items: stretch;
  position: relative;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}
.ai-compose.ai-compose-drag {
  background: color-mix(in srgb, var(--accent, #3366aa) 8%, var(--bg, #fff));
  box-shadow: inset 0 0 0 2px var(--accent, #3366aa);
  border-radius: 8px;
}
.ai-compose.ai-compose-drag::after {
  content: "Отпустите файл, чтобы прикрепить";
  position: absolute;
  inset: 6px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  border-radius: 6px;
  border: 2px dashed var(--accent, #3366aa);
  background: color-mix(in srgb, var(--bg, #fff) 82%, transparent);
  color: var(--text, #222);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  padding: 12px;
}
.ai-main.ai-main-drag .ai-compose:not(.ai-compose-drag) {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent, #3366aa) 50%, transparent);
}
/* Раскладка «как в VS Code»: поле ввода сверху, панель инструментов снизу внутри
   той же рамки; отправка — справа в той же строке. */
.ai-compose-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border, #ccc);
  border-radius: 12px;
  background: var(--bg, #fff);
  transition: border-color .12s ease;
}
.ai-compose-field:focus-within { border-color: var(--accent, #888); }
.ai-compose-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-compose-tools {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}
.ai-tool-btn {
  height: 30px;
  min-width: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #666);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ai-tool-btn:hover { color: var(--text); border-color: var(--border, #ccc); background: var(--surface2, #f2f2f2); }
.ai-mode-btn {
  gap: 5px;
  padding: 0 8px;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}
.ai-mode-icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.ai-mode-icon svg { display: block; }
.ai-mode-btn.is-auto {
  color: var(--accent, #3366aa);
  border-color: color-mix(in srgb, var(--accent, #3366aa) 45%, transparent);
  background: color-mix(in srgb, var(--accent, #3366aa) 12%, transparent);
}
.ai-mode-btn.is-auto:hover {
  color: var(--accent, #3366aa);
  background: color-mix(in srgb, var(--accent, #3366aa) 20%, transparent);
}
.ai-tool-btn.recording {
  color: #c0392b;
  border-color: #c0392b;
  animation: ai-mic-pulse 1.2s ease-in-out infinite;
}
@keyframes ai-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(192, 57, 43, 0); }
}
.ai-compose-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 2px;
}
.ai-compose-chips[hidden] { display: none !important; }
.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border, #ccc);
  background: var(--bg-soft, #f6f6f6);
  font-size: 12px;
  line-height: 1.3;
}
.ai-chip-preview {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.ai-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.ai-chip-mode {
  border: none;
  background: transparent;
  color: var(--accent, #336);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
  white-space: nowrap;
}
.ai-chip-x {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted, #888);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.ai-chip-x:hover { color: var(--text); }
.ai-chip-context { background: var(--accent-soft, #eaf2ff); border-color: var(--accent, #336); }
.ai-chip-patch { background: #fff3d6; border-color: #d9a441; }
/* Тема переключается и вручную ([data-theme]), не только системно — иначе
   светлый фон чипа остаётся под тёмной темой и текст почти не читается. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ai-chip-context { background: rgba(80, 130, 220, 0.18); color: var(--text); }
  :root:not([data-theme="light"]) .ai-chip-patch { background: rgba(217, 164, 65, 0.18); color: var(--text); }
}
[data-theme="dark"] .ai-chip-context { background: rgba(80, 130, 220, 0.18); color: var(--text); }
[data-theme="dark"] .ai-chip-patch { background: rgba(217, 164, 65, 0.18); color: var(--text); }
.ai-chip-pasted .ai-chip-label, .ai-chip-patch .ai-chip-label { cursor: pointer; }
.ai-paste-preview {
  width: 100%;
  max-height: 160px;
  overflow: auto;
  margin-top: 4px;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border, #ddd);
  background: var(--bg, #fff);
  font-size: 12px;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ai-msg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.ai-msg-chip {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border, #ccc);
  background: var(--bg-soft, #f6f6f6);
  color: var(--muted, #555);
}
/* Высоту задаёт autosizeAiInput (2→7 строк). flex: 1 (basis 0) съедал inline-height,
   и поле никогда не росло — размер брался из rows="2". */
.ai-compose textarea {
  flex: 0 0 auto;
  resize: none;
  font: inherit;
  padding: 4px 2px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: inherit;
  min-height: 0;
}
.ai-compose textarea:focus { outline: none; }
.ai-send-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  flex: none;
  margin-left: auto;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}
.ai-send-btn .ai-send-icon,
.ai-send-btn .ai-stop-icon {
  display: block;
  pointer-events: none;
}
.ai-send-btn.ai-send-btn-stop {
  background: var(--text, #222);
  color: var(--surface, #fff);
  border-color: var(--text, #222);
}
.ai-send-btn.ai-send-btn-stop:hover {
  filter: brightness(1.1);
}
/* Подвал меню модели: дефолт для новых чатов + Whisper. Раньше здесь был
   второй экземпляр списка моделей — читалось как дубль. */
.ai-model-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 8px 6px;
  font-size: 12px;
  color: var(--muted, #666);
}
.ai-model-foot label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ai-model-foot select {
  font: inherit;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border, #ccc);
  background: var(--bg, #fff);
  color: var(--text);
  max-width: 100%;
}

.ai-chat-item.ai-chat-busy .ai-chat-title::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent, #3b6ef5);
  vertical-align: middle;
  animation: ai-busy-pulse 1.1s ease-in-out infinite;
}
@keyframes ai-busy-pulse {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50% { opacity: 1; transform: scale(1); }
}
.ai-progress {
  opacity: .9;
  border: 1px dashed var(--border, #ccc);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 6px 0 10px;
  background: color-mix(in srgb, var(--surface2, #f4f4f4) 70%, transparent);
}
.ai-progress-body {
  font-size: 13px;
  color: var(--muted, #666);
  font-variant-numeric: tabular-nums;
}
.ai-progress-body.ai-progress-stalled {
  color: #9a5b00;
}
.ai-progress-error .ai-progress-body { color: #b00020; }
.ai-progress-trail {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* Одна строка на шаг: пишем до конца строки, дальше — многоточие (полный текст в title). */
.ai-progress-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 100%;
}
.ai-progress-line-done {
  opacity: .55;
}
.ai-progress-line-live {
  opacity: 1;
  font-weight: 500;
}
/* Анимация «Думаю…»: три точки на месте всегда, мигает только видимость —
   иначе хвост подписи ездит по строке каждые 450 мс. */
.ai-progress-dots > span.is-off { visibility: hidden; }
.ai-progress-toggle {
  align-self: flex-start;
  display: inline;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 0 0 2px;
  cursor: pointer;
  font-weight: 500;
}
.ai-progress-toggle:hover { color: var(--accent); }

.wiki-selection-fix-btn {
  position: fixed;
  z-index: 500;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #ccc);
  background: var(--bg, #fff);
  color: var(--text, #222);
  font-size: 12px;
  font-family: inherit;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}
.wiki-selection-fix-btn:hover { border-color: var(--accent, #336); }
.wiki-selection-fix-btn.hidden { display: none; }


/* Profile / Telegram link */
/* Страница во всю ширину: узкая колонка на 520px делала из четырёх карточек
   ленту, по которой надо скроллить, хотя данные легко ложатся рядом. */
.profile-page { max-width: 1500px; margin: 24px auto; padding: 0 20px; }

/* Сетка на 12 колонок. Карточка объявляет ширину классом .col-N; на узком
   экране все схлопываются в одну колонку — порядок в разметке и есть порядок
   чтения на телефоне. */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.profile-grid > .col-3 { grid-column: span 3; }
.profile-grid > .col-4 { grid-column: span 4; }
.profile-grid > .col-5 { grid-column: span 5; }
.profile-grid > .col-6 { grid-column: span 6; }
.profile-grid > .col-7 { grid-column: span 7; }
.profile-grid > .col-8 { grid-column: span 8; }
.profile-grid > .col-12 { grid-column: span 12; }

@media (max-width: 1100px) {
  .profile-grid > .col-3,
  .profile-grid > .col-4,
  .profile-grid > .col-5,
  .profile-grid > .col-7,
  .profile-grid > .col-8 { grid-column: span 6; }
}
@media (max-width: 760px) {
  .profile-page { padding: 0 12px; }
  .profile-grid > [class*="col-"] { grid-column: span 12; }
}

.game-head, .game-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.game-head h2 { margin: 0 0 12px; }
.game-card-head h3 { margin: 0 0 8px; }

.profile-card { border: 1px solid var(--border, #ddd); border-radius: 10px; padding: 16px 18px; }
.profile-card h3 { margin: 0 0 8px; }
.profile-muted { color: var(--muted, #888); font-size: 0.9rem; }
.profile-code {
  font-size: 2rem; letter-spacing: 0.35em; font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 12px 0;
}
.profile-code-label { margin-bottom: 4px; }


.profile-dl { margin: 0; display: grid; gap: 10px; }
.profile-dl > div { display: grid; grid-template-columns: 140px 1fr; gap: 8px; align-items: baseline; }
.profile-dl dt { margin: 0; color: var(--muted, #888); font-size: 0.9rem; }
.profile-dl dd { margin: 0; word-break: break-word; }
.profile-steps { margin: 10px 0 16px; padding-left: 1.25rem; line-height: 1.45; }
.profile-steps li { margin: 0.4rem 0; }
.profile-action-link {
  display: inline-block; text-decoration: none; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--border, #ddd);
}

/* ---------------------------------------------------------- ТГ Входящие */
.tgi-page { max-width: 980px; margin: 0 auto; padding: 16px; }
.tgi-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tgi-head h2 { margin: 0; flex: 1; }
.tgi-actions { display: flex; gap: 8px; align-items: center; }

.tgi-tiles { display: grid; gap: 8px; margin: 14px 0 20px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tgi-tile { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px; background: var(--card); }
.tgi-tile-k { font-size: 12px; color: var(--muted); }
.tgi-tile-v { font-size: 18px; font-weight: 600; }
/* Строка прогресса: она нужна, только пока прогон идёт, и не должна спорить
   за внимание с самим значением — отсюда мелкий кегль и приглушённый цвет. */
.tgi-tile-sub { font-size: 11px; color: var(--muted); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tgi-tile.accent { border-color: var(--accent); }
.tgi-tile.warn { border-color: #d9822b; }
.tgi-tile.warn .tgi-tile-v { color: #d9822b; }

.tgi-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  margin-bottom: 16px; background: var(--card); }
.tgi-card-warn { border-color: #d9822b; }
.tgi-card-head h3 { margin: 0 0 4px; }
.tgi-card-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.tgi-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tgi-btn { border: 1px solid var(--border); background: transparent; color: inherit;
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.tgi-btn.primary { border-color: var(--accent); color: var(--accent); font-weight: 600; }
/* «Не следить» — действие редкое и с последствиями: не должно выглядеть
   равноправным с разбором, но и прятать его в меню незачем. */
.tgi-btn.quiet { color: var(--muted); border-style: dashed; margin-left: auto; }
.tgi-btn:hover { background: var(--hover); }

.tgi-runpick { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.tgi-runpick select { margin-left: 6px; font-size: 13px; }
/* Пока применяется — экран не должен выглядеть рабочим: молчащая кнопка
   читается как «не сработало», и человек жмёт ещё раз. */
.tgi-busy { opacity: .55; pointer-events: none; }
.tgi-contact { white-space: nowrap; }
.tgi-link { border: 0; background: none; color: var(--muted); cursor: pointer;
  padding: 0 2px; font-size: 12px; }
.tgi-link:hover { color: var(--accent); }
.tgi-merge { display: inline-flex; gap: 4px; align-items: center; }
.tgi-merge-pick { font-size: 12px; max-width: 220px; }

.tgi-section { margin-bottom: 14px; }
.tgi-section h4 { margin: 0 0 6px; font-size: 14px; }
.tgi-items { list-style: none; margin: 0; padding: 0; }
.tgi-item { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.tgi-item:first-child { border-top: none; }
.tgi-item-body { flex: 1; min-width: 0; }
.tgi-item-text { font-size: 14px; line-height: 1.45; }
.tgi-item-tools { display: none; gap: 6px; margin-top: 6px; align-items: center; }
.tgi-item:hover .tgi-item-tools, .tgi-item:focus-within .tgi-item-tools { display: flex; }
.tgi-mini { border: 1px solid var(--border); background: transparent; color: var(--muted);
  border-radius: 6px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.tgi-mini:hover { color: inherit; background: var(--hover); }
.tgi-dest { font-size: 12px; padding: 2px 4px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent; color: inherit; }

.tgi-badge { font-size: 11px; border: 1px solid var(--border); border-radius: 5px;
  padding: 0 5px; color: var(--muted); }
/* «тянется с …» / «повтор ×N» — служебная пометка о возрасте пункта: должна
   читаться боковым зрением, а не спорить за внимание с текстом пункта. */
.tgi-badge.quiet { border-style: dashed; opacity: .75; }
.tgi-who { color: var(--muted); }
.tgi-due { font-weight: 600; }
.tgi-due.soft { font-weight: 400; color: var(--muted); }
.tgi-asof { font-size: 12px; color: var(--muted); }

.tgi-auto { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--hover); }
.tgi-auto h5 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.tgi-item-stale .tgi-item-text { opacity: .65; text-decoration: line-through; }
.tgi-item-deferred .tgi-item-text { opacity: .6; }

.tgi-brief { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  margin-bottom: 12px; background: var(--hover); }
.tgi-brief-body { font-size: 14px; line-height: 1.5; }
.tgi-brief-body :first-child { margin-top: 0; }
.tgi-brief-body :last-child { margin-bottom: 0; }
.tgi-brief-actions { display: flex; gap: 8px; margin-top: 10px; }
/* Чекбоксы у пунктов сводки — маленькие, инлайн с текстом, не отдельные
   карточки-строки, как было в очереди пунктов до compose_card. */
.tgi-brief-body li.md-task { list-style: none; margin: 2px 0; }
.tgi-brief-body li.md-task label { display: flex; align-items: flex-start; gap: 6px;
  cursor: pointer; }
.tgi-brief-body li.md-task input.md-task-cb { width: 14px; height: 14px; margin: 3px 0 0;
  flex: none; accent-color: var(--accent, #4a7dfc); }
.tgi-brief-body li.md-task input.md-task-cb:not(:checked) + span { opacity: .55;
  text-decoration: line-through; }
.tgi-raw { margin-top: 4px; }
.tgi-raw summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; }
.tgi-raw summary:hover { color: inherit; }
.tgi-raw[open] summary { margin-bottom: 8px; }

.tgi-empty { color: var(--muted); padding: 16px 0; }
.tgi-warn { color: #d9822b; margin: 4px 0 0; }
.tgi-log { width: 100%; border-collapse: collapse; font-size: 13px; }
.tgi-log th, .tgi-log td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.tgi-log th { color: var(--muted); font-weight: 500; }
.tgi-mistakes { font-size: 13px; color: var(--muted); }

@media (max-width: 640px) {
  .tgi-item-tools { display: flex; }
  .tgi-card-actions .tgi-btn { flex: 1; }
}
.tgi-tile.clickable { cursor: pointer; }
.tgi-tile.clickable:hover { border-color: var(--accent); }
.tgi-tile.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tgi-mini.accent { color: var(--accent); border-color: var(--accent); }
.tgi-hint { font-size: 12px; color: var(--muted); margin: 0 0 6px; }

/* --- Контракт недели -------------------------------------------------- */

.contract-badge {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--chip-bg, rgba(0, 0, 0, 0.06));
  white-space: nowrap;
  cursor: pointer;
}

.contract-badge:hover {
  color: var(--fg, inherit);
}

/* Отставание от собственного графика — единственное, что в шапке краснеет. */
.contract-badge--behind {
  color: #b3261e;
  background: rgba(179, 38, 30, 0.12);
}

.contract-live {
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.contract-live--behind {
  border-color: rgba(179, 38, 30, 0.45);
}

.contract-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.contract-goal {
  font-weight: 600;
}

.contract-days,
.contract-stake {
  font-size: 0.82rem;
  color: var(--muted);
}

.contract-stake {
  margin-top: 8px;
}

.contract-note {
  margin: 8px 0 0;
  font-size: 0.85rem;
}

.contract-options {
  margin: 8px 0;
  padding-left: 20px;
  font-size: 0.85rem;
}

.contract-form {
  margin: 12px 0;
}

.contract-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.contract-form label,
.contract-note-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.contract-note-label {
  margin-top: 10px;
}

.contract-form input[type="number"] {
  width: 100px;
}

.contract-debt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(179, 38, 30, 0.1);
}

.contract-debt-sum {
  font-weight: 600;
}

/* Заработанная награда — противоположность долгу и выглядеть должна так же
   заметно: иначе выигранная неделя проходит незамеченной. */
.contract-reward {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(47, 158, 68, 0.12);
}

/* Обещание словами — то, под чем подписывались. Читается первым. */
.contract-pledge {
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.45;
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 3px solid var(--accent, #4a7dfc);
}

.contract-kr {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.contract-form textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.4;
  resize: vertical;
}

.contract-titles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.contract-title {
  font-size: 0.82rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chip-bg, rgba(0, 0, 0, 0.06));
}

/* Колонки, а не space-between: даты и ветки должны стоять друг под другом
   независимо от длины названия — та же причина, что у .skill-sub. */
.contract-hist-row {
  display: grid;
  grid-template-columns: 24px 96px 1fr;
  gap: 8px;
  align-items: baseline;
  font-size: 0.84rem;
  padding: 4px 0;
}

.contract-hist-week {
  color: var(--muted);
}

/* --- Дерево навыков --------------------------------------------------- */

/* Ветки идут колонками, а не лентой: дерево должно читаться одним экраном,
   иначе «что дальше» не видно без скролла и карта перестаёт быть картой. */
.tree-branches, .tree-full {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px 24px;
  align-items: start;
}

.tree-branch {
  margin-bottom: 18px;
}

.tree-branch-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.tree-branch-count {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
}

.tree-node {
  border-left: 2px solid var(--border, rgba(0, 0, 0, 0.12));
  padding: 8px 0 8px 12px;
  margin-bottom: 6px;
}

.tree-node--opened {
  border-left-color: #2f9e44;
}

/* Компактный ряд — одна строка: карта должна читаться сканированием сверху
   вниз, а не чтением. Всё объясняющее живёт на отдельной странице. */
.tree-node--compact {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 5px 0 5px 12px;
  margin-bottom: 0;
  font-size: 0.88rem;
}
.tree-node--compact .tree-label { font-weight: 500; }
.tree-node--compact .tree-rank {
  margin: 0;
  font-size: 0.72rem;
  white-space: nowrap;
}

/* Туман: узел не назван и не объяснён. Пунктир вместо сплошной черты — это
   не «закрыто», а «неизвестно, что там». */
.tree-node--fog {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  padding: 5px 0 5px 12px;
  margin-bottom: 0;
  border-left-style: dashed;
  opacity: 0.4;
  font-size: 0.88rem;
  user-select: none;
}

.tree-fog-note {
  margin: 4px 0 0 32px;
  font-size: 0.75rem;
  color: var(--muted);
}

.tree-head {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 8px;
  align-items: baseline;
}

.tree-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.tree-tier,
.tree-cross {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.tree-why {
  grid-column: 2;
  margin: 4px 0 0 28px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.tree-rank {
  display: inline-block;
  margin: 6px 0 0 28px;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip-bg, rgba(0, 0, 0, 0.06));
}

.tree-you {
  margin: 4px 0 0 28px;
  font-size: 0.85rem;
}

.tree-next,
.tree-locked {
  margin: 2px 0 0 28px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* --- Отложенные -------------------------------------------------------- */

/* Снуз и блокер видно прямо в списке: отложенное, о котором не напоминают,
   перестаёт существовать. */
.task-defer {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--muted);
  background: var(--chip-bg, rgba(0, 0, 0, 0.06));
}

.snooze-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.snooze-btn {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.15));
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.snooze-btn:hover {
  color: var(--fg, inherit);
  border-color: var(--muted);
}

/* --- Анти-залипание --------------------------------------------------- */

.task-stale {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--muted);
  background: var(--chip-bg, rgba(0, 0, 0, 0.06));
}

/* Две недели без движения — это уже не «забыл», а решение не делать. */
.task-stale--hard {
  color: #b3261e;
  background: rgba(179, 38, 30, 0.12);
}

.detail-stale {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(179, 38, 30, 0.08);
}

.detail-stale-head {
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.detail-stale-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-stale-btn {
  font-size: 0.78rem;
  padding: 4px 10px;
}

.detail-stale-result:not(:empty) {
  margin-top: 8px;
  font-size: 0.82rem;
}

/* --- Дерево: уровень навыка ------------------------------------------- */

.tree-skill {
  margin: 0 0 12px;
  padding: 10px 0 10px 12px;
  border-left: 2px solid var(--border, rgba(0, 0, 0, 0.12));
}

.tree-skill--opened {
  border-left-color: #2f9e44;
}

/* Закрытый навык приглушён, но «что даёт» читается: именно оно объясняет,
   зачем вообще идти в эту сторону. */
.tree-skill--closed {
  opacity: 0.72;
}

.tree-skill-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.tree-skill-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.tree-skill-nodes {
  margin-top: 8px;
  padding-left: 10px;
}

/* Свёрнутый навык: видна структура, а не текст. */
.tree-skill > summary {
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
  list-style: none;
}

.tree-skill > summary::-webkit-details-marker {
  display: none;
}

.tree-skill > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.8rem;
}

.tree-skill[open] > summary::before {
  content: "▾";
}

.tree-skill .tree-mark {
  font-size: 0.8rem;
}

/* Приватность записи: флаг «видна только автору и админу» (см. _can_view_audio). */
.audio-private-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted, #6b7280);
  cursor: pointer;
}
.audio-private-row input { margin: 0; }

/* Расход LLM (#/settings/llm) — таблица токенов и денег */
.llm-usage-scroll { overflow-x: auto; }
.llm-usage-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.llm-usage-table th,
.llm-usage-table td { padding: 6px 10px; border-bottom: 1px solid var(--border, #e3e3e3); vertical-align: top; text-align: left; }
.llm-usage-table th { font-weight: 600; white-space: nowrap; }
.llm-usage-table .num { text-align: right; white-space: nowrap; }
.llm-usage-table tfoot th { border-top: 2px solid var(--border, #e3e3e3); border-bottom: none; }
.llm-usage-table .muted { font-size: 11px; }
.llm-usage-summary { margin-top: 16px; }
.llm-usage-summary h3 { margin: 0 0 6px; font-size: 14px; }
.llm-usage-summary ul { margin: 0; padding-left: 18px; line-height: 1.7; }
.llm-usage-transcribe { margin-top: 22px; }
.llm-usage-transcribe h3 { margin: 0 0 8px; font-size: 14px; }
.llm-usage-transcribe h4 { margin: 14px 0 4px; font-size: 13px; font-weight: 600; }
.llm-usage-details { margin-top: 8px; }
.llm-usage-details summary { cursor: pointer; font-size: 13px; }


/* Строка прогресса проактивной раскладки над списком записей */
.prep-status { margin: 8px 0 12px; padding: 8px 10px; border-radius: 6px;
  background: rgba(128,128,128,.07); font-size: 13px; }
.prep-head { font-weight: 600; margin-bottom: 4px; }
.prep-row { padding: 2px 0; display: flex; align-items: baseline; gap: 6px; }
.prep-text { flex: 1; min-width: 0; }
.prep-dismiss { flex: none; border: 0; background: none; padding: 0 4px; cursor: pointer;
  font-size: 16px; line-height: 1; color: var(--muted, #888); opacity: .4; }
.prep-row:hover .prep-dismiss, .prep-dismiss:focus-visible { opacity: 1; }
.prep-dismiss:hover { color: #d1544f; }
.prep-schedule { margin: 4px 0 8px; font-size: 13px; color: var(--muted, #888); }
.prep-row a { text-decoration: none; }
.prep-row a:hover { text-decoration: underline; }
.prep-tail { color: var(--muted, #888); }
.prep-fail { color: #d1544f; }
.prep-wait { color: var(--muted, #888); }


/* Ежедневник в профиле: настройки дня — узкая колонка полей, а не форма-простыня */
.dp-fields { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.dp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dp-row input[type="time"], .dp-row select { max-width: 150px; }
.dp-switch { justify-content: flex-start; gap: 8px; }
.dp-switch input { margin: 0; }

/* ── Дерево задач + гантт ─────────────────────────────────────────────────── */
/* Планирование идёт деревом: проект → задача → подзадача, справа — сроки.
   Строки левой и правой колонок держатся на одной высоте (--tree-row), иначе
   полоска уезжает от своей задачи. */
.tree-wrap { --tree-row: 30px; --gantt-day: 26px; margin-top: 8px; }
.tree-hint {
  display: flex; flex-wrap: wrap; gap: 14px; padding: 6px 10px; margin-bottom: 6px;
  color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border);
}
.tree-hint b { color: var(--text); font-weight: 600; }
.tree-grid { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; }
.tree-col { flex: 0 0 min(52vw, 620px); min-width: 320px; }
.app-content.task-detail-open .tree-col { flex-basis: min(46vw, 560px); }
.gantt-col { flex: 1 0 auto; border-left: 1px solid var(--border); position: relative; }

.tree-row {
  display: flex; align-items: center; gap: 6px; height: var(--tree-row);
  padding: 0 6px; border-radius: 5px; cursor: pointer; white-space: nowrap;
}
.tree-row:hover { background: var(--surface2); }
.tree-row.selected { background: var(--chip-active-bg); }
.tree-row--project { font-weight: 600; cursor: default; color: var(--muted); }
.tree-row--project:hover { background: transparent; }
/* Потоки: корень-сфера, строка потока и метка «шага нет».
   Вставший поток подсвечен слева — это главный сигнал слоя, его надо
   видеть боковым зрением, не вчитываясь. */
.tree-row--stream { font-weight: 500; }
.tree-row--stream .tree-title { color: var(--text); }
.tree-row--stalled { box-shadow: inset 2px 0 0 var(--stream-warn); }
/* Цвет активности потока (уточнено 17.09.2026):
   зелёный — идёт · жёлтый — пауза · серый — не сейчас.
   Рыжий не статус, а степень внимания: он выше зелёного по «посмотри сюда»,
   поэтому им светится только «шага нет». Красного в палитре нет вообще. */
:root { --stream-go: #3dd68c; --stream-pause: #f0d030; --stream-warn: #ff8c42; }
[data-theme="light"] {
  --stream-go: #1f9d55; --stream-pause: #ca8a04; --stream-warn: #ea580c;
}
.stream-mark {
  width: 18px; text-align: center; cursor: pointer; flex: 0 0 auto;
  border-radius: 4px; user-select: none; font-size: 12px; line-height: 1;
}
.stream-mark:hover { background: var(--surface2); }
.stream-mark--active { color: var(--stream-go); }
.stream-mark--paused { color: var(--stream-pause); }
.stream-mark--later,
.stream-mark--done,
.stream-mark--archived { color: var(--muted); }
.stream-gap {
  font-size: 11px; color: var(--stream-warn); border: 1px solid currentColor;
  border-radius: 4px; padding: 0 4px; flex: 0 0 auto;
}
.tree-row--loose { color: var(--muted); font-size: 12px; cursor: default; }
.tree-row--loose:hover { background: transparent; }
.tree-add--stream { width: auto; padding: 0 5px; font-size: 11px; }
/* Код потока. Моноширинный и не уже четырёх знаков: владелец хочет, чтобы
   коды выглядели одинаково, но правило «ровно четыре буквы» ещё не принято —
   ровную колонку даёт вёрстка, а не ограничение длины в базе. */
.stream-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; min-width: 4ch; text-align: center; flex: 0 0 auto;
  padding: 0 4px; border-radius: 4px;
  background: var(--surface2); color: var(--muted); letter-spacing: 0.04em;
}
/* Перетаскивание задач в дереве: тащим задачу, целимся в поток, сферу или
   «Вне потоков». Подсветка цели обязана быть заметной — без неё не понять,
   куда именно упадёт задача в плотном списке. */
/* Два действия вверху карточки: закрыть и отменить. Они же есть в селекте
   статуса, но там их надо искать — а это два самых частых исхода задачи. */
.detail-top-actions { display: flex; gap: 8px; padding: 10px 14px 0; }
/* Селектор подробнее общего `button{background:var(--accent)}` — иначе действия
   выглядят как главная кнопка формы и перетягивают на себя всё внимание. */
.task-detail-body .detail-top-actions button {
  flex: 1 1 0; padding: 6px 10px; border-radius: 6px; font-size: 13px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); cursor: pointer; font-weight: 500;
}
.task-detail-body .detail-top-actions button:disabled { opacity: 0.45; cursor: default; }
.task-detail-body .detail-done-btn:hover { border-color: var(--stream-go); color: var(--stream-go); }
.task-detail-body .detail-cancel-btn:hover { border-color: var(--stream-warn); color: var(--stream-warn); }
.task-detail-body .detail-reopen-btn:hover { border-color: var(--accent); color: var(--accent); }
.sphere-letter {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px;
  background: var(--surface2); color: var(--muted); font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.tree-row--dragging { opacity: 0.45; }
.tree-row--droptarget {
  background: var(--chip-active-bg);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.stream-panel-tasks { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.stream-panel-task {
  display: flex; align-items: center; gap: 6px; padding: 3px 4px;
  border-radius: 5px; cursor: pointer; white-space: nowrap; overflow: hidden;
}
.stream-panel-task:hover { background: var(--surface2); }
/* Панель предложенных шагов: строки редактируемые — поправить формулировку
   здесь дешевле, чем переименовывать заведённую задачу. */
.stream-steps {
  margin: 4px 0 8px 46px; padding: 8px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); display: flex;
  flex-direction: column; gap: 6px; max-width: 720px;
}
.stream-step { display: flex; align-items: center; gap: 8px; }
.stream-step-title {
  flex: 1 1 auto; background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; font-size: 13px;
}
.stream-steps-actions { display: flex; gap: 8px; }
.stream-steps-actions button {
  padding: 3px 10px; border-radius: 4px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); cursor: pointer; font-size: 12px;
}
.stream-steps-actions button:hover:not(:disabled) { border-color: var(--accent); }
.stream-ai { font-size: 12px; }
.tree-row--project .tree-add { width: auto; padding: 0 6px; }
.tree-title { overflow: hidden; text-overflow: ellipsis; }
.tree-row--done .tree-title { text-decoration: line-through; color: var(--muted); }
.tree-id { color: var(--muted); font-size: 11px; }
.tree-twist {
  width: 16px; text-align: center; color: var(--muted); background: none;
  border: 0; cursor: pointer; font-size: 11px; padding: 0;
}
.tree-add {
  width: 20px; height: 20px; line-height: 18px; text-align: center; padding: 0;
  border: 1px solid var(--border); border-radius: 4px; background: var(--surface);
  color: var(--muted); cursor: pointer; opacity: 0; flex: 0 0 auto;
}
.tree-row:hover .tree-add, .tree-add:focus { opacity: 1; }
.tree-add:hover { color: var(--text); border-color: var(--accent); }
.tree-new { flex: 1 1 auto; min-width: 120px; }
.tree-new input {
  width: 100%; background: var(--surface2); color: var(--text);
  border: 1px solid var(--accent); border-radius: 4px; padding: 2px 6px; font-size: 13px;
}
.tree-menu {
  position: absolute; z-index: 40; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px; box-shadow: 0 6px 18px var(--fab-shadow); min-width: 190px;
}
.tree-menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  color: var(--text); padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 13px;
}
.tree-menu button:hover { background: var(--surface2); }
.tree-menu kbd {
  float: right; color: var(--muted); font-size: 11px; border: 1px solid var(--border);
  border-radius: 3px; padding: 0 4px;
}

.gantt-head { display: flex; height: var(--tree-row); align-items: flex-end; }
.gantt-day {
  flex: 0 0 var(--gantt-day); text-align: center; font-size: 10px; color: var(--muted);
  border-left: 1px solid var(--border); box-sizing: border-box;
}
.gantt-day--off { background: var(--surface2); }
.gantt-day--today { color: var(--accent); font-weight: 700; }
.gantt-row { position: relative; height: var(--tree-row); }
.gantt-row .gantt-grid { position: absolute; inset: 0; display: flex; }
.gantt-bar {
  position: absolute; top: 6px; height: 16px; border-radius: 4px; opacity: 0.9;
  font-size: 10px; line-height: 16px; padding: 0 5px; box-sizing: border-box;
  color: #0f1419; overflow: hidden; white-space: nowrap;
}
.gantt-bar--A { background: var(--a); }
.gantt-bar--B { background: var(--b); }
.gantt-bar--C { background: var(--c); }
.gantt-bar--D { background: var(--muted); }
.gantt-bar--overdue { outline: 2px solid var(--a); }
.gantt-day--month { border-left: 1px solid var(--muted); color: var(--text); }

/* ---------------------------------------------------------------- Суфлёр --
   Пульт записи ролика: слева карта блоков с таймингом, справа сцена
   (что говорю прямо сейчас) и вопросы, всплывшие по ходу дубля. */
.sfl-page { display: flex; flex-direction: column; height: calc(100vh - 108px); min-height: 420px; }
.sfl-bar {
  display: flex; align-items: center; gap: 12px; padding: 8px 4px 12px;
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.sfl-select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; max-width: 340px; font-size: 14px;
}
.sfl-status { font-size: 12px; color: var(--muted); }
.sfl-status.bad { color: var(--a); }
.sfl-clock { margin-left: auto; display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.sfl-clock b { font-size: 28px; font-weight: 600; }
.sfl-clock span { font-size: 13px; color: var(--muted); }
.sfl-clock.over b { color: var(--a); }
.sfl-go {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.sfl-go:hover { filter: brightness(1.08); }
.sfl-go.rec { background: var(--a); }

.sfl-split { flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, 47fr) minmax(0, 53fr); min-height: 0; }
.sfl-blocks { overflow-y: auto; padding: 12px 16px 12px 0; display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--border); }
.sfl-side { display: flex; flex-direction: column; min-height: 0; }
.sfl-stage { flex: 1 1 auto; overflow-y: auto; padding: 16px 4px 16px 20px; display: flex; flex-direction: column; gap: 12px; }

.sfl-blk {
  display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: start;
  padding: 10px 12px; border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.sfl-blk:hover { background: var(--surface); }
.sfl-blk.done { opacity: .5; }
.sfl-blk.now { background: var(--surface); border-color: var(--b); opacity: 1; }
.sfl-blk.edit { cursor: default; background: var(--surface); border-color: var(--border); align-items: start; }
.sfl-num { font-size: 18px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.sfl-blk.now .sfl-num { color: var(--b); }
.sfl-blk.done .sfl-num { color: var(--ok); }
.sfl-num span { display: block; font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.sfl-body h3 { margin: 0 0 5px; font-size: 16px; line-height: 1.25; }
.sfl-blk.now .sfl-body h3 { font-size: 18px; }
.sfl-body ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.45; color: var(--text); }
.sfl-body ul li { margin: 1px 0; }
.sfl-line {
  margin: 7px 0 0; padding: 8px 11px; background: var(--surface2); border-radius: 8px;
  border-left: 3px solid var(--b); font-size: 14px; line-height: 1.4;
}
.sfl-ex { display: flex; gap: 8px; align-items: baseline; margin-top: 6px; font-size: 13px; color: var(--muted); }
.sfl-ex-kind {
  flex: 0 0 auto; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: var(--surface2); color: var(--muted);
}
.sfl-ex-kind.quote { color: var(--b); }
.sfl-ex em { color: var(--muted); font-style: normal; opacity: .8; }
.sfl-ex.edit { display: grid; grid-template-columns: 90px 1fr 130px 28px; gap: 6px; align-items: start; }
.sfl-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 17px; line-height: 1; }
.sfl-x:hover { color: var(--a); }

.sfl-blk.edit textarea, .sfl-title-in, .sfl-sec, .sfl-mini, .sfl-kb-row input {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 9px; font: inherit; font-size: 14px;
}
.sfl-blk.edit textarea { resize: vertical; line-height: 1.4; }
.sfl-title-in { font-weight: 600; margin-bottom: 6px; }
.sfl-sec { font-size: 12px; padding: 3px 5px; margin-top: 3px; }
.sfl-mini { font-size: 12px; padding: 5px 7px; }
.sfl-lbl { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 9px 0 4px; }
.sfl-ex-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.sfl-kb { margin-top: 10px; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.sfl-kb-row { display: flex; gap: 6px; }
.sfl-kb-res { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 220px; overflow-y: auto; }
.sfl-kb-hit {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 9px; cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 2px;
}
.sfl-kb-hit:hover { border-color: var(--accent); }
.sfl-kb-hit b { font-size: 13px; }
.sfl-kb-hit span { font-size: 12px; color: var(--muted); }

.sfl-eyebrow { display: flex; gap: 12px; align-items: center; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sfl-stage h2 { margin: 0; font-size: clamp(19px, 2vw, 27px); line-height: 1.2; }
.sfl-say {
  margin: 0; padding: 13px 17px; background: var(--surface); border-radius: 12px;
  border-left: 4px solid var(--b); font-size: clamp(18px, 1.9vw, 26px); line-height: 1.32; font-weight: 500;
}
.sfl-points { margin: 0; padding-left: 20px; font-size: clamp(15px, 1.4vw, 19px); line-height: 1.5; }
.sfl-points li { margin: 4px 0; }
.sfl-hint { color: var(--muted); font-size: 13px; margin: 0; }
.sfl-hint.bad { color: var(--a); }
.sfl-tally { display: inline-flex; align-items: center; gap: 6px; color: var(--a); font-weight: 600; }
.sfl-tally i { width: 9px; height: 9px; border-radius: 50%; background: var(--a); display: inline-block; }
.sfl-count { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.sfl-count-n { font-size: clamp(80px, 15vw, 170px); font-weight: 700; line-height: .9; color: var(--b); font-variant-numeric: tabular-nums; }
.sfl-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.sfl-checks li { display: flex; gap: 10px; align-items: baseline; font-size: 15px; padding-bottom: 7px; border-bottom: 1px solid var(--border); }
.sfl-checks li:last-child { border-bottom: 0; }
.sfl-checks b { font-size: 11px; color: var(--b); font-weight: 500; font-variant-numeric: tabular-nums; }

.sfl-notes { flex: 0 0 auto; max-height: 36vh; display: flex; flex-direction: column; gap: 8px; padding: 12px 4px 8px 20px; border-top: 1px solid var(--border); }
.sfl-notes form { display: flex; gap: 8px; }
.sfl-notes input {
  flex: 1 1 auto; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 11px; font: inherit; font-size: 14px;
}
.sfl-qlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; overflow-y: auto; }
.sfl-qlist li { display: grid; grid-template-columns: 48px 1fr auto auto; gap: 8px; align-items: baseline; font-size: 14px; }
.sfl-qlist time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sfl-qlist button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 3px; }
.sfl-qlist button:hover { color: var(--accent); }
.sfl-empty { color: var(--muted); font-size: 13px; display: block !important; }

@media (max-width: 900px) {
  .sfl-split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .sfl-blocks { border-right: 0; border-bottom: 1px solid var(--border); padding-right: 0; }
  .sfl-stage, .sfl-notes { padding-left: 4px; }
}
.sfl-ex-count { margin-top: 6px; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

/* --- Шаблоны задач и роли в настройках (PHASE15/16) ---------------------- */

.tpl-admin-list,
.roles-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.tpl-admin-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.tpl-admin-item.selected { border-color: var(--accent, #4c8bf5); }
.tpl-admin-item.is-inactive { opacity: 0.55; }

.tpl-admin-detail,
.role-detail { border-top: 1px solid var(--border); padding-top: 12px; }

.tpl-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.tpl-preset-row label { flex: 1 1 160px; }

#tpl-json {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* Заготовка в форме создания: человек видит, что получит, до сохранения. */
.create-preset-box {
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.create-preset-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.create-preset-title { font-weight: 600; font-size: 13px; }

.create-preset-checklist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0;
  font-size: 13px;
}

.create-preset-item { display: flex; gap: 4px; align-items: center; }
.create-preset-item input { flex: 1; }

.detail-recurrence-row #detail-recurrence-interval { width: 64px; }

/* Быстрый путь «⚡ Из заготовки»: список заготовок прямо над задачами. */
.preset-quick { position: relative; display: inline-block; }

.preset-quick-menu {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0;
  min-width: 260px;
  margin-top: 4px;
  padding: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.preset-quick-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 6px 8px;
  background: none;
  border: none;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
}

.preset-quick-item:hover { background: var(--border); }

.detail-source-link { display: inline-block; margin-bottom: 6px; }

.recurrence-days { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; }
.recurrence-days label { display: flex; align-items: center; gap: 3px; }

/* Строки редактора полей и статусов шаблона. */
.tpl-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }

.tpl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tpl-row input[type="text"], .tpl-row input:not([type]) { flex: 1 1 120px; min-width: 100px; }
.tpl-row .tpl-row-req { display: flex; align-items: center; gap: 3px; font-size: 12px; }

/* Метка приоритета в дереве работает галочкой: клик отмечает задачу сделанной,
   повторный — возвращает в работу. Зона намеренно шире самого значка — по
   двум символам мышью не попасть, а отмечают ими подряд по списку. */
.tree-row .task-prio {
  cursor: pointer;
  padding: 2px 6px;
  margin: -2px 0;
  border-radius: 6px;
  user-select: none;
}

.tree-row .task-prio:hover,
.tree-row .task-prio:focus-visible {
  background: var(--border);
  outline: none;
}

.tree-row .task-prio--done { opacity: 0.75; }

/* Слайд суфлёра: зачин крупно, полная фраза под ним приглушённо. */
.sfl-say-pair { display: flex; flex-direction: column; gap: 4px; }
.sfl-dots { color: var(--b); opacity: .7; }
.sfl-full {
  margin: 0; padding: 9px 17px; font-size: clamp(14px, 1.25vw, 17px); line-height: 1.45;
  color: var(--muted); border-left: 4px solid transparent;
}
.sfl-points b { color: var(--text); font-weight: 600; }
.sfl-points li { color: var(--muted); }
.sfl-manual { color: var(--b); }
.sfl-nav { display: flex; gap: 10px; align-items: center; margin-top: auto; padding-top: 12px; }
.sfl-nav-btn, .sfl-nav-go {
  border: 1px solid var(--border); border-radius: 9px; padding: 10px 16px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.sfl-nav-go { margin-left: auto; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; padding: 11px 26px; font-size: 15px; }
.sfl-nav-btn:hover { border-color: var(--accent); }
.sfl-nav-go:hover { filter: brightness(1.08); }
.sfl-nav-btn[disabled], .sfl-nav-go[disabled] { opacity: .4; cursor: default; }

/* Справка «Как снимать» — оверлей поверх пульта. */
.sfl-help {
  position: fixed; inset: 0; z-index: 60; background: var(--overlay);
  display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; overflow-y: auto;
}
.sfl-help-in {
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px;
  max-width: 820px; width: 100%; padding: 22px 26px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.sfl-help-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sfl-help-head h2 { margin: 0; font-size: 22px; }
.sfl-help-in h3 { margin: 20px 0 10px; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sfl-rigs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 640px; }
.sfl-rigs > div { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 5px 6px 6px; }
.sfl-rig-svg { width: 100%; height: auto; display: block; }
.sfl-rig-cap { font-size: 11px; line-height: 1.25; margin-top: 2px; }
.sfl-rig-cap.good { color: var(--ok); }
.sfl-rig-cap.bad { color: var(--muted); }
.sfl-bgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-width: 640px; margin: 8px 0 4px; }
.sfl-bgs a { display: block; text-decoration: none; color: inherit; }
.sfl-bgs img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.sfl-bgs span { display: block; font-size: 11px; line-height: 1.25; margin-top: 3px; }
.sfl-bgs em { display: block; color: var(--muted); font-style: normal; font-size: 10.5px; }
.sfl-bgs a:hover img { border-color: var(--accent, var(--muted)); }
.sfl-help-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; font-size: 14.5px; line-height: 1.5; }
.sfl-help-list b { color: var(--text); }

/* Проверка загруженного файла (renderFileCheck) */
.file-check { margin: 8px 0; font-size: 0.82rem; color: var(--muted); }
.file-check ul { margin: 4px 0 0 18px; padding: 0; }
.file-check li { word-break: break-word; }
.file-check details { margin-top: 4px; }
.file-check summary { cursor: pointer; }
.file-check.warn, .file-check.danger {
  padding: 8px 10px; border-radius: 8px; color: inherit;
  border: 1px solid #d97706; background: color-mix(in srgb, #d97706 8%, transparent);
}
.file-check.danger {
  border-color: var(--danger, #c0392b);
  background: color-mix(in srgb, var(--danger, #c0392b) 10%, transparent);
}
.file-check.warn .file-check-head { color: #b45309; font-weight: 600; }
.file-check.danger .file-check-head { color: var(--danger, #c0392b); font-weight: 600; }
.file-check-tip { margin-top: 6px; font-weight: 600; }

/* ── «Сегодня» → «🗓 Неделя»: план недели по уровням (week_plan.js) ── */
.plan-container--week .plan-header,
.plan-container--week .plan-add-btn,
.plan-container--week .plan-add-unplanned-btn,
.plan-container--week .plan-resend-btn,
.plan-container--week .plan-add-form { display: none; }

.plan-week-line {
  margin: 0 0 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.9rem;
}
.plan-week-line.hidden { display: none; }
.plan-week-mark { font-size: 0.85rem; }

.week-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.week-bar button { padding: 4px 10px; }
.week-title { font-size: 1.1rem; font-weight: 700; }
.week-state { font-size: 0.82rem; color: var(--muted); padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; }
.week-state.is-approved { color: var(--ok); border-color: var(--ok); }

.week-split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr) minmax(0, 6fr); }
.week-goals .plan-day-panel-body { max-height: calc((100vh - 280px) / 2); min-height: 120px; }
.week-okr-link { margin-left: auto; text-decoration: none; color: var(--accent); }

.wk-obj { font-weight: 600; font-size: 0.84rem; padding: 8px 4px 4px; }
.wk-kr {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "code title prog" "code meta prog";
  gap: 0 8px;
  align-items: center;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 0.84rem;
}
.wk-kr:hover { background: var(--surface2); }
.wk-kr.is-active { background: var(--chip-active-bg); }
.wk-kr-code { grid-area: code; color: var(--muted); font-variant-numeric: tabular-nums; }
.wk-kr-title { grid-area: title; cursor: pointer; line-height: 1.3; }
.wk-kr-meta { grid-area: meta; font-size: 0.74rem; color: var(--muted); }
.wk-warn { color: var(--b); }
.wk-kr-progress { grid-area: prog; display: inline-flex; align-items: center; gap: 2px; font-size: 0.78rem; color: var(--muted); }
.wk-kr-progress input { width: 52px; padding: 2px 4px; text-align: right; }
.wk-kr-progress.is-lagging input { border-color: var(--b); }

.wk-stream { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 4px 6px; border-radius: 6px; font-size: 0.84rem; }
.wk-stream:hover { background: var(--surface2); }
.wk-stream.is-active { background: var(--chip-active-bg); }
.wk-stream.is-quiet .wk-stream-title { color: var(--muted); }
.wk-stream-status { padding: 1px 2px; font-size: 0.76rem; max-width: 118px; }
.wk-stream-title { flex: 1; min-width: 0; cursor: pointer; }
.wk-stream-kw {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
}
.wk-flag { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.wk-flag--stalled { color: var(--a); }
.wk-later summary { cursor: pointer; font-size: 0.8rem; color: var(--muted); padding: 6px 4px; }
#week-streams-count.is-error { color: var(--b); font-weight: 600; }

.wk-carry { margin-bottom: 10px; padding: 8px; border: 1px dashed var(--b); border-radius: 8px; }
.wk-carry-title { font-size: 0.8rem; color: var(--b); margin-bottom: 4px; }
.wk-carry-row { display: flex; align-items: center; gap: 6px; padding: 3px 2px; font-size: 0.86rem; }
.wk-carry-row .wk-title { flex: 1; min-width: 0; cursor: pointer; }

.wk-tier { margin-bottom: 10px; padding: 6px; border-radius: 8px; border: 1px solid transparent; }
.wk-tier.is-over { border-color: var(--accent); background: var(--surface2); }
.wk-tier--1 { background: rgba(255, 140, 40, 0.07); }
.wk-tier-head { display: flex; align-items: baseline; gap: 6px; padding: 2px 4px 6px; }
.wk-tier-name { font-weight: 700; font-size: 0.9rem; }
.wk-tier-count { margin-left: auto; font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.wk-mark { font-size: 0.95rem; line-height: 1; }
.wk-mark--spare { color: var(--muted); font-weight: 700; }
.wk-list { list-style: none; margin: 0; padding: 0; min-height: 30px; }
.wk-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  user-select: none;
}
.wk-item:hover { border-color: var(--accent); }
.wk-item.dragging { opacity: 0.35; }
.wk-item .wk-title { flex: 1 1 160px; min-width: 0; cursor: pointer; font-size: 0.9rem; line-height: 1.35; }
.wk-item.is-done .wk-title { text-decoration: line-through; color: var(--muted); }
.wk-item.is-cancelled .wk-title { text-decoration: line-through; color: var(--muted); opacity: 0.7; }
.wk-meta { display: inline-flex; gap: 4px; align-items: center; font-size: 0.74rem; color: var(--muted); }
.wk-steps { white-space: nowrap; }
.wk-slot {
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.wk-drop-ph { height: 30px; margin-bottom: 4px; border: 2px dashed var(--accent); border-radius: 8px; }

.wk-tier-btns { display: inline-flex; gap: 2px; opacity: 0; }
.wk-item:hover .wk-tier-btns,
.wk-tree-row:hover .wk-tier-btns,
.wk-carry-row .wk-tier-btns { opacity: 1; }
.wk-tier-btn, .wk-remove, .wk-dismiss {
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
}
.wk-tier-btn:hover { border-color: var(--accent); }
.wk-remove, .wk-dismiss { border-color: transparent; background: none; }
.wk-remove:hover, .wk-dismiss:hover { color: var(--a); border-color: var(--a); }
.wk-prio { font-size: 0.72rem; font-weight: 700; color: var(--muted); min-width: 1em; text-align: center; }

.week-add-form { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.week-add-form input { flex: 1 1 180px; min-width: 0; }
.week-add-form select { flex: 0 1 170px; min-width: 0; }
.week-approve { padding: 8px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.wk-approve-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.85rem; }
.wk-approve-row input[type="number"] { width: 90px; }
.wk-approve-row .hidden { display: none; }
#week-approve-btn { margin-left: auto; }
.wk-contract { font-size: 0.84rem; padding: 6px 8px; border-radius: 6px; background: var(--surface2); }
.wk-note { font-size: 0.82rem; color: var(--ok); }

.week-tree-tools { padding: 8px 8px 0; }
.week-tree-tools input { width: 100%; box-sizing: border-box; }
.week-filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 1px 4px 1px 8px;
  border-radius: 999px;
  background: var(--chip-active-bg);
  color: var(--text);
  font-weight: 500;
  font-size: 0.76rem;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.week-filter.hidden { display: none; }
.week-filter button { padding: 0 4px; border: 0; background: none; color: var(--muted); cursor: pointer; }

@media (hover: none) {
  .wk-tier-btns { opacity: 1; }
}

@media (max-width: 1100px) {
  .week-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .week-split .week-goals { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
  .week-split { grid-template-columns: minmax(0, 1fr); }
  .week-goals .plan-day-panel-body { max-height: 40vh; }
  .wk-item .wk-title { flex-basis: 100%; order: 5; }
}

/* Неделя, правки 21.09.2026: KR — цель перетаскивания, компактные потоки,
   задачи в одну строку, быстрая задача рядом с поиском. */
.wk-kr.is-over { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--surface2); }
.wk-kr-code { font-weight: 700; color: var(--text); min-width: 2.2em; }
.wk-stream { flex-wrap: nowrap; gap: 4px; }
.wk-stream .dp-handle { cursor: grab; color: var(--muted); font-size: 0.8rem; }
.wk-stream-status {
  flex: 0 0 auto;
  width: 34px;
  max-width: 34px;
  padding: 1px 0;
  text-align: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.wk-stream-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-flag--kr { color: var(--accent); font-weight: 600; }
.wk-tree-row { flex-wrap: nowrap; }
.wk-tree-row .tree-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-tree-row .wk-tier-btns { display: none; }
.wk-tree-row:hover .wk-tier-btns { display: inline-flex; }
.week-tree-tools { display: flex; gap: 6px; }
.week-tree-tools #week-search { flex: 0 1 120px; width: auto; min-width: 70px; }
.week-quick-form { flex: 1 1 auto; display: flex; min-width: 0; }
.week-quick-form input { flex: 1; min-width: 0; width: 100%; box-sizing: border-box; }
@media (hover: none) {
  .wk-tree-row .wk-tier-btns { display: inline-flex; }
}

/* Плюсик у сферы и потока в деревьях «Набор задач» и «Неделя» (21.09.2026):
   открывает ту же строку ввода, что в «Задачах» (`startTreeInput`). */
.plan-day-tree-group { display: flex; align-items: center; gap: 6px; }
.plan-day-tree-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-day-tree-group:hover .tree-add { opacity: 1; }
.tree-head-add { margin-right: 4px; }
.plan-day-panel .tree-row--new { height: auto; min-height: 30px; padding-right: 6px; cursor: default; }
@media (hover: none) {
  .plan-day-tree-group .tree-add { opacity: 1; }
}
.tree-head-toggle { font-size: 11px; }
.plan-day-tree-group .tree-head-toggle { opacity: 0.7; }

/* Перетаскивание в дереве (22.09.2026): куда встанет задача. Пунктир —
   соседом, со сдвигом вправо и ↳ — подзадачей (`showTreeDrop` в app.js). */
.tree-drop-mark {
  position: fixed;
  z-index: 1001;
  height: 0;
  border-top: 2px dashed var(--accent);
  pointer-events: none;
}
.tree-drop-mark.is-nest { border-top-style: solid; }
.tree-drop-mark.is-nest::before {
  content: attr(data-hint);
  position: absolute;
  left: -2px;
  top: -11px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  transform: translateY(-50%);
  white-space: nowrap;
}
