:root {
  color-scheme: dark;
  --bg: #0f1417;
  --card: #161d21;
  --border: #2b383f;
  --text: #e7edef;
  --dim: #8ca0a8;
  --accent: #4fd1c5;
  --error: #e2645a;
  --warn: #e0b84f;
}

* { box-sizing: border-box; }

/* .auth-view/.main-view set their own `display`, which — same specificity,
   later in the cascade — beats the UA [hidden]{display:none} rule. Without
   this, toggling the `hidden` attribute in app.js stops actually hiding
   anything and both views render stacked on top of each other. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 40px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.hint {
  font-weight: 400;
  font-size: 12px;
  color: var(--dim);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

/* --- auth --- */

.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(15, 20, 23, 0.55), rgba(15, 20, 23, 0.85)),
    url("assets/auth-bg.jpg") center / cover no-repeat;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 340px;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  height: 1.3em;
  width: auto;
  flex-shrink: 0;
}

.auth-card .brand {
  margin-bottom: 20px;
  justify-content: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--dim);
  padding: 7px 0;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.tab.active {
  background: var(--border);
  color: var(--text);
}

form { display: flex; flex-direction: column; gap: 14px; }

label {
  font-size: 12px;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

input[type="email"], input[type="password"], input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 10px;
  font-family: inherit;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: #08211f;
  border: none;
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-primary:disabled {
  background: var(--border);
  color: var(--dim);
  cursor: not-allowed;
  filter: none;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-small { padding: 5px 10px; font-size: 12px; }

.form-error {
  color: var(--error);
  font-size: 13px;
}

/* Нейтральное сообщение (например, «письмо отправлено») — не ошибка и не успех
   конкретного действия, поэтому обычный приглушённый цвет. */
.form-info {
  color: var(--dim);
  font-size: 13px;
}

.form-success {
  color: var(--accent);
  font-size: 13px;
}

/* Центрированная мелкая ссылка в карточке (вход ↔ сброс пароля). */
.form-link {
  text-align: center;
  font-size: 12px;
  margin-top: 4px;
}

.form-link a {
  color: var(--dim);
  text-decoration: none;
}

.form-link a:hover { color: var(--accent); text-decoration: underline; }

/* --- сброс пароля --- */

/* Карточка сброса использует .auth-card, но у неё нет вкладок входа, поэтому
   заголовок свой (глобальный h2 рассчитан на карточки главного экрана). */
.reset-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 16px;
  text-align: center;
}

/* Панель «ссылка недействительна»: текст и кнопка друг под другом. */
.reset-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- main --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.account-email {
  color: var(--dim);
  font-size: 13px;
}

.content {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.banner {
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
}

.banner-error {
  background: rgba(226, 100, 90, 0.12);
  border: 1px solid rgba(226, 100, 90, 0.4);
  color: #f2a19b;
}

/* Баннер неподтверждённой почты: это не ошибка, а незавершённое действие —
   поэтому предупреждающий (жёлтый), а не красный тон. */
.banner-warn {
  background: rgba(224, 184, 79, 0.12);
  border: 1px solid rgba(224, 184, 79, 0.4);
  color: #ead9a2;
}

/* Текст баннера и кнопка повторной отправки — в строку, но с переносом на
   узких экранах (баннер живёт в общей .content-колонке). */
.banner-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.banner-status { font-size: 12px; }
.banner-status-error { color: var(--error); }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kv-grid div { display: flex; flex-direction: column; gap: 4px; }
.kv-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); }
.kv-value { font-size: 15px; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  width: fit-content;
}

.pill-ok { background: rgba(79, 209, 197, 0.15); color: var(--accent); }
.pill-bad { background: rgba(226, 100, 90, 0.15); color: var(--error); }

.quota-block { display: flex; flex-direction: column; gap: 8px; }

.quota-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.quota-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.quota-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.quota-bar-fill.over { background: var(--error); }
.quota-bar-fill.warn { background: var(--warn); }

.inline-form {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-bottom: 16px;
}

.inline-form input { flex: 1; }

.reveal-box {
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reveal-label { font-size: 12px; color: var(--dim); }
.reveal-box code { word-break: break-all; color: var(--accent); }

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.item-row:last-child { border-bottom: none; }

.item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-title a { color: var(--accent); text-decoration: none; }
.item-title a:hover { text-decoration: underline; }
.item-sub { color: var(--dim); font-size: 12px; }

.empty-state { color: var(--dim); font-size: 13px; padding: 8px 0; }

.icon-btn {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 5px;
  flex-shrink: 0;
}

.icon-btn:hover { color: var(--error); background: rgba(226, 100, 90, 0.1); }

.icon-btn.confirming {
  color: var(--error);
  background: rgba(226, 100, 90, 0.12);
  font-weight: 600;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--error);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.cli-intro {
  margin: 0 0 16px;
  font-size: 13px;
}

.cli-download {
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.cli-download:hover { text-decoration: underline; }

.cli-steps {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 12px;
  overflow-x: auto;
}

.cli-steps code {
  color: var(--text);
  line-height: 1.7;
  white-space: pre;
}

.cli-note {
  color: var(--dim);
  font-size: 12px;
}

.cli-note code { color: var(--dim); }

.gui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.gui-table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.gui-table tr:last-child td { border-bottom: none; }

.gui-table td:first-child {
  font-weight: 500;
  white-space: nowrap;
  padding-right: 16px;
}

.gui-table td:last-child { color: var(--dim); }

.gui-table a { color: var(--accent); text-decoration: none; }
.gui-table a:hover { text-decoration: underline; }

/* --- форма обратной связи --- */

/* .fb-backdrop задаёт display:flex, поэтому без правила [hidden] выше он не
   скрывался бы. z-index выше тоста (100): модалка должна перекрывать его. */
.fb-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 11, 13, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.fb-modal {
  position: relative;
  width: 100%;
  max-width: 500px;
  /* Длинное обращение (до 4000 символов) иначе уводит верх модалки за экран. */
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.fb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.fb-title { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.fb-sub { margin: 0 0 16px; color: var(--dim); font-size: 12px; line-height: 1.55; }

.fb-close {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.fb-close:hover { color: var(--text); }

.fb-seg {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.fb-seg-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--dim);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 0;
  border-radius: 6px;
  cursor: pointer;
}

.fb-seg-btn.on { background: var(--border); color: var(--text); }

#feedback-message {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 10px;
  min-height: 104px;
  resize: vertical;
  line-height: 1.5;
}

#feedback-message:focus { outline: none; border-color: var(--accent); }

/* Счётчик идёт сразу под полем, а не через общий gap формы. */
.fb-counter {
  text-align: right;
  font-size: 11px;
  color: var(--dim);
  margin-top: -8px;
  font-variant-numeric: tabular-nums;
}

/* Honeypot: за экраном, но в DOM — иначе боты его не увидят. */
.fb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Адрес ответа — строка, а не поле: сервер берёт почту аккаунта. */
.fb-contact { margin: 0; font-size: 12px; color: var(--dim); }
.fb-contact span { color: var(--text); }

.fb-foot { display: flex; justify-content: flex-end; gap: 8px; }

/* Состояние успеха — свой контейнер, и отступы ему задаёт этот gap: у формы
   расстояние между элементами даёт form{gap}, а здесь его не было, и кнопки
   липли к тексту. */
#feedback-success { display: flex; flex-direction: column; gap: 16px; }

.fb-state { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; line-height: 1.55; }
.fb-state-mark { font-size: 15px; line-height: 1; flex-shrink: 0; }
.fb-ok { color: var(--accent); }
.fb-state-title { font-weight: 600; margin-bottom: 4px; }
.fb-state-text { color: var(--dim); }

/* Клавиатурная навигация: у кнопок без этого фокус не виден. */
.fb-close:focus-visible,
.fb-seg-btn:focus-visible,
.fb-foot .btn-ghost:focus-visible,
.fb-foot .btn-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Мобильный: модалка уезжает вниз и занимает всю ширину — на телефоне
   клавиатура съедает пол-экрана, и центрированная форма становится недоступной.
   Кнопки встают в столбик и растягиваются: попадать по ним большим пальцем
   проще, а основная («Отправить») оказывается внизу. */
@media (max-width: 720px) {
  .fb-backdrop { padding: 0; align-items: flex-end; }
  .fb-modal {
    max-width: none;
    max-height: calc(100vh - 24px);
    border-radius: 14px 14px 0 0;
    padding: 16px 16px 18px;
  }
  #feedback-message { min-height: 84px; }
  .fb-foot { flex-direction: column; }
  .fb-foot .btn-primary, .fb-foot .btn-ghost { width: 100%; }
}
