/*
 * Страница входа и кабинета Vrata.
 * Оформление по макету «login» (Figma, кадр 1920×1080): карточка 492 px с радиусом 21, поля и
 * кнопка высотой 60 px с радиусом 12, вкладки-«таблетка» с градиентной рамкой в 1 px.
 * Шрифт Inter (свой, из /static/fonts), подмножества: кириллица и латиница.
 */

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/static/fonts/inter-cyrillic-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/static/fonts/inter-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Тёмная тема: значения сняты с макета. */
:root {
  color-scheme: dark;
  --bg: #060608;
  --card: #1a1a23;
  --field: #1e1e29;
  --field-line: #343447;
  --ring-from: #272735; /* начало градиентной рамки; конец совпадает с цветом карточки */
  --pill: #121219; /* выбранная вкладка: чёрный с прозрачностью 30 % поверх карточки */
  --text: #ffffff;
  --dim: rgba(255, 255, 255, 0.5);
  --btn-bg: #060609;
  --btn-text: #ffffff;
  --ok: #5fcf9a;
  --bad: #ff8a80;
}

/* Светлая тема в макете не нарисована, цвета подобраны в том же строе. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eceef5;
  --card: #ffffff;
  --field: #f4f5fa;
  --field-line: #d3d6e4;
  --ring-from: #d9dbea;
  --pill: #efeff4;
  --text: #14141c;
  --dim: rgba(20, 20, 28, 0.6);
  --btn-bg: #14141c;
  --btn-text: #ffffff;
  --ok: #17794a;
  --bad: #b3261e;
}
/* Без скрипта тему выбирает система. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #eceef5;
    --card: #ffffff;
    --field: #f4f5fa;
    --field-line: #d3d6e4;
    --ring-from: #d9dbea;
    --pill: #efeff4;
    --text: #14141c;
    --dim: rgba(20, 20, 28, 0.6);
    --btn-bg: #14141c;
    --btn-text: #ffffff;
    --ok: #17794a;
    --bad: #b3261e;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 16px 24px;
}
main > * { width: 100%; max-width: 492px; }
/* Кабинет длинный: прижимаем к верху. */
body[data-view="account"] main { justify-content: flex-start; }

.foot {
  padding: 0 16px 22px;
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
}

/* Правый верхний угол (как в макете): выбор языка и переключатель темы. */
.topbar { position: fixed; top: 12px; right: 14px; z-index: 10; display: flex; align-items: center; gap: 4px; }
.theme-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: block; }
:root[data-theme="light"] .theme-toggle .i-moon { display: none; }

h1 { margin: 0; font-size: 31px; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.muted { color: var(--dim); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.9rem; }
.big { font-size: 1.25rem; font-weight: 600; }
small { display: block; margin-top: 8px; font-size: 13px; line-height: 1.4; font-weight: 400; color: var(--dim); }
code { font-family: ui-monospace, Consolas, monospace; }

/* ---------- карточки ---------- */

.card {
  background: var(--card);
  border-radius: 21px;
  padding: 24px;
  margin-bottom: 16px;
}
.row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

/* Карточка входа: поля 30 px, высота как в макете. */
.auth { padding: 24px 30px 30px; margin-bottom: 0; display: flex; flex-direction: column; }
@media (min-width: 560px) { .auth { min-height: 608px; } }
.auth-head { margin-bottom: 33px; }
.auth-head p { margin: 2px 0 0; font-size: 15px; line-height: 1.5; }
.page-head { margin-bottom: 24px; }
.page-head p { margin: 2px 0 0; }

/* ---------- вкладки ---------- */

.tabs {
  display: flex;
  gap: 4px;
  padding: 5px;
  margin: 0 -3px 35px;
  border: 1px solid transparent;
  border-radius: 30px;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(150deg, var(--ring-from), var(--card)) border-box;
}
.tabs button {
  flex: 1 1 auto;
  height: 50px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 25px;
  background: none;
  color: var(--dim);
  font-family: inherit; font-size: 18px; font-weight: 500; line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}
.tabs button[aria-selected="true"] {
  color: var(--text);
  background:
    linear-gradient(var(--pill), var(--pill)) padding-box,
    linear-gradient(114deg, var(--ring-from), var(--card)) border-box;
}

/* ---------- формы ---------- */

form { display: block; }
.auth form:not([hidden]) { display: flex; flex-direction: column; flex: 1; }

label { display: block; margin-bottom: 23px; font-size: 18px; line-height: 24px; font-weight: 500; }

/* Поле 60 px внутри и рамка 1 px снаружи (в макете рамка выступает на 1 px). */
input {
  display: block;
  width: calc(100% + 2px);
  height: 62px;
  margin: 6px -1px 0;
  padding: 0 18px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font-family: inherit; font-size: 18px; font-weight: 400; line-height: 1;
}
input::placeholder { color: var(--dim); }
input:focus { border-color: var(--accent, var(--text)); outline: none; }
input:focus-visible { box-shadow: 0 0 0 2px var(--accent, var(--text)); }

button { font: inherit; }
button:focus-visible, a.btn:focus-visible { outline: 2px solid var(--accent, var(--text)); outline-offset: 2px; }
button:disabled { opacity: 0.6; cursor: progress; }

button.primary {
  width: 100%;
  height: 60px;
  margin-top: auto;
  border: 0;
  border-radius: 12px;
  background: var(--accent, var(--btn-bg));
  color: var(--accent-text, var(--btn-text));
  font-family: inherit; font-size: 18px; font-weight: 600; line-height: 1;
  cursor: pointer;
}
button.primary:hover:not(:disabled) { filter: brightness(1.2); }
:root[data-theme="light"] button.primary:hover:not(:disabled) { filter: brightness(1.35); }

/* Второстепенные кнопки (кабинет, восстановление). */
button:not(.primary):not(.eye):not(.theme-toggle):not([role="tab"]):not(.lang-btn):not([role="menuitemradio"]) {
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}
button:not(.primary):not(.eye):not(.theme-toggle):not([role="tab"]):not(.lang-btn):not([role="menuitemradio"]):hover:not(:disabled) { border-color: var(--dim); }

a.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font-family: inherit; font-size: 18px; font-weight: 500; line-height: 1;
  text-decoration: none;
}
a.btn:hover { border-color: var(--dim); }
#google-wrap { margin: 16px 0 0; }

fieldset { margin: 0 0 16px; padding: 16px; border: 1px solid var(--field-line); border-radius: 12px; }
legend { padding: 0 6px; color: var(--dim); font-size: 15px; }
fieldset label { font-size: 16px; margin-bottom: 16px; }
fieldset input { height: 54px; font-size: 16px; }

/* ---------- кнопка-глазок у поля пароля ---------- */

.pw { position: relative; display: block; width: calc(100% + 2px); margin: 6px -1px 0; }
.pw input { width: 100%; margin: 0; padding-right: 56px; }
.eye {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--dim);
  cursor: pointer;
}
.eye:hover { color: var(--text); }
.eye .i-hide { display: none; }
.eye[aria-pressed="true"] .i-show { display: none; }
.eye[aria-pressed="true"] .i-hide { display: block; }

/* ---------- кабинет ---------- */

#view-account label { font-size: 16px; margin-bottom: 16px; }
#view-account input { height: 52px; font-size: 16px; }
form.inline { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
form.inline input { flex: 1 1 180px; min-width: 0; width: auto; height: 48px; margin: 0; font-size: 16px; }
form.inline .pw { flex: 1 1 180px; min-width: 0; width: auto; margin: 0; }
form.inline .pw input { width: 100%; height: 48px; }
form.inline button { height: 48px; white-space: nowrap; }

ul.plain { list-style: none; margin: 0 0 12px; padding: 0; }
ul.plain li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--field-line);
}
ul.plain li:last-child { border-bottom: none; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--field-line); color: var(--dim); }
.tag.ok { color: var(--ok); border-color: var(--ok); }
pre { margin: 12px 0 0; padding: 12px; border: 1px solid var(--field-line); border-radius: 12px; background: var(--field); white-space: pre-wrap; }

/* ---------- сообщения и подсказки ---------- */

#msg {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--card);
  font-size: 15px;
  white-space: pre-line;
}
#msg.ok { color: var(--ok); border-color: var(--ok); }
#msg.bad { color: var(--bad); border-color: var(--bad); }

/* Подсказка о стойкости пароля под полем ввода. */
.pw-hint {
  margin: -11px 0 23px;
  padding: 10px 12px;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 400;
  white-space: pre-line;
}
.pw-hint.good { color: var(--ok); border-color: var(--ok); }
.pw-hint.bad { color: var(--bad); border-color: var(--bad); }

@media (prefers-reduced-motion: no-preference) {
  button, a.btn, input, .eye { transition: background-color 0.15s, border-color 0.15s, color 0.15s, filter 0.15s; }
}

/* ---------- узкие экраны ---------- */

@media (max-width: 520px) {
  main { padding-top: 64px; }
  .auth { padding: 20px 20px 24px; }
  h1 { font-size: 26px; }
  .tabs button { padding: 0 8px; font-size: 16px; }
  label { font-size: 17px; }
  input { font-size: 17px; }
}
.pw-hint strong { font-weight: 600; }

/* ---------- выбор языка (как в макете: «Русский ▾» слева от значка темы) ---------- */

.lang { position: relative; }
.lang-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}
.lang-btn svg { color: var(--dim); }
.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 170px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.lang-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.lang-menu button:hover { background: var(--field); }
.lang-menu button[aria-checked="true"] { font-weight: 600; }
.lang-menu button[aria-checked="true"]::after { content: "✓"; color: var(--dim); }

/* До подстановки текстов на языке человека страница скрыта (см. theme.ts). */
html[data-pending] body { visibility: hidden; }

/* Длинные подписи вкладок (испанский, английский) не должны упираться в край панели. */
html[lang="es"] .tabs button, html[lang="en"] .tabs button { font-size: 16px; padding: 0 12px; }
@media (max-width: 520px) {
  .tabs button, html[lang="es"] .tabs button, html[lang="en"] .tabs button { font-size: 15px; padding: 0 6px; }
}
