/* Geologica — заголовки и интерфейс, JetBrains Mono — данные (адреса, ключи,
   коды). Лежат локально: CSP запрещает чужие домены, а вместе с PWA сайт
   благодаря этому открывается без интернета. */
@font-face {
  font-family: 'Geologica';
  src: url('/fonts/geologica-cyrillic.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Geologica';
  src: url('/fonts/geologica-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2192, U+2212;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-cyrillic.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2192, U+2212;
}

/* Стекло не бывает на плоской заливке: под ним всегда есть что размывать.
   Поэтому фон — цветные пятна, а поверхности полупрозрачны и подкрашиваются
   тем, что под ними. Тема следует за системной; переключатель в шапке
   перекрывает её через data-theme на <html>.

   Палитра «Фарфор и тушь»: холодный белый и чёрный акцент. Цвет в интерфейсе
   появляется только там, где он что-то значит — состояние, ошибка, голограмма. */
:root {
  --bg: #f8f9fa;
  --tint-1: #dce4e6;
  --tint-2: #e6e4e9;
  --tint-3: #e9e7e2;

  --glass: rgba(255, 255, 255, .62);
  --glass-2: rgba(255, 255, 255, .4);
  --glass-hi: rgba(255, 255, 255, .92);
  --stroke: rgba(13, 15, 18, .1);
  --line: rgba(13, 15, 18, .07);

  --text: #0d0f12;
  --muted: #6b7075;

  /* --accent — действия: главная кнопка, фокус, ссылки, змейка.
     --ok — состояния: аптайм, успех, штамп «забран». Раньше это был один
     токен, но чёрная полоса аптайма читается как поломка, а не как «работает». */
  --accent: #0d0f12;
  --accent-hover: #2a2e33;
  --accent-soft: rgba(13, 15, 18, .07);
  --accent-ink: #f8f9fa;
  --ok: #2e7d57;
  --ok-soft: rgba(46, 125, 87, .12);
  --danger: #c0392b;

  /* Плёнка на пропуске. Четыре тона замыкают круг, ни один не уходит
     в чистый RGB — перелив остаётся частью палитры, а не радугой поверх неё. */
  --ovd-1: #8fd3c7;
  --ovd-2: #f2c9a8;
  --ovd-3: #c9b8e8;
  --ovd-4: #a8c8e8;

  /* Поле змейки. Canvas рисуется пикселями и не умеет пропускать сквозь себя
     размытый фон, поэтому цвет непрозрачный, а не из стеклянных токенов. */
  --board: #ffffff;
  --board-line: rgba(13, 15, 18, .06);

  --blur: 14px;
  --shadow: 0 1px 1px rgba(13, 15, 18, .04), 0 10px 30px rgba(13, 15, 18, .07);
  --radius: 18px;
}

[data-theme='dark'] {
  --bg: #0e1013;
  --tint-1: #1b2a2e;
  --tint-2: #232430;
  --tint-3: #2a2926;

  --glass: rgba(255, 255, 255, .07);
  --glass-2: rgba(255, 255, 255, .04);
  --glass-hi: rgba(255, 255, 255, .16);
  --stroke: rgba(255, 255, 255, .12);
  --line: rgba(255, 255, 255, .08);

  --text: #f2f4f6;
  --muted: #9ba1a8;

  --accent: #f2f4f6;
  --accent-hover: #d8dce0;
  --accent-soft: rgba(242, 244, 246, .12);
  --accent-ink: #0e1013;
  --ok: #6fcf97;
  --ok-soft: rgba(111, 207, 151, .16);
  --danger: #e88374;

  --board: #15181c;
  --board-line: rgba(255, 255, 255, .06);

  --shadow: 0 1px 1px rgba(0, 0, 0, .4), 0 14px 40px rgba(0, 0, 0, .55);
}

[data-theme='terminal'] {
  --bg: #050806; --tint-1: #0b2416; --tint-2: #102217; --tint-3: #07140d;
  --glass: rgba(10, 35, 19, .78); --glass-2: rgba(5, 25, 12, .7); --glass-hi: rgba(82, 255, 143, .16);
  --stroke: rgba(98, 255, 152, .3); --line: rgba(98, 255, 152, .16);
  --text: #9dffb8; --muted: #5caf73; --accent: #65ff91; --accent-hover: #9dffb8; --accent-soft: rgba(101, 255, 145, .14); --accent-ink: #041008;
  --ok: #65ff91; --ok-soft: rgba(101, 255, 145, .18); --danger: #ff857e; --board: #07140d; --board-line: rgba(101, 255, 145, .12); --radius: 6px; --blur: 4px;
}
[data-theme='paper'] {
  --bg: #eee8dc; --tint-1: #ded2bc; --tint-2: #e5d6c8; --tint-3: #d7cbb6;
  --glass: rgba(255, 251, 241, .78); --glass-2: rgba(255, 251, 241, .5); --glass-hi: rgba(255, 255, 255, .95);
  --stroke: rgba(59, 45, 29, .2); --line: rgba(59, 45, 29, .12); --text: #30271f; --muted: #776957; --accent: #30271f; --accent-hover: #514334; --accent-soft: rgba(48, 39, 31, .1); --accent-ink: #fffaf0; --ok: #3f7850; --ok-soft: rgba(63, 120, 80, .14); --danger: #a54135; --board: #fffaf0; --board-line: rgba(48, 39, 31, .1); --blur: 2px; --radius: 10px;
}
[data-theme='violet'] {
  --bg: #100d1d; --tint-1: #291c46; --tint-2: #321d3b; --tint-3: #171f46;
  --glass: rgba(37, 27, 61, .65); --glass-2: rgba(23, 18, 43, .55); --glass-hi: rgba(233, 173, 255, .18);
  --stroke: rgba(221, 178, 255, .2); --line: rgba(221, 178, 255, .12); --text: #f5edff; --muted: #b7a8ca; --accent: #e3a8ff; --accent-hover: #f0caff; --accent-soft: rgba(227, 168, 255, .16); --accent-ink: #21102e; --ok: #78e7bd; --ok-soft: rgba(120, 231, 189, .16); --danger: #ff8fa4; --board: #19132b; --board-line: rgba(227, 168, 255, .1);
}
.theme-picker { position: relative; }
.theme-picker summary { list-style: none; }
.theme-picker summary::-webkit-details-marker { display: none; }
.theme-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; display: grid; min-width: 130px; gap: 3px; padding: 6px; border: 1px solid var(--stroke); border-radius: 12px; background: var(--bg); box-shadow: var(--shadow); }
.theme-menu button { width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; backdrop-filter: none; font-size: 12px; text-align: left; }
.theme-menu button:hover { background: var(--accent-soft); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e1013;
    --tint-1: #1b2a2e;
    --tint-2: #232430;
    --tint-3: #2a2926;

    --glass: rgba(255, 255, 255, .07);
    --glass-2: rgba(255, 255, 255, .04);
    --glass-hi: rgba(255, 255, 255, .16);
    --stroke: rgba(255, 255, 255, .12);
    --line: rgba(255, 255, 255, .08);

    --text: #f2f4f6;
    --muted: #9ba1a8;

    --accent: #f2f4f6;
    --accent-hover: #d8dce0;
    --accent-soft: rgba(242, 244, 246, .12);
    --accent-ink: #0e1013;
    --ok: #6fcf97;
    --ok-soft: rgba(111, 207, 151, .16);
    --danger: #e88374;

    --board: #15181c;
    --board-line: rgba(255, 255, 255, .06);

    --shadow: 0 1px 1px rgba(0, 0, 0, .4), 0 14px 40px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(38vw 38vw at 12% 8%, var(--tint-1), transparent 65%),
    radial-gradient(44vw 44vw at 88% 22%, var(--tint-2), transparent 62%),
    radial-gradient(40vw 40vw at 50% 96%, var(--tint-3), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.6 'Geologica', ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Подложка для стекла: размытые пятна, зафиксированные за контентом. Слои
   намеренно статичны: если вращать градиент под backdrop-filter, браузер
   пересобирает размытие на каждом кадре и интерфейс начинает заикаться.

   translate стоит отдельным свойством, а не внутри transform: параллакс
   за курсором тогда не конфликтует с остальными стилями слоя. */
body::before,
body::after {
  content: '';
  position: fixed;
  inset: -24vh -24vw;
  z-index: -1;
  pointer-events: none;
}

body::before {
  background:
    radial-gradient(38vw 38vw at 30% 26%, var(--tint-1), transparent 62%),
    radial-gradient(44vw 44vw at 72% 40%, var(--tint-2), transparent 60%);
  opacity: .85;
  translate: none;
  animation: none;
}

body::after {
  background: radial-gradient(46vw 46vw at 50% 74%, var(--tint-3), transparent 60%);
  opacity: .7;
  translate: none;
  animation: none;
}

[data-theme='dark'] body::before { opacity: .9; }
[data-theme='dark'] body::after { opacity: .75; }
[data-theme='terminal'] {
  --bg: #050806; --tint-1: #0b2416; --tint-2: #102217; --tint-3: #07140d;
  --glass: rgba(10, 35, 19, .78); --glass-2: rgba(5, 25, 12, .7); --glass-hi: rgba(82, 255, 143, .16);
  --stroke: rgba(98, 255, 152, .3); --line: rgba(98, 255, 152, .16);
  --text: #9dffb8; --muted: #5caf73; --accent: #65ff91; --accent-hover: #9dffb8; --accent-soft: rgba(101, 255, 145, .14); --accent-ink: #041008;
  --ok: #65ff91; --ok-soft: rgba(101, 255, 145, .18); --danger: #ff857e; --board: #07140d; --board-line: rgba(101, 255, 145, .12); --radius: 6px; --blur: 4px;
}
[data-theme='paper'] {
  --bg: #eee8dc; --tint-1: #ded2bc; --tint-2: #e5d6c8; --tint-3: #d7cbb6;
  --glass: rgba(255, 251, 241, .78); --glass-2: rgba(255, 251, 241, .5); --glass-hi: rgba(255, 255, 255, .95);
  --stroke: rgba(59, 45, 29, .2); --line: rgba(59, 45, 29, .12); --text: #30271f; --muted: #776957; --accent: #30271f; --accent-hover: #514334; --accent-soft: rgba(48, 39, 31, .1); --accent-ink: #fffaf0; --ok: #3f7850; --ok-soft: rgba(63, 120, 80, .14); --danger: #a54135; --board: #fffaf0; --board-line: rgba(48, 39, 31, .1); --blur: 2px; --radius: 10px;
}
[data-theme='violet'] {
  --bg: #100d1d; --tint-1: #291c46; --tint-2: #321d3b; --tint-3: #171f46;
  --glass: rgba(37, 27, 61, .65); --glass-2: rgba(23, 18, 43, .55); --glass-hi: rgba(233, 173, 255, .18);
  --stroke: rgba(221, 178, 255, .2); --line: rgba(221, 178, 255, .12); --text: #f5edff; --muted: #b7a8ca; --accent: #e3a8ff; --accent-hover: #f0caff; --accent-soft: rgba(227, 168, 255, .16); --accent-ink: #21102e; --ok: #78e7bd; --ok-soft: rgba(120, 231, 189, .16); --danger: #ff8fa4; --board: #19132b; --board-line: rgba(227, 168, 255, .1);
}
.theme-picker { position: relative; }
.theme-picker summary { list-style: none; }
.theme-picker summary::-webkit-details-marker { display: none; }
.theme-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; display: grid; min-width: 130px; gap: 3px; padding: 6px; border: 1px solid var(--stroke); border-radius: 12px; background: var(--bg); box-shadow: var(--shadow); }
.theme-menu button { width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; backdrop-filter: none; font-size: 12px; text-align: left; }
.theme-menu button:hover { background: var(--accent-soft); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) body::before { opacity: .9; }
  :root:not([data-theme]) body::after { opacity: .75; }
}

/* На ПК фоновые слои вообще не участвуют в отрисовке. Это не «пауза» и не
   скрытая анимация: браузер не создаёт огромные фиксированные поверхности. */
/* Псевдослои больше не нужны: пятна живут в обычном background body,
   поэтому браузеру нечего композить и размывать отдельными поверхностями. */
body::before,
body::after { display: none !important; }

/* Вращение огромных градиентов заставляет backdrop-filter пересобираться
   на каждом кадре. Поэтому фон намеренно статичен на всех экранах, а
   параллакс отключён в CSS — скрипт оставляет переменные только для обратной
   совместимости. */

/* Стекло оставляем и на desktop: хэдер должен выглядеть одинаково
   на телефоне и большом экране. Фон статичный, поэтому эффект не вызывает
   постоянную переработку слоя. */
.topbar,
.card,
button,
.btn,
.overlay,
.tabbar {
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
}

main { max-width: 960px; margin: 0 auto; padding: 30px 20px 72px; }

/* --- Bento-обзор дашборда --- */
/* Разные размеры плиток создают иерархию: главный ключ заметнее служебных
   данных. Здесь нет backdrop-filter — это лёгкая статичная композиция,
   поэтому красивый обзор не возвращает лаги на 2K и iPhone. */
.bento-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(122px, auto);
  gap: 12px;
  margin: 0 0 22px;
}
.bento-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  min-height: 122px;
  padding: 17px 18px;
  overflow: hidden;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: var(--glass-2);
  box-shadow: 0 8px 22px rgba(13, 15, 18, .045);
}
.bento-tile::after {
  content: '';
  position: absolute;
  right: -28px;
  bottom: -38px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--accent-soft);
  pointer-events: none;
}
.bento-key-tile {
  grid-column: span 2;
  grid-row: span 2;
  justify-content: space-between;
  min-height: 256px;
  background: linear-gradient(145deg, var(--glass-hi), var(--glass-2));
}
.bento-status-tile { grid-column: span 4; }
.bento-happ-tile,
.bento-action-tile { grid-column: span 1; }
.bento-head,
.bento-tile form { position: relative; z-index: 1; }
.bento-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}
.bento-label,
.bento-kicker {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.bento-kicker { margin-top: auto; font-size: 11px; }
.bento-ip {
  position: relative;
  z-index: 1;
  margin: 2px 0 3px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(25px, 5vw, 38px);
  font-weight: 400;
  letter-spacing: -.05em;
  line-height: 1.1;
}
.bento-tile > .muted { position: relative; z-index: 1; }
.bento-main-action {
  position: relative;
  z-index: 1;
  margin-top: 14px;
}
.bento-empty-title {
  position: relative;
  z-index: 1;
  margin-top: auto;
  font-size: 20px;
  font-weight: 500;
}
.bento-status-value {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  font-size: 17px;
  font-weight: 500;
}
.bento-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px var(--ok-soft);
}
.bento-number {
  position: relative;
  z-index: 1;
  margin-top: auto;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
}
.bento-number small { color: var(--muted); font-size: 15px; }
.bento-action-tile { justify-content: space-between; }
.bento-action-btn {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 12px;
}
.bento-action-btn:hover:not(:disabled) { background: var(--glass-hi); }
.bento-secondary-link {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 11.5px;
  text-decoration: none;
}
.bento-secondary-link:hover { color: var(--text); }

/* --- Минимальное состояние дашборда --- */
.dashboard-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -10px 2px 18px;
  padding: 0 0 9px;
  border-bottom: 1px solid var(--line);
}
.dashboard-status-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}
.dashboard-status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--ok);
}
.dashboard-status-note {
  color: var(--muted);
  font-size: 12px;
}

h1 {
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 500;
  letter-spacing: -.035em;
  margin: 0 0 22px;
}
h2 { font-size: 18px; font-weight: 500; margin: 0 0 14px; letter-spacing: -.02em; }
h3 { font-size: 15px; font-weight: 500; margin: 0 0 4px; }

.status-page { max-width: 860px; margin: 0 auto; padding: 4vh 0 7vh; }
.status-intro { margin-bottom: 24px; }
.status-kicker { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.status-intro h1 { margin: 8px 0 8px; }
.status-hero { position: relative; isolation: isolate; min-height: 290px; display: flex; align-items: flex-end; overflow: hidden; padding: 30px; border: 1px solid var(--stroke); border-radius: 24px; background: linear-gradient(135deg, var(--glass-hi), var(--glass-2)); box-shadow: var(--shadow); transform: perspective(900px) rotateX(var(--status-rx, 0deg)) rotateY(var(--status-ry, 0deg)); transition: transform .25s ease-out, border-color .25s, background .25s; }
.status-hero::before { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(circle at 78% 25%, var(--ok-soft), transparent 40%); opacity: .8; }
.status-hero.is-down { border-color: var(--danger); }
.status-hero.is-down::before { background: radial-gradient(circle at 78% 25%, color-mix(in srgb, var(--danger) 22%, transparent), transparent 40%); }
.status-orbit { position: absolute; top: 34px; right: 12%; width: 150px; height: 150px; border: 1px solid var(--ok); border-radius: 50%; opacity: .55; animation: status-pulse 3s ease-in-out infinite; }
.status-orbit::before, .status-orbit::after { content: ''; position: absolute; inset: 18px; border: 1px solid var(--ok); border-radius: 50%; opacity: .55; }
.status-orbit::after { inset: 38px; }
.status-orbit span { position: absolute; top: 50%; left: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 8px var(--ok-soft), 0 0 28px var(--ok); transform: translate(-50%, -50%); }
.is-down .status-orbit { border-color: var(--danger); animation: none; }

/* Голографический блик: мягкий белый отсвет следует за курсором по стеклу
   карточки (координаты приходят из status.js как --glare-x/--glare-y). */
.status-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(300px circle at var(--glare-x, 50%) var(--glare-y, 30%), rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 65%);
  opacity: 0;
  transition: opacity .25s ease;
}
.status-hero:hover::after { opacity: 1; }
@media (hover: none) { .status-hero::after { display: none; } }

/* Провод «Вы — Сервер»: точки бегут со скоростью последней проверки. */
.status-wire { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.wire-node { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }
.wire-line { position: relative; flex: 1; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--stroke) 15%, var(--stroke) 85%, transparent); }
.wire-line i {
  position: absolute;
  top: 50%;
  left: 0;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
  animation: wire-pulse var(--pulse-dur, 1.4s) linear infinite;
}
.wire-line i:nth-child(2) { animation-delay: calc(var(--pulse-dur, 1.4s) / -3); }
.wire-line i:nth-child(3) { animation-delay: calc(var(--pulse-dur, 1.4s) / -3 * 2); }
@keyframes wire-pulse {
  from { left: 0; opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  to { left: 100%; opacity: 0; }
}
.is-down .wire-line i { background: var(--danger); box-shadow: 0 0 10px var(--danger); animation-play-state: paused; }

/* Скелетоны списка пользователей на время фоновой подгрузки фильтра. */
.users-list[data-loading] .user-block { display: none; }
.skeleton-user {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--glass);
}
.skeleton-row { display: flex; align-items: center; gap: 10px; }
.sk {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--glass) 25%, var(--glass-2) 45%, var(--glass) 65%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.2s linear infinite;
}
.sk-avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }
.sk-line { flex: 1; }
.sk-short { width: 90px; }
@keyframes sk-shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .wire-line i { animation: none; opacity: .85; }
  .sk { animation: none; }
  .status-hero:hover::after { opacity: 0; }
}
.is-down .status-orbit::before, .is-down .status-orbit::after { border-color: var(--danger); }
.is-down .status-orbit span { background: var(--danger); box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 18%, transparent), 0 0 28px var(--danger); }
.status-hero-content { position: relative; z-index: 1; max-width: 560px; }
.status-indicator { display: flex; align-items: center; gap: 9px; color: var(--ok); font-size: 13px; }
.status-indicator span { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 5px var(--ok-soft); }
.is-down .status-indicator { color: var(--danger); }
.status-hero h2 { margin: 10px 0 4px; font-size: clamp(25px, 5vw, 38px); }
.status-hero p { margin: 0 0 10px; color: var(--muted); }
.status-hero small { color: var(--muted); }
.status-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.status-metric { display: flex; flex-direction: column; gap: 3px; padding: 20px; border: 1px solid var(--stroke); border-radius: 16px; background: var(--glass); box-shadow: var(--shadow); }
.status-metric span, .status-metric small { color: var(--muted); }
.status-metric strong { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 28px; font-weight: 400; }
.status-history { margin-bottom: 14px; }
.status-heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.status-heatmap {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  grid-auto-flow: column;
  grid-auto-columns: 12px;
  gap: 4px;
  width: max-content;
}
.status-heatmap-week { display: contents; }
.status-cell {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok-soft);
  transition: transform .15s ease, filter .15s ease;
}
.status-cell:hover { transform: scale(1.35); filter: brightness(1.15); }
.status-cell.warn { background: #c79a43; box-shadow: none; }
.status-cell.bad { background: var(--danger); box-shadow: none; }
.status-cell.empty { background: var(--line); box-shadow: none; }
.status-heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 10px;
}
.status-heatmap-legend .status-cell { width: 11px; height: 11px; }
@media (max-width: 560px) {
  .status-heatmap { grid-template-columns: repeat(7, 10px); grid-template-rows: repeat(5, 10px); gap: 3px; }
  .status-heatmap-week { grid-template-rows: repeat(7, 10px); gap: 3px; }
  .status-cell { width: 10px; height: 10px; border-radius: 2px; }
}
.status-updated { color: var(--muted); font-size: 12px; text-align: center; }
.status-uptime-summary {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--glass-2);
}
.status-uptime-day { display: grid; justify-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.status-uptime-day i { display: block; width: 100%; max-width: 32px; aspect-ratio: 1.25; border-radius: 7px; background: var(--ok); box-shadow: 0 0 12px var(--ok-soft); }
.status-uptime-day.warn i { background: #c79a43; box-shadow: none; }
.status-uptime-day.bad i { background: var(--danger); box-shadow: none; }
.status-uptime-day.empty i { background: var(--line); border: 1px dashed var(--stroke); box-shadow: none; }
@media (max-width: 560px) { .status-uptime-summary { gap: 5px; padding: 8px 5px; } .status-uptime-day { font-size: 9px; } .status-uptime-day i { max-width: 25px; } }
.public-footer { padding: 0 20px 30px; text-align: center; }
.public-footer a { color: var(--muted); }
@keyframes status-pulse { 0%, 100% { transform: scale(.94); opacity: .35; } 50% { transform: scale(1.04); opacity: .7; } }
@media (max-width: 600px) { .status-page { padding-top: 2vh; } .status-hero { min-height: 330px; padding: 22px; } .status-orbit { top: 28px; right: 8%; width: 120px; height: 120px; } .status-metrics { gap: 8px; } .status-metric { padding: 14px 10px; } .status-metric strong { font-size: 22px; } .status-days { gap: 4px; } .status-day i { height: 30px; } }


.notification-picker { position: relative; }
.notification-picker > summary { list-style: none; }
.notification-picker > summary::-webkit-details-marker { display: none; }
.notification-link { position: relative; display: inline-flex; align-items: center; text-decoration: none; cursor: pointer; }
.notification-count { display: inline-flex; min-width: 18px; height: 18px; align-items: center; justify-content: center; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; line-height: 1; }
.notification-popover { position: absolute; top: calc(100% + 10px); right: -8px; z-index: 40; width: min(390px, calc(100vw - 24px)); max-height: min(70vh, 560px); overflow: auto; padding: 14px; border: 1px solid var(--stroke); border-radius: 16px; background: var(--bg); box-shadow: 0 16px 45px rgba(0, 0, 0, .28); backdrop-filter: none; -webkit-backdrop-filter: none; }
.notification-popover-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.notification-read-all, .notification-read { border: 0; background: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; color: var(--muted); cursor: pointer; }
.notification-read-all { padding: 3px 0; font-size: 11px; }
.notification-read { width: 25px; height: 25px; padding: 0; border-radius: 6px; font-size: 15px; }
.notification-read:hover, .notification-read-all:hover { background: transparent; color: var(--ok); }
.notification-popover .notification-item { grid-template-columns: 1fr auto; padding: 10px; background: var(--glass); }
.happ-uuid-cell, .happ-link-cell { vertical-align: middle; white-space: nowrap; }
.happ-uuid-cell, .happ-link-cell { display: table-cell; }
.happ-link { display: inline-block; max-width: 180px; overflow: hidden; color: var(--text); text-overflow: ellipsis; vertical-align: middle; }
.happ-link-cell .copy-icon { vertical-align: middle; margin-left: 4px; }
.notification-popover .notification-item strong { font-size: 12px; }
.notification-popover .notification-item p { font-size: 11px; }
.notification-popover .notification-item time { display: block; margin-top: 4px; }
.notification-all { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; text-align: center; }
.notification-list { display: grid; gap: 8px; }
.notification-item { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--glass-2); }
.notification-item.unread { border-color: var(--ok); background: var(--ok-soft); }
.notification-item p { margin: 2px 0 0; }
.notification-item form { margin: 0; }
.new-invite { animation: invite-highlight 2.8s ease-out; }
@keyframes invite-highlight { 0%, 70% { background: var(--ok-soft); box-shadow: 0 0 0 4px var(--ok-soft); } 100% { background: transparent; box-shadow: none; } }
.copy-icon {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: 18px;
  line-height: 1;
}
.copy-icon:hover:not(:disabled) { background: transparent; border: 0; color: var(--text); }
.copy-icon.is-copied { color: var(--ok); }@media (max-width: 600px) { .notification-popover { position: fixed; top: 62px; right: 12px; }

  .notification-item { grid-template-columns: 1fr; gap: 7px; } .bulk-toolbar, .bulk-actions { align-items: stretch; } .bulk-actions select, .bulk-actions input, .bulk-actions button { width: 100%; } .copy-icon { width: 24px; height: 24px; font-size: 17px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar nav { min-width: 0; flex: 1; justify-content: flex-end; gap: 1px; }
  .topbar nav > a { padding: 7px 6px; font-size: 12px; }
  .topbar nav > form { margin: 0; }
  .topbar nav > form .link { padding: 7px 6px; font-size: 12px; }
  .brand { flex: 0 0 auto; font-size: 15px; }
  main { padding: 20px 12px 52px; }
  .admin-page { width: 100%; overflow: hidden; }
  .admin-command-grid, .admin-secondary-grid { display: block; }
  .admin-command-grid > .card, .admin-secondary-grid > .card { width: 100%; margin-bottom: 14px; }
  .admin-card { min-width: 0; overflow: visible; padding: 16px 13px; }
  .admin-card table { display: block; width: 100%; overflow-x: auto; }
  .admin-actions, .admin-actions form, .admin-create-form, .payment-actions, .user-actions { width: 100%; }
  .admin-actions { display: grid; gap: 10px; }
  .admin-actions form { min-width: 0; }
  .admin-actions input, .admin-actions select, .admin-actions button { max-width: 100%; }
  .user-block-head { display: block; }
  .user-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 12px; }
  .user-actions form { min-width: 0; }
  .user-actions form:first-child { grid-column: 1 / -1; }
  .user-actions button, .user-actions select { width: 100%; }
  .user-block-body { display: block; }
  .user-settings { min-width: 0; }
  .user-form-row, .payment-form { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .user-form-row .user-block-label, .payment-form .check { grid-column: 1 / -1; }
  .user-form-row button, .payment-form button { width: 100%; }
  .happ-actions { display: grid; grid-template-columns: 1fr; }
}


.topbar {
  position: sticky;
  overflow: visible;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 22px;
  background: var(--glass-2);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  border-bottom: 1px solid var(--stroke);
  transform: translateZ(0);
}

.brand {
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.04em;
}
.brand span { color: var(--muted); font-weight: 300; }

nav { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.topbar nav > details { flex: 0 0 auto; }
.notification-link { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; padding: 7px 9px; border-radius: 999px; color: var(--muted); cursor: pointer; }
.notification-link:hover { background: var(--glass); color: var(--text); }
.topbar .theme-picker { order: 10; }
.topbar .logout-form { order: 9; margin: 0; }
.topbar .logout-form .link { margin: 0; }
nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 999px;
  transition: background .15s, color .15s;
}
nav a:hover { background: var(--glass); color: var(--text); }

/* --- Смена аккаунта (как в Steam) --------------------------------------- */
/* Аватар в шапке открывает окно со списком аккаунтов, которые уже входили
   с этого браузера; клик по чужой строке мгновенно переключает сессию. */
.account-picker { position: relative; }
.topbar .account-picker { order: 9; }
.account-picker > summary { list-style: none; cursor: pointer; }
.account-picker > summary::-webkit-details-marker { display: none; }
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  transition: background .15s;
}
.account-chip:hover { background: var(--glass); }
.account-name {
  font-size: 14px;
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-caret { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  user-select: none;
}
.account-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  width: 280px;
  padding: 14px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: 0 16px 45px rgba(0, 0, 0, .28);
}
.account-popover-title {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.account-list { display: grid; gap: 4px; }
.account-list .account-row { margin: 0; }
.account-row.is-current {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--glass);
}
.account-row.is-current .account-login { flex: 1; }
.account-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}
.account-switch:hover { background: var(--glass); }
.account-switch .account-login { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-popover-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--stroke);
}
.account-popover-foot form { margin: 0; }

/* Карточки «продолжить как …» на экране входа. */
.account-continue-hint {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.account-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.account-picker-grid form { margin: 0; }
.account-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 16px 10px 12px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--glass);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color .15s, background .15s, translate .15s;
}
.account-card:hover { border-color: var(--accent); background: var(--glass-2); translate: 0 -1px; }
.account-card .account-avatar { width: 44px; height: 44px; font-size: 20px; }
.account-card .account-login { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.gate-other { margin-bottom: 14px; }
.gate-other summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.gate-other form { display: grid; gap: 12px; }
.account-forget { margin-top: 12px; }
.account-forget .link { font-size: 12px; color: var(--muted); }

/* Цвета аватарок: классом, а не инлайновым стилем — CSP запрещает style-атрибуты. */
.avatar-c0 { background: #e0533d; }
.avatar-c1 { background: #d9a013; }
.avatar-c2 { background: #3fa14e; }
.avatar-c3 { background: #3e7fd6; }
.avatar-c4 { background: #8f5fd6; }
.avatar-c5 { background: #d65fa0; }
.avatar-c6 { background: #12a5a5; }
.avatar-c7 { background: #c96a2d; }

/* Шторка с формой входа на экране «продолжить как …». */
.gate-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 12px;
}
.gate-divider::before,
.gate-divider::after { content: ''; flex: 1; height: 1px; background: var(--stroke); }
.gate-toggle { width: 100%; justify-content: center; }
.gate-toggle.is-open { border-color: var(--accent); color: var(--text); }
.gate-collapse {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows .3s ease, opacity .25s ease;
}
.gate-collapse.is-collapsed { grid-template-rows: 0fr; opacity: 0; }
.gate-collapse-inner { overflow: hidden; min-height: 0; }
.gate-collapse.is-collapsed .gate-collapse-inner {
  visibility: hidden;
  transition: visibility 0s .3s;
}
.gate-collapse form { display: grid; gap: 12px; margin-top: 12px; }

.card {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

/* Блик по верхней кромке — то, что отличает стекло от просто мутного слоя:
   свет собирается на ребре. Через ::before, чтобы не занимать border-image. */
.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, transparent, var(--glass-hi) 22%, var(--glass-hi) 78%, transparent);
  pointer-events: none;
}
.card.narrow { max-width: 400px; margin: 9vh auto; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- Формы --- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }

input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 13px;
  background: var(--glass-2);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--glass);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* Список раскрывается вне стекла и прозрачным был бы нечитаемым. */
select option { background: var(--bg); color: var(--text); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; align-items: end; }
/* Отступ у label сместил бы его вниз относительно кнопки — здесь расстояние даёт gap. */
.grid > label { margin-bottom: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row input, .row select { margin-top: 0; width: auto; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; margin: 0; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 17px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
button:hover:not(:disabled), .btn:hover { background: var(--glass-hi); border-color: var(--muted); }
button:active:not(:disabled), .btn:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: not-allowed; }

.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 500;
}
/* На чёрной кнопке brightness почти не виден — осветляем отдельным токеном. */
.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: transparent; }
.danger { color: var(--danger); }
.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: var(--danger); }
.link { background: none; backdrop-filter: none; border-color: transparent; color: var(--muted); padding: 8px 12px; }
.link:hover { background: var(--glass); border-color: transparent; color: var(--text); }

/* Акцент равен цвету текста, поэтому ссылку в абзаце опознать не по цвету.
   Подчёркивание тонкое и серое, под курсором становится чёрным. */
main a:not(.btn):not(.brand) {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--stroke);
  text-underline-offset: 3px;
}
main a:not(.btn):not(.brand):hover { text-decoration-color: var(--accent); }

/* --- Ключ как пропуск --- */
/* Метафора доведена до языка защищённых документов: плёнка, играющая
   на наклоне, микротекст по кромке и печать. isolation: isolate запирает
   mix-blend-mode внутри карточки — иначе плёнка смешалась бы с фоном страницы. */
.pass {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 18px;
  align-items: center;
  padding: 18px 20px 16px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--glass-2);
  margin-top: 12px;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .35s ease-out;
}

/* Плёнка OVD. Полоса переливов шире карточки втрое и ездит по ней
   background-position'ом: анимировать саму переменную нельзя — без
   @property браузер переключил бы её скачком, а не плавно. */
.pass::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .45;
  mix-blend-mode: color-dodge;
  background-image: linear-gradient(
    115deg,
    transparent 0%,
    var(--ovd-1) 18%,
    var(--ovd-2) 34%,
    var(--ovd-3) 50%,
    var(--ovd-4) 66%,
    transparent 86%
  );
  background-size: 320% 100%;
  background-position: calc(var(--holo, .5) * 100%) 0;
  transition: background-position .25s ease-out;
}

/* Микротекст по нижней кромке: несёт имя владельца, а не украшает.
   Строку собирает шаблон — CSS только печатает её. */
.pass::after {
  content: attr(data-micro);
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  white-space: nowrap;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 6px;
  line-height: 1;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .5;
}

/* Содержимое поднимаем над плёнкой: иначе color-dodge выбелил бы текст. */
.pass-main,
.pass-stamp,
.pass-actions { position: relative; z-index: 1; }

.pass-main { display: flex; flex-direction: column; min-width: 0; }

.pass-eyebrow {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Адрес — главное на карточке и одновременно данные, поэтому моно и крупно. */
.pass-ip {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(21px, 4.4vw, 27px);
  letter-spacing: -.02em;
  line-height: 1.25;
}
.pass-date { font-size: 12px; color: var(--muted); }

/* Штамп: пока файл не скачан — бледная пустая рамка, после скачивания
   «проставляется» с наклоном. Несёт реальное состояние, а не украшает. */
.pass-stamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 92px;
  padding: 8px 6px;
  border: 1.5px dashed var(--stroke);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  transform: rotate(-4deg);
}
.pass-stamp.on {
  border-style: solid;
  border-color: var(--ok);
  color: var(--ok);
  background: var(--ok-soft);
  transform: rotate(-7deg);
}
.stamp-word { font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; }
.stamp-date { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10.5px; }

.pass-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }

/* Ключи читаются как отдельные документы, а не как строки внутри одной
   карточки: на широком экране два помещаются рядом, на телефоне складываются
   в один столбец без горизонтального скролла. */
.pass-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.pass-grid .pass { margin-top: 0; min-width: 0; }

/* --- Сцена входа --- */
/* Первое, что видит человек: огромное тонкое имя слева, форма справа
   и пустой бланк пропуска — тот самый, который после входа станет его ключом. */
.gate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
  gap: 56px;
  align-items: center;
  padding: 6vh 0;
}

.gate-brand { display: flex; flex-direction: column; align-items: flex-start; }

.gate-word {
  font-size: clamp(44px, 9vw, 88px);
  font-weight: 300;
  letter-spacing: -.05em;
  line-height: .96;
}
.gate-word.dim { color: var(--muted); }

.gate .pass { width: 100%; max-width: 360px; margin-top: 40px; }
.gate-form { margin: 0; }
.gate-form h1 { font-size: 26px; margin-bottom: 18px; }

@media (max-width: 860px) {
  .admin-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-command-grid, .admin-secondary-grid { grid-template-columns: 1fr; gap: 20px; }
  .admin-page > .card { margin-top: 20px; }
  .admin-page > .admin-command-grid, .admin-page > .admin-secondary-grid { margin-bottom: 20px; }
  .admin-command-grid > .card, .admin-secondary-grid > .card { height: auto; }
  /* На телефоне бланк уходит под форму, но остаётся таким же ярким,
     как на ПК: иначе переход вход → ключ начинался бы с другого документа. */
  .gate { grid-template-columns: 1fr; gap: 22px; padding: 2vh 0; }
  .gate-brand { order: 1; }
  .gate-form { order: 2; }
  .gate .pass { order: 3; opacity: 1; margin-top: 8px; max-width: none; }
  .gate-brand .pass { display: none; }
}

/* На тёмном color-dodge выжигает карточку добела — там мягче overlay. */
[data-theme='dark'] .pass::before { mix-blend-mode: overlay; opacity: .6; }
[data-theme='terminal'] {
  --bg: #050806; --tint-1: #0b2416; --tint-2: #102217; --tint-3: #07140d;
  --glass: rgba(10, 35, 19, .78); --glass-2: rgba(5, 25, 12, .7); --glass-hi: rgba(82, 255, 143, .16);
  --stroke: rgba(98, 255, 152, .3); --line: rgba(98, 255, 152, .16);
  --text: #9dffb8; --muted: #5caf73; --accent: #65ff91; --accent-hover: #9dffb8; --accent-soft: rgba(101, 255, 145, .14); --accent-ink: #041008;
  --ok: #65ff91; --ok-soft: rgba(101, 255, 145, .18); --danger: #ff857e; --board: #07140d; --board-line: rgba(101, 255, 145, .12); --radius: 6px; --blur: 4px;
}
[data-theme='paper'] {
  --bg: #eee8dc; --tint-1: #ded2bc; --tint-2: #e5d6c8; --tint-3: #d7cbb6;
  --glass: rgba(255, 251, 241, .78); --glass-2: rgba(255, 251, 241, .5); --glass-hi: rgba(255, 255, 255, .95);
  --stroke: rgba(59, 45, 29, .2); --line: rgba(59, 45, 29, .12); --text: #30271f; --muted: #776957; --accent: #30271f; --accent-hover: #514334; --accent-soft: rgba(48, 39, 31, .1); --accent-ink: #fffaf0; --ok: #3f7850; --ok-soft: rgba(63, 120, 80, .14); --danger: #a54135; --board: #fffaf0; --board-line: rgba(48, 39, 31, .1); --blur: 2px; --radius: 10px;
}
[data-theme='violet'] {
  --bg: #100d1d; --tint-1: #291c46; --tint-2: #321d3b; --tint-3: #171f46;
  --glass: rgba(37, 27, 61, .65); --glass-2: rgba(23, 18, 43, .55); --glass-hi: rgba(233, 173, 255, .18);
  --stroke: rgba(221, 178, 255, .2); --line: rgba(221, 178, 255, .12); --text: #f5edff; --muted: #b7a8ca; --accent: #e3a8ff; --accent-hover: #f0caff; --accent-soft: rgba(227, 168, 255, .16); --accent-ink: #21102e; --ok: #78e7bd; --ok-soft: rgba(120, 231, 189, .16); --danger: #ff8fa4; --board: #19132b; --board-line: rgba(227, 168, 255, .1);
}
.theme-picker { position: relative; }
.theme-picker summary { list-style: none; }
.theme-picker summary::-webkit-details-marker { display: none; }
.theme-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; display: grid; min-width: 130px; gap: 3px; padding: 6px; border: 1px solid var(--stroke); border-radius: 12px; background: var(--bg); box-shadow: var(--shadow); }
.theme-menu button { width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; backdrop-filter: none; font-size: 12px; text-align: left; }
.theme-menu button:hover { background: var(--accent-soft); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .pass::before { mix-blend-mode: overlay; opacity: .6; }
}

/* На тач-устройствах курсора нет. Постоянная анимация плёнки поверх
   backdrop-filter заставляет мобильный браузер пересобирать весь слой при
   каждом кадре, поэтому оставляем статичный блик — смысл карточки не теряется,
   а прокрутка не превращается в слайд-шоу. */
@media (hover: none) {
  body::before,
  body::after {
    animation: none;
    transition: none;
    translate: none;
  }

  .pass { touch-action: pan-y; }

  /* На телефоне эти поверхности можно оставить стеклянными: слой меньше,
     чем на 2K, а blur делает карточки заметно приятнее. Фон при этом
     остаётся статичным, поэтому размытие не пересобирается бесконечно. */
  .topbar,
  .card,
  .gate-form,
  .key,
  input,
  select,
  textarea,
  button,
  .btn,
  .overlay,
  .tabbar {
    backdrop-filter: blur(var(--blur)) saturate(180%) !important;
    -webkit-backdrop-filter: blur(var(--blur)) saturate(180%) !important;
  }

  .topbar,
  .card,
  .pass,
  .key { background: var(--glass); }

  .admin-page .card,
  .admin-page .user-block { background: var(--glass); }
}

/* Админская панель тоже сохраняет стеклянную иерархию на touch-экранах. */
.admin-page .card,
.admin-page .user-block { backdrop-filter: blur(var(--blur)) saturate(180%); -webkit-backdrop-filter: blur(var(--blur)) saturate(180%); }

/* --- Подписки Happ --- */
.key {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--glass-2);
  margin-top: 12px;
}
.key-info { min-width: 0; flex: 1; }
.qr { width: 116px; height: 116px; border-radius: 10px; background: #fff; padding: 6px; }

.happ-list { display: grid; gap: 12px; margin-top: 12px; }
.happ-card {
  overflow: hidden;
  border: 1px solid var(--stroke);
  border-radius: 15px;
  background: var(--glass-2);
}
.happ-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.happ-identity { min-width: 0; }
.happ-kicker,
.happ-label {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.happ-identity h3 {
  margin: 2px 0 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 16px;
  letter-spacing: -.02em;
}
.happ-identity .hint { margin-top: 2px; }
.happ-card-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px 16px;
}
.happ-card-main { min-width: 0; }
.happ-url {
  min-height: 58px;
  margin-top: 6px;
  resize: vertical;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px;
  line-height: 1.45;
}
.happ-actions { margin-top: 9px; }
.happ-qr {
  display: grid;
  justify-items: center;
  gap: 5px;
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
}
.happ-qr .qr { width: 104px; height: 104px; }

.keyrow { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.keyrow form { display: inline; }

/* --- Рабочая панель админки --- */
.admin-page { padding-top: 4px; }
.admin-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.admin-title h1 { margin-bottom: 2px; }
.admin-title p { margin: 0; }
.admin-command-grid,
.admin-secondary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
  align-items: stretch;
}
.admin-command-grid > .card,
.admin-secondary-grid > .card { min-width: 0; height: 100%; box-sizing: border-box; }
.admin-command-grid .card,
.admin-secondary-grid .card { margin-bottom: 0; }
.admin-secondary-grid { margin-top: 8px; }
.admin-page > .card { margin-top: 28px; }
.admin-page > .admin-command-grid,
.admin-page > .admin-secondary-grid { margin-bottom: 28px; }
.invite-options {
  grid-column: 1 / -1;
  margin: 2px 0 4px;
  padding: 0;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  overflow: hidden;
}
.invite-options summary {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 13px;
  color: var(--text);
  background: var(--glass-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  list-style: none;
}
.invite-options summary::-webkit-details-marker { display: none; }
.invite-options summary::before { content: '⋯'; margin-right: 9px; color: var(--accent); font-size: 20px; line-height: 1; }
.invite-options summary::after { content: '＋'; margin-left: auto; color: var(--muted); font-size: 18px; }
.invite-options[open] summary::after { content: '−'; }
.invite-options[open] summary { border-bottom: 1px solid var(--stroke); }
.invite-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  padding: 14px;
}
.invite-options-grid label { margin: 0; }
@media (max-width: 620px) {
  .invite-options-grid { grid-template-columns: 1fr; }
}
.admin-secondary-grid { margin-top: 0; }

/* Редактирование Happ-подписки: имя раскрывается в мини-форму. */
.happ-edit summary {
  cursor: pointer;
  list-style: none;
  border-radius: 8px;
  padding: 2px 6px;
  margin: -2px -6px;
}
.happ-edit summary::-webkit-details-marker { display: none; }
.happ-edit summary:hover { background: var(--accent-soft); }
.happ-edit[open] summary { color: var(--accent); }
.happ-edit-forms { display: grid; gap: 7px; min-width: 180px; padding-top: 8px; }
.happ-edit-row { display: flex; gap: 6px; align-items: center; }
.happ-edit-row input { flex: 1; min-width: 0; margin: 0; padding: 7px 9px; font-size: 12px; }
.happ-edit-row .btn { padding: 7px 10px; font-size: 12px; white-space: nowrap; }

/* Рассылка: сообщение, картинка, получатели мини-карточками, история. */
.broadcast-form { display: grid; gap: 12px; }
.broadcast-audience,
.broadcast-format { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 7px 14px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--glass-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.chip:hover { border-color: var(--glass-hi); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip.is-active,
.chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.broadcast-hint { margin: -4px 0 0; }
.broadcast-text-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.broadcast-form textarea {
  width: 100%;
  margin: 0;
  min-height: 110px;
  padding: 11px 13px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--glass-2);
  color: var(--text);
  font: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.broadcast-form textarea:focus { outline: none; border-color: var(--accent); }
.broadcast-format .hint { flex-basis: 100%; margin: 0; }

/* Картинка: панель вида + пресеты с превью + файл + ссылка. */
/* Правило сильнее UA-стиля: у панелей ниже display:grid, и атрибут hidden без него не сработал бы. */
[hidden] { display: none !important; }
.broadcast-photo-block { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--glass-2); }
/* Вид сообщения — сегментированные вкладки: активная подсвечивается, как у .chip. */
.broadcast-photo-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 4px;
  width: 100%;
  padding: 4px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--glass-2);
  box-sizing: border-box;
}
.broadcast-photo-modes .chip { justify-content: center; border: none; background: transparent; border-radius: 9px; }
.broadcast-photo-modes .chip:hover { background: var(--glass); }
.broadcast-photo-pane { display: grid; gap: 10px; justify-items: start; }
.broadcast-presets { display: flex; gap: 10px; flex-wrap: wrap; }
.broadcast-preset {
  position: relative;
  display: grid;
  gap: 6px;
  justify-items: center;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--glass-2);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
/* Миниатюра пресета: маленькая всегда, при наведении слегка увеличивается. */
.broadcast-preset img {
  width: 84px;
  height: 84px;
  max-width: 84px;
  border-radius: 8px;
  object-fit: cover;
  background: #0e1013;
  transition: transform .18s ease, box-shadow .18s ease;
}
.broadcast-preset:hover img { transform: scale(1.07); box-shadow: 0 6px 18px rgb(0 0 0 / .35); }
.broadcast-preset:hover { z-index: 2; color: var(--text); }
.broadcast-preset.is-active { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent); }
.broadcast-filedrop {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  padding: 18px 14px;
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.broadcast-filedrop:hover,
.broadcast-filedrop.is-over { border-color: var(--accent); background: var(--glass-2); }
.broadcast-filedrop input[type="file"] { display: none; }
.broadcast-filedrop-hint { color: var(--muted); font-size: 12.5px; }
.broadcast-filedrop-preview { max-width: 100%; max-height: 200px; border-radius: 10px; }
.broadcast-url-input { width: 100%; max-width: 460px; margin: 0; }
.broadcast-url-preview { max-width: 100%; max-height: 200px; border-radius: 10px; }

/* Получатели: поиск/группы + мини-карточки людей. */
.broadcast-people-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.broadcast-people-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.broadcast-search { width: 180px; margin: 0; padding: 7px 10px; font-size: 13px; }
.broadcast-people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 2px;
}
.broadcast-person {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--glass-2);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.broadcast-person:hover { border-color: var(--glass-hi); }
.broadcast-person:has(input:checked) { border-color: var(--accent); background: var(--glass-2); box-shadow: 0 0 0 1px var(--accent); }
/* Глобальный input { width:100% } раздувает чекбокс до сотен пикселей и ломает карточку. */
.broadcast-person input[type="checkbox"] { width: auto; flex: 0 0 auto; margin: 3px 0 0; padding: 0; border: none; background: none; accent-color: var(--accent); }
.broadcast-person-body { display: grid; gap: 3px; min-width: 0; flex: 1 1 auto; color: var(--text); }
.broadcast-person-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.broadcast-person-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.broadcast-footer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.broadcast-footer .primary { min-width: 140px; }
.broadcast-history { margin-top: 14px; }
.broadcast-history summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 0; }
.broadcast-history[open] summary { color: var(--text); }
.broadcast-history-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.broadcast-item { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--glass-2); }
.broadcast-item-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.broadcast-item-text { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.broadcast-fails { margin-top: 8px; }
.broadcast-fails summary { cursor: pointer; color: var(--danger); font-size: 12px; }
.broadcast-fail-list { margin: 6px 0 0; padding-left: 18px; font-size: 12px; }
@media (max-width: 640px) {
  .chip { padding: 8px 13px; }
  .broadcast-footer .primary { width: 100%; }
  .broadcast-people { grid-template-columns: 1fr 1fr; }
  .broadcast-preset img { width: 64px; height: 64px; max-width: 64px; }
}

/* Чат с ботом: оверлей на весь экран, лента с пузырями, поле ответа. */
.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(0 0 0 / .55);
  backdrop-filter: blur(6px);
}
.chat-window {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(560px, 100%);
  max-height: min(720px, 90vh);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: 0 24px 80px rgb(0 0 0 / .45);
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--glass-2);
}
.chat-head-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.chat-head-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Длинный текст ошибки не должен вытеснять заголовок из шапки. */
.chat-head-title .badge { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chat-head-actions .btn { padding: 6px 10px; font-size: 12.5px; }
.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 14px;
  overflow-y: auto;
  background: var(--glass);
}
.chat-empty { margin: auto; color: var(--muted); font-size: 13px; text-align: center; padding: 30px 20px; }
.chat-msg { display: grid; gap: 3px; max-width: 78%; }
.chat-msg time { font-size: 10.5px; color: var(--muted); padding: 0 4px; }
.chat-msg-in { align-self: flex-start; }
.chat-msg-out { align-self: flex-end; align-items: end; }
.chat-bubble {
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
}
.chat-msg-in .chat-bubble { background: var(--glass-2); border-bottom-left-radius: 5px; }
.chat-msg-out .chat-bubble { background: var(--accent-soft); border-color: var(--accent); border-bottom-right-radius: 5px; }
/* Форматирование как в Telegram внутри пузырей. */
.chat-bubble a { color: var(--accent-hover); text-decoration: underline; }
.chat-bubble blockquote {
  margin: 4px 0;
  padding: 4px 10px;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--glass);
}
.chat-bubble code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgb(127 127 127 / .18);
  font-family: ui-monospace, 'JetBrains Mono', monospace;
  font-size: 12.5px;
}
.chat-bubble pre {
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgb(127 127 127 / .18);
  font-family: ui-monospace, 'JetBrains Mono', monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
}
/* Спойлер: текст скрыт размытием, показывается по клику/наведению (как в TG). */
.chat-bubble .tg-spoiler {
  cursor: pointer;
  border-radius: 4px;
  background: rgb(127 127 127 / .45);
  color: transparent;
  transition: color .15s ease, background .15s ease;
}
.chat-bubble .tg-spoiler.is-open,
.chat-bubble .tg-spoiler:hover { background: rgb(127 127 127 / .18); color: inherit; }
/* Разделитель дат: «Сегодня», «Вчера», дата. */
.chat-day { display: flex; justify-content: center; margin: 4px 0; }
.chat-day span {
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--glass-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}
/* Панель форматирования над полем ввода. */
.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px 0;
  background: var(--glass-2);
  flex-wrap: wrap;
}
.chat-tool {
  margin: 0;
  padding: 4px 9px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.chat-tool:hover { border-color: var(--accent); color: var(--accent-hover); }
.chat-toolbar .hint { flex-basis: 100%; font-size: 10.5px; }
.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--glass-2);
}
.chat-input input { flex: 1 1 auto; width: auto; margin: 0; }
.chat-input .primary { flex: 0 0 auto; }
body.chat-open { overflow: hidden; }

/* Подписки Happ: строки-карточки вместо таблицы. */
.happ-subs-list { display: grid; gap: 10px; margin-top: 14px; }
.happ-sub {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--glass-2);
  flex-wrap: wrap;
}
.happ-sub-main { display: grid; gap: 5px; min-width: 240px; flex: 1; }
.happ-sub-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.happ-sub-title strong { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 15px; }
.happ-sub-uuid { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.happ-sub-link { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.happ-sub-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.happ-sub-edit { position: relative; }
.happ-sub-edit > summary { list-style: none; cursor: pointer; }
.happ-sub-edit > summary::-webkit-details-marker { display: none; }
.happ-sub-edit[open] > summary { border-color: var(--accent); }
.happ-sub-edit-forms {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  display: grid;
  gap: 8px;
  min-width: 280px;
  padding: 12px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--bg, #14161a);
  box-shadow: 0 10px 30px rgb(0 0 0 / 35%);
}
.happ-sub-edit-forms .row { margin: 0; }
.happ-sub-edit-forms input { flex: 1; min-width: 0; margin: 0; }
@media (max-width: 720px) {
  .happ-sub { flex-direction: column; }
  .happ-sub-edit-forms { position: static; min-width: 0; }
}

.admin-card { padding: 20px; }
.admin-card h2 { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

/* Таблица подписок должна оставаться компактной и ровной даже при длинных UUID. */
.admin-page #happ-subscriptions { overflow: hidden; }
.happ-subscriptions-form { grid-template-columns: minmax(150px, .7fr) minmax(260px, 1.5fr) auto; }
.happ-subscriptions-form { grid-template-columns: minmax(150px, .7fr) minmax(260px, 1.5fr) auto; }
.happ-subscriptions-table { table-layout: fixed; }
.happ-subscriptions-table th:nth-child(1), .happ-subscriptions-table td:nth-child(1) { width: 10%; }
.happ-subscriptions-table th:nth-child(2), .happ-subscriptions-table td:nth-child(2) { width: 24%; }
.happ-subscriptions-table th:nth-child(3), .happ-subscriptions-table td:nth-child(3) { width: 11%; }
.happ-subscriptions-table th:nth-child(4), .happ-subscriptions-table td:nth-child(4) { width: 17%; }
.happ-subscriptions-table th:nth-child(5), .happ-subscriptions-table td:nth-child(5) { width: 26%; }
.happ-subscriptions-table th:nth-child(6), .happ-subscriptions-table td:nth-child(6) { width: 12%; }
.happ-subscriptions-table th:nth-child(2), .happ-subscriptions-table td:nth-child(2) { padding-left: 12px; padding-right: 12px; }
.happ-subscriptions-table td:nth-child(2) { font-size: 11px; }
.happ-subscriptions-table td { overflow: hidden; overflow-wrap: anywhere; }
.happ-uuid-cell, .happ-link-cell { vertical-align: middle; }
.happ-uuid-cell { display: grid; grid-template-columns: minmax(0, 1fr) 22px; align-items: center; gap: 5px; }
.happ-uuid-cell > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.happ-uuid-cell .copy-icon { width: 22px; min-width: 22px; padding: 0; }
.happ-link-cell { min-width: 0; }
.happ-link-cell .happ-link { display: inline-block; max-width: calc(100% - 30px); margin-right: 4px; vertical-align: middle; overflow-wrap: anywhere; }
.happ-subscriptions-table td form.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.happ-subscriptions-table td form.row select { min-width: 0; width: 100%; margin: 0; }
.happ-subscriptions-table td form.row .btn { min-width: 0; padding: 8px 10px; font-size: 12px; }
@media (max-width: 900px) {
  .happ-subscriptions-table { min-width: 760px; }
  .happ-subscriptions-table { display: table; }
  .happ-subscriptions-table thead { display: table-header-group; }
  .happ-subscriptions-table tbody { display: table-row-group; }
  .happ-subscriptions-table tr { display: table-row; padding: 0; }
  .happ-subscriptions-table th, .happ-subscriptions-table td { display: table-cell; }
  #happ-subscriptions { overflow-x: auto; }
}
@media (max-width: 760px) {
  .happ-subscriptions-form { grid-template-columns: 1fr; }
}
.admin-card > .muted { margin-top: 0; }
.admin-actions {
  padding: 10px;
  border: 1px solid var(--stroke);
  border-radius: 13px;
  background: var(--accent-soft);
  gap: 10px;
}
.admin-actions > form { margin: 0; }
.admin-actions input[name='count'] { width: 78px; }
.admin-create-form { gap: 10px; }

/* Маленькая справка рядом с опасными действиями. Работает и мышью, и
   клавиатурой/касанием: tabindex даёт фокус, а popover не требует JS. */
.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--stroke);
  border-radius: 50%;
  background: var(--glass-2);
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  outline: none;
}
.info-tip:hover,
.info-tip:focus {
  border-color: var(--accent);
  color: var(--text);
}
.info-tip-popover {
  position: absolute;
  z-index: 40;
  left: 50%;
  top: calc(100% + 9px);
  width: min(290px, calc(100vw - 36px));
  padding: 10px 12px;
  border: 1px solid var(--stroke);
  border-radius: 11px;
  background: var(--bg);
  box-shadow: var(--shadow);
  color: var(--text);
  font: 12px/1.5 'Geologica', ui-sans-serif, sans-serif;
  font-weight: 400;
  text-align: left;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition: opacity .15s, transform .15s, visibility .15s;
}
.info-tip:hover .info-tip-popover,
.info-tip:focus .info-tip-popover {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
.admin-card h2 .info-tip { margin-right: 2px; }
.admin-actions .info-tip { align-self: center; }
.admin-create-form label { margin-bottom: 0; }
.admin-page table { margin-top: 12px; }
.admin-page .guide { margin-top: 12px; }

.users-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.user-block {
  overflow: hidden;
  padding: 14px 16px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--glass-2);
}
.user-block.off { opacity: .52; }
.user-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.user-identity,
.user-actions,
.keyrow,
.user-form-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.user-identity strong { font-size: 16px; }
.user-identity .hint { flex-basis: 100%; margin-top: 0; }
.user-actions form { margin: 0; }
.user-details { margin-top: 12px; }
.user-details summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 8px 0; }
.user-details[open] summary { color: var(--text); }
.user-block-body {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(270px, .75fr);
  gap: 14px;
  padding-top: 12px;
}
.user-keys { min-width: 0; }
.user-block-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.user-keys .keyrow {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.user-keys .keyrow:last-child { border-bottom: 0; }
.payment-settings {
  grid-column: 1 / -1;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--glass-1);
}
.payment-summary, .payment-form, .payment-paid-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.payment-summary { min-height: 28px; }
.payment-form label.check { margin: 0; }
.payment-paid-form { margin-top: 9px; }
.payment-paid-form .hint { margin: 0; }
.payment-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 10px; }
.payment-actions form { margin: 0; }
.payment-actions .hint { flex-basis: 100%; margin: 0; }
.payment-form { margin-top: 9px; }
.payment-form input { width: 120px; margin: 0; }
@media (max-width: 700px) {
  .user-block-body { grid-template-columns: 1fr; }
  .user-settings { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); padding-top: 12px; }
  .payment-form input { width: 100%; }
  .payment-form > * { flex: 1 1 140px; }
}
.payment-free { margin: 0; }
.user-settings {
  display: grid;
  align-content: start;
  gap: 9px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
.user-form-row input {
  width: 62px;
  margin-top: 0;
  padding: 7px 8px;
  font-size: 12px;
}
.user-form-row input[name='password'] { width: 150px; }
.user-form-row .user-block-label {
  flex: 0 0 92px;
  margin: 0;
}
.user-form-row .btn { padding: 7px 11px; font-size: 12px; }

@media (max-width: 900px) {
  .admin-command-grid,
  .admin-secondary-grid { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 640px) {
  .dashboard-status { margin: -7px 0 16px; padding-bottom: 8px; }
  .dashboard-status-note { font-size: 11px; }

  .admin-title { align-items: flex-start; flex-direction: column; gap: 8px; }
  .admin-title .badge { align-self: flex-start; }
  .admin-card { padding: 18px; }
  .admin-actions { align-items: stretch; flex-direction: column; }
  .admin-actions > form,
  .admin-actions > form button { width: 100%; }
  .admin-actions input[name='count'] { width: 100%; }
  .user-block-head { align-items: flex-start; flex-direction: column; }
  .user-actions { width: 100%; }
  .user-actions form,
  .user-actions button { flex: 1; }
  .user-actions button { width: 100%; }
  .user-block-body { grid-template-columns: 1fr; }
  .user-settings {
    padding-top: 12px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
  .user-form-row { align-items: stretch; }
  .user-form-row .user-block-label { flex-basis: 100%; }
  .user-form-row input,
  .user-form-row input[name='password'],
  .user-form-row button { flex: 1; width: auto; }
}

/* --- Таблицы --- */
table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 14px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
tr.off { opacity: .45; }

.mono, code { font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: 12.5px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--glass-2);
  border: 1px solid var(--stroke);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.badge.dot { color: var(--ok); background: var(--ok-soft); border-color: transparent; }

.muted { color: var(--muted); font-size: 13.5px; }
.hint { display: inline-block; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.empty { padding: 28px 0; text-align: center; color: var(--muted); }

.alert { padding: 12px 15px; border-radius: 11px; font-size: 14px; border: 1px solid transparent; }
.alert.error {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
}
.alert.ok {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
  color: var(--ok);
}

details.guide {
  margin-top: 16px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--glass-2);
  padding: 14px 18px;
}
details.guide summary { cursor: pointer; color: var(--text); font-size: 14px; font-weight: 500; }
details.guide[open] summary { margin-bottom: 6px; }
details.guide p { font-size: 14px; margin: 14px 0 6px; }
details.guide ol { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.8; }

/* --- Полоса аптайма --- */
.admin-uptime-summary {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0 8px;
  padding: 10px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--glass-2);
}
.admin-uptime-day {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}
.admin-uptime-label { text-transform: uppercase; }
.admin-uptime-day i {
  display: block;
  width: 100%;
  max-width: 28px;
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok-soft);
}
.admin-uptime-day.good i { background: var(--ok); }
.admin-uptime-day.warn i { background: #d59b2c; box-shadow: none; }
.admin-uptime-day.bad i { background: var(--danger); box-shadow: none; }
.admin-uptime-day.nodata i { background: var(--line); border: 1px dashed var(--stroke); box-shadow: none; }
.admin-uptime-day strong { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10px; color: var(--text); }
@media (max-width: 640px) {
  .admin-uptime-summary { gap: 3px; padding: 7px 5px; }
  .admin-uptime-day { font-size: 8px; }
  .admin-uptime-day strong { font-size: 8px; }
}

/* --- Змейка --- */
.game-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
.game-card { display: flex; flex-direction: column; gap: 12px; }
.game-toolbar,
.game-board-title,
.game-stats,
.game-actions { display: flex; align-items: center; gap: 8px; }
.game-toolbar,
.game-board-title { justify-content: space-between; }
.game-stats { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.game-stats .badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 34px;
  padding: 4px 8px;
  text-align: center;
}
.game-stats .badge small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.game-stats .badge strong { color: var(--text); font-weight: 600; display: inline-block; }

/* Счёт подпрыгивает, когда змейка ловит яблоко. */
@keyframes bump { 40% { scale: 1.3; } }
.game-stats .badge strong.bump { animation: bump .35s ease; }

/* Проигрыш: поле коротко встряхивается. */
@keyframes board-shake {
  20% { translate: -6px 0; }
  40% { translate: 6px 0; }
  60% { translate: -4px 0; }
  80% { translate: 4px 0; }
}
.board-holder.shake { animation: board-shake .45s ease; }
.game-actions { flex-shrink: 0; }
.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 11px;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn .play-icon { display: none; }
.icon-btn.is-paused .pause-icon { display: none; }
.icon-btn.is-paused .play-icon { display: block; }
.icon-btn .sound-off-icon { display: none; }
.icon-btn.is-muted .sound-on-icon { display: none; }
.icon-btn.is-muted .sound-off-icon { display: block; }
.game-actions .is-pressed { transform: scale(.94); background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.game-board-title { align-items: flex-start; }
.game-board-title h2,
.game-board-title p { margin-bottom: 0; }

.board-holder {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--stroke);
  border-radius: 15px;
  background: var(--board);
  box-shadow: inset 0 0 0 1px var(--line);
}
#snake {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.game-tip { margin: 0; }

/* Шторка паузы лежит на ярко-зелёном поле, поэтому вместо стеклянной темы —
   нейтральное затемнение с размытием: иначе поле просвечивает ядовитым
   зелёным. Текст всегда белый — скрима это касается в любой теме. */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  background: rgba(15, 23, 10, .52);
  backdrop-filter: blur(7px) saturate(120%);
  -webkit-backdrop-filter: blur(7px) saturate(120%);
  text-align: center;
  padding: 20px;
}
.overlay.hidden { display: none; }
.overlay p { margin: 0; color: #fff; text-shadow: 0 1px 10px rgba(0, 0, 0, .35); }
.overlay p.muted { color: rgba(255, 255, 255, .78); text-shadow: none; }
#overlay-title { font-size: 22px; font-weight: 500; letter-spacing: -.02em; }
.overlay button { margin-top: 6px; }

.dpad {
  display: grid;
  grid-template-areas: '. up .' 'left down right';
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}
.pad {
  width: 66px;
  height: 56px;
  font-size: 22px;
  line-height: 1;
  padding: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.pad:active,
.pad.is-pressed { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); transform: scale(.94); }

/* --- Мягкие переходы между страницами --- */
/* Шапка и пропуска переезжают между страницами сами (MPA View Transitions).
   Браузеры без поддержки просто игнорируют блок, а те, кто просил
   «без анимаций», его не получают вовсе. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

/* --- Оптимистичная выдача ключа --- */
.btn.is-busy {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-busy::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--accent-ink);
  border-right-color: transparent;
  animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Новая карточка пропуска мягко всплывает. Индивидуальные свойства
   translate/scale не трогают transform с наклоном от motion.js. */
@keyframes pass-enter {
  from { opacity: 0; translate: 0 14px; scale: .97; }
}
.pass-enter { animation: pass-enter .5s cubic-bezier(.2, .8, .2, 1); }
@media (prefers-reduced-motion: reduce) {
  .pass-enter { animation: none; }
}
.pad.up { grid-area: up; }
.pad.left { grid-area: left; }
.pad.down { grid-area: down; }
.pad.right { grid-area: right; }

@media (max-width: 760px) {
  .game-wrap { grid-template-columns: 1fr; }
  .game-toolbar { align-items: flex-start; gap: 7px; }
  .game-stats { gap: 5px; }
  .game-stats .badge { flex-direction: column; gap: 0; min-height: 42px; padding: 4px 3px; }
  .game-stats .badge small { font-size: 8px; }
  .game-actions { width: auto; flex-direction: column; }
  .game-board-title { align-items: flex-start; flex-direction: column; }
}

/* На настольном компьютере играют с клавиатуры — кнопки только занимают место. */
@media (hover: hover) and (pointer: fine) {
  .dpad { display: none; }
}

/* Переключатель темы: показываем значок, противоположный текущей теме */
.theme-toggle { padding: 8px 12px; font-size: 15px; line-height: 1; }
.theme-toggle .sun { display: none; }
[data-theme='dark'] .theme-toggle .sun { display: inline; }
[data-theme='dark'] .theme-toggle .moon { display: none; }
[data-theme='terminal'] {
  --bg: #050806; --tint-1: #0b2416; --tint-2: #102217; --tint-3: #07140d;
  --glass: rgba(10, 35, 19, .78); --glass-2: rgba(5, 25, 12, .7); --glass-hi: rgba(82, 255, 143, .16);
  --stroke: rgba(98, 255, 152, .3); --line: rgba(98, 255, 152, .16);
  --text: #9dffb8; --muted: #5caf73; --accent: #65ff91; --accent-hover: #9dffb8; --accent-soft: rgba(101, 255, 145, .14); --accent-ink: #041008;
  --ok: #65ff91; --ok-soft: rgba(101, 255, 145, .18); --danger: #ff857e; --board: #07140d; --board-line: rgba(101, 255, 145, .12); --radius: 6px; --blur: 4px;
}
[data-theme='paper'] {
  --bg: #eee8dc; --tint-1: #ded2bc; --tint-2: #e5d6c8; --tint-3: #d7cbb6;
  --glass: rgba(255, 251, 241, .78); --glass-2: rgba(255, 251, 241, .5); --glass-hi: rgba(255, 255, 255, .95);
  --stroke: rgba(59, 45, 29, .2); --line: rgba(59, 45, 29, .12); --text: #30271f; --muted: #776957; --accent: #30271f; --accent-hover: #514334; --accent-soft: rgba(48, 39, 31, .1); --accent-ink: #fffaf0; --ok: #3f7850; --ok-soft: rgba(63, 120, 80, .14); --danger: #a54135; --board: #fffaf0; --board-line: rgba(48, 39, 31, .1); --blur: 2px; --radius: 10px;
}
[data-theme='violet'] {
  --bg: #100d1d; --tint-1: #291c46; --tint-2: #321d3b; --tint-3: #171f46;
  --glass: rgba(37, 27, 61, .65); --glass-2: rgba(23, 18, 43, .55); --glass-hi: rgba(233, 173, 255, .18);
  --stroke: rgba(221, 178, 255, .2); --line: rgba(221, 178, 255, .12); --text: #f5edff; --muted: #b7a8ca; --accent: #e3a8ff; --accent-hover: #f0caff; --accent-soft: rgba(227, 168, 255, .16); --accent-ink: #21102e; --ok: #78e7bd; --ok-soft: rgba(120, 231, 189, .16); --danger: #ff8fa4; --board: #19132b; --board-line: rgba(227, 168, 255, .1);
}
.theme-picker { position: relative; }
.theme-picker summary { list-style: none; }
.theme-picker summary::-webkit-details-marker { display: none; }
.theme-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; display: grid; min-width: 130px; gap: 3px; padding: 6px; border: 1px solid var(--stroke); border-radius: 12px; background: var(--bg); box-shadow: var(--shadow); }
.theme-menu button { width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; backdrop-filter: none; font-size: 12px; text-align: left; }
.theme-menu button:hover { background: var(--accent-soft); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .sun { display: inline; }
  :root:not([data-theme]) .theme-toggle .moon { display: none; }
}

/* --- Плавающая панель разделов (телефон) --- */
/* На широком экране те же ссылки уже есть в шапке, поэтому по умолчанию
   панели нет — она включается ниже, в мобильном блоке. */
.tabbar { display: none; }

@media (max-width: 640px) {
  .tabbar {
    position: fixed;
    z-index: 30;
    left: 50%;
    transform: translateX(-50%);
    width: min(calc(100vw - 28px), 520px);
    justify-content: space-between;
    /* Отступ от края с поправкой на домашнюю полоску iPhone: без env()
       панель липнет к ней и нижний ряд перестаёт нажиматься. */
    bottom: calc(14px + env(safe-area-inset-bottom));
    display: flex;
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--stroke);
    border-radius: 999px;
    background: var(--glass);
    backdrop-filter: blur(var(--blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
    box-shadow: var(--shadow);
  }

  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    /* Один ровный ряд; ширина распределяется по всей панели. */
    flex: 1 1 0;
    min-width: 0;
    padding: 7px 12px 6px;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    font-size: 10.5px;
    letter-spacing: .01em;
    transition: background .15s, color .15s;
  }
  .tabbar a.on { background: var(--accent-soft); color: var(--accent); }

  .tabbar svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Разделы переехали в нижнюю панель — в шапке они были бы вторым экземпляром
     тех же ссылок. Остаются «Выйти» и переключатель темы. */
  body:has(.tabbar) .topbar nav a { display: none; }
  body:has(.tabbar) .topbar { align-items: center; min-height: 66px; padding: 12px 14px 12px 20px; }
  body:has(.tabbar) .topbar .brand { flex: 1 1 auto; min-width: 0; }
  body:has(.tabbar) .topbar nav { flex: 0 0 auto; flex-wrap: nowrap; gap: 4px; }
  body:has(.tabbar) .topbar .notification-link { min-width: 34px; padding: 7px 6px; }
  body:has(.tabbar) .topbar .logout-form .link { padding: 8px 10px; font-size: 12px; }
  /* На телефоне в шапке остаётся только аватар — имя прячем, чтобы влезло. */
  body:has(.tabbar) .topbar .account-chip .account-name { display: none; }
  body:has(.tabbar) .topbar .account-chip { padding: 4px; }
  body:has(.tabbar) .topbar .account-popover { width: min(300px, calc(100vw - 28px)); }
  body:has(.tabbar) .topbar .theme-toggle { padding: 8px 11px; font-size: 14px; }

  main { padding: 20px 14px 52px; }
  /* Место под панель, иначе она накрывает последнюю карточку. */
  body:has(.tabbar) main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .card { padding: 18px; }
  .pass-grid { grid-template-columns: 1fr; }
  .pass { padding: 16px; gap: 12px; }
  .pass-stamp { width: 78px; padding: 6px 4px; }
  .key { flex-direction: column; align-items: stretch; }
  .qr { align-self: center; }
  .happ-card-head { padding: 13px 14px 11px; }
  .happ-card-body { grid-template-columns: 1fr; gap: 12px; padding: 13px 14px 14px; }
  .happ-qr { justify-items: start; grid-template-columns: auto auto; align-items: center; }
  .happ-qr .qr { width: 92px; height: 92px; }
  .happ-actions .btn { flex: 1; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  td { border: none; padding: 5px 0; }
  tr { border-top: 1px solid var(--line); padding: 14px 0; }
}

/* --- Переходы между страницами --- */
/* Не анимируем общую страницу: это убирает рывок и повторную отрисовку шапки
   при обычном переходе по ссылкам. */
@view-transition { navigation: none; }

/* Шапка и нижняя панель одинаковы на всех страницах: без своих имён они
   уезжали бы вместе с содержимым и мигали на каждом переходе. */
.topbar { view-transition-name: topbar; }
.tabbar { view-transition-name: tabbar; }

/* Убираем общий crossfade всей страницы: он конкурировал с morph карточки
   и создавал ощущение рывка. Шапка и нижняя панель остаются на месте совсем. */
::view-transition-old(root),
::view-transition-new(root),
::view-transition-group(topbar),
::view-transition-group(tabbar),
::view-transition-old(topbar),
::view-transition-new(topbar),
::view-transition-old(tabbar),
::view-transition-new(tabbar) { animation: none; }

/* Бланк на входе и первый пропуск на дашборде носят одно имя, поэтому вход
   выглядит не как смена страницы, а как спокойная выдача документа. */
.pass-hero { view-transition-name: pass-hero; }
::view-transition-group(pass-hero) {
  animation-duration: .56s;
  animation-timing-function: cubic-bezier(.16, 1, .3, 1);
}
::view-transition-image-pair(pass-hero) { isolation: isolate; }
::view-transition-old(pass-hero) {
  animation: pass-hero-old .24s ease-out both;
}
::view-transition-new(pass-hero) {
  animation: pass-hero-new .56s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes pass-hero-old {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes pass-hero-new {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  body::before, body::after { animation: none; translate: none; }
  .pass { transform: none; }
  .pass::before { animation: none; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}
