:root {
  --bg: #eef4f7;
  --panel: #fff;
  --panel-soft: #f6f9fb;
  --text: #0f1724;
  --muted: #6b7788;
  --line: #dce5ed;
  --accent: #2aabee;
  --accent-dark: #1f91d2;
  --accent-soft: #dff3fd;
  --danger: #d54848;
  --success: #22a06b;
  --shadow: 0 14px 34px rgba(15, 23, 36, .08);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font-size: 14px; }
button, input { font: inherit; }
button { min-height: 38px; border: 0; border-radius: 10px; padding: 0 14px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
button:hover { filter: brightness(.98); }
button.ghost { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.22); }
button.secondary { background: #e8f4fb; color: var(--accent-dark); }
button.link-button { min-height: 30px; justify-self: start; padding: 0; background: transparent; color: var(--accent-dark); font-weight: 700; }
button.danger { background: var(--danger); }
button.compact { min-height: 30px; padding: 0 10px; border-radius: 999px; font-size: 12px; }
button.icon-button { width: 38px; padding: 0; border-radius: 999px; font-size: 18px; line-height: 1; }
button:disabled { opacity: .45; cursor: default; }
input { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; color: var(--text); background: #fff; outline: none; }
input:focus { border-color: rgba(42, 171, 238, .75); box-shadow: 0 0 0 3px rgba(42, 171, 238, .14); }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
h1, h2, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.12; letter-spacing: 0; }
h2 { font-size: 16px; line-height: 1.25; }
.shell { width: min(1180px, 100%); min-height: 100vh; margin: 0 auto; padding: 10px; }

.auth { display: grid; gap: 16px; width: min(390px, 100%); margin: 8vh auto 0; padding: 24px; border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.auth-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--accent); color: #fff; font-size: 22px; font-weight: 900; }
.brand { color: var(--accent-dark); font-size: 11px; font-weight: 850; text-transform: uppercase; }
.stack, .app, .side, .chat, .people { display: grid; gap: 10px; }
.error { color: #a61f2b; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: -10px -10px 0; padding: 14px 18px; background: #1f91d2; color: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.04); }
.top .brand { color: #ccefff; }
.top h1 { font-size: 22px; font-weight: 850; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 2px 0; }
.status span { border: 1px solid rgba(42, 171, 238, .15); border-radius: 999px; padding: 6px 10px; background: #fff; color: var(--muted); font-size: 12px; font-weight: 750; }
.diagnostics { display: grid; gap: 6px; border: 1px solid rgba(42, 171, 238, .2); border-radius: 12px; padding: 10px 12px; background: #fff; color: var(--muted); font-size: 12px; }
.diagnostics strong { color: var(--text); }
#diagnosticText { white-space: pre-wrap; line-height: 1.45; }

.grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 10px; align-items: stretch; }
.side, .chat { min-height: calc(100vh - 126px); padding: 14px; align-content: start; border-radius: 14px; background: var(--panel); box-shadow: 0 1px 0 rgba(15,23,36,.04); }
.section-head, .chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid #edf2f6; }
.section-head span, .chat-head span { color: var(--muted); font-size: 12px; font-weight: 700; }

.person { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px; border: 1px solid #edf2f6; border-radius: 12px; padding: 10px; background: #fff; }
.person::before { content: attr(data-initial); display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-size: 16px; font-weight: 900; }
.person strong { display: block; overflow: hidden; color: var(--text); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.person span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.person .online { color: var(--success); }
.person button { min-width: 42px; width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 12px; background: var(--accent); }

.chat { display: grid; grid-template-rows: auto minmax(260px, 1fr) auto; }
.messages { display: flex; flex-direction: column; gap: 8px; overflow: auto; padding: 12px; border-radius: 14px; background: #dff0f7; background-image: radial-gradient(circle at 20px 20px, rgba(255,255,255,.34) 0 1px, transparent 1px); background-size: 24px 24px; }
.message { max-width: 74%; border-radius: 14px 14px 14px 5px; padding: 8px 11px; background: #fff; box-shadow: 0 2px 8px rgba(15,23,36,.06); color: var(--text); }
.message.mine { align-self: flex-end; border-radius: 14px 14px 5px 14px; background: #e2f7cb; }
.message small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 800; }
.compose { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 0 0; background: transparent; }
.compose input { min-height: 42px; border-radius: 999px; border-color: transparent; box-shadow: 0 2px 10px rgba(15,23,36,.06); }
.compose button { min-width: 74px; border-radius: 999px; }

.incoming { position: fixed; right: 14px; bottom: 14px; left: 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; width: min(660px, calc(100% - 28px)); margin: 0 auto; border: 1px solid rgba(42,171,238,.2); border-radius: 14px; padding: 12px; background: #fff; box-shadow: var(--shadow); }
.incoming span { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; }
.actions { display: flex; gap: 8px; }

@media (max-width: 760px) {
  body { font-size: 13px; }
  .shell { padding: 0 0 max(14px, env(safe-area-inset-bottom)); }
  .auth { margin: 7vh auto 0; width: min(370px, calc(100% - 24px)); padding: 22px; border-radius: 16px; }
  .top { margin: 150px 0 0; padding: 12px 14px; }
  .top h1 { font-size: 20px; }
  .grid { grid-template-columns: 1fr; gap: 8px; padding: 0 8px 8px; }
  .status { padding: 10px 10px 0; }
  .diagnostics { margin: 0 8px; }
  .side, .chat { min-height: auto; padding: 12px; border-radius: 14px; }
  .chat { min-height: calc(100vh - 390px); }
  .messages { min-height: 280px; }
  .message { max-width: 90%; }
  .compose { grid-template-columns: 1fr 64px; }
  .incoming { display: grid; grid-template-columns: 1fr; bottom: max(76px, calc(env(safe-area-inset-bottom) + 14px)); }
}

