/* Токены - из макета «lambda — токены», тёмная палитра. */
:root {
  --bg: #000000;
  --card: #151517;
  --block: #1C1C1F;
  --line: #2E2E32;
  --skeleton: #232327;
  --disabled: #48484A;
  --muted: #86868B;
  --text: #F5F5F7;
  --error: #FF453A;
  --danger: #C9322A;
  --font: -apple-system, BlinkMacSystemFont, "Golos Text", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); }
body {
  font-family: var(--font);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
a { color: var(--text); text-decoration: none; }
button { font: inherit; color: inherit; border: 0; padding: 0; background: none; cursor: pointer; appearance: none; -webkit-appearance: none; }
input, textarea { font: inherit; color: var(--text); border: 0; outline: 0; background: var(--block); }
input::placeholder, textarea::placeholder { color: var(--muted); }
:focus-visible { outline: 2px solid var(--disabled); outline-offset: 2px; }

#app {
  max-width: 480px;
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100vh);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.screen { flex-grow: 1; display: flex; flex-direction: column; }
.screen.with-nav { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px); }
.screen.no-nav { padding-bottom: calc(var(--safe-b) + 8px); }

/* Шапки */
.brand { display: flex; align-items: baseline; gap: 9px; padding: 22px 16px 14px; }
.brand b { font-size: 19px; font-weight: 600; line-height: 1; letter-spacing: -0.04em; }
.brand span { font-size: 15px; font-weight: 500; letter-spacing: -0.012em; }
.title-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 16px 14px; }
.title-bar h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.title-bar a, .title-bar button { display: flex; align-items: center; height: 44px; padding: 0 4px; font-size: 15px; font-weight: 500; }
.back-bar { display: flex; align-items: center; gap: 6px; padding: 14px 16px 12px; }
.back-bar h1 { flex-grow: 1; margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.icon-btn { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; }
.icon-btn.lead { margin-left: -12px; }
.icon-btn.trail { margin-right: -10px; }

/* Каркас содержимого */
.stack { display: flex; flex-direction: column; gap: 10px; padding: 0 16px; }
.stack.tight { gap: 8px; }
.shell { padding: 12px; background: var(--card); border-radius: 26px; display: flex; flex-direction: column; gap: 10px; }
.block { background: var(--block); border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; }
.label { padding: 10px 4px 0; font-size: 13px; color: var(--muted); }
.center { flex-grow: 1; display: flex; flex-direction: column; justify-content: center; padding: 0 16px 60px; }
.empty { flex-grow: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 0 16px 80px; text-align: center; }
.empty h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.025em; }
.muted { color: var(--muted); }
.hr { height: 1px; background: var(--line); margin: 0 20px; }
.hr.inset { margin-left: 60px; }

/* Строки «ключ - значение» */
.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 15px 20px; font-size: 15px; }
.kv > :first-child { color: var(--muted); flex-shrink: 0; }
.kv > :last-child { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv.dim > :last-child { color: var(--muted); }
.progress { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 4px; background: var(--text); border-radius: 999px; }
.progress-pad { padding: 0 20px 18px; }

/* Статус на главной */
.status { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px; background: var(--block); border-radius: 18px; }
.status small { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.status strong { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.alert { display: flex; flex-direction: column; gap: 14px; padding: 20px; background: rgba(255, 69, 58, 0.10); border-radius: 18px; }
.alert h2 { margin: 0 0 5px; font-size: 20px; font-weight: 600; letter-spacing: -0.025em; color: var(--error); }
.alert p { margin: 0; font-size: 14px; color: var(--muted); }

/* Переключатель */
.switch { position: relative; flex-shrink: 0; width: 50px; height: 30px; border-radius: 999px; background-color: #2E2E32; transition: background-color .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background-color: #86868B; border-radius: 999px; transition: transform .15s, background-color .15s; }
/* Цвета здесь числами, а не переменными: во встроенном браузере Telegram на macOS включённый
   переключатель с var() оставался тёмным, и чёрная ручка на нём терялась. */
.switch[aria-checked="true"] { background-color: #F5F5F7; }
.switch[aria-checked="true"]::after { transform: translateX(20px); background-color: #000000; }
.switch:disabled { opacity: .5; }

/* Шаги */
.step { display: flex; align-items: center; gap: 14px; padding: 15px 20px; font-size: 16px; color: var(--muted); }
.step i { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 600; font-style: normal; color: var(--muted); }
.step.current { color: var(--text); font-weight: 500; }
.step.current i { background: var(--text); border-color: var(--text); color: #000; }
.step.done i { border-color: var(--muted); }
.step code { font-family: var(--mono); font-size: 14px; color: var(--text); }

/* Кнопки */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 54px; width: 100%; border-radius: 16px; font-size: 16px; font-weight: 500; background: var(--text); color: #000; }
.btn:active { background: #C7C7CC; }
.btn.second { background: var(--block); color: var(--text); }
.btn.second:active { background: var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost-danger { background: none; color: var(--error); }
.btn.small { height: 48px; border-radius: 14px; font-size: 15px; }
.btn.mid { height: 50px; font-size: 15px; }
.btn.inline { width: auto; height: 52px; padding: 0 26px; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--block); color: var(--disabled); pointer-events: none; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1 1 0; min-width: 0; }
.row > .fixed { flex: 0 0 110px; }
.actions { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 22px; }

/* Поля */
.field { height: 50px; width: 100%; padding: 0 18px; border-radius: 16px; font-size: 16px; font-weight: 500; display: block; text-align: left; }
button.field { background: var(--block); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.field.placeholder { color: var(--muted); }
textarea.field { height: auto; padding: 16px 18px; resize: none; font-size: 15px; font-weight: 400; line-height: 1.6; }
.field.invalid, .pick.invalid { box-shadow: 0 0 0 3px var(--error); }
.hint { padding: 0 4px 4px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.hint code { font-family: var(--mono); font-size: 12px; color: var(--text); }
.field-error { padding: 0 4px; font-size: 13px; line-height: 1.45; color: var(--error); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; padding: 0 12px 0 18px; background: var(--block); border-radius: 16px; font-size: 15px; }
.pick { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 50px; width: 100%; padding: 0 18px; background: var(--block); border-radius: 16px; font-size: 15px; }
.pick > span:first-child { color: var(--muted); flex-shrink: 0; }
.pick > span:last-child { display: flex; align-items: center; gap: 6px; font-weight: 500; min-width: 0; }
.pick > span:last-child > b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Пилюли и чипы */
.pills { display: flex; gap: 8px; }
.pill { flex: 1 1 0; display: flex; align-items: center; justify-content: center; height: 44px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted); }
.pill[aria-current="true"] { background: var(--line); color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: flex; align-items: center; height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.chip:active { background: var(--block); color: var(--text); }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--muted); }

/* Карточки списков */
.item { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; background: var(--block); border-radius: 18px; }
.item.link { gap: 7px; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.item-title { flex-grow: 1; min-width: 0; font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-title.wrap { white-space: normal; line-height: 1.3; }
.item-sub { font-size: 13px; color: var(--muted); }
.item-meta { display: flex; flex-direction: column; gap: 8px; }
.clamp { font-size: 13px; line-height: 1.5; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.salary { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.log { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 20px; }
.log > span:first-child { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.log > span:first-child > b { font-size: 15px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log small { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 6px 2px; font-size: 13px; color: var(--muted); }
.section-head a { color: var(--muted); }
.count-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 2px 18px 12px; }
.count-bar h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.025em; }
.count-bar button { font-size: 15px; color: var(--muted); }

/* Плитки статистики */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 18px; background: var(--block); border-radius: 18px; }
.tile b { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.tile span { font-size: 13px; color: var(--muted); }

/* Предпросмотр письма */
.preview { padding: 16px 18px; background: var(--block); border-radius: 16px; font-size: 14px; line-height: 1.6; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.preview mark { background: none; color: var(--text); }

/* Сообщение на весь экран */
.message { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 44px 24px; background: var(--block); border-radius: 18px; text-align: center; }
.message h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.025em; }
.message p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.message .btn { width: auto; height: 50px; padding: 0 22px; font-size: 15px; }

/* Скелетон */
.sk { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--block); border-radius: 18px; }
.sk i { display: block; height: 11px; background: var(--skeleton); border-radius: 999px; }
.sk i:first-child { height: 13px; background: var(--line); }
.sk i { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .sk i { animation: none; } .switch, .switch::after, .sheet, .scrim { transition: none !important; } }

/* Нижняя навигация */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--bg); border-top: 1px solid var(--block); }
.nav > div { max-width: 480px; margin: 0 auto; display: flex; gap: 2px; padding: 7px 8px calc(8px + var(--safe-b)); }
.nav a { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 7px 0 0; font-size: 11px; color: var(--muted); }
.nav a[aria-current="page"] { color: var(--text); }

/* Шторка */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .6); opacity: 0; transition: opacity .18s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 480px; margin: 0 auto; max-height: 86vh; padding: 10px 12px calc(26px + var(--safe-b)); background: var(--card); border-radius: 26px 26px 0 0; display: flex; flex-direction: column; gap: 10px; transform: translateY(100%); transition: transform .2s ease-out; }
.open > .scrim { opacity: 1; }
.open > .sheet { transform: none; }
.sheet::before { content: ""; align-self: center; width: 40px; height: 4px; margin-bottom: 8px; background: var(--line); border-radius: 999px; flex-shrink: 0; }
.sheet-head { display: flex; flex-direction: column; gap: 6px; padding: 4px 12px 14px; }
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.025em; }
.sheet-head p { margin: 0; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
.sheet-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.option { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; width: 100%; padding: 8px 18px; background: var(--block); border-radius: 16px; font-size: 16px; font-weight: 500; text-align: left; }
.option small { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--muted); }
.option[aria-checked="true"] { box-shadow: inset 0 0 0 1.5px var(--disabled); }
.option[aria-checked="true"]::after { content: ""; flex-shrink: 0; width: 7px; height: 13px; margin-right: 4px; border: solid #F5F5F7; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-2px, -2px); }
.option:active { background: var(--line); }

/* Тост */
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 30; max-width: 448px; margin: 0 auto; padding: 14px 18px; background: var(--line); border-radius: 16px; font-size: 14px; line-height: 1.45; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .18s, transform .18s; }
#toast.show { opacity: 1; transform: none; }
#toast.error { color: var(--error); }
