/* Хаб проекта: рабочий трекер в духе Linear. Цвета из Design/tokens (тёплый
   грейдж, акцент clay), но интерфейс плотный: один шрифт Inter 13px, строки
   по 34px, узкий сайдбар, мелкие скругления. Cormorant Garamond только в
   логотипе. Жирного нет (самый тяжёлый вес 500), заглавных с разрядкой нет.
   Страница входа и стили публичны, здесь нет ничего секретного. */
:root {
  --paper: #ffffff;
  --canvas: #ece8e5;
  --greige-50: #f6f3f0;
  --greige-100: #efece8;
  --greige-200: #e7e3df;
  --greige-300: #ddd8d1;
  --greige-400: #d9d4cc;
  --greige-500: #b6afa6;
  --greige-600: #9a948c;
  --greige-700: #6e6a64;
  --greige-800: #4a4640;
  --greige-900: #34312c;
  --clay-100: #f0e4d6;
  --clay-200: #e9dccb;
  --clay-300: #dec5b0;
  --clay-500: #c8996f;
  --clay-600: #c07a3e;
  --clay-800: #8e5021;
  --danger: #8a3a2b;

  --text: var(--greige-900);
  --text-2: var(--greige-800);
  --text-3: var(--greige-700);
  --muted: var(--greige-600);
  --line: var(--greige-200);
  --line-2: var(--greige-300);
  --hover: rgba(52, 49, 44, .045);
  --hover-2: rgba(52, 49, 44, .075);
  --selected: rgba(192, 122, 62, .09);
  --focus: var(--clay-600);

  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-logo: "Cormorant Garamond", "Cormorant", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  --sidebar-w: 220px;
  --head-h: 44px;
  --topbar-h: 48px;
  --row-h: 34px;
  --gutter: 8px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --shadow-pop: 0 10px 30px rgba(52, 49, 44, .14), 0 2px 6px rgba(52, 49, 44, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--greige-100);
  color: var(--text);
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: 4px; }
::placeholder { color: var(--greige-500); opacity: 1; }
.icon, .state-icon { flex: none; display: block; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Оболочка ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.topbar { display: none; }
.main {
  min-width: 0; overflow: auto; overscroll-behavior: contain;
  margin: var(--gutter) var(--gutter) var(--gutter) 0;
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 8px;
}
.view { min-height: 100%; }

.sidebar { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 14px 8px 10px; }
.brand { padding: 2px 10px 16px; }
.brand-mark { font-family: var(--font-logo); font-weight: 500; font-size: 17px; line-height: 1.2; color: var(--text); }
.brand-sub { margin-top: 1px; font-size: 12px; color: var(--muted); }
.nav { display: grid; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px 0 10px; border-radius: 6px;
  color: var(--text-2); text-decoration: none; transition: background-color 120ms ease;
}
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--hover-2); }
.nav a[aria-current="page"] { background: rgba(52, 49, 44, .09); color: var(--text); font-weight: 500; }
.nav a[aria-current="page"] .icon { color: var(--text); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.account { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 8px 4px 2px 10px; }
.account-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.account .avatar {
  display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--greige-200); color: var(--text-2); font-size: 10px; font-weight: 500; line-height: 1;
}
.scrim { display: none; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--greige-400); border-radius: 6px; background: var(--paper); color: var(--text);
  font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms var(--ease-out);
}
.btn:hover { background: var(--greige-50); border-color: var(--greige-500); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; transform: none; }
.btn--primary { background: var(--greige-900); border-color: var(--greige-900); color: #fff; }
.btn--primary:hover { background: var(--greige-800); border-color: var(--greige-800); }
.btn--quiet { border-color: transparent; background: transparent; }
.btn--quiet:hover { background: var(--hover-2); border-color: transparent; }
.btn--danger { color: var(--danger); }
.btn--danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger-solid:hover { background: #77301f; border-color: #77301f; }
.btn--ghost { background: transparent; }
.btn--sm { height: 28px; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  transition: background-color 120ms ease, color 120ms ease;
}
.icon-btn:hover { background: var(--hover-2); color: var(--text); }

.seg { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--greige-400); border-radius: 7px; background: var(--paper); }
.seg-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border: 0; border-radius: 5px;
  background: transparent; color: var(--text-3); font-size: 12px; transition: background-color 120ms ease, color 120ms ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--greige-200); color: var(--text); font-weight: 500; }

.link-quiet { font-size: 12px; color: var(--muted); text-decoration: none; padding: 4px 6px; border-radius: 5px; }
.link-quiet:hover { color: var(--text); background: var(--hover-2); }

/* ---------- Шапка страницы и сводка ---------- */
.page-head {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--head-h); padding: 0 12px 0 20px; background: var(--paper); border-bottom: 1px solid var(--line-2);
}
.page-head h1 { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-actions { display: flex; align-items: center; gap: 8px; }
.status-line { padding: 14px 20px; color: var(--muted); }

.summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 28px; padding: 9px 20px;
  border-bottom: 1px solid var(--line); font-size: 12px;
}
.summary-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn-add .icon { margin-left: -2px; }
.summary-label { color: var(--muted); }
.summary-value { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.meter { position: relative; width: 44px; height: 4px; border-radius: 2px; background: var(--greige-200); overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: var(--clay-600); border-radius: 2px; }

.status-grid { display: grid; grid-template-columns: minmax(0, 1fr); }
.status-col { min-width: 0; }
@media (min-width: 1100px) {
  .status-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .status-col + .status-col { border-left: 1px solid var(--line); }
}

/* ---------- Группы ---------- */
.group-head {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 10px;
  background: var(--greige-50); border-bottom: 1px solid var(--line);
}
.group + .group .group-head { border-top: 1px solid var(--line); }
.group-toggle {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 26px; padding: 0 6px 0 2px;
  border: 0; border-radius: 5px; background: transparent; color: var(--text-2); font-size: 12px; font-weight: 500;
}
.group-toggle:hover { background: var(--hover-2); }
.group-toggle .icon-chevron { color: var(--muted); transform: rotate(90deg); transition: transform 150ms var(--ease-out); }
.group.is-collapsed .group-toggle .icon-chevron { transform: none; }
.group.is-collapsed .group-body { display: none; }
.group.is-collapsed .group-head { border-bottom-color: transparent; }
.group-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-count { font-size: 12px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.group-tools { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.group-tools .seg-btn span { display: none; }
.group-tools .seg-btn { padding: 0 6px; }
.group-add { opacity: 0; transition: opacity 120ms ease, background-color 120ms ease; }
.group-head:hover .group-add, .group-add:focus-visible { opacity: 1; }

.subhead {
  position: sticky; top: var(--head-h); z-index: 2; display: flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 12px; background: var(--greige-50); border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 500; color: var(--text-3);
}

/* ---------- Строка записи ----------
   Широкий экран: одна линия. Название не обрезается, пока есть место; начало
   описания стоит за ним и уходит первым: ему нужно не меньше 96px, иначе оно
   переносится на вторую строку линии и прячется (высота линии одна строка).
   Справа только дата и подпись статуса там, где она нужна. */
.row {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: var(--row-h); padding: 0 14px 0 12px;
  border-bottom: 1px solid var(--line); cursor: pointer; transition: background-color 80ms ease;
}
.row.is-open { background: var(--selected); }
.row:focus-within { background: var(--hover); }
.row.is-open:focus-within { background: var(--selected); }

.state {
  position: relative; display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; padding: 0;
  border: 0; border-radius: 5px; background: transparent; color: var(--muted);
}
button.state::after { content: ''; position: absolute; inset: -7px; }
button.state:active .state-icon { transform: scale(.88); }
.state-icon { transition: transform 120ms var(--ease-out); }
.state--in_progress, .state--now { color: var(--clay-600); }
.state--done, .state--accepted, .state--live { color: var(--clay-800); }
.state--plain { color: var(--greige-500); }
.state-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--greige-500); }

.row-main {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; align-self: stretch;
  padding: 0; border: 0; background: transparent; text-align: left; color: inherit;
}
.row-main:focus-visible { outline-offset: -2px; }
.row-line { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; height: 19px; overflow: hidden; line-height: 19px; }
.row-title { flex: 0 1 auto; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--text); }
.row-title--body { font-weight: 400; color: var(--text-2); }
.row-sub { flex: 1 1 0; min-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.row.is-done .row-title { color: var(--muted); font-weight: 400; text-decoration: line-through; text-decoration-color: var(--greige-500); }
.row-meta { display: none; }
.row-aside { flex: none; display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--muted); }
.row-state, .row-when, .row-author { white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-when { min-width: 44px; text-align: right; }
.row-state { min-width: 62px; }
.row-author { color: var(--greige-500); }
.row-empty {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; min-height: 44px; padding: 8px 14px 8px 42px;
  border-bottom: 1px solid var(--line); color: var(--muted);
}

/* ---------- Плашка черновиков ---------- */
.draft-bar {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 10px 4px 20px;
  background: #faf5ef; border-bottom: 1px solid var(--clay-200); color: var(--text-2);
}
.draft-bar-text { flex: 1; min-width: 0; }
.draft-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--clay-600); }
.draft-bar-btn { color: var(--clay-800); }
.draft-bar-btn:hover { background: rgba(192, 122, 62, .1); }
.draft-bar.is-filtering { background: var(--clay-100); }
.draft-bar-btn[aria-pressed="true"] { background: rgba(192, 122, 62, .12); }

/* ---------- Быстрое добавление: строка-поле в начале группы ---------- */
.add-form {
  display: flex; align-items: center; gap: 10px; height: var(--row-h); padding: 0 14px 0 15px;
  border-bottom: 1px solid var(--line); background: var(--greige-50); box-shadow: inset 2px 0 0 var(--clay-600);
}
.add-mark { color: var(--muted); display: inline-flex; }
.add-input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; color: var(--text); }
.add-input:focus-visible { outline: none; }
.add-error { flex: none; max-width: 50%; color: var(--danger); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.add-error:empty { display: none; }
.add-slot:not(:empty) + .rows .row-empty { display: none; }

/* ---------- Доска ---------- */
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px;
  padding: 12px 16px 16px; overflow-x: auto; align-items: start;
}
.board--compact { grid-auto-columns: minmax(0, 1fr); gap: 8px; overflow: visible; padding: 10px 10px 12px; border-bottom: 1px solid var(--line); }
.col {
  display: flex; flex-direction: column; gap: 6px; min-height: 120px; padding: 4px 6px 8px;
  background: var(--greige-50); border: 1px dashed transparent; border-radius: 8px;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.col.is-over { background: var(--clay-100); border-color: var(--clay-500); }
.col-head { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.col-head .state { width: 16px; height: 16px; }
.col-cards { display: grid; gap: 6px; }
.col-empty { padding: 6px 6px 2px; font-size: 12px; color: var(--greige-500); }
.card {
  display: grid; gap: 4px; padding: 8px 8px 8px 10px; background: var(--paper);
  border: 1px solid var(--line-2); border-radius: 7px; cursor: grab;
  box-shadow: 0 1px 1px rgba(52, 49, 44, .03);
  transition: border-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}
.card:hover { border-color: var(--greige-500); }
.card:active { cursor: grabbing; }
.card.is-dragging { opacity: .4; }
.card-title {
  min-width: 0; padding: 1px 0 0; border: 0; background: transparent; text-align: left;
  font-weight: 500; color: var(--text); line-height: 1.4; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card.is-done .card-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--greige-500); }
.card-sub {
  font-size: 12px; color: var(--muted); line-height: 1.4; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.card-meta:empty { display: none; }
.card-kind { font-size: 11px; color: var(--text-3); background: var(--greige-100); border-radius: 4px; padding: 1px 6px; }
.board--compact .card-sub { display: none; }

/* ---------- Боковая панель записи ---------- */
.panel {
  position: fixed; top: var(--gutter); right: var(--gutter); bottom: var(--gutter); z-index: 50;
  width: 420px; max-width: calc(100vw - 2 * var(--gutter));
  display: flex; flex-direction: column; background: var(--paper);
  border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow-pop);
  transform: translateX(calc(100% + 24px)); visibility: hidden;
  transition: transform 220ms var(--ease-out), visibility 0s linear 220ms;
}
.panel.is-open { transform: none; visibility: visible; transition-delay: 0s; }
.panel:focus { outline: none; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none;
  height: var(--head-h); padding: 0 8px 0 16px; border-bottom: 1px solid var(--line);
}
.panel-crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
.panel-crumbs .icon { color: var(--greige-500); }
.panel-kind { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.panel-form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 12px; }
.panel-draft {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; padding: 10px 12px;
  border-radius: 8px; background: #faf5ef; border: 1px solid var(--clay-200); font-size: 12.5px; color: var(--text-3); line-height: 1.45;
}
.panel-draft .draft-dot { margin-top: 6px; }
.panel-draft-body { display: grid; justify-items: start; gap: 8px; }
.panel-title {
  display: block; width: 100%; padding: 4px 0; border: 0; background: transparent; outline: none;
  font-size: 16px; font-weight: 500; line-height: 1.35; color: var(--text);
}
.panel-body {
  display: block; width: 100%; min-height: 72px; margin-top: 4px; padding: 4px 0; border: 0; background: transparent;
  outline: none; resize: none; overflow: hidden; font-size: 14px; line-height: 1.6; color: var(--text-2);
}
.panel-title:focus-visible, .panel-body:focus-visible { outline: none; box-shadow: inset 0 -1px 0 var(--line-2); border-radius: 0; }
.props { display: grid; gap: 1px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.prop-slot:empty { display: none; }
.prop { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; min-height: 32px; }
.prop-label { color: var(--muted); }
.prop-value { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; color: var(--text-2); }
.prop-input {
  width: 100%; max-width: 240px; height: 28px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px;
  background-color: transparent; color: var(--text); transition: background-color 120ms ease, border-color 120ms ease;
}
.prop-input:hover { background-color: var(--greige-50); border-color: var(--line-2); }
.prop-input:focus-visible { outline: none; border-color: var(--focus); background-color: var(--paper); }
select.prop-input {
  appearance: none; -webkit-appearance: none; padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none' stroke='%239a948c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.panel-foot { flex: none; padding: 10px 16px 12px; border-top: 1px solid var(--line); }
.panel-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.spacer { flex: 1; }
.panel-note { font-size: 12px; color: var(--muted); }
.confirm-text { color: var(--text); font-weight: 500; margin-right: 4px; }
.form-error { margin-bottom: 8px; color: var(--danger); font-size: 12px; line-height: 1.45; }
.form-error:empty { display: none; }

/* ---------- Меню и сообщение ---------- */
.menu {
  position: fixed; z-index: 60; min-width: 184px; max-width: calc(100vw - 16px); padding: 4px;
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow-pop);
  transform-origin: top right; animation: pop-in 120ms var(--ease-out);
}
@keyframes pop-in { from { opacity: 0; transform: scale(.97); } }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 28px; padding: 0 8px; border: 0; border-radius: 5px;
  background: transparent; color: var(--text); text-align: left; white-space: nowrap;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--greige-100); outline: none; }
.menu-item[aria-current="true"] { font-weight: 500; }
.menu-item .state { width: 16px; height: 16px; }
.menu-item--danger { color: var(--danger); }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--line); }

.toast {
  position: fixed; left: 50%; bottom: 16px; z-index: 70; max-width: calc(100vw - 32px);
  padding: 8px 12px; border-radius: 8px; background: var(--greige-900); color: #fff; font-size: 13px;
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none;
  transition: opacity 160ms ease, transform 160ms var(--ease-out);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Пустое состояние, ошибки ---------- */
.empty { display: grid; justify-items: start; gap: 10px; padding: 20px; color: var(--text-3); }

/* ---------- Документы ---------- */
.docs { display: grid; grid-template-columns: 260px minmax(0, 1fr); align-items: start; }
.docs-list {
  position: sticky; top: var(--head-h); overflow-y: auto; overscroll-behavior: contain;
  height: calc(100vh - 2 * var(--gutter) - 2px - var(--head-h)); height: calc(100dvh - 2 * var(--gutter) - 2px - var(--head-h));
  padding: 6px 6px 24px; border-right: 1px solid var(--line);
}
.docs-group + .docs-group { margin-top: 6px; }
.docs-group-title { display: flex; justify-content: space-between; align-items: center; height: 28px; padding: 0 8px; font-size: 12px; font-weight: 500; color: var(--muted); }
.docs-link {
  display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border-radius: 6px;
  color: var(--text-2); text-decoration: none; transition: background-color 100ms ease;
}
.docs-link span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-link .icon { color: var(--greige-500); }
.docs-link:hover { background: var(--hover-2); }
.docs-link[aria-current="page"] { background: rgba(52, 49, 44, .09); color: var(--text); font-weight: 500; }
.docs-link[aria-current="page"] .icon { color: var(--text-3); }
.docs-read { min-width: 0; padding: 22px clamp(20px, 3vw, 40px) 72px; }
.docs-pick { display: grid; justify-items: center; align-content: center; gap: 10px; min-height: 50vh; color: var(--muted); text-align: center; }
.back { display: none; align-items: center; gap: 4px; margin: -6px 0 12px -4px; padding: 4px; border-radius: 5px; font-size: 12px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); background: var(--hover-2); }

.note {
  max-width: 72ch; margin-bottom: 18px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--greige-50); font-size: 13px; color: var(--text-3);
}
.note a { color: var(--clay-800); text-underline-offset: 2px; }

.doc { display: block; }
.toc { margin-bottom: 18px; max-width: 72ch; border: 1px solid var(--line); border-radius: 7px; }
.toc-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%; height: 32px; padding: 0 10px; border: 0; background: transparent;
  font-size: 12px; font-weight: 500; color: var(--text-3); text-align: left;
}
.toc-toggle .icon { color: var(--muted); transition: transform 150ms var(--ease-out); }
.toc.is-open .toc-toggle .icon { transform: rotate(90deg); }
.toc-list { display: none; list-style: none; padding: 2px 8px 10px; max-height: 50vh; overflow-y: auto; }
.toc.is-open .toc-list { display: block; }
.toc-list a {
  display: block; padding: 3px 8px; border-left: 1px solid var(--line); font-size: 12px; line-height: 1.45;
  color: var(--text-3); text-decoration: none;
}
.toc-list a:hover { color: var(--text); border-left-color: var(--greige-500); }
.toc-l3 a { padding-left: 18px; color: var(--muted); }

.doc-body { min-width: 0; max-width: 72ch; font-size: 15px; line-height: 1.65; color: var(--text-2); }
.doc-body > * + * { margin-top: 12px; }
.doc-body h1 { font-size: 22px; font-weight: 500; line-height: 1.3; color: var(--text); margin-bottom: 4px; }
.doc-body h2 { margin-top: 36px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 17px; font-weight: 500; line-height: 1.35; color: var(--text); }
.doc-body h3 { margin-top: 26px; font-size: 15px; font-weight: 500; line-height: 1.4; color: var(--text); }
.doc-body h4, .doc-body h5, .doc-body h6 { margin-top: 20px; font-size: 13px; font-weight: 500; color: var(--text-3); }
.doc-body h1, .doc-body h2, .doc-body h3, .doc-body h4 { scroll-margin-top: 60px; overflow-wrap: anywhere; }
.doc-body ul, .doc-body ol { padding-left: 22px; }
.doc-body li { margin: 4px 0; }
.doc-body li > ul, .doc-body li > ol { margin-top: 4px; }
.doc-body strong, .doc-body b { font-weight: 500; color: var(--text); }
.doc-body a { color: var(--clay-800); text-underline-offset: 2px; overflow-wrap: anywhere; }
.doc-body .doc-link-off { color: var(--text-2); }
.doc-body blockquote { padding: 2px 0 2px 14px; border-left: 2px solid var(--clay-300); color: var(--text-3); }
.doc-body hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.doc-body code { font-family: var(--font-mono); font-size: .84em; background: var(--greige-100); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.doc-body pre { padding: 12px 14px; background: var(--greige-50); border: 1px solid var(--line); border-radius: 7px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; }
.doc-body pre code { padding: 0; background: none; overflow-wrap: normal; }
.doc-body img { max-width: 100%; height: auto; }
.table-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 7px; }
.doc-body table { border-collapse: collapse; min-width: 100%; font-size: 13px; line-height: 1.5; }
.doc-body th {
  text-align: left; padding: 7px 10px; font-size: 12px; font-weight: 500; color: var(--text-3);
  background: var(--greige-50); border-bottom: 1px solid var(--line-2); vertical-align: bottom;
}
.doc-body td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; min-width: 100px; }
.doc-body tr:last-child td { border-bottom: 0; }

@media (min-width: 1200px) {
  .doc.has-toc { display: grid; grid-template-columns: minmax(0, 72ch) 200px; gap: 32px; align-items: start; }
  .doc.has-toc .toc { order: 2; position: sticky; top: 64px; margin: 0; border: 0; max-height: calc(100vh - 96px); overflow-y: auto; }
  .doc.has-toc .toc-toggle { pointer-events: none; padding: 0 8px; height: 26px; }
  .doc.has-toc .toc-toggle .icon { display: none; }
  .doc.has-toc .toc-list { display: block; max-height: none; padding: 0; }
}

/* ---------- Вход ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--greige-100); }
.login-card {
  width: 100%; max-width: 360px; padding: 26px 26px 22px; background: var(--paper);
  border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 1px 2px rgba(52, 49, 44, .04);
}
.login-brand { margin-bottom: 22px; }
.login h1 { font-size: 16px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.login-lead { margin-bottom: 18px; color: var(--text-3); }
.login-widget { display: flex; align-items: center; min-height: 40px; margin-bottom: 8px; }
.login-hint { font-size: 12px; color: var(--muted); }

/* ---------- Наведение только там, где есть мышь ---------- */
@media (hover: hover) and (pointer: fine) {
  .row:hover { background: var(--hover); }
  .row.is-open:hover { background: var(--selected); }
  button.state:hover { background: var(--hover-2); }
}

/* ---------- Узкие экраны ---------- */
@media (max-width: 1000px) {
  .row-author { display: none; }
}
@media (max-width: 900px) {
  body { background: var(--paper); }
  .app { display: block; height: auto; }
  .main { margin: 0; border: 0; border-radius: 0; overflow: visible; }
  .topbar {
    display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
    padding: 0 12px 0 6px; background: var(--paper); border-bottom: 1px solid var(--line-2);
  }
  .menu-button { width: 40px; height: 40px; color: var(--text-2); }
  .topbar-title { min-width: 0; font-size: 15px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Действия страницы встают в правую часть верхней полосы. */
  .page-head {
    position: fixed; top: 0; right: 0; z-index: 25; height: var(--topbar-h); padding: 0 6px 0 0;
    background: transparent; border: 0; pointer-events: none;
  }
  .page-head h1 { display: none; }
  .page-actions { pointer-events: auto; gap: 4px; }
  .subhead { top: var(--topbar-h); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; width: min(80vw, 280px);
    background: var(--greige-100); border-right: 1px solid var(--line-2);
    padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom));
    transform: translateX(-100%); visibility: hidden;
    transition: transform 240ms cubic-bezier(.32, .72, 0, 1), visibility 0s linear 240ms;
  }
  .nav-open .sidebar { transform: none; visibility: visible; transition-delay: 0s; }
  .nav a { height: 40px; font-size: 15px; gap: 12px; }
  .nav-count { font-size: 13px; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(52, 49, 44, .32); }
  .scrim[hidden] { display: none !important; }
  .nav-open body, .panel-open body { overflow: hidden; }
  .docs-list { top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); }
  .doc-body h1, .doc-body h2, .doc-body h3, .doc-body h4 { scroll-margin-top: 64px; }
  .back { display: inline-flex; }
}
@media (max-width: 768px) {
  body { font-size: 14px; }
  /* Поле ввода мельче 16px заставляет iOS увеличивать страницу. */
  input, select, textarea { font-size: 16px !important; }

  /* Кнопка добавления в шапке: значок 36x36 без подписи. */
  .btn-add { width: 36px; height: 36px; padding: 0; border-color: transparent; background: transparent; color: var(--text); }
  .btn-add:hover { background: var(--hover-2); border-color: transparent; }
  .btn-add .btn-label { display: none; }
  .btn-add .icon { width: 20px; height: 20px; margin: 0; }
  .page-actions .seg { padding: 2px; }
  .page-actions .seg-btn { height: 28px; padding: 0 8px; }
  .page-actions .seg-btn span { display: none; }

  .draft-bar { padding: 4px 6px 4px 16px; font-size: 13px; }
  .group-head { height: 40px; padding: 0 6px 0 8px; }
  .group-toggle { font-size: 13px; }
  .group-add { width: 36px; height: 36px; opacity: 1; }
  .group-tools .seg-btn { height: 26px; padding: 0 8px; }
  .subhead { height: 30px; padding: 0 16px; }

  /* Строка в две линии: название до двух строк, под ним мета. */
  .row { align-items: flex-start; gap: 12px; min-height: 0; padding: 11px 16px 11px 14px; }
  .row .state { margin-top: 1px; }
  .row-line { display: block; height: auto; overflow: visible; line-height: 21px; }
  .row-title {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    white-space: normal; overflow-wrap: anywhere; font-size: 15px; line-height: 21px;
  }
  .row-sub, .row-aside { display: none; }
  .row-meta {
    display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 13px; line-height: 18px; color: var(--muted);
  }
  .row-meta-part + .row-meta-part::before { content: '\00b7'; margin: 0 6px; color: var(--greige-500); }
  .row-meta-sub { color: var(--greige-500); }
  .row-empty { padding: 12px 16px 12px 46px; }
  .add-form { height: 48px; padding: 0 16px 0 17px; }

  /* Сводка Статуса: сетка 2x2 одинаковых ячеек. */
  .summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 0; background: var(--line); border-bottom: 1px solid var(--line); }
  .summary-item {
    display: grid; grid-template-areas: 'value' 'label'; align-content: center; gap: 1px;
    min-height: 62px; padding: 10px 16px; background: var(--paper); white-space: normal;
  }
  .summary-value { grid-area: value; font-size: 18px; line-height: 24px; }
  .summary-label { grid-area: label; font-size: 12.5px; line-height: 16px; }
  .meter { display: none; }

  /* Доска: колонки листаются вбок внутри доски, страница стоит. */
  .board, .board--compact {
    grid-auto-flow: column; grid-auto-columns: 85%; grid-template-columns: none; gap: 10px;
    padding: 12px 16px 16px; overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scroll-padding-inline: 16px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .board::-webkit-scrollbar { display: none; }
  .col { scroll-snap-align: start; min-height: 0; }
  .card { padding: 10px 12px; }
  .card-title { font-size: 15px; line-height: 21px; }
  .card-sub { font-size: 13px; }
  .board--compact .card-sub { display: -webkit-box; }

  .panel { inset: 0; width: auto; max-width: none; border: 0; border-radius: 0; }
  .panel-head { height: var(--topbar-h); padding-top: env(safe-area-inset-top); }
  .panel-scroll { padding: 16px 16px 12px; }
  .panel-title { font-size: 18px !important; }
  .panel-foot { padding: 10px 16px max(12px, env(safe-area-inset-bottom)); }
  .panel-foot .btn { height: 36px; padding: 0 14px; }
  .prop { min-height: 40px; }
}
@media (max-width: 700px) {
  .docs { display: block; }
  .docs-list { position: static; height: auto; border-right: 0; padding: 4px 8px 24px; }
  .docs.has-doc .docs-list { display: none; }
  .docs:not(.has-doc) .docs-read { display: none; }
  .docs-read { padding: 16px 16px 56px; }
  .doc-body { font-size: 15px; }
  .docs-group-title { height: 34px; font-size: 13px; }
  .docs-link { height: auto; min-height: 44px; padding: 10px 8px; font-size: 15px; line-height: 21px; align-items: flex-start; }
  .docs-link .icon { margin-top: 3px; }
  .docs-link span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}
@media (hover: none) {
  .group-add { opacity: 1; }
  /* На касание :hover залипает после тапа: фон наведения не показываем. */
  .icon-btn:hover, .btn--quiet:hover, .btn-add:hover { background-color: transparent; }
  .draft-bar-btn[aria-pressed="true"]:hover { background: rgba(192, 122, 62, .12); }
}
