:root {
  --bg: #050505;
  --surface: rgba(18, 18, 20, 0.92);
  --surface-2: #161618;
  --border: rgba(212, 175, 55, 0.18);
  --text: #f7f3ea;
  --muted: #9c958a;
  --gold: #d4af37;
  --gold-2: #f0d78c;
  --ok: #34d399;
  --err: #f87171;
  --bubble-me: linear-gradient(145deg, rgba(201, 162, 39, 0.28), rgba(138, 112, 32, 0.18));
  --bubble-them: rgba(255, 255, 255, 0.05);
  --radius: 18px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --sidebar-w: clamp(320px, 34vw, 420px);
  --ui-pad: clamp(0.65rem, 1.8vw, 1.1rem);
  /* Base UI scale — larger on phone and desktop */
  --fs: clamp(16px, 0.95rem + 0.45vw, 18px);
  --touch: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.45;
  overflow: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(800px 500px at 15% -10%, rgba(212, 175, 55, 0.14), transparent 55%),
    radial-gradient(700px 400px at 90% 10%, rgba(240, 215, 140, 0.07), transparent 50%),
    radial-gradient(600px 400px at 50% 100%, rgba(212, 175, 55, 0.05), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.hidden {
  display: none !important;
}

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.gradient-text {
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.btn {
  border: none;
  cursor: pointer;
  border-radius: 12px;
  font-weight: 650;
  font: inherit;
  font-size: 1rem;
  padding: 0.85rem 1.15rem;
  min-height: var(--touch);
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.15s ease;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.primary {
  background: linear-gradient(135deg, #e0c15a, #b8922a);
  color: #111;
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost.danger,
.btn.danger {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.35);
}
.btn.sm {
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
  border-radius: 10px;
  min-height: 42px;
}
.btn.block {
  width: 100%;
}

.icon-btn {
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  min-height: var(--touch);
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-size: 1.15rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.icon-btn:hover {
  border-color: var(--border);
  background: rgba(212, 175, 55, 0.1);
}
.icon-btn.danger {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
}

input,
textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: #0c0c0e;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  min-height: var(--touch);
  outline: none;
  resize: none;
}
input:focus,
textarea:focus {
  border-color: rgba(212, 175, 55, 0.55);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

label {
  display: block;
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 0.95rem;
  text-align: left;
}
label input {
  margin-top: 0.4rem;
}

.hint {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}
.error {
  color: var(--err);
  font-size: 1rem;
  margin-top: 0.75rem;
}
.muted {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Auth ─────────────────────────────────────────────── */
.auth-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(1.25rem, var(--safe-top)) 1.25rem max(1.5rem, var(--safe-bottom));
}
.auth-card {
  width: min(480px, 100%);
  padding: 2rem 1.65rem;
  border-radius: 24px;
  text-align: center;
}
.logo-hero {
  width: 120px;
  height: 120px;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  border: none;
  box-shadow: none;
  margin-bottom: 0.85rem;
}
.auth-card h1 {
  margin: 0.25rem 0;
  font-size: clamp(1.85rem, 1.5rem + 1.2vw, 2.15rem);
}
.auth-tagline {
  color: var(--muted);
  margin: 0 0 1.35rem;
  font-size: 1rem;
}
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem;
  min-height: var(--touch);
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
}
.tab.active {
  color: var(--text);
  background: rgba(212, 175, 55, 0.12);
  border-color: rgba(212, 175, 55, 0.4);
}
.auth-form {
  text-align: left;
}
.feature-pills {
  list-style: none;
  padding: 0;
  margin: 1.35rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
}
.feature-pills li {
  font-size: 0.82rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--gold-2);
  background: rgba(212, 175, 55, 0.08);
}

.encrypt-callout {
  text-align: left;
  margin-top: 1.1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background: rgba(212, 175, 55, 0.06);
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}
.encrypt-callout strong {
  display: block;
  color: var(--gold-2);
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}
.encrypt-callout p {
  margin: 0;
}

.audit-block {
  display: block !important;
  white-space: pre-wrap;
  text-align: left;
  line-height: 1.55;
  font-size: 0.78rem !important;
}

.settings-card {
  max-height: min(90dvh, 720px);
  overflow-y: auto;
  text-align: left;
}
.settings-card h2 {
  text-align: center;
}

/* ── App shell ────────────────────────────────────────── */
.app-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: var(--ui-pad);
  padding: var(--ui-pad);
  padding-bottom: max(var(--ui-pad), var(--safe-bottom));
  padding-top: max(var(--ui-pad), var(--safe-top));
}

.sidebar {
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.sidebar-top {
  flex-shrink: 0;
  padding: 1rem 1rem 0.9rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.brand-row > div {
  min-width: 0;
  flex: 1;
}
.brand-row strong {
  font-size: 1.1rem;
  display: block;
  line-height: 1.25;
}
.logo-sm {
  width: 44px;
  height: 44px;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  border: none;
  flex-shrink: 0;
}
.me-sub {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conn {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--err);
  margin-left: auto;
}
.conn.online {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.55);
}
.sidebar-tools {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.search-input {
  flex: 1;
  margin: 0;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  min-height: var(--touch);
}
.add-row {
  display: flex;
  gap: 0.45rem;
  align-items: stretch;
}
.add-row input {
  margin: 0;
  flex: 1;
  min-height: var(--touch);
}
.add-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}
.sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding: 0.55rem 0.75rem 0.75rem;
  -webkit-overflow-scrolling: touch;
}
.section-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0.75rem 0.4rem 0.4rem;
}
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.nav-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.7rem 0.7rem;
  min-height: 56px;
  border-radius: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
}
.nav-item:hover,
.nav-item.active {
  background: rgba(212, 175, 55, 0.08);
  border-color: rgba(212, 175, 55, 0.25);
}
.nav-item .meta {
  min-width: 0;
}
.nav-item .name {
  font-weight: 650;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item .preview {
  font-size: 0.86rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item .right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}
.nav-item .time {
  font-size: 0.78rem;
  color: var(--muted);
}
.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--gold);
  color: #111;
  font-size: 0.78rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.nav-empty {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 0.6rem 0.7rem;
}

/* Sticky logout bar — always full-width at bottom of sidebar */
.sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: 0.75rem 0.9rem calc(0.85rem + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(10, 10, 12, 0.55), rgba(8, 8, 10, 0.92));
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
}
.logout-btn {
  margin: 0;
  width: 100%;
  min-height: var(--touch);
  font-size: 1rem;
  font-weight: 650;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3a3218, #1a160c);
  border: 1px solid rgba(212, 175, 55, 0.35);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--gold-2);
  font-size: 0.95rem;
  position: relative;
  flex-shrink: 0;
}
.avatar.lg {
  width: 48px;
  height: 48px;
  font-size: 1rem;
}
.avatar .online-pip {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #475569;
  border: 2px solid #121214;
}
.avatar .online-pip.on {
  background: var(--ok);
}

/* Chat main */
.chat-main {
  border-radius: var(--radius);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.empty-state {
  margin: auto;
  text-align: center;
  max-width: 420px;
  padding: 2rem;
  color: var(--muted);
}
.empty-state h2 {
  color: var(--text);
  margin: 0.75rem 0 0.4rem;
}
.logo-empty {
  border-radius: 0;
  border: none;
  background: transparent;
  object-fit: contain;
  opacity: 0.95;
}

.active-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}
.chat-head-text {
  min-width: 0;
  flex: 1;
}
.chat-title {
  font-weight: 700;
  font-size: 1.12rem;
  line-height: 1.25;
}
.chat-sub {
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-toolbar {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: min(100%, 340px);
}
.mobile-only {
  display: none;
}

.chat-search-bar {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.1rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.day-sep {
  align-self: center;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin: 0.5rem 0;
}

.msg {
  max-width: min(88%, 44rem);
  padding: 0.7rem 0.9rem 0.5rem;
  border-radius: 16px;
  position: relative;
  animation: pop 0.18s ease;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.msg.self {
  align-self: flex-end;
  background: var(--bubble-me);
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-bottom-right-radius: 6px;
}
.msg.other {
  align-self: flex-start;
  background: var(--bubble-them);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 6px;
}
.msg.system {
  align-self: center;
  max-width: 90%;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}
.msg-from {
  font-size: 0.72rem;
  color: var(--gold);
  margin-bottom: 0.15rem;
  font-weight: 650;
}
.msg-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: 1.02rem;
}
.msg-reply {
  border-left: 3px solid var(--gold);
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 8px 8px 0;
}
.msg-media {
  margin: 0.25rem 0;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
}
.msg-media img {
  max-width: 100%;
  max-height: 280px;
  display: block;
  border-radius: 12px;
}
.msg-media audio,
.msg-media video {
  width: 100%;
  max-width: 320px;
  border-radius: 10px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  color: var(--gold-2);
  text-decoration: none;
  font-size: 0.85rem;
}
.msg-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  font-size: 0.68rem;
  color: var(--muted);
}
.msg-meta .ticks {
  letter-spacing: -0.05em;
  font-weight: 700;
  cursor: pointer;
}
.msg-meta .ticks.sent {
  color: var(--muted);
}
.msg-meta .ticks.delivered {
  color: #cbd5e1;
}
.msg-meta .ticks.seen {
  color: #60a5fa;
}
.msg-actions {
  display: none;
  position: absolute;
  top: -12px;
  right: 8px;
  gap: 0.2rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.15rem;
}
.msg:hover .msg-actions {
  display: flex;
}
.msg-actions button {
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
}
.msg-actions button:hover {
  background: rgba(212, 175, 55, 0.15);
}
.msg.highlight {
  outline: 2px solid var(--gold);
}

.typing-line {
  padding: 0.2rem 1rem 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-style: italic;
}

.reply-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.85rem;
  border-top: 1px solid var(--border);
  background: rgba(212, 175, 55, 0.06);
}
.reply-label {
  display: block;
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 700;
}
.reply-preview {
  font-size: 0.82rem;
  color: var(--muted);
}

.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem calc(0.75rem + var(--safe-bottom));
  border-top: 1px solid var(--border);
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}
.composer-input-wrap {
  flex: 1;
  min-width: 0;
}
.composer textarea {
  max-height: 160px;
  line-height: 1.4;
  padding: 0.8rem 0.95rem;
  min-height: var(--touch);
  font-size: 1.02rem;
}
.send-btn {
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  padding: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
}

.rec-indicator {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem;
  background: rgba(248, 113, 113, 0.1);
  border-top: 1px solid rgba(248, 113, 113, 0.3);
  font-size: 0.88rem;
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--err);
  animation: blink 1s infinite;
}
@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

/* Calls */
.call-stage {
  border-bottom: 1px solid var(--border);
  background: #000;
  padding: 0.65rem;
}
.call-info {
  display: flex;
  justify-content: space-between;
  color: var(--gold-2);
  font-size: 0.85rem;
  margin-bottom: 0.45rem;
  padding: 0 0.25rem;
}
.videos {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.5rem;
}
.local-wrap,
.remote-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  border: 1px solid var(--border);
  aspect-ratio: 4/3;
}
.local-wrap video,
.remote-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.remotes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}
.vlabel {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
}
.call-controls {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.55rem;
}
.call-ctrl {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-weight: 650;
}
.call-ctrl.end {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 1rem;
}
.modal-card {
  width: min(440px, 100%);
  padding: 1.35rem;
  border-radius: 20px;
  text-align: center;
}
.modal-card h2 {
  margin-top: 0.5rem;
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: center;
}
.fp-block {
  margin: 0.75rem 0;
  padding: 0.7rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  text-align: left;
}
.fp-block code {
  display: block;
  margin-top: 0.35rem;
  color: var(--gold);
  font-size: 0.8rem;
  word-break: break-all;
  line-height: 1.45;
}
.seen-list {
  text-align: left;
  max-height: 280px;
  overflow-y: auto;
  margin: 0.75rem 0 1rem;
}
.seen-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.seen-row .when {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}
.check-row input {
  width: auto;
  margin: 0;
}
.pulse-ring {
  animation: pulse 1.6s ease infinite;
}
@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.35);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(212, 175, 55, 0);
  }
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: #1a1a1c;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  :root {
    --fs: clamp(16px, 4.2vw, 18px);
    --touch: 48px;
    --ui-pad: 0;
  }
  html,
  body {
    overflow: hidden;
    height: 100%;
    height: 100dvh;
  }
  .app-shell {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
    max-width: none;
    height: 100dvh;
    padding-top: var(--safe-top);
    padding-bottom: 0;
  }
  .sidebar {
    border-radius: 0;
    height: 100dvh;
    height: 100svh;
  }
  .sidebar-top {
    padding-top: max(0.85rem, 0.25rem);
  }
  .sidebar-footer {
    /* Logout pinned above home indicator on phones */
    padding: 0.8rem 1rem calc(0.9rem + var(--safe-bottom));
  }
  .logout-btn {
    min-height: 50px;
    font-size: 1.05rem;
    border-radius: 14px;
  }
  .chat-main {
    border-radius: 0;
    display: none;
    height: 100dvh;
    height: 100svh;
  }
  .app-shell.chat-open .sidebar {
    display: none;
  }
  .app-shell.chat-open .chat-main {
    display: flex;
  }
  .mobile-only {
    display: grid;
  }
  .videos {
    grid-template-columns: 1fr;
  }
  .msg {
    max-width: 92%;
  }
  .msg-body {
    font-size: 1.05rem;
  }
  .chat-header {
    padding: 0.75rem 0.75rem;
    gap: 0.5rem;
  }
  .chat-toolbar {
    max-width: none;
    flex: 1 1 auto;
    justify-content: flex-end;
  }
  .chat-toolbar .icon-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    font-size: 1.05rem;
  }
  .composer {
    padding: 0.7rem 0.7rem calc(0.7rem + var(--safe-bottom));
  }
  .auth-view {
    overflow-y: auto;
    align-items: flex-start;
    padding: max(1rem, var(--safe-top)) 1rem max(1.5rem, var(--safe-bottom));
  }
  .auth-card {
    margin: 0.5rem 0 2rem;
    width: 100%;
    padding: 1.75rem 1.25rem;
  }
  .logo-hero {
    width: 100px;
    height: 100px;
  }
  .empty-state {
    padding: 1.5rem 1.25rem;
    font-size: 1rem;
  }
  .empty-state h2 {
    font-size: 1.35rem;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  :root {
    --sidebar-w: clamp(300px, 32vw, 360px);
    --fs: clamp(16px, 0.95rem + 0.35vw, 17.5px);
  }
}

@media (min-width: 1201px) {
  :root {
    --fs: clamp(16.5px, 0.9rem + 0.35vw, 18px);
    --sidebar-w: clamp(340px, 30vw, 420px);
  }
  .msg-body {
    font-size: 1.05rem;
  }
  .chat-title {
    font-size: 1.18rem;
  }
}
