/* VUZL 0.9 · Design system "Възел" 2.0.
   Theme IDs stay stable for saved preferences: calm, night, terminal, nerd, arcade. */

@font-face {
  font-family: "VUZL Sans";
  src: url("/fonts/manrope-cyrillic.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "VUZL Sans";
  src: url("/fonts/manrope-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "VUZL Serif";
  src: url("/fonts/serif-cyrillic.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "VUZL Serif";
  src: url("/fonts/serif-latin.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC;
}

:root {
  color-scheme: light;
  /* Минерал: студено-зелена хартия, мастило и нефрит */
  --bg: #f2f4f1;
  --panel: #e9ede9;
  --paper: #ffffff;
  --raised: #f8faf7;
  --text: #14211e;
  --muted: #535f5a;
  --faint: #5a6661;
  --line: #dce2dd;
  --line-strong: #c5cdc7;
  --accent: #1d5e50;
  --active: #dfe9e2;
  --on-accent: #ffffff;
  --out-bg: #1d5e50;
  --out-text: #ffffff;
  --out-muted: #cfe3db;
  --brass: #8a6631;
  --warn: #a3313c;
  --shadow: 0 1px 2px rgb(20 33 30 / 4%), 0 10px 30px rgb(20 33 30 / 7%);
  --shadow-soft: 0 1px 2px rgb(20 33 30 / 5%);
  --radius: 14px;
  --bubble: 20px;
  --font: "VUZL Sans", "Segoe UI Variable Text", "Segoe UI", "Noto Sans", system-ui, sans-serif;
  --display: "VUZL Serif", Georgia, "Noto Serif", serif;
  --message-size: 15px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --tone-0-bg: #dde8e0; --tone-0-fg: #1d5446;
  --tone-1-bg: #eee4d2; --tone-1-fg: #6a4c1c;
  --tone-2-bg: #f1ded6; --tone-2-fg: #7a3a27;
  --tone-3-bg: #dde4ee; --tone-3-fg: #2f4766;
  --tone-4-bg: #e9dee9; --tone-4-fg: #5b3759;
  --tone-5-bg: #e5e6d1; --tone-5-fg: #4b5121;
}
html[data-theme="night"] {
  color-scheme: dark;
  /* Нощ: същата система, без отблясъци */
  --bg: #0e1412;
  --panel: #121a17;
  --paper: #18221e;
  --raised: #1b2622;
  --text: #ecefea;
  --muted: #a7b1ac;
  --faint: #9ba69f;
  --line: #26322d;
  --line-strong: #34433d;
  --accent: #8cc5b1;
  --active: #1f2e29;
  --on-accent: #0e1412;
  --out-bg: #1f4a3e;
  --out-text: #eef6f2;
  --out-muted: #b4d2c6;
  --brass: #d4b47c;
  --warn: #ff9fa7;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 12px 32px rgb(0 0 0 / 35%);
  --shadow-soft: 0 1px 2px rgb(0 0 0 / 30%);
  --tone-0-bg: #1f3a31; --tone-0-fg: #b9dccd;
  --tone-1-bg: #3a3020; --tone-1-fg: #e5cfa6;
  --tone-2-bg: #3d2721; --tone-2-fg: #efc2b2;
  --tone-3-bg: #233042; --tone-3-fg: #c1d1e8;
  --tone-4-bg: #352536; --tone-4-fg: #e0c4de;
  --tone-5-bg: #30321f; --tone-5-fg: #d6d9ad;
}
html[data-theme="terminal"] {
  color-scheme: dark;
  --bg: #182323;
  --panel: #1d2b2a;
  --paper: #253432;
  --raised: #253432;
  --text: #e8f0ea;
  --muted: #adbfba;
  --faint: #a4b8b0;
  --line: #3d504b;
  --line-strong: #4d625c;
  --accent: #abcab5;
  --active: #334a3d;
  --on-accent: #182323;
  --out-bg: #334a3d;
  --out-text: #e8f0ea;
  --out-muted: #adbfba;
  --brass: #d9c48f;
  --warn: #ffb5bb;
  --shadow: none;
  --shadow-soft: none;
  --radius: 6px;
  --bubble: 6px;
  --font: "Cascadia Code", "SFMono-Regular", "Liberation Mono", ui-monospace, monospace;
  --display: var(--font);
  --message-size: 14px;
}
html[data-theme="nerd"] {
  color-scheme: dark;
  --bg: #171e27;
  --panel: #1e2834;
  --paper: #253140;
  --raised: #253140;
  --text: #d9e5f3;
  --muted: #a8b7ca;
  --faint: #a1b1c5;
  --line: #3a4b60;
  --line-strong: #4a5d75;
  --accent: #a8bbd6;
  --active: #2e3d53;
  --on-accent: #171e27;
  --out-bg: transparent;
  --out-text: #d9e5f3;
  --out-muted: #a8b7ca;
  --brass: #d6c49b;
  --warn: #ffc1bf;
  --shadow: none;
  --shadow-soft: none;
  --radius: 3px;
  --bubble: 3px;
  --font: "Cascadia Code", "SFMono-Regular", "Liberation Mono", ui-monospace, monospace;
  --display: var(--font);
  --message-size: 14px;
}
html[data-theme="arcade"] {
  color-scheme: dark;
  --bg: #211f32;
  --panel: #29263d;
  --paper: #332f49;
  --raised: #332f49;
  --text: #f2edf9;
  --muted: #c0b7d2;
  --faint: #baafcd;
  --line: #504862;
  --line-strong: #635a78;
  --accent: #c6b4ed;
  --active: #44385c;
  --on-accent: #211f32;
  --out-bg: #c6b4ed;
  --out-text: #211f32;
  --out-muted: #4c3f6b;
  --brass: #f1d38f;
  --warn: #ffb9c6;
  --shadow: 0 10px 30px rgb(0 0 0 / 25%);
  --shadow-soft: none;
  --radius: 20px;
  --bubble: 24px;
  --message-size: 16px;
}
html[data-theme="terminal"],
html[data-theme="nerd"],
html[data-theme="arcade"] {
  --tone-0-bg: var(--active); --tone-0-fg: var(--accent);
  --tone-1-bg: var(--active); --tone-1-fg: var(--accent);
  --tone-2-bg: var(--active); --tone-2-fg: var(--accent);
  --tone-3-bg: var(--active); --tone-3-fg: var(--accent);
  --tone-4-bg: var(--active); --tone-4-fg: var(--accent);
  --tone-5-bg: var(--active); --tone-5-fg: var(--accent);
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-feature-settings: "locl";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    color 140ms ease,
    border-color 140ms ease,
    transform 120ms var(--ease);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:active:not(:disabled) {
  transform: scale(0.97);
}
a {
  color: var(--accent);
  text-underline-offset: 3px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
input,
textarea,
select {
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 46px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
input:hover,
textarea:hover,
select:hover {
  border-color: var(--muted);
}
input::placeholder,
textarea::placeholder {
  color: var(--faint);
}
label {
  display: block;
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
h1,
h2,
h3,
p {
  margin: 0;
}
p {
  line-height: 1.6;
}
h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.02em;
}
.icon-button {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: var(--text);
}
.icon-button:hover {
  background: var(--active);
}
.primary,
.secondary,
.danger {
  min-height: 46px;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 650;
  letter-spacing: 0.005em;
}
.primary {
  background: var(--accent);
  color: var(--on-accent);
}
.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 88%, var(--text));
}
.secondary {
  border: 1px solid var(--line-strong);
  background: var(--paper);
}
.secondary:hover:not(:disabled) {
  border-color: var(--text);
}
.danger {
  color: var(--warn);
  border: 1px solid currentColor;
}
.text-button {
  min-height: 44px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
}
.text-button:hover {
  color: var(--text);
}
.fineprint,
.alpha-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.issue {
  color: var(--warn);
  font-size: 13px;
  line-height: 1.6;
  margin: 12px 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Brand ---------- */
.vuzl-mark {
  width: 64px;
  height: 64px;
  fill: none;
  color: var(--accent);
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vuzl-wordmark {
  width: 96px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--text);
}
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  pointer-events: none;
  animation: splash-out 0.28s ease 0.86s forwards;
}
.splash .vuzl-mark {
  width: 72px;
  height: 72px;
  animation: knot 0.5s var(--ease) 0.5s both;
}
.splash .vuzl-mark path {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: tie 0.6s var(--ease) forwards;
}
.splash .vuzl-mark path:nth-child(2) {
  animation-delay: 0.12s;
}
.splash .vuzl-wordmark {
  width: 104px;
  height: 35px;
  opacity: 0;
  animation: rise 0.4s var(--ease) 0.35s forwards;
}
@keyframes tie {
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes knot {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(0.94);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes splash-out {
  to {
    opacity: 0;
    visibility: hidden;
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes slide-in {
  from {
    opacity: 0;
  }
}

/* ---------- Gate ---------- */
.gate {
  width: min(440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0 36px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: fade-in 0.4s ease both;
}
.gate-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.gate-brand .vuzl-mark {
  width: 34px;
  height: 34px;
}
.gate-brand .vuzl-wordmark {
  width: 78px;
  height: 26px;
}
.gate-copy {
  margin: 64px 0 32px;
}
.gate h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 46px;
  line-height: 1.04;
  letter-spacing: -0.025em;
  margin-bottom: 18px;
  font-variation-settings: "opsz" 60;
}
.gate-copy p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  max-width: 34ch;
}
.gate form label {
  font-size: 13px;
}
.gate form input {
  width: 100%;
  font-size: 16px;
}
.gate form .primary {
  width: 100%;
  margin-top: 24px;
}
.gate form .fineprint {
  margin-top: 16px;
}
.gate-choices {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  margin: 18px 0 0 -10px;
}
.gate-choices a {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.alpha-note {
  margin-top: auto;
  padding-top: 28px;
  border-top: 0;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.alpha-note::before {
  content: "Алфа";
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 8px;
  flex: none;
}
.invite-card {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 18px;
  padding: 20px 22px;
  margin-bottom: 26px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}
.invite-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
}
.invite-card h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -0.015em;
}
.invite-card p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}
.invite-card .invite-meta {
  color: var(--text);
  font-weight: 600;
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 76px 340px minmax(0, 1fr);
  height: var(--vh, 100dvh);
  max-width: 1600px;
  margin: auto;
  position: relative;
  background: var(--bg);
  animation: fade-in 0.3s ease both;
}
.rail {
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 8px 20px;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 7px;
  border-radius: 14px;
  color: var(--accent);
}
.brand .vuzl-mark {
  width: 32px;
  height: 32px;
}
.brand:hover {
  background: var(--active);
}
.rail-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  flex: 1;
}
.rail-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 44px;
  flex-shrink: 0;
  color: var(--muted);
  border-radius: 999px;
  position: relative;
}
.rail-button:hover {
  color: var(--text);
  background: var(--active);
}
.rail-button.selected {
  color: var(--on-accent);
  background: var(--accent);
}
.avatar {
  --tone-bg: var(--tone-0-bg);
  --tone-fg: var(--tone-0-fg);
  height: 44px;
  width: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--tone-bg);
  color: var(--tone-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
}
.avatar[data-tone="1"] { --tone-bg: var(--tone-1-bg); --tone-fg: var(--tone-1-fg); }
.avatar[data-tone="2"] { --tone-bg: var(--tone-2-bg); --tone-fg: var(--tone-2-fg); }
.avatar[data-tone="3"] { --tone-bg: var(--tone-3-bg); --tone-fg: var(--tone-3-fg); }
.avatar[data-tone="4"] { --tone-bg: var(--tone-4-bg); --tone-fg: var(--tone-4-fg); }
.avatar[data-tone="5"] { --tone-bg: var(--tone-5-bg); --tone-fg: var(--tone-5-fg); }
.avatar.group {
  border-radius: 14px;
}
.avatar.self {
  width: 44px;
  height: 44px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--line-strong);
}

/* ---------- Sidebar ---------- */
.sidebar {
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}
.side-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 30px 20px 18px 24px;
}
.side-heading h1 {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  font-variation-settings: "opsz" 48;
}
.count {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#newChat {
  background: var(--text);
  color: var(--bg);
  border-radius: 50%;
}
#newChat:hover {
  background: var(--accent);
  color: var(--on-accent);
}
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  transition: border-color 140ms ease;
}
.search span {
  color: var(--muted);
  display: flex;
}
.search input {
  background: transparent;
  border: 0;
  border-radius: 0;
  width: 100%;
  min-width: 0;
  font-size: 14px;
  padding: 10px 0;
  min-height: 44px;
  outline-offset: 2px;
}
.search:focus-within {
  border-color: var(--accent);
}
.filters {
  display: flex;
  gap: 2px;
  padding: 10px 14px 10px;
}
.filters button {
  padding: 8px 12px;
  min-height: 44px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
}
.filters button:hover {
  color: var(--text);
}
.filters button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--text);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--line);
}
.chat-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 2px 10px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.chat-item {
  display: flex;
  gap: 14px;
  width: 100%;
  padding: 14px 14px;
  min-height: 80px;
  text-align: left;
  border-radius: 16px;
  position: relative;
  margin-bottom: 2px;
  align-items: center;
}
.chat-item:hover {
  background: color-mix(in srgb, var(--paper) 60%, transparent);
}
.chat-item.active {
  background: var(--paper);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--line);
}
.chat-item:active:not(:disabled) {
  transform: scale(0.99);
}
.chat-summary {
  min-width: 0;
  flex: 1;
}
.chat-top {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}
.chat-top strong {
  font-size: 15px;
  font-weight: 650;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-top time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.chat-preview {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  margin-top: 4px;
  padding-right: 22px;
}
.chat-item.unread .chat-preview {
  color: var(--text);
  font-weight: 600;
}
.chat-label {
  display: block;
  font-size: 11px;
  color: var(--faint);
  margin-top: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 22px;
}
.chat-label:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 1px;
  background: currentColor;
  vertical-align: middle;
  margin-right: 6px;
}
.unread-dot {
  height: 9px;
  width: 9px;
  background: var(--accent);
  border-radius: 50%;
  position: absolute;
  right: 16px;
  bottom: 22px;
}
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 8px 14px 8px 22px;
  min-height: 60px;
}
.connection {
  font-size: 12px;
  color: var(--muted);
}
.connection:before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  vertical-align: 1px;
}
.pending-notice {
  padding: 12px 16px;
  background: var(--paper);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  min-height: 46px;
  text-align: left;
  margin: 2px 18px 12px;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--line), inset 3px 0 var(--brass);
}
.empty-list {
  padding: 28px 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

/* ---------- Conversation ---------- */
.conversation {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 80px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  touch-action: pan-y;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}
.contact-heading {
  flex: 1;
  min-width: 0;
}
.contact-heading h2 {
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}
.contact-heading p {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message-pane {
  min-height: 0;
  flex: 1;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  overscroll-behavior: contain;
}
.welcome {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}
.welcome .vuzl-mark {
  width: 56px;
  height: 56px;
  margin-bottom: 28px;
}
.welcome h2 {
  font-family: var(--display);
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 500;
  margin-bottom: 14px;
  font-variation-settings: "opsz" 60;
}
.welcome p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 28px;
  max-width: 36ch;
}
.messages {
  padding: 24px 40px 16px;
  max-width: 980px;
  margin: auto;
}
.day-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 18px 0 22px;
}
.day-divider::before,
.day-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 12px 0 2px;
}
.message.out {
  align-items: flex-end;
}
.message.grouped {
  margin-top: 3px;
}
.message .author {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 0 14px;
  margin-bottom: 5px;
}
.message-content {
  background: var(--paper);
  padding: 10px 15px;
  border-radius: 6px var(--bubble) var(--bubble) var(--bubble);
  max-width: min(78%, 62ch);
  position: relative;
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--line);
  cursor: pointer;
}
.message.grouped .message-content {
  border-top-left-radius: var(--bubble);
}
.message.out .message-content {
  background: var(--out-bg);
  color: var(--out-text);
  border-radius: var(--bubble) 6px var(--bubble) var(--bubble);
  box-shadow: none;
}
.message.out.grouped .message-content {
  border-top-right-radius: var(--bubble);
}
.message.out .message-content a,
.message.out .file-button {
  color: var(--out-text);
}
.message-text {
  font-size: var(--message-size);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}
.message.emoji-only .message-content,
.message.out.emoji-only .message-content {
  background: transparent;
  box-shadow: none;
  font-size: 34px;
  padding: 2px 8px;
}
.message.emoji-only .message-text {
  font-size: 34px;
  line-height: 1.4;
}
.message-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 17px;
  padding: 3px 8px 0;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.message-meta .receipt {
  color: var(--muted);
}
.message-meta .receipt.read {
  color: var(--accent);
}
.message-actions {
  display: none;
  gap: 0;
}
.message.expanded .message-actions,
.message:focus-within .message-actions {
  display: inline-flex;
}
.message-actions button {
  min-height: 44px;
  min-width: 44px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--muted);
}
.message-actions button:hover {
  background: var(--active);
  color: var(--text);
}
.message.expanded .message-meta {
  min-height: 44px;
}
.message.expanded .message-content {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.message-quote {
  border-left: 2px solid var(--accent);
  padding: 4px 10px;
  margin: 2px 0 8px;
  font-size: 12px;
  color: var(--muted);
  background: color-mix(in srgb, var(--active) 70%, transparent);
  border-radius: 4px 8px 8px 4px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message.out .message-quote {
  border-left-color: var(--out-text);
  color: var(--out-muted);
  background: rgb(255 255 255 / 10%);
}
.message.retracted .message-text {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}
.message.out.retracted .message-text {
  color: var(--out-muted);
}
.message-media {
  max-width: 100%;
  max-height: 340px;
  border-radius: 12px;
  margin-top: 8px;
  display: block;
}
.message-media audio {
  width: 100%;
}
.file-button {
  display: block;
  max-width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  border: 1px solid currentColor;
  border-radius: 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.reactions {
  display: flex;
  gap: 5px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.reaction {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  padding: 2px 9px;
  font-size: 12px;
  min-height: 28px;
  box-shadow: var(--shadow-soft);
}

/* ---------- Composer ---------- */
.composer {
  padding: 8px 28px 22px;
  flex: none;
}
.composer form {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  padding: 6px 8px 6px 14px;
  box-shadow: var(--shadow);
  max-width: 980px;
  margin: 0 auto;
  transition: border-color 140ms ease;
}
.composer form:focus-within {
  border-color: var(--line-strong);
}
#messageInput {
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  width: 100%;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 2px 6px;
  font-size: 15px;
  line-height: 1.5;
  border-radius: 0;
  box-shadow: none;
}
.composer-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.composer-actions .icon-button {
  color: var(--muted);
}
.composer-actions .icon-button:hover {
  color: var(--text);
}
.composer-hint {
  flex: 1;
  font-size: 11px;
  color: var(--faint);
  padding-left: 7px;
}
.send-button {
  border-radius: 50%;
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: var(--on-accent);
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.send-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 88%, var(--text));
}
.terminal-prompt {
  display: none;
}
.reply-preview,
.attachment-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-left: 2px solid var(--accent);
  margin: 0 auto 8px;
  max-width: 980px;
  background: var(--paper);
  border-radius: 4px 12px 12px 4px;
  font-size: 13px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.reply-preview > span,
.attachment-preview > span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.emoji-picker {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  padding: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  margin: 0 auto 10px;
  max-width: 980px;
  box-shadow: var(--shadow);
}
.emoji-choice {
  font-size: 24px;
  min-height: 44px;
  min-width: 36px;
  border-radius: 10px;
}
.emoji-choice:hover {
  background: var(--active);
}
.pixel-emoji {
  display: inline-flex;
  align-items: center;
  vertical-align: -0.16em;
  width: 1.2em;
  height: 1.2em;
  position: relative;
  color: var(--accent);
}
.pixel-emoji svg {
  width: 100%;
  height: 100%;
}
.chat-banner {
  padding: 12px 28px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.demo-banner {
  position: absolute;
  bottom: 0;
  left: 76px;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 18px;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  z-index: 3;
}
.demo-banner a {
  color: var(--bg);
}
.app.is-demo {
  padding-bottom: 26px;
}
.mobile-only {
  display: none;
}

/* ---------- Theme personalities ---------- */
html[data-theme="nerd"] .message,
html[data-theme="nerd"] .message.out {
  align-items: flex-start;
}
html[data-theme="nerd"] .message-content,
html[data-theme="nerd"] .message.out .message-content {
  background: transparent;
  color: var(--text);
  box-shadow: none;
  padding: 0 0 0 12px;
  border-left: 1px solid var(--line);
  border-radius: 0;
  max-width: 95%;
}
html[data-theme="nerd"] .message.out .message-content {
  border-left-color: var(--accent);
}
html[data-theme="nerd"] .message .author {
  display: block;
  padding-left: 13px;
}
html[data-theme="nerd"] .messages {
  padding-top: 15px;
}
html[data-theme="nerd"] .terminal-prompt,
html[data-theme="terminal"] .terminal-prompt {
  display: block;
  font-size: 11px;
  color: var(--accent);
  padding: 5px 3px 0;
}
html[data-theme="nerd"] .avatar {
  border-radius: 2px;
  border: 1px solid var(--line);
}
html[data-theme="terminal"] .avatar {
  border-radius: 5px;
}
html[data-theme="terminal"] .rail-button,
html[data-theme="nerd"] .rail-button,
html[data-theme="terminal"] .primary,
html[data-theme="nerd"] .primary,
html[data-theme="terminal"] .secondary,
html[data-theme="nerd"] .secondary,
html[data-theme="terminal"] .filters button,
html[data-theme="nerd"] .filters button,
html[data-theme="terminal"] #newChat,
html[data-theme="nerd"] #newChat,
html[data-theme="terminal"] .send-button,
html[data-theme="nerd"] .send-button {
  border-radius: var(--radius);
}
html[data-theme="terminal"] .composer form,
html[data-theme="nerd"] .composer form,
html[data-theme="terminal"] .chat-item,
html[data-theme="nerd"] .chat-item {
  border-radius: var(--radius);
}
html[data-theme="terminal"] .chat-item,
html[data-theme="nerd"] .chat-item {
  min-height: 70px;
  padding-top: 10px;
  padding-bottom: 10px;
}
html[data-theme="terminal"] .avatar,
html[data-theme="nerd"] .avatar {
  font-family: var(--font);
  font-size: 14px;
}
html[data-theme="arcade"] .message.emoji-only .message-text {
  font-size: 42px;
}
html[data-theme="arcade"] .send-button:active {
  transform: scale(0.9);
}

/* ---------- Dialogs ---------- */
dialog {
  color: var(--text);
  background: var(--bg);
  padding: 0;
  width: min(540px, calc(100% - 28px));
  max-height: min(88dvh, calc(var(--vh, 100dvh) - 24px));
  border: 1px solid var(--line);
  border-radius: 22px;
  margin: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow);
}
dialog[open] {
  animation: dialog-in 0.22s var(--ease) both;
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}
dialog::backdrop {
  background: rgb(14 22 19 / 45%);
  backdrop-filter: blur(6px);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 14px 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
  border-bottom: 1px solid var(--line);
}
.dialog-head h2 {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 40;
}
.dialog-body {
  padding: 22px 24px 26px;
  line-height: 1.6;
}
.dialog-body > p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}
.dialog-body form input,
.dialog-body form textarea,
.dialog-body form select {
  width: 100%;
}
.dialog-body form .primary {
  margin-top: 22px;
  width: 100%;
}
.dialog-body > label:not(.check-row) > input,
.dialog-body > label:not(.check-row) > textarea {
  display: block;
  width: 100%;
}
.dialog-body .row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.row .grow {
  flex: 1;
  min-width: 0;
}
.row strong {
  display: block;
  font-size: 15px;
  font-weight: 650;
}
.row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.row button {
  flex-shrink: 0;
}
.button-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.section-title {
  font-size: 11px;
  margin: 28px 0 10px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.theme-choice {
  padding: 16px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 16px;
  min-height: 96px;
}
.theme-choice:hover {
  border-color: var(--line-strong);
}
.theme-choice[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.theme-choice strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}
.theme-choice small {
  font-size: 12px;
  line-height: 1.5;
  display: block;
  color: var(--muted);
}
.swatches {
  display: flex;
  gap: 5px;
  margin-bottom: 12px;
}
.swatches i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #8886;
}

/* ---------- Визитка ---------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  margin: 4px 0 6px;
}
.segmented button {
  min-height: 40px;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}
.segmented button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--text);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--line);
}
.profile-card {
  position: relative;
  padding: 22px 22px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  margin: 6px 0 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.profile-card::after {
  content: "";
  position: absolute;
  right: 20px;
  top: 20px;
  width: 22px;
  height: 22px;
  opacity: 0.85;
  background: var(--accent);
  -webkit-mask: var(--mark-mask) center / contain no-repeat;
  mask: var(--mark-mask) center / contain no-repeat;
}
:root {
  --mark-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7 14 25 20 13'/%3E%3Cpath d='M12 19 18 7 27 25'/%3E%3C/svg%3E");
}
.profile-card .avatar {
  width: 52px;
  height: 52px;
  font-size: 20px;
}
.profile-card h3 {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 16px 0 2px;
  font-variation-settings: "opsz" 48;
}
.profile-card .card-role {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.profile-card p {
  color: var(--muted);
  font-size: 13px;
}
.profile-card .card-lines {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 2px;
}
.profile-card .card-lines p {
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.profile-card .card-face {
  position: absolute;
  right: 54px;
  top: 21px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.profile-card .card-met {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--brass);
  font-weight: 600;
}
.profile-card.work {
  background: #14211e;
  color: #f5f2eb;
  border-color: #14211e;
}
.profile-card.work::after {
  background: #d4b47c;
}
.profile-card.work .card-role,
.profile-card.work .card-lines p {
  color: #f5f2eb;
}
.profile-card.work p,
.profile-card.work .card-face {
  color: #b9c2bd;
}
.profile-card.work .card-lines {
  border-top-color: #2d3b37;
}
.profile-card.work .card-met {
  color: #d4b47c;
}
.profile-card.work .avatar {
  --tone-bg: #24332f;
  --tone-fg: #e9d6ae;
}
html[data-theme="night"] .profile-card.work {
  background: #ece5d6;
  color: #14211e;
  border-color: #ece5d6;
}
html[data-theme="night"] .profile-card.work .card-role,
html[data-theme="night"] .profile-card.work .card-lines p {
  color: #14211e;
}
html[data-theme="night"] .profile-card.work p,
html[data-theme="night"] .profile-card.work .card-face {
  color: #4f5a55;
}
html[data-theme="night"] .profile-card.work .card-lines {
  border-top-color: #d3cab6;
}
html[data-theme="night"] .profile-card.work .card-met,
html[data-theme="night"] .profile-card.work::after {
  color: #7a5a28;
  background: #7a5a28;
}
html[data-theme="night"] .profile-card.work .card-met {
  background: none;
}
html[data-theme="night"] .profile-card.work .avatar {
  --tone-bg: #d9cfba;
  --tone-fg: #14211e;
}
.qr-image {
  display: block;
  width: 232px;
  max-width: 100%;
  margin: 22px auto;
  background: #fff;
  padding: 12px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.link-box {
  font:
    11px/1.7 ui-monospace,
    monospace;
  width: 100%;
  word-break: break-all;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  user-select: all;
}
.safety-code {
  white-space: pre-wrap;
  text-align: center;
  padding: 20px;
  font:
    15px/2 ui-monospace,
    monospace;
  letter-spacing: 1px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.check-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
}
.check-row input,
.dialog-body .check-row input {
  min-height: 20px;
  width: 20px;
  min-width: 20px;
  flex: 0 0 20px;
  padding: 0;
  accent-color: var(--accent);
}
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
  max-width: calc(100% - 32px);
  width: max-content;
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  box-shadow: var(--shadow);
  animation: toast-in 0.24s var(--ease) both;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}
.recording {
  color: var(--warn) !important;
  background: var(--active);
}

/* ---------- Icons ---------- */
.ui-icon {
  width: 24px;
  height: 24px;
  display: block;
  flex-shrink: 0;
}
.search .ui-icon {
  width: 18px;
  height: 18px;
}
.receipt .ui-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: middle;
}
.message-actions .ui-icon {
  width: 18px;
  height: 18px;
}
.rail-button .ui-icon,
#newChat .ui-icon {
  width: 22px;
  height: 22px;
}

/* ---------- Responsive ---------- */
@media (min-width: 1700px) {
  .app {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}
@media (max-width: 1000px) {
  .app {
    grid-template-columns: 64px 280px minmax(0, 1fr);
  }
  .rail {
    padding-left: 6px;
    padding-right: 6px;
  }
  .side-heading {
    padding-left: 18px;
    padding-right: 14px;
  }
  .messages {
    padding: 22px;
  }
  .composer {
    padding: 8px 18px 18px;
  }
  .message-content {
    max-width: 88%;
  }
  .demo-banner {
    left: 64px;
  }
  .chat-header {
    padding: 14px 20px;
  }
}
@media (max-width: 700px) {
  body {
    height: var(--vh, 100dvh);
    overflow: hidden;
  }
  .app {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 64px;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .rail {
    grid-row: 2;
    flex-direction: row;
    justify-content: space-around;
    padding: 6px 14px;
    border-right: 0;
    border-top: 1px solid var(--line);
    gap: 6px;
    background: var(--paper);
  }
  .rail .brand {
    display: none;
  }
  .rail-main {
    flex-direction: row;
    justify-content: space-around;
    gap: 0;
    margin: 0;
    flex: 1;
  }
  .rail-button {
    height: 44px;
    width: 56px;
  }
  .rail-button.selected {
    color: var(--accent);
    background: var(--active);
  }
  .avatar.self {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }
  .sidebar {
    grid-row: 1;
    border-right: 0;
    background: var(--bg);
  }
  .conversation {
    display: none;
  }
  .app.show-chat {
    grid-template-rows: 1fr;
  }
  .app.show-chat .rail,
  .app.show-chat .sidebar {
    display: none;
  }
  .app.show-chat .conversation {
    display: flex;
    grid-row: 1;
    animation: slide-in 0.18s ease both;
  }
  .side-heading {
    padding: 22px 16px 14px 20px;
  }
  .side-heading h1 {
    font-size: 32px;
  }
  .search {
    margin: 0 16px;
  }
  .search input {
    font-size: 16px;
  }
  .filters {
    padding: 10px 12px;
  }
  .chat-item {
    padding: 12px 12px;
    min-height: 76px;
  }
  .chat-item.active {
    background: transparent;
    box-shadow: none;
  }
  .chat-list {
    padding: 0 6px;
  }
  .sidebar-footer {
    min-height: 44px;
    padding: 0 12px 0 20px;
    border: 0;
  }
  .mobile-only {
    display: inline-flex;
  }
  .chat-header {
    min-height: 60px;
    padding: 6px 10px 6px 4px;
    gap: 8px;
  }
  .chat-header .avatar {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }
  .contact-heading h2 {
    font-size: 15px;
    margin-bottom: 0;
  }
  .contact-heading p {
    font-size: 11px;
  }
  .messages {
    padding: 10px 12px;
  }
  .day-divider {
    margin: 12px 0 16px;
    font-size: 10px;
  }
  .message-content {
    max-width: 86%;
    padding: 8px 13px;
  }
  .message-text {
    font-size: 15px;
  }
  .message .author {
    font-size: 11px;
  }
  .message-meta {
    min-height: 17px;
  }
  .composer {
    padding: 4px 8px max(8px, env(safe-area-inset-bottom));
  }
  .composer form {
    padding: 2px 4px 4px 10px;
    border-radius: 20px;
  }
  .composer-hint {
    font-size: 10px;
  }
  #messageInput {
    font-size: 16px;
    max-height: 112px;
    min-height: 42px;
    padding: 8px 2px 4px;
  }
  .emoji-picker {
    grid-template-columns: repeat(5, 1fr);
    max-height: 210px;
    overflow: auto;
  }
  .welcome {
    padding: 28px;
  }
  .welcome h2 {
    font-size: 30px;
  }
  .gate {
    height: var(--vh, 100dvh);
    overflow: auto;
    padding-top: 32px;
    padding-bottom: 28px;
  }
  .gate-copy {
    margin: 44px 0 26px;
  }
  .gate h1 {
    font-size: 40px;
  }
  .demo-banner {
    left: 0;
    padding: 4px 12px;
    font-size: 10px;
  }
  .app.is-demo {
    padding-bottom: 24px;
  }
  .toast {
    bottom: 84px;
  }
  dialog {
    width: 100%;
    max-width: 100%;
    max-height: calc(var(--vh, 100dvh) - 16px);
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
  }
  dialog[open] {
    transform-origin: 50% 100%;
  }
  @keyframes dialog-in {
    from {
      transform: scale(0.97);
      opacity: 0;
    }
  }
  .dialog-body {
    padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  }
  .dialog-head {
    padding: 14px 10px 12px 20px;
  }
  .dialog-head h2 {
    font-size: 22px;
  }
}
@media (max-width: 380px) {
  .theme-grid {
    grid-template-columns: 1fr;
  }
  .rail {
    padding-inline: 6px;
    gap: 4px;
  }
  .rail-button {
    width: 48px;
  }
  .dialog-body .row {
    flex-wrap: wrap;
  }
  .row .grow {
    flex-basis: 60%;
  }
  .gate h1 {
    font-size: 35px;
  }
  .side-heading h1 {
    font-size: 28px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .splash {
    display: none;
  }
}

/* Language: English interface labels that live in CSS, wrapping language switch. */
html:lang(en) .alpha-note::before {
  content: "Alpha";
}
.segmented {
  flex-wrap: wrap;
  max-width: 100%;
}
