:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-elev: #101826;
  --bg-elev-2: #172235;
  --line: rgba(140, 176, 214, 0.18);
  --text: #e7eef8;
  --muted: #8ea0b8;
  --aurora: #3ee0c5;
  --aurora-2: #4c8dff;
  --aurora-3: #8b6cff;
  --danger: #ff8b98;
  --warn: #e6c36a;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --control-bg: #0c121e;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 7.5 10 12.5 15 7.5' fill='none' stroke='%238ea0b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(142, 160, 184, 0.55) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background-color: rgba(142, 160, 184, 0.38);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: rgba(62, 224, 197, 0.72); }
*::-webkit-scrollbar-corner { background: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45; }
body {
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(62, 224, 197, 0.16), transparent 60%),
    radial-gradient(700px 380px at 90% 0%, rgba(139, 108, 255, 0.14), transparent 55%),
    var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: 44px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: 100%; min-height: 0; min-width: 0; max-width: 100%; overflow: hidden; }
.side, .bottom {
  display: flex;
  gap: 6px;
}
.side {
  flex-direction: column;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: rgba(8, 12, 22, 0.72);
  height: 100%;
  min-height: 0;
  overflow: auto;
}
.bottom { display: none; }
.brand, .nav-link, .bottom a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
}
.brand {
  font-weight: 650;
  letter-spacing: 0.01em;
  margin-bottom: 18px;
  background: linear-gradient(100deg, var(--aurora), var(--aurora-2) 55%, var(--aurora-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.version {
  font-size: 0.75rem;
  font-weight: 560;
  letter-spacing: 0.04em;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  background: none;
}
.nav-link { color: var(--muted); }
.nav-link.active, .bottom a.active { color: var(--text); background: rgba(62, 224, 197, 0.1); }
.nav-icon { width: 20px; height: 20px; flex: 0 0 auto; }
.nav-icon, .nav-icon path, .nav-icon circle { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { margin-top: auto; }
.side-foot .logout { margin-top: 0; }
.build-rev {
  margin: 0 0 6px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}
.side .logout {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border-color: transparent;
  cursor: pointer;
}
.main {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 28px 32px 24px;
  width: 100%;
  min-width: 0;
}
.main:not(:has(.screen)) { overflow: auto; }
.screen { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; }
.screen > * { flex: none; }
.screen > .scroll,
.screen > .clients-split { flex: 1 1 auto; min-height: 0; }
.scroll { min-width: 0; overflow-x: clip; overflow-y: auto; }
h1 { font-size: 1.5rem; font-weight: 640; line-height: 1.25; margin: 0 0 16px; }
.page-mark { display: none; }
h2 { font-size: 1.05rem; font-weight: 620; line-height: 1.3; margin: 22px 0 10px; }
.toolbar h1, .card h2, .connection-card h2 { margin: 0; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.error { color: var(--danger); margin: 8px 0; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.toolbar h1 { flex: 1; }
.toolbar input, .toolbar select { width: auto; flex: 1; max-width: 320px; min-width: 0; }
.stack, .feed {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: 14px;
  align-items: start;
}
.stack:has(> .server-block) {
  grid-template-columns: repeat(auto-fit, minmax(min(560px, 100%), 1fr));
  align-items: stretch;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 14px; min-width: 0; align-items: stretch; }
.card, .panel, .auth-card, .stub {
  background:
    linear-gradient(180deg, rgba(62, 224, 197, 0.07), transparent 42%),
    var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.card, .panel { padding: 16px; min-width: 0; }
.admin-link { display: grid; justify-items: start; gap: 8px; margin: 4px 0 8px; }
.admin-qr { width: 120px; height: 120px; background: #fff; padding: 6px; border-radius: 12px; }
.connection-card header p { margin: 6px 0 0; color: var(--muted); }
.connection-card .hscroll { margin-top: 12px; }
.with-flag { display: flex; align-items: center; gap: 8px; }
.flag { width: 20px; height: 15px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16); flex: 0 0 auto; }
.pings { display: flex; gap: 16px; margin: 14px 0; }
.pings div { display: flex; gap: 8px; }
.pings dt { color: var(--muted); }
.pings dd { margin: 0; }
.qr-wrap { display: flex; justify-content: center; margin: 4px 0 12px; }
button.qr { background: #fff; padding: 12px; border-radius: 16px; border: 0; min-height: 0; line-height: 0; width: min(420px, 100%); box-sizing: border-box; }
button.qr img { width: 100%; height: auto; aspect-ratio: 1; display: block; }
.sub-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sub-link { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: Consolas, "Courier New", monospace; font-size: 0.92rem; }
button.icon {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  line-height: 0;
  flex: 0 0 auto;
}
button.icon svg { width: 16px; height: 16px; display: block; }
.row-actions, .form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-actions { margin-bottom: 14px; min-width: 0; }
.form-actions > * { max-width: 100%; }
.form.panel > button, .form.panel > .button { justify-self: start; }
.panel + .panel, .stack + .form { margin-top: 14px; }
.stack > .panel + .panel { margin-top: 0; }
.server-block .add-block {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  align-items: stretch;
}
.server-block .add-block > button { margin-top: auto; width: 100%; }
.server-block { display: flex; flex-direction: column; gap: 14px; }
.param-list, .connection-list { display: flex; flex-direction: column; gap: 10px; }
.connection-list { gap: 14px; }
.pager { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; }
.pager button { min-width: 44px; padding: 0 10px; }
.pager button.active {
  color: var(--text);
  border-color: transparent;
  background: rgba(62, 224, 197, 0.16);
}
.server-block > h2 { margin: 0; }
.server-block .form { gap: 10px; }
.connection-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto auto;
  gap: 8px;
  align-items: end;
}
button, .button {
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  border-radius: 12px;
  padding: 0 14px;
  cursor: pointer;
}
button.primary, .button.primary {
  border-color: transparent;
  background: linear-gradient(100deg, #1f8f86, #315dbe 60%, #6a4ed0);
  background-origin: border-box;
}
button.danger { color: var(--danger); }
label, .field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; font-size: 0.92rem; color: var(--muted); }
.import-servers { display: flex; flex-direction: column; gap: 14px; }
.import-head { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 8px; }
.import-head h2 { margin: 0; }
.import-head label { max-width: 420px; }
.import-group { margin: 16px 0 4px; font-size: 1rem; }
.import-group:first-of-type { margin-top: 0; }
label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}
input:not([type="checkbox"]):not([type="file"]), select, textarea, .select-face {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background-color: var(--control-bg);
}
select {
  appearance: none;
  padding-right: 44px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px 16px;
}
input[type="number"] { appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { appearance: none; margin: 0; }
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none; }
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-internal-autofill-selected,
textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--control-bg) inset !important;
  transition: background-color 99999s ease-out;
}
input.secret { -webkit-text-security: disc; }
input.autofill-trap:not([type="checkbox"]):not([type="file"]) {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  min-width: 0;
  min-height: 0;
  max-width: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  flex: 0 0 auto;
  border-radius: 6px;
  border: 1px solid var(--line);
  background-color: var(--control-bg);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}
input[type="checkbox"]:checked {
  border-color: transparent;
  background-color: var(--aurora);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 8.2 6.4 11.4 12.8 4.6' fill='none' stroke='%2306221c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.select-shell { position: relative; }
.select-shell.open { z-index: 22; }
.select-face {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  padding-right: 44px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px 16px;
}
.select-face > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-face .placeholder { color: var(--muted); }
.select-backdrop { position: fixed; inset: 0; z-index: 20; min-height: 0; padding: 0; border: 0; background: transparent; }
.select-menu {
  position: absolute;
  z-index: 21;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: 320px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}
.select-options { overflow: auto; min-height: 0; }
.select-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  justify-content: flex-start;
  gap: 8px;
  border: 0;
  background: transparent;
  border-radius: 8px;
}
.select-menu button.active,
.select-menu button:hover { background: rgba(62, 224, 197, 0.1); }
.select-menu input.select-filter {
  position: static;
  flex: none;
  z-index: 1;
  min-height: 36px;
  margin-bottom: 4px;
  padding: 8px 10px;
  background-color: var(--bg-elev);
}
.select-menu .empty { margin: 8px; font-size: 0.85rem; }
.select-menu button.combo-option {
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 6px 8px;
  min-height: 40px;
}
.select-menu button.combo-option .muted { font-size: 0.78rem; }
.file-field { display: grid; gap: 6px; font-size: 0.92rem; color: var(--muted); }
label.file {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--text);
  font-size: 0.95rem;
}
label.file input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
select option { background: #0c121e; color: var(--text); }
textarea { min-height: 120px; resize: vertical; }
.form { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; overflow-x: clip; }
.param-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; min-width: 0; }
.param-row button { white-space: nowrap; }
a.card { display: block; }
.card .toolbar { margin-bottom: 8px; }
.card strong, .panel strong { font-weight: 640; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; min-width: 0; }
.group-row { display: flex; align-items: end; gap: 8px; max-width: 520px; }
.group-row label { flex: 1; }
.group-row button { flex: 0 0 auto; }
.page-lead { margin-top: -8px; }
.throne-panel { margin-bottom: 16px; }
.throne-head { position: relative; z-index: 4; display: flex; align-items: center; gap: 8px; margin-bottom: 0; }
.throne-panel.open .throne-head { margin-bottom: 12px; }
button.throne-toggle {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: auto;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 620;
  text-align: left;
}
.throne-toggle .fold-mark {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  background: var(--chevron) center / 16px 16px no-repeat;
}
.throne-panel.open .throne-toggle .fold-mark { transform: rotate(180deg); }
.throne-body { display: none; }
.throne-panel.open .throne-body { display: block; }
.hint-button svg { width: 18px; height: 18px; }
.hint-button circle, .hint-button path { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.hint-anchor { position: relative; flex: 0 0 auto; }
.hint-pop {
  position: absolute;
  z-index: 21;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #172235;
  box-shadow: var(--shadow);
}
.clip-row { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.clip-row.open { position: relative; z-index: 6; }
.clip-row .hint-anchor { position: static; }
.clip-row .hint-pop { left: 0; right: 0; width: auto; }
.card:has(.clip-row.open) { position: relative; z-index: 4; }
.clip-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-card header .clip-text { color: var(--muted); }
.route-json { min-height: 320px; font-family: Consolas, "Courier New", monospace; font-size: 0.86rem; }
.hint-pop p { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.hint-pop p + p { margin-top: 8px; }
.throne-panel > .muted, .message p { max-width: 76ch; }
.throne-actions { display: grid; gap: 8px; margin-top: 0; container: throne / inline-size; }
.os-icon { display: none; width: 18px; height: 18px; flex: 0 0 auto; }
.btn-short { display: none; }
@container throne (max-width: 560px) {
  .os-icon { display: block; }
  .btn-short { display: inline; }
  .btn-full { display: none; }
  .row-actions { flex-wrap: nowrap; gap: 6px; }
  .row-actions > * {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    padding: 0 8px;
    font-size: 0.8rem;
    white-space: nowrap;
  }
}
@container throne (max-width: 420px) {
  .throne-actions > .row-actions:last-child {
    flex-wrap: wrap;
  }
  .throne-actions > .row-actions:last-child > * {
    flex: 1 1 auto;
    width: 100%;
  }
}
.throne-panel p:last-child { margin-bottom: 0; }
a.button.is-disabled { opacity: 0.45; pointer-events: none; }
.clients-split {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  min-width: 0;
  overflow: hidden;
}
.clients-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(520px, 100%), 1fr));
  column-gap: 28px;
  align-content: start;
  align-items: start;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  padding-right: 4px;
}
.clients-side { display: grid; gap: 14px; align-content: start; min-height: 0; min-width: 0; overflow: auto; }
.clients-side > * { min-width: 0; }
.clients-side .panel { margin-top: 0; }
.clients-side h2 { margin-top: 0; }
.fold-toggle { display: none; }
.inbound-list { display: grid; gap: 4px; min-width: 0; }
.clients-board { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: hidden; }
.clients-search { display: flex; gap: 8px; align-items: center; }
.clients-search input { flex: 1 1 auto; width: auto; min-width: 0; }
.clients-search button { flex: 0 0 auto; }
.client-row { display: grid; gap: 8px; min-width: 0; padding: 12px 0; border-top: 1px solid var(--line); }
.client-main { min-width: 0; }
.client-row strong, .client-row .muted { overflow-wrap: anywhere; }
.client-row:first-child { border-top: 0; padding-top: 0; }
@media (min-width: 801px) {
  .clients-list .client-row {
    display: flex;
    align-items: center;
    gap: 16px;
    container: client-row / inline-size;
  }
  .clients-list .client-row .client-main {
    flex: 1 0 auto;
    min-width: 0;
  }
  .clients-list .client-row .client-main strong,
  .clients-list .client-row .client-main .muted {
    overflow-wrap: normal;
    word-break: normal;
  }
  .clients-list .client-row .hscroll {
    flex: 0 0 auto;
  }
  .clients-list .client-row .row-actions {
    flex-wrap: nowrap;
  }
}
@container client-row (max-width: 560px) {
  .row-actions button.danger > span { display: none; }
  .row-actions button.danger { width: 44px; min-width: 44px; padding: 0; }
}
@container client-row (max-width: 420px) {
  .row-actions button > span { display: none; }
  .row-actions button { width: 44px; min-width: 44px; padding: 0; }
}
.btn-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.btn-icon, .btn-icon path { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.client-row .row-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
}
.client-row .row-actions button span { white-space: nowrap; }
.client-row .muted { margin: 4px 0 0; }
.clients-none { flex: 1; display: grid; place-items: center; margin: 0; min-height: 140px; text-align: center; }
.clients-notice { display: grid; gap: 8px; justify-items: start; max-width: 480px; }
.clients-notice h2 { margin: 0; }
.clients-notice p { margin: 0; }
.auth-wrap, .stub-wrap { height: 100%; min-height: 0; overflow: auto; display: grid; place-items: center; padding: 24px; }
.auth-card, .stub { width: min(420px, 100%); padding: 28px; }
.auth-card h1, .stub h1 { margin-bottom: 8px; }
.tabs-shell { min-width: 0; margin-bottom: 16px; }
.hscroll { position: relative; max-width: 100%; --hscroll-fade: rgba(16, 24, 38, 0.72); }
.tabs-shell.hscroll { --hscroll-fade: rgba(7, 11, 20, 0.55); }
.hscroll::before,
.hscroll::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 16px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
}
.hscroll::before {
  left: 0;
  background: linear-gradient(90deg, var(--hscroll-fade), transparent);
}
.hscroll::after {
  right: 0;
  background: linear-gradient(270deg, var(--hscroll-fade), transparent);
}
.hscroll.hint-left::before,
.hscroll.hint-right::after { opacity: 1; }
.hscroll:has(> .pager) { min-width: 0; }
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-bottom: 0;
}
.tabs a {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  white-space: nowrap;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid transparent;
}
.tabs .nav-icon { width: 16px; height: 16px; }
.tabs a.active { color: var(--text); background: rgba(62, 224, 197, 0.12); border-color: var(--line); }
.feed { grid-template-columns: minmax(0, 1fr); align-items: start; }
.prose a { color: #8eb7ff; }
.prose p { margin: 0 0 0.75rem; }
.prose ul, .prose ol { padding-left: 1.2rem; }
.chat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.message {
  width: fit-content;
  max-width: min(82%, 540px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 6px;
  background: rgba(23, 34, 53, 0.9);
  overflow-wrap: anywhere;
}
.message.mine {
  align-self: flex-end;
  border-radius: 16px 16px 6px 16px;
  background: rgba(62, 224, 197, 0.12);
}
.message strong { display: block; font-size: 0.86rem; }
.message p { margin: 0; }
.message .muted { margin: 2px 0 6px; }
.message img { max-width: 100%; }
.badge { display: inline-flex; align-items: center; align-self: flex-start; min-height: 28px; padding: 0 10px; border-radius: 999px; background: rgba(76, 141, 255, 0.16); }
.badge.closed { background: rgba(142, 160, 184, 0.16); }
.badge.progress { background: rgba(62, 224, 197, 0.16); }
.attachment { display: inline-flex; margin: 8px 8px 0 0; }
.attachment img { max-width: 220px; border-radius: 10px; }
.editor-shell { background: var(--control-bg); border: 1px solid var(--line); border-radius: 12px; overflow: visible; }
.editor-shell .ql-toolbar.ql-snow { position: relative; z-index: 3; border: 0; border-bottom: 1px solid var(--line); background: transparent; overflow: visible; }
.editor-shell .ql-container.ql-snow { position: relative; z-index: 1; border: 0; font-family: inherit; font-size: 1rem; }
.editor-shell .ql-toolbar.ql-snow button,
.editor-shell .ql-toolbar.ql-snow .ql-picker-label { min-height: 28px; height: 28px; padding: 2px 6px; }
.editor-shell .ql-toolbar.ql-snow button { width: 28px; padding: 3px 5px; }
.editor-shell .ql-toolbar.ql-snow .ql-picker { width: auto; height: auto; }
.editor-shell .ql-toolbar [data-tip] { position: relative; }
.editor-shell .ql-toolbar [data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #172235;
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  z-index: 6;
}
.editor-status { margin: 0; padding: 8px 12px 12px; }
.ql-editor { min-height: 240px; color: var(--text); }
.ql-editor img { max-width: 100%; height: auto; }
.ql-editor a { color: #8eb7ff; }
.ql-snow .ql-stroke { stroke: #c5d2e4 !important; }
.ql-snow .ql-fill { fill: #c5d2e4 !important; }
.ql-snow .ql-picker { color: #c5d2e4 !important; }
.ql-snow .ql-picker.ql-expanded { z-index: 4; }
.ql-snow .ql-picker-options { background: #172235; color: #e7eef8; border-color: var(--line) !important; z-index: 5; }
.ql-snow .ql-picker-item { color: #e7eef8; cursor: pointer; }
.ql-snow .ql-picker-item:hover { color: var(--aurora); }
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
.ql-snow .ql-picker.ql-header .ql-picker-item::before { content: "Обычный"; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before { content: "Заголовок 1"; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { content: "Заголовок 2"; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { content: "Заголовок 3"; }
.ql-snow .ql-color-picker .ql-picker-options,
.ql-snow .ql-icon-picker .ql-picker-options { padding: 4px; }
.prose .ql-align-center { text-align: center; }
.prose .ql-align-right { text-align: right; }
.prose .ql-align-justify { text-align: justify; }
.prose img { max-width: 100%; border-radius: 10px; cursor: zoom-in; }
button.zoomable { padding: 0; border: 0; background: transparent; min-height: 0; line-height: 0; cursor: zoom-in; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: max(56px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(5, 8, 14, 0.94);
}
.lightbox img {
  max-width: min(1200px, 100%);
  max-height: calc(100dvh - 88px);
  object-fit: contain;
  border-radius: 8px;
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
}
.lightbox-close svg { width: 20px; height: 20px; }
.lightbox-close path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
body.lightbox-open { overflow: hidden; }
.prose pre { overflow: auto; padding: 12px; border-radius: 10px; background: var(--control-bg); }
.prose blockquote { margin: 0 0 0.75rem; padding-left: 12px; border-left: 3px solid var(--aurora); }

@media (max-width: 800px) {
  .shell { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
  .side { display: none; }
  .main { order: 1; flex: 1 1 auto; height: auto; }
  .bottom {
    order: 2;
    display: flex;
    align-items: center;
    position: relative;
    left: auto; right: auto; bottom: auto;
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(8, 12, 22, 0.94);
    border-top: 1px solid var(--line);
    z-index: 5;
  }
  .bottom a, .bottom button {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    font-size: 0.72rem;
    line-height: 1.15;
    padding: 6px 2px;
    text-align: center;
    min-height: 0;
    background: transparent;
    border-color: transparent;
    color: var(--muted);
  }
  .bottom a span, .bottom button span { display: block; max-width: 100%; }
  .bottom .nav-icon { width: 22px; height: 22px; }
  .bottom .home svg { width: 48px; height: 48px; }
  .bottom .logout { color: var(--muted); }
  .page-title { display: flex; align-items: center; gap: 10px; }
  .page-mark { display: flex; }
  .page-mark svg { width: 32px; height: 32px; }
  .main { padding: 18px 14px 18px; }
  .grid-2, .cards, .stack, .feed, .connection-row, .clients-split { grid-template-columns: minmax(0, 1fr); }
  .group-row { display: flex; align-items: end; max-width: none; }
  .server-block { gap: 10px; }
  .server-block .connection-row,
  .server-block .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .server-block .connection-row > button { white-space: nowrap; padding: 0 8px; }
  .screen, .form, .panel, .clients-board, .clients-search { max-width: 100%; }
  .screen > .clients-split,
  .clients-split { overflow-x: clip; overflow-y: auto; min-width: 0; align-content: start; }
  .clients-side, .clients-board { overflow: visible; min-height: auto; }
  .clients-list { overflow: visible; flex: none; }
  .fold {
    border: 1px solid var(--line);
    border-radius: 16px;
    background:
      linear-gradient(180deg, rgba(62, 224, 197, 0.07), transparent 42%),
      var(--bg-elev);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  .fold-toggle {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: var(--text);
    background: transparent;
  }
  .fold-mark {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    background: var(--chevron) center / 16px 16px no-repeat;
  }
  .fold.open .fold-mark { transform: rotate(180deg); }
  .fold-title { display: none; }
  .fold-body { display: none; }
  .fold.open .fold-body { display: grid; }
  .fold .fold-body {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    margin: 0;
  }
  .inbound-list { max-height: 180px; overflow: auto; }
  .client-row > .hscroll {
    min-width: 0;
    container-type: inline-size;
    container-name: client-actions;
  }
  .client-row .row-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    min-width: 0;
  }
  .client-row .row-actions > * {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  @container client-actions (max-width: 460px) {
    button.danger > span { display: none; }
    button.danger { width: 44px; min-width: 44px; padding: 0; }
  }
  @container client-actions (max-width: 300px) {
    button > span { display: none; }
    button { width: 44px; min-width: 44px; padding: 0; }
  }
  .screen > .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar input, .toolbar select { max-width: none; width: 100%; }
  .import-head label { max-width: none; }
}

@media (max-width: 480px) {
  .bottom a span, .bottom button span { display: none; }
  .bottom .nav-icon, .bottom .home svg { width: 40px; height: 40px; }
  .main { padding-bottom: 18px; }
}
