/* Сброс, типографика, раскладка приложения: шапка, рейка, разделы, панели.
   Источник — docs/redesign/canvas/_head.part и build.py (topbar/rail).
   Владелец — блок A (контракты). Файл заморожен. */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

/* Стиль 2 «Тонированный холст» (plan2.md §4): ровно один радиальный слой —
   едва заметная подкраска в сторону акцента у правого верхнего угла экрана.
   Второй слой не добавлять — подкраска легко переливается и начинает спорить
   с превью роликов. */
body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 76% -6%, rgba(225, 29, 52, .055), transparent 62%),
    var(--bg);
  color: var(--ink);
  font: 400 13px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
html[data-theme="dark"] body {
  background:
    radial-gradient(1100px 520px at 76% -6%, rgba(255, 66, 88, .075), transparent 62%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); text-decoration: underline; }

img { max-width: 100%; }

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

[hidden] { display: none !important; }

/* Заголовки нужны скринридеру, а размер и вес им задают классы .t-h1/.t-h2/
   .t-h3 — собственная типографика браузера здесь только мешала бы. */
h1, h2, h3, h4, h5, h6 { margin: 0; font: inherit; }

/* Спрайт иконок: живёт в начале body и ничего не занимает. */
.sprite { display: none; }

/* ---- Фокус ----
   Общее кольцо на всё приложение. Гасить системный контур можно только там,
   где на его месте появляется своё кольцо и только при :focus-visible —
   единственное такое место — поле поиска в шапке (см. .tb-input ниже).
   Класс .foc — тот же вид для случаев, когда фокус надо показать вручную
   (демонстрация состояний). */
:focus-visible,
.foc {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Типографика ---- */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.cap {
  font-size: 10px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink4);
}
.t-h1 { font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.t-h2 { font-size: 15px; line-height: 1.3; font-weight: 700; letter-spacing: -.005em; }
.t-h3 { font-size: 13px; line-height: 1.35; font-weight: 600; }
.t-b { font-size: 13px; line-height: 1.45; }
.t-s { font-size: 12px; line-height: 1.4; color: var(--ink3); }
.t-xs { font-size: 11px; line-height: 1.35; color: var(--ink4); }

/* ---- Утилиты раскладки ---- */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Панели ---- */
.pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--sh1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ph {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 44px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.pane-body { flex: 1; min-height: 0; overflow: auto; }

/* ---- Шапка ---- */
#topbar {
  height: 52px;
  flex: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
/* Знак и правый блок держат по 250 px, чтобы поиск стоял по центру шапки,
   но уступают ширину середине, когда её перестаёт хватать (см. также
   responsive.css: на планшете оба ужимаются по содержимому). */
.tb-brand {
  display: flex; align-items: center; gap: 9px;
  width: 250px; flex: 0 1 auto; min-width: 0; overflow: hidden;
  color: var(--ink);
}
.tb-brand:hover { color: var(--ink); text-decoration: none; }
.tb-mark {
  width: 28px; height: 28px; border-radius: 9px;
  background: var(--accent); color: var(--on-dark);
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.tb-name { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }

.tb-mid { flex: 1 1 auto; display: flex; justify-content: center; min-width: 0; }
.tb-search {
  position: relative;
  width: 640px; max-width: 100%; min-width: 0; height: 36px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px 0 4px;
  border: 1px solid var(--line2); border-radius: 10px;
  background: var(--surface);
}
.tb-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accentSoft);
}
.tb-sep { width: 1px; height: 18px; background: var(--line); flex: none; }
.tb-search-ic { color: var(--ink4); }
.tb-input {
  flex: 1; min-width: 0;
  border: 0; background: none;
  color: var(--ink); font-size: 13.5px;
}
/* Кольцо фокуса рисует вся пилюля (.tb-search:focus-within выше) — системный
   контур у поля внутри неё был бы вторым кольцом в 8 px от первого. Гасим его
   ровно там, где замена гарантированно есть. */
.tb-input:focus-visible { outline: none; }
.tb-input::placeholder { color: var(--ink4); }
.tb-input::-webkit-search-cancel-button { display: none; }
.tb-kbd { flex: none; }

.tb-right {
  width: 250px; flex: 0 0 auto; min-width: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
}
.tb-div { width: 1px; height: 22px; background: var(--line); margin: 0 2px; flex: none; }
#status-live, #status-bar { display: flex; align-items: center; }
#account-slot { display: flex; align-items: center; }
#dl-button { position: relative; }
#theme-toggle .ic-sun { display: none; }
html[data-theme="dark"] #theme-toggle .ic-sun { display: block; }
html[data-theme="dark"] #theme-toggle .ic-moon { display: none; }

/* Тонкая полоса индексации по нижней кромке шапки. Наполняет её /status. */
.tb-progress {
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--surf3);
}
.tb-progress > i { display: block; height: 100%; background: var(--accent); }

/* ---- Рабочая зона ---- */
#work {
  flex: 1; min-height: 0;
  display: flex; gap: 10px; padding: 10px;
}

/* ---- Рейка разделов ---- */
#rail {
  width: 68px; flex: none;
  padding: 8px 0; gap: 2px;
  align-items: center;
}
.rail-item {
  width: 52px; height: 54px; border-radius: 10px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  position: relative;
  color: var(--ink3);
  font-size: 10px; font-weight: 600;
  cursor: pointer;
}
.rail-item:hover { background: var(--surf2); color: var(--ink2); text-decoration: none; }
.rail-item.is-on {
  background: var(--accentSoft); color: var(--accent); font-weight: 700;
}
.rail-item.is-on:hover { background: var(--accentSoft); color: var(--accent); }
.rail-dot {
  position: absolute; top: 6px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}

/* ---- Разделы ---- */
.sec {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; gap: 10px;
}
/* Ширины колонок макета: 300 — дерево рубрик и список каналов,
   340 — панель гаджетов, середина тянется. */
.w300 { width: 300px; flex: none; }
.w340 { width: 340px; flex: none; }
/* Слот, который наполняет htmx: не панель и не колонка, просто место. */
.pane-slot { flex: none; }

/* ---- Уважение к настройке «меньше движения» ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
