/* Компоненты интерфейса: карточка, кнопки, чип, сегмент, тумблер, поле, строка настроек,
   пилюля статуса, полоса прогресса, пустое состояние, заглушка загрузки, тост, автосохранение.
   Разметку собирает js/app/ui.js. Цель нажатия не меньше 44 px. */

/* ── Карточка и ряды ─────────────────────────────────────────── */
.card {
  padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--s1); box-shadow: var(--shadow);
}
.card-in { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-block); background: var(--s2); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-between { justify-content: space-between; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }

/* ── Кнопки ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 18px; border: 1px solid transparent; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink); font: 600 var(--fs-text) var(--font-ui);
  text-align: center; text-decoration: none; cursor: pointer;
  transition: transform var(--t-press) var(--ease), opacity var(--t-press) linear;
}
.btn:active { transform: scale(.97); }
.btn.second { background: none; border-color: var(--line-2); color: var(--ink); }
.btn.text { min-height: var(--tap); padding: 0 var(--sp-2); background: none; border: 0; color: var(--accent-text); }
.btn.danger { background: var(--bad); color: var(--bg); }
.btn.sm { padding: 0 var(--sp-3); font-size: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.busy { cursor: progress; }
.btn-row { display: flex; gap: var(--sp-2); }
.btn-row > * { flex: 1; min-width: 0; }
.btn-col { display: flex; flex-direction: column; gap: var(--sp-2); }
.link-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
  padding: 0 var(--sp-2); border: 0; background: none; color: var(--accent-text);
  font: 600 14px var(--font-ui); text-decoration: none; cursor: pointer;
}
.icon-btn {
  display: grid; place-items: center; flex: none; width: var(--tap); height: var(--tap);
  border: 0; border-radius: var(--r-pill); background: none; color: var(--ink); cursor: pointer;
  transition: background-color var(--t-press) linear, transform var(--t-press) var(--ease);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.sm { width: 36px; height: 36px; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
.spinner {
  display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Чип, метка, тег ─────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px;
  border: 1px solid var(--line); border-radius: var(--r-chip);
  background: var(--s2); color: var(--ink-2); font: 500 12.5px var(--font-ui);
}
.chip i.dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--ink-3)); }
.chip[data-tone="ok"] { --dot: var(--ok); }
.chip[data-tone="wait"] { --dot: var(--wait); }
.chip[data-tone="bad"] { --dot: var(--bad); }
.chip b { font: 600 12.5px var(--font-ui); color: var(--ink); }
.chip.pick { min-height: var(--tap); padding: 0 12px; background: none; cursor: pointer; font-weight: 600; }
.chip.pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-dim); color: var(--accent-text); }
.chip.pick[aria-pressed="true"] b { color: var(--accent-text); }
.chip.on { border-color: var(--accent); background: var(--accent-dim); color: var(--accent-text); }
.chip button {
  display: grid; place-items: center; width: 24px; height: 24px; margin: 0 -6px 0 -2px;
  border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer;
}
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink);
  font: 600 var(--fs-mono) var(--font-ui);
}
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--ink-3);
  font: 600 var(--fs-mono) var(--font-ui);
}
.tag.internal { border-color: var(--line-2); color: var(--ink-2); }

/* ── Сегмент ─────────────────────────────────────────────────── */
.seg {
  position: relative; display: grid; grid-template-columns: repeat(var(--n, 2), 1fr);
  padding: 4px; border: 1px solid var(--line); border-radius: var(--r-block); background: var(--s2);
}
.seg-thumb {
  position: absolute; top: 4px; left: 4px; width: calc((100% - 8px) / var(--n, 2)); height: calc(100% - 8px);
  border-radius: 10px; background: var(--s3);
  transform: translateX(calc(var(--i, 0) * 100%)); transition: transform var(--t-sheet) var(--ease);
}
.seg-btn {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; min-height: var(--tap); padding: 2px 4px; border: 0; border-radius: 10px; background: none;
  color: var(--ink-3); font: 600 13px var(--font-ui); cursor: pointer; transition: color var(--t-screen) linear;
}
.seg-btn[aria-checked="true"] { color: var(--ink); }
.seg.has-count .seg-btn { min-height: 52px; }
.seg-n { font: 600 14px var(--font-display); letter-spacing: -.02em; }
.seg-l { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 600; }

/* ── Тумблер ─────────────────────────────────────────────────── */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: var(--row-h); cursor: pointer; }
.switch-txt b { display: block; font: 600 var(--fs-text) var(--font-ui); }
.switch-txt small { display: block; margin-top: 2px; color: var(--ink-3); font-size: 13px; }
.switch-row input { position: absolute; width: 0; height: 0; opacity: 0; }
.sw {
  position: relative; flex: none; width: 51px; height: 31px; border-radius: var(--r-pill);
  background: var(--s3); transition: background-color var(--t-screen) linear;
}
.sw::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 25px; height: 25px; border-radius: 50%;
  background: var(--ink-3); transition: transform var(--t-screen) var(--ease), background-color var(--t-screen) linear;
}
.switch-row input:checked + .sw { background: var(--accent-dim); }
.switch-row input:checked + .sw::after { transform: translateX(20px); background: var(--accent); }
.switch-row input:focus-visible + .sw { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* ── Поле ввода ──────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font: 600 13px var(--font-ui); color: var(--ink-2); }
.field-hint { color: var(--ink-3); font-size: 12.5px; line-height: 1.45; }
.input {
  width: 100%; min-height: var(--tap); padding: 11px var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--r-chip);
  background: var(--s2); color: var(--ink); font: 16px var(--font-ui);
  transition: border-color var(--t-press) linear;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--line-2); }
.input.bad, .bad .input { border-color: var(--bad); }
textarea.input { min-height: 96px; line-height: 1.55; resize: vertical; }
.field-row { display: flex; gap: var(--sp-2); }
.field-row > .field { flex: 1; }
.chips-in {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 48px; padding: 6px;
  border: 1px solid var(--line); border-radius: var(--r-chip); background: var(--s2); cursor: text;
}
.chips-in:focus-within { border-color: var(--line-2); }
.chips-text { flex: 1; min-width: 96px; min-height: 36px; border: 0; outline: none; background: none; color: var(--ink); font: 16px var(--font-ui); }

/* ── Строка настроек: иконка, название, значение, шеврон ─────── */
.set-group { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--s1); }
.set-group-title { padding: var(--sp-3) var(--sp-4) var(--sp-1); }
.set-row {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: var(--row-h);
  padding: var(--sp-2) var(--sp-4); border: 0; border-radius: 0; background: none;
  color: var(--ink); font: 400 var(--fs-text) var(--font-ui); text-align: left; text-decoration: none; cursor: pointer;
}
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row:active { background: var(--s2); }
.set-row.danger .set-title { color: var(--bad); }
.set-ico { display: grid; place-items: center; flex: none; width: 28px; height: 28px; color: var(--ink-2); }
.set-main { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.set-title { font: 600 14.5px var(--font-ui); }
.set-sub { color: var(--ink-3); font-size: 12.5px; }
.set-val { flex: none; max-width: 45%; color: var(--ink-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-chev { flex: none; color: var(--ink-3); }

/* ── Пилюля статуса ──────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none; max-width: 50%;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--s2); color: var(--ink-2); font: 600 var(--fs-mono) var(--font-ui);
}
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.pill[data-tone="ok"] { color: var(--ok); }
.pill[data-tone="ok"] .pill-dot { background: var(--ok); }
.pill[data-tone="wait"] { color: var(--wait); }
.pill[data-tone="wait"] .pill-dot { background: var(--wait); }
.pill[data-tone="bad"] { color: var(--bad); }
.pill[data-tone="bad"] .pill-dot { background: var(--bad); }

/* ── Полоса прогресса ────────────────────────────────────────── */
.progress { height: 6px; border-radius: var(--r-pill); background: var(--s3); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 400ms var(--ease); }
.progress[data-tone="wait"] i { background: var(--wait); }
.progress[data-tone="bad"] i { background: var(--bad); }

/* ── Пустое состояние: фраза и одно действие ─────────────────── */
.state { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: 44px var(--sp-5); text-align: center; }
.state-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--r-block); background: var(--s2); color: var(--ink-2); }
.state-ico.bad { color: var(--bad); }
.state-ico.ok { color: var(--ok); }
.state h2 { font: 600 17px var(--font-ui); letter-spacing: -.01em; }
.state p { max-width: 34ch; color: var(--ink-2); font-size: 14px; }
.state.compact { padding: var(--sp-5) var(--sp-3); }

/* ── Заглушка загрузки ───────────────────────────────────────── */
.sk { display: block; height: 10px; border-radius: 5px; background: var(--s3); animation: skPulse 1.4s ease-in-out infinite; }
.sk.w40 { width: 40%; } .sk.w60 { width: 60%; } .sk.w90 { width: 90%; } .sk.w100 { width: 100%; }
.sk.btn { width: 46%; height: 36px; border-radius: var(--r-pill); margin-top: var(--sp-1); }
.sk-rows { display: flex; flex-direction: column; gap: 10px; }
.sk-card { display: flex; flex-direction: column; gap: 10px; padding: var(--sp-4); }
@keyframes skPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.load-note { padding: var(--sp-2) 0; color: var(--ink-3); font-size: 12.5px; text-align: center; }

/* ── Тост ────────────────────────────────────────────────────── */
.toast-root {
  position: fixed; left: 0; right: 0; z-index: 60; display: flex; justify-content: center;
  bottom: calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
  padding: 0 var(--pad-screen); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; max-width: 460px;
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4); border: 1px solid var(--line);
  border-radius: var(--r-block); background: var(--s1); box-shadow: var(--shadow-lift);
  pointer-events: auto; animation: toastIn var(--t-screen) var(--ease) both;
}
.toast.out { animation: toastOut var(--t-screen) var(--ease) both; }
.toast[data-tone="ok"] { border-color: var(--ok); }
.toast[data-tone="bad"] { border-color: var(--bad); }
.toast-text { flex: 1; font-size: 14px; }
.toast-act {
  min-height: var(--tap); padding: 0 var(--sp-3); border: 0; border-radius: var(--r-chip);
  background: none; color: var(--accent-text); font: 600 14px var(--font-ui); cursor: pointer;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ── Голосовой ввод: круглая кнопка-микрофон у поля ───────────── */
.voice-field { position: relative; display: block; }
.voice-field .input { padding-right: 48px; }
.mic-btn {
  position: absolute; right: 6px; bottom: 6px; display: grid; place-items: center;
  width: var(--tap); height: var(--tap); padding: 0; border: 1px solid var(--line);
  border-radius: 50%; background: var(--s2); color: var(--ink-2); cursor: pointer;
}
.mic-btn[data-on="true"] { border-color: var(--bad); background: var(--s1); color: var(--bad); }
.mic-dot { display: none; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
.mic-btn[data-on="true"] .mic-dot { display: block; animation: micPulse 1.1s ease-in-out infinite; }
@keyframes micPulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

/* ── Автосохранение в шапке ──────────────────────────────────── */
.save-ind {
  flex: none; padding: 4px 8px; border-radius: var(--r-chip); background: none;
  font: 500 var(--fs-mono) var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}
.save-ind[data-state="saving"] { color: var(--ink-2); }
.save-ind[data-state="saved"] { color: var(--ok); }
.save-ind[data-state="fail"] { color: var(--bad); text-decoration: underline; cursor: pointer; }

/* ── Пул вакансий под фильтрами (static/js/app/pool-meter.js) ─────────────── */
.pool-meter { display: flex; flex-direction: column; gap: var(--sp-2); }
.pool-line {
  display: flex; align-items: baseline; gap: var(--sp-2); margin: 0;
  color: var(--ink-2); font-size: 13px; line-height: 1.35;
}
.pool-tag {
  flex: none; padding: 2px 8px; border-radius: var(--r-pill); background: var(--s2);
  font: 500 var(--fs-mono) var(--font-mono); letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-2);
}
.pool-tag[data-level="low"], .pool-tag[data-level="none"] { background: var(--s1); color: var(--wait); }
.pool-tag[data-level="ok"] { background: var(--s1); color: var(--ok); }
.pool-hints { display: flex; flex-direction: column; gap: var(--sp-2); }
.pool-hint { justify-content: flex-start; text-align: left; white-space: normal; font-size: 13px; }
