:root {
  color-scheme: dark;
  --bg: #05070b;
  --bg-soft: #090d12;
  --panel: #101720;
  --panel-2: #15202a;
  --panel-3: #0c1218;
  --field: #080d13;
  --line: #253342;
  --line-strong: #355064;
  --text: #f5f8fb;
  --muted: #a0adba;
  --quiet: #718190;
  --cyan: #5fe2dd;
  --green: #82e6a7;
  --blue: #72a7ff;
  --amber: #ffd06b;
  --coral: #ff8d75;
  --rose: #ff7ba3;
  --violet: #b49cff;
  --mine: #0a696d;
  --bubble: #182433;
  --shadow: 0 20px 60px rgba(0, 0, 0, .36);
}

:root.light {
  color-scheme: light;
  --bg: #eef3f6;
  --bg-soft: #f7fafc;
  --panel: #ffffff;
  --panel-2: #eef5f8;
  --panel-3: #f8fbfc;
  --field: #ffffff;
  --line: #d6e0e7;
  --line-strong: #b8c8d2;
  --text: #17212b;
  --muted: #5a6874;
  --quiet: #788795;
  --mine: #0c8c91;
  --bubble: #ffffff;
  --shadow: 0 18px 50px rgba(48, 67, 82, .16);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
textarea { font: inherit; letter-spacing: 0; }
button { border: 0; color: var(--text); cursor: pointer; }
button:disabled { opacity: .58; cursor: wait; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: start center;
  overflow: hidden;
  background: #03060a;
  transition: opacity .34s ease, visibility .34s ease;
}
.splash-screen.hidden {
  display: grid !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-screen img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.splash-title {
  position: relative;
  z-index: 1;
  margin-top: max(48px, env(safe-area-inset-top));
  text-align: center;
  text-shadow:
    0 2px 0 #06131c,
    0 8px 22px rgba(0,0,0,.72),
    0 0 34px rgba(95,226,221,.42);
}
.splash-title b {
  display: block;
  font-size: clamp(40px, 11vw, 86px);
  line-height: .9;
  color: #eaffff;
  font-weight: 950;
}
.splash-title span {
  display: block;
  margin-top: 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(12, 18, 25, .96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--text);
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(2, 5, 9, .34), rgba(3, 6, 10, .94)),
    url("/static/assets/velvetlink-splash.png") center top / cover no-repeat;
}
.auth-card {
  width: min(1040px, 100%);
  min-height: 520px;
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(14, 20, 28, .92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.auth-hero {
  padding: 42px;
  background:
    radial-gradient(circle at 28% 20%, rgba(95, 226, 221, .16), transparent 25%),
    radial-gradient(circle at 82% 10%, rgba(255, 208, 107, .10), transparent 22%),
    linear-gradient(180deg, #0f1720, #070b10);
}
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  padding: 9px 13px 9px 9px;
  border: 1px solid rgba(95, 226, 221, .24);
  border-radius: 8px;
  background: rgba(7, 12, 18, .7);
}
.brand-lockup b {
  display: block;
  font-size: 16px;
}
.brand-lockup span {
  color: var(--muted);
  font-size: 12px;
}
.brand-mark, .rail-mark {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  color: #061014;
  font-weight: 950;
  font-size: 23px;
  box-shadow: 0 12px 34px rgba(95, 226, 221, .18);
}
.brand-mark.image, .rail-mark.image {
  object-fit: cover;
  padding: 0;
  border: 1px solid rgba(95, 226, 221, .32);
  background: #071018;
}
.eyebrow, .pane-section, .stat span, .meta, .inline-note {
  color: var(--quiet);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 850;
}
.auth-hero h1 { margin: 8px 0 12px; font-size: clamp(36px, 6vw, 62px); line-height: .96; }
.hero-copy { max-width: 520px; color: var(--muted); font-size: 16px; }
.hero-grid {
  margin-top: 34px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.hero-grid div, .panel, .stat, .thread, .portal-card, .search-wrap, .bubble, .auth-form input, .field, select {
  border: 1px solid var(--line);
  border-radius: 8px;
}
.hero-grid div { padding: 14px; background: rgba(9, 14, 20, .72); }
.hero-grid span, .portal-card span, .thread span, .chat-title p, .profile-panel p, .compose-tools, .activity-list { color: var(--muted); }
.hero-grid b { display: block; margin-top: 4px; font-size: 18px; }
.auth-form { padding: 42px; display: grid; align-content: center; gap: 14px; background: rgba(10, 15, 21, .7); }
.auth-mobile-brand { display: none; }
.auth-mobile-brand img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border: 1px solid rgba(95, 226, 221, .32);
  border-radius: 8px;
}
.auth-mobile-brand b {
  display: block;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}
.auth-mobile-brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-top: 4px;
}
.form-head h2 { margin: 0; font-size: 26px; }
.form-head p { margin: 6px 0 6px; color: var(--muted); }
.auth-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 750; }
.auth-form input, .field, select {
  min-height: 46px;
  padding: 0 13px;
  outline: 0;
  background: var(--field);
  color: var(--text);
}
.auth-form input:focus, .field:focus, select:focus, .search-wrap:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(95, 226, 221, .12);
}
.auth-actions { display: flex; gap: 10px; margin-top: 2px; }
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
}
.auth-tab {
  min-height: 36px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-tab.active {
  background: var(--cyan);
  color: #061014;
}
.auth-panel {
  display: grid;
  gap: 12px;
}
.recovery-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.recovery-row input {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
}
.app-download {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(95,226,221,.28);
  border-radius: 8px;
  padding: 11px 13px;
  background: linear-gradient(135deg, rgba(95,226,221,.12), rgba(114,167,255,.06));
}
.app-download span {
  color: var(--quiet);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 900;
}
.app-download b {
  color: var(--text);
}
.primary, .ghost, .tool-button, .micro {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 850;
}
.primary { color: #061014; background: linear-gradient(135deg, var(--cyan), var(--green)); }
.ghost, .tool-button, .micro {
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.small { min-height: 42px; }
.micro { min-height: 28px; padding: 0 10px; font-size: 12px; color: var(--muted); }

.app-shell {
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-columns: 78px 326px minmax(0, 1fr);
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 34%);
  overflow: hidden;
}
.pagebar { display: none; }
.rail {
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  background: rgba(8, 11, 16, .94);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.rail-button {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--muted);
  font-weight: 950;
}
.rail-button.active { color: #061014; background: var(--cyan); border-color: var(--cyan); }
.rail-button.bottom { margin-top: auto; }
.rail-mark.image {
  width: 52px;
  height: 52px;
}
.left-pane, .right-pane {
  min-width: 0;
  height: 100vh;
  padding: 18px;
  overflow: auto;
  background: rgba(11, 16, 23, .88);
}
.left-pane { border-right: 1px solid var(--line); }
.right-pane { border-left: 1px solid var(--line); }
.right-pane, #app[data-page="home"] .conversation, #app[data-page="home"] .left-pane,
#app[data-page="rooms"] .conversation, #app[data-page="rooms"] .right-pane,
#app[data-page="portals"] .conversation, #app[data-page="portals"] .right-pane {
  display: none;
}
#app[data-page="chat"] .right-pane { display: none; }
#app[data-page="home"] {
  grid-template-columns: 78px minmax(0, 1120px);
  justify-content: center;
}
#app[data-page="home"] .right-pane {
  display: block;
  grid-column: 2;
  border-left: 0;
}
#app[data-page="rooms"], #app[data-page="portals"] {
  grid-template-columns: 78px minmax(320px, 780px);
  justify-content: start;
}
#app[data-page="rooms"] .left-pane,
#app[data-page="portals"] .left-pane {
  grid-column: 2;
  border-right: 0;
}
#app[data-page="rooms"] .portals-block { display: none; }
#app[data-page="chat"] .portals-block { display: none; }
#app[data-page="chat"] .people-block { display: none; }
#app[data-page="portals"] .pane-tools,
#app[data-page="portals"] .rooms-block,
#app[data-page="portals"] .people-block { display: none; }
#app[data-page="portals"] .portal-list {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.account-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.account-card h1 { margin: 0; font-size: 24px; line-height: 1; }
.account-card p { margin: 5px 0 0; color: var(--muted); }
.search-wrap {
  margin: 18px 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 0 12px;
  background: var(--field);
}
.search-icon {
  width: 14px;
  height: 14px;
  border: 2px solid var(--quiet);
  border-radius: 50%;
  position: relative;
}
.search-icon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  right: -5px;
  bottom: -3px;
  border-radius: 2px;
  background: var(--quiet);
  transform: rotate(45deg);
}
.search-wrap input {
  height: 42px;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}
.pane-section {
  margin: 20px 0 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.count-pill {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 11px;
}
.thread-list, .portal-list { display: grid; gap: 8px; }
.thread, .portal-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 10px;
  text-align: left;
  background: transparent;
}
.thread:hover, .portal-card:hover { background: var(--panel); border-color: var(--line-strong); }
.thread.active { background: #142432; border-color: rgba(95, 226, 221, .38); }
.thread b, .portal-card b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread span, .portal-card span { display: block; margin-top: 2px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar, .portal-card i {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #061014;
  background: linear-gradient(135deg, var(--green), #b9ed8a);
  font-style: normal;
  font-weight: 950;
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar.velvetlink, .portal-card.cyan i { background: linear-gradient(135deg, var(--cyan), var(--green)); }
.avatar.naiya, .portal-card[href*="naiya"] i, .portal-card.blue i { background: linear-gradient(135deg, var(--cyan), var(--blue)); }
.avatar.home, .portal-card[href*="home"] i { background: linear-gradient(135deg, var(--amber), var(--coral)); }
.portal-card.green i { background: linear-gradient(135deg, var(--green), var(--cyan)); }
.portal-card.amber i { background: linear-gradient(135deg, var(--amber), var(--coral)); }
.portal-card.violet i { background: linear-gradient(135deg, var(--violet), var(--blue)); }
.avatar.large { width: 64px; height: 64px; font-size: 24px; margin: 0 auto 10px; }
.portal-card em {
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  color: var(--quiet);
  font-size: 10px;
  text-transform: uppercase;
  font-style: normal;
  font-weight: 850;
}
.badge {
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #061014;
  background: var(--cyan);
  font-size: 11px;
  font-weight: 900;
}
.conversation { min-width: 0; height: 100vh; display: flex; flex-direction: column; background: rgba(6, 9, 13, .62); }
.chat-header {
  min-height: 74px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 22px;
  background: rgba(10, 15, 21, .9);
  backdrop-filter: blur(16px);
}
.chat-title { display: flex; align-items: center; gap: 13px; min-width: 0; }
.chat-title h2 { margin: 0; font-size: 20px; }
.chat-title p { margin: 2px 0 0; }
.header-tools { display: flex; align-items: center; gap: 8px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: var(--panel-3);
}
.status-pill i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(131, 224, 146, .13);
}
.status-pill.offline i { background: var(--coral); box-shadow: 0 0 0 4px rgba(255, 141, 117, .13); }
.messages {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.day-sep {
  align-self: center;
  color: var(--quiet);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
}
.empty {
  margin: auto;
  max-width: 460px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 24px;
  background: rgba(17, 24, 32, .6);
}
.msgrow {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: min(84%, 900px);
}
.msgrow.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble {
  background: var(--bubble);
  padding: 10px 12px;
  box-shadow: 0 13px 30px rgba(0, 0, 0, .18);
}
.msgrow.mine .bubble {
  background: linear-gradient(180deg, #0d777b, var(--mine));
  border-color: rgba(95, 226, 221, .34);
}
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
.body { white-space: pre-wrap; overflow-wrap: anywhere; }
.state {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 6px;
  color: var(--quiet);
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 850;
}
.state.hot { color: var(--amber); border-color: rgba(255, 208, 107, .42); }
.state.bad { color: var(--coral); border-color: rgba(255, 141, 117, .45); }
.media {
  display: block;
  max-width: 330px;
  max-height: 240px;
  margin-top: 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.typing {
  margin: 0 24px 12px;
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  animation: pulse 1.1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.composer {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  background: rgba(10, 15, 21, .95);
}
.composer-main { display: grid; gap: 8px; min-width: 0; }
.input-row { display: grid; grid-template-columns: minmax(0, 1fr) 86px; gap: 8px; }
.send { min-height: 46px; }
.compose-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 12px; }
.attach {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--panel);
  cursor: pointer;
}
.attach input { display: none; }
.preview {
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel);
}
.preview img { max-width: 220px; max-height: 150px; display: block; border-radius: 6px; }
.drop-zone {
  border: 1px dashed var(--cyan);
  border-radius: 8px;
  padding: 14px;
  color: var(--cyan);
  background: rgba(95, 226, 221, .08);
  text-align: center;
}
.panel {
  padding: 14px;
  margin-bottom: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 12px; font-size: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.profile-panel { text-align: center; }
.profile-panel h3 { margin-bottom: 4px; font-size: 20px; }
.profile-panel p { margin: 0; }
.me-panel {
  display: grid;
  gap: 10px;
}
.me-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.text-field {
  min-height: 86px;
  padding: 10px 12px;
  resize: vertical;
}
.profile-photo {
  width: fit-content;
  border-radius: 8px;
}
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  padding: 10px;
  background: var(--panel-3);
}
.stat b { display: block; margin-top: 4px; font-size: 16px; }
.activity-list { display: grid; gap: 9px; }
.activity {
  display: grid;
  gap: 2px;
  border-left: 2px solid var(--line-strong);
  padding-left: 9px;
}
.activity b { color: var(--text); }
.quick-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-links a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-3);
  color: var(--text);
  font-weight: 800;
}
.access-list { display: grid; gap: 10px; }
.access-user {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 112px auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-3);
}
.access-user b, .access-user span { display: block; }
.access-user span { color: var(--muted); font-size: 12px; }
.access-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.access-perms label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 11px;
  background: rgba(255,255,255,.02);
}
.access-perms input { accent-color: var(--cyan); }
.portal-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(95, 226, 221, .13), transparent 26%),
    radial-gradient(circle at 84% 8%, rgba(255, 208, 107, .08), transparent 24%),
    linear-gradient(180deg, #091018, var(--bg));
}
.portal-page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 44px;
}
.portal-hero {
  min-height: 160px;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.portal-hero img {
  width: 82px;
  height: 82px;
  border-radius: 8px;
  border: 1px solid rgba(95, 226, 221, .34);
  object-fit: cover;
}
.portal-hero h1 { margin: 2px 0 6px; font-size: clamp(30px, 5vw, 54px); line-height: 1; }
.portal-hero p { margin: 0; color: var(--muted); }
.portal-home { display: inline-grid; place-items: center; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 68px 306px minmax(0, 1fr); }
  .right-pane { display: none; }
}
@media (max-width: 760px) {
  .auth-screen {
    place-items: end center;
    padding: 16px;
  }
  .auth-card {
    grid-template-columns: 1fr;
    min-height: 0;
    margin-top: 70px;
  }
  .auth-hero { display: none; }
  .auth-form {
    padding: 18px;
    gap: 12px;
    background: rgba(8, 13, 19, .88);
  }
  .auth-mobile-brand {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .form-head h2 { font-size: 22px; }
  .auth-tabs { gap: 5px; }
  .auth-tab { font-size: 13px; }
  .app-shell {
    display: grid;
    height: 100dvh;
    min-height: 100dvh;
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) auto;
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }
  .rail { display: none; }
  .pagebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(8, 12, 17, .96);
    backdrop-filter: blur(16px);
  }
  .pagebar button {
    min-height: 46px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-weight: 900;
  }
  .pagebar button.active {
    background: var(--cyan);
    color: #061014;
    border-color: var(--cyan);
  }
  .left-pane, .right-pane, .conversation {
    grid-column: 1 !important;
    grid-row: 1;
    height: calc(100dvh - 68px - env(safe-area-inset-bottom));
    border: 0;
  }
  #app[data-page="chat"] .left-pane,
  #app[data-page="chat"] .right-pane,
  #app[data-page="rooms"] .conversation,
  #app[data-page="rooms"] .right-pane,
  #app[data-page="home"] .left-pane,
  #app[data-page="home"] .conversation,
  #app[data-page="portals"] .conversation,
  #app[data-page="portals"] .right-pane {
    display: none;
  }
  #app[data-page="chat"] .conversation,
  #app[data-page="rooms"] .left-pane,
  #app[data-page="home"] .right-pane,
  #app[data-page="portals"] .left-pane {
    display: flex;
  }
  #app[data-page="rooms"] .left-pane,
  #app[data-page="home"] .right-pane,
  #app[data-page="portals"] .left-pane {
    display: block;
  }
  .chat-header { position: sticky; top: 0; z-index: 4; padding: 12px 18px; min-height: 68px; }
  .tool-button { display: inline-grid; place-items: center; }
  .messages { min-height: 0; padding: 20px; }
  .msgrow { max-width: 96%; }
  .composer { grid-template-columns: 1fr; padding: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  #app[data-page="portals"] .portal-list { grid-template-columns: 1fr; }
  .access-user { grid-template-columns: 1fr; }
  .portal-hero { grid-template-columns: 64px minmax(0, 1fr); }
  .portal-hero img { width: 58px; height: 58px; }
  .portal-home { grid-column: 1 / -1; }
}
