:root {
  --bg: #06070c;
  --bg-soft: #0d1018;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-strong: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eef1f7;
  --muted: #8a93a6;
  --accent: #4ade80;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Пока перевод не применён, страницу не показываем — иначе пользователь
   успевает увидеть русскую разметку. Атрибут снимает /js/i18n.js (в т.ч. по
   страховочному таймауту), поэтому «залипнуть» скрытой она не может. */
html[data-i18n-pending] body { visibility: hidden; }

/* Кириллица и латиница отдают Inter, но CJK-глифов в нём нет — добавляем
   системные восточноазиатские шрифты в конец стека. */
html[lang^="zh"] body {
  font-family: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei",
    "Hiragino Sans GB", "Source Han Sans SC", system-ui, sans-serif;
}

.glow {
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(50% 55% at 20% 25%, rgba(74, 222, 128, 0.16), transparent 70%),
    radial-gradient(45% 50% at 82% 20%, rgba(34, 211, 238, 0.14), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
  z-index: 0;
}

code { font-family: var(--mono); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ layout */

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 40px 20px 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}

.brand__mark {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand__mark:hover { text-decoration: none; }
.brand__dot { color: var(--accent); }

.brand__tag {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.footer {
  margin-top: auto;
  font-size: 13px;
  color: var(--muted);
}
.footer code { color: var(--text); }

/* ---------------------------------------------------------------- sponsors */

.sponsors {
  display: grid;
  gap: 14px;
}

.sponsors__title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-align: center;
}

/* ---------------------------------------------------------------- banners */

.banners {
  display: grid;
  gap: 14px;
}

.banner {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  transition: transform 0.16s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.banner:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

.banner:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.banner img {
  display: block;
  width: 100%;
  height: auto;
}

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  backdrop-filter: blur(14px);
}

.card--center { text-align: center; }

.card__title {
  margin: 0 0 12px;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 700;
}

.card__text {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 15px;
}

.card__text code { color: var(--accent); }

.card__note {
  min-height: 20px;
  margin: 16px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}
.card__note.is-error { color: var(--danger); }

.card__retention {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.card__footer {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--muted);
}

/* ----------------------------------------------------------------- buttons */

.actions {
  display: grid;
  gap: 12px;
}

/* Виджет «я не робот». Держим высоту минимальной, чтобы при выключенной
   капче (или пока скрипт грузится) форма не прыгала. */
.captcha {
  margin: 16px 0 0;
  display: flex;
  justify-content: center;
  min-height: 0;
}
.captcha[hidden] { display: none; }

/* Своя проверка: рисуем сами, без внешних скриптов и iframe. */
.captcha--pow {
  display: block;
}

.pow {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  padding: 12px 14px;
  text-align: left;
}

.pow__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.pow__control {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.pow__control:disabled { cursor: default; }

.pow__tick {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 2px solid var(--line-strong);
  border-radius: 5px;
  background: var(--bg-soft);
  position: relative;
  transition: border-color 0.18s ease, background 0.18s ease;
}

/* Внутри — только одна галочка, поэтому псевдоэлементом поворачиваем уголок. */
.pow__tick::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 2px;
  width: 6px;
  height: 12px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.18s ease;
}

.pow__brand {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.pow__hint {
  margin: 8px 0 0;
  min-height: 1em;
  font-size: 12px;
  color: var(--muted);
}

.pow__hint:empty { display: none; }

/* Решаем: показываем бегунок и слегка подсвечиваем рамку. */
.captcha--pow.is-busy .pow { border-color: var(--line-strong); }

.captcha--pow.is-busy .pow__tick {
  border-color: var(--accent-2);
  border-top-color: transparent;
  border-radius: 50%;
  animation: pow-spin 0.75s linear infinite;
}

/* Готово: зелёная галочка. */
.captcha--pow.is-done .pow__tick {
  border-color: var(--accent);
  background: var(--accent);
}
.captcha--pow.is-done .pow__tick::after { transform: rotate(45deg) scale(1); }
.captcha--pow.is-done .pow__control { color: var(--accent); }

@keyframes pow-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .captcha--pow.is-busy .pow__tick { animation-duration: 2s; }
  .pow__tick, .pow__tick::after { transition: none; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04120a;
}
.btn--primary:hover { filter: brightness(1.06); }

.btn--ghost {
  background: var(--panel-strong);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.1); }

.btn--sm { padding: 9px 14px; font-size: 11.5px; letter-spacing: 0.08em; }
.btn--full { width: 100%; }

.copy {
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.copy:hover { color: var(--text); background: rgba(255, 255, 255, 0.1); }
.copy--sm { padding: 4px 8px; font-size: 10.5px; }

.copy-all {
  width: 100%;
  margin-top: 2px;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(74, 222, 128, 0.45);
  background: rgba(74, 222, 128, 0.12);
  color: var(--accent);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.copy-all:hover { background: rgba(74, 222, 128, 0.2); border-color: var(--accent); }
.copy-all.is-done {
  background: var(--accent);
  border-color: var(--accent);
  color: #04120a;
}

/* ------------------------------------------------------------------ inputs */

.form { display: grid; gap: 16px; }

.input { display: grid; gap: 7px; }

.input span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.input input {
  width: 100%;
  padding: 13px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.input input:focus { border-color: var(--accent); }
.input input::placeholder { color: #5b6373; }

/* ------------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 9, 0.78);
  backdrop-filter: blur(6px);
}

.modal__box {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: pop 0.18s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal__title {
  margin: 0 0 20px;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.modal__warn {
  margin: 20px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.09);
  border: 1px solid rgba(248, 113, 113, 0.28);
  color: #fca5a5;
  font-size: 13px;
}

.modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.field { margin-bottom: 14px; }

.field__label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 7px;
}

.field__value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.field__value code {
  font-size: 15px;
  overflow-wrap: anywhere;
  color: var(--accent);
}

/* ---------------------------------------------------------------- app view */

body.app { display: block; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  background: rgba(6, 7, 12, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.topbar__address {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 8px 12px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.topbar__address code { font-size: 13.5px; color: var(--accent); }

.topbar__actions { display: flex; gap: 8px; }

.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  padding: 18px 22px 40px;
  align-items: start;
}

.list, .reader {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.list__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.list__head h2 { margin: 0; font-size: 15px; letter-spacing: 0.02em; }

.pill {
  min-width: 26px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.14);
  color: var(--accent);
  font-size: 12px;
  text-align: center;
}

.list__body { max-height: calc(100vh - 190px); overflow-y: auto; }

.item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.item:hover { background: rgba(255, 255, 255, 0.04); }
.item.is-active { background: rgba(74, 222, 128, 0.09); box-shadow: inset 2px 0 0 var(--accent); }

.item__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.item__subject {
  margin: 5px 0 3px;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item__intro {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader { padding: 24px; min-height: 320px; }

.reader__subject {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 1.25;
}

.reader__meta {
  display: grid;
  gap: 4px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--muted);
}
.reader__meta code { color: var(--text); }

.reader__body {
  font-size: 14.5px;
  overflow-wrap: anywhere;
}

.reader__body iframe {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.reader__body pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 13px;
}

.empty {
  margin: 0;
  padding: 40px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  font-size: 13px;
}
.toast[hidden] { display: none; }

/* ----------------------------------------------------------- lang switcher */

.lang {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.lang__btn {
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.6;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.lang__btn:hover { color: var(--text); }

.lang__btn.is-active {
  background: var(--panel-strong);
  color: var(--accent);
}

.lang__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* В верхней панели место справа уже занято кнопками — сдвиг не нужен. */
.topbar__actions .lang { margin-left: 4px; }

.modal__retention {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

/* ------------------------------------------------------------------- media */

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .list__body { max-height: 46vh; }
  .topbar { gap: 10px; }
  .topbar__address { margin-left: 0; order: 3; width: 100%; }
  .topbar__actions { margin-left: auto; }
}

@media (max-width: 640px) {
  .shell { padding: 26px 16px; }
  .card { padding: 22px; }
  .card__title { font-size: 25px; }
  .modal__actions { grid-template-columns: 1fr; }
  .layout { padding: 14px; }
}
