* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; }
[hidden] { display: none !important; }
button, input { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Auth */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; background: var(--sidebar); padding: var(--space-4); }
.auth-card { width: 100%; max-width: 380px; background: var(--bg); border: 1px solid var(--hairline); border-radius: var(--radius-lg); padding: var(--space-6); display: flex; flex-direction: column; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 24px; letter-spacing: -0.02em; }
.brand-mark { width: 40px; height: 40px; flex: none; }
.auth-alt { font-size: 13.5px; color: var(--muted); text-align: center; }

/* App shell */
.app { height: 100%; display: flex; flex-direction: column; }
.app-body { flex: 1; min-height: 0; display: flex; }
.sidebar { --dot-ring: var(--sidebar); width: 300px; flex: none; background: var(--sidebar); border-right: 1px solid var(--hairline); display: flex; flex-direction: column; min-height: 0; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); --dot-ring: var(--bg); }

.topbar { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px var(--space-4); padding: 8px var(--space-4); border-bottom: 1px solid var(--hairline); background: var(--bg); min-height: 56px; }
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-brand { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.me { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; max-width: 100%; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; text-align: right; }
.me-name { font-weight: 700; font-size: 14.5px; overflow-wrap: anywhere; } /* full name, wraps instead of being cut */
.me-handle { font-size: 12.5px; color: var(--muted); font-weight: 400; overflow-wrap: anywhere; }
.me-handle:empty { display: none; }
.conn { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-left: var(--space-2); }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: #d99a00; }
.conn-dot.ok { background: var(--online); }
.side-controls { padding: var(--space-3) var(--space-4) var(--space-3); display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: var(--space-2); }
.grow { flex: 1; min-width: 0; }
.list { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-1) 10px; display: flex; flex-direction: column; gap: 2px; }

/* Chat pane */
.empty-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); text-align: center; padding: var(--space-4); }
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.chat-body { flex: 1; min-height: 0; display: flex; }
.chat-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 22px; border-bottom: 1px solid var(--hairline); height: 72px; }
.icon-btn.back { display: none; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-2) 28px var(--space-3); display: flex; flex-direction: column; }
.messages .spacer { flex: 1; }
.composer { display: flex; gap: 10px; padding: var(--space-4) 22px 18px; align-items: center; border-top: 1px solid var(--hairline); }

/* Mobile: one pane at a time */
@media (max-width: 760px) {
  .sidebar { width: 100%; border-right: 0; }
  .main { display: none; }
  .app[data-view='chat'] .sidebar { display: none; }
  .app[data-view='chat'] .topbar { display: none; } /* the chat header takes the whole screen */
  .topbar { padding: 8px var(--space-3); }
  .topbar-brand { display: none; }
  .app[data-view='chat'] .main { display: flex; }
  .icon-btn.back { display: flex; }
  .chat-head { padding: var(--space-3) 10px var(--space-3) 6px; }
  .messages { padding: var(--space-2) var(--space-4); }
  .composer { padding: var(--space-3) var(--space-3) 20px; }
  .composer input { height: 48px; font-size: 16px; }
  .send { width: 48px; height: 48px; }
  .bubble { max-width: 80%; font-size: 15.5px; }
  .auth-card { padding: var(--space-5); }
}
