/* YM Sync: стили всех страниц. Тема — светлая или тёмная, как в системе. */

:root {
  color-scheme: light dark;
  --bg: #f4f4f6;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #5c5c63;
  --line: #e2e2e7;
  --chip: #efeff2;
  --accent-bg: #d0193f;
  --accent-hover: #b3122f;
  --accent-text: #b3122f;
  --ok: #1a7f37;
  --ok-bg: #e6f4ea;
  --warn: #8a5a00;
  --warn-bg: #fff3d1;
  --err: #b42318;
  --err-bg: #fdecea;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --card: #1c1c1f;
    --text: #f2f2f4;
    --muted: #a8a8b0;
    --line: #2e2e34;
    --chip: #2a2a2f;
    --accent-hover: #e0284a;
    --accent-text: #ff7088;
    --ok: #4cc26b;
    --ok-bg: #16301f;
    --warn: #f0b43c;
    --warn-bg: #352a10;
    --err: #ff7b72;
    --err-bg: #3a1a18;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont,
    system-ui, sans-serif;
}

a { color: var(--accent-text); }
a:hover { color: var(--text); }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 18px; }
p { margin: 0; }

/* Шапка и разделы */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 32px;
  padding: 14px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-size: 18px; font-weight: 700; text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}
.nav a:hover { background: var(--chip); color: var(--text); }
.nav a[aria-current="page"] { background: var(--chip); color: var(--text); font-weight: 600; }
.badge {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13px;
  font-weight: 600;
}
.badge:empty { display: none; }

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Карточки и раскладка */

.card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}
.card-narrow { width: 100%; max-width: 440px; margin: 24px auto; }
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.sections { display: flex; flex-direction: column; gap: 24px; }
.stack { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 16px;
  align-items: start;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 16px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}
.tile-value { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.numbers { font-variant-numeric: tabular-nums; }
.list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.list > li { display: flex; flex-direction: column; gap: 4px; padding: 14px 0; border-top: 1px solid var(--line); }

/* Кнопки */

.btn {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--chip); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { border-color: transparent; background: var(--accent-bg); color: #ffffff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); color: #ffffff; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
[hidden] { display: none !important; } /* иначе display у .btn показал бы скрытую кнопку */
.btn-link {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* Состояния */

.status { display: flex; align-items: flex-start; gap: 12px; }
.dot { flex: none; width: 12px; height: 12px; margin-top: 6px; border-radius: 50%; background: var(--muted); }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-error { background: var(--err); }
.ok { color: var(--ok); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.error { color: var(--err); font-weight: 600; }
.notice { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-error { background: var(--err-bg); color: var(--err); }
.form-message:empty { display: none; } /* место для сообщения формы: пустое — без отступа */
/* Итог действия и панель режима выбора: висят у верха окна, даже если человек внизу
   длинного списка. Места в странице не занимают — строки не сдвигаются; вверху страницы
   ложатся на шапку, а не на только что изменённый трек. */
.float {
  position: fixed;
  top: 8px;
  left: 50%;
  z-index: 10;
  width: min(1056px, calc(100% - 32px));
  transform: translateX(-50%);
}
.toast .notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.2);
}
.close {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: -4px -6px 0 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.close:hover { background: rgb(0 0 0 / 0.08); }
.close:has(input:focus-visible) { outline: 2px solid currentColor; outline-offset: 2px; }
.toast:has(.close input:checked) { display: none; } /* закрыто крестиком — без скрипта */
.messages .toast { z-index: 11; } /* ошибка — поверх итога прошлого действия */
.bulk {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.2);
}
#bulk-confirm:empty { display: none; }
.bulk .confirm { padding-top: 12px; border-top: 1px solid var(--line); }
.invisible { visibility: hidden; }
.messages:empty { display: none; }
.lines { white-space: pre-line; }

progress {
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  overflow: hidden;
  appearance: none;
}
progress::-webkit-progress-bar { background: var(--chip); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent-bg); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent-bg); border-radius: 999px; }

.log .warn, .log .error { font-weight: 400; }
.log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
  list-style: none;
}

/* Таблицы */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
th { border-top: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Переключатель вкл/выкл */

.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.switch input {
  position: relative;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  appearance: none;
  transition: background 0.15s;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.15s;
}
.switch input:checked { background: var(--accent-bg); }
.switch input:checked::after { transform: translateX(18px); }

/* Ненайденные: вкладки, поля, треки, варианты */

.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--chip); }
.tabs a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { background: var(--card); color: var(--text); font-weight: 600; }
.input {
  min-height: 44px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
}
input.input { flex: 999 1 280px; }
.search-box { flex: 1 1 360px; max-width: 520px; flex-wrap: nowrap; }
.track h2 { font-size: 17px; }
.track h3 { margin: 0; color: var(--muted); font-size: 15px; }
.track .search { padding-top: 16px; border-top: 1px solid var(--line); }
.list > li.variant { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.variant > .stack { flex: 999 1 420px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 10px; border-radius: 999px; background: var(--chip); font-size: 13px; font-weight: 600; }
.chip-ok { background: var(--ok-bg); color: var(--ok); font-weight: 400; }
.chip-warn { background: var(--warn-bg); color: var(--warn); font-weight: 400; }
.listen { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 8px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Перенесённые: строки с флажком, подгрузка при прокрутке */

.list > li.track-line { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; }
.list > li.track-line:first-child { border-top: 0; padding-top: 0; }
.track-line > .stack { flex: 1 1 200px; }
.track-line .warn { font-weight: 400; }
.track-line .replace { flex: 1 1 100%; gap: 16px; }
.pick { display: inline-flex; align-items: center; justify-content: center; width: 44px; min-height: 44px; cursor: pointer; }
.card-head.picking { justify-content: flex-start; flex-wrap: nowrap; }
.card-head.picking > .stack { flex: 1 1 auto; }
.pick input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent-bg); cursor: pointer; }
.list > li.more { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 0; }

/* Входы и настройки: поля формы, код Яндекса */

.field { display: grid; gap: 6px; max-width: 520px; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend { padding: 0; font-weight: 600; }
.field > label.choice { font-weight: 400; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent-bg); }
.path { font-family: ui-monospace, Consolas, monospace; font-size: 14px; word-break: break-all; }
.list > li.setting-row { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.login-code { font-size: 32px; font-weight: 700; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.steps { display: flex; flex-direction: column; gap: 6px; margin: 0; padding-left: 22px; }

/* Мастер первого запуска: шаги */

.wizard { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0; padding: 0; list-style: none; }
.wizard li { display: flex; align-items: center; gap: 8px; min-height: 44px; color: var(--muted); }
.wizard li.done, .wizard li[aria-current="step"] { color: var(--text); }
.wizard li[aria-current="step"] { font-weight: 600; }
.wizard a { color: inherit; text-decoration: none; }
.wizard a:hover { color: var(--accent-text); text-decoration: underline; }
.wizard-mark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--chip);
  font-size: 14px;
  font-weight: 600;
}
.wizard li.done .wizard-mark { background: var(--ok-bg); color: var(--ok); }
.wizard li[aria-current="step"] .wizard-mark { background: var(--accent-bg); color: #ffffff; }

/* htmx: «идёт запрос» */

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

@media (max-width: 600px) {
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
}
