@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #07070c;
  --bg-2: #0c0d15;
  --surface: rgba(16, 18, 30, 0.72);
  --surface-2: rgba(22, 24, 40, 0.88);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-2: rgba(255, 255, 255, 0.14);
  --text: #f5f6fb;
  --muted: #9aa1b8;
  --faint: #6c738c;
  --accent: #6ee7ff;
  --accent-2: #8b7bff;
  --danger: #ff5c7a;
  --ok: #34d399;
  --lucas: #3ec7ff;
  --grok: #ffb020;
  --alfa: #b794f6;
  --charlie: #ff7a59;
  --codex: #34d399;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 22px;
  --font: "Plus Jakarta Sans", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app { position: relative; z-index: 1; height: 100%; min-height: 0; }

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(139, 123, 255, 0.18), transparent 55%),
    radial-gradient(900px 600px at 100% 0%, rgba(62, 199, 255, 0.14), transparent 50%),
    radial-gradient(800px 500px at 80% 100%, rgba(255, 122, 89, 0.08), transparent 50%),
    var(--bg);
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: drift 22s ease-in-out infinite;
}
.orb-a { width: 340px; height: 340px; left: -80px; top: 12%; background: #6ee7ff; }
.orb-b { width: 420px; height: 420px; right: -120px; top: -80px; background: #8b7bff; animation-delay: -8s; }
.orb-c { width: 280px; height: 280px; right: 15%; bottom: -80px; background: #ff7a59; animation-delay: -14s; opacity: 0.3; }
.grain {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}
@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(30px, -24px, 0) scale(1.08); }
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
textarea { resize: none; }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke);
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); border-color: var(--stroke-2); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.live {
  background: rgba(255, 92, 122, 0.16);
  border-color: rgba(255, 92, 122, 0.45);
  color: #ffd0d8;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 122, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255, 92, 122, 0); }
}

/* ——— Login ——— */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
}
.login-card {
  width: min(420px, 100%);
  padding: 32px 28px 28px;
  border-radius: 28px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(1.3);
  -webkit-backdrop-filter: blur(28px) saturate(1.3);
  animation: rise .6s ease both;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 30% 30%, #6ee7ff, transparent 50%),
    radial-gradient(circle at 70% 70%, #8b7bff, #12141f 70%);
  border: 1px solid var(--stroke-2);
  box-shadow: 0 0 24px rgba(110, 231, 255, 0.25);
}
.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}
.brand p, .login-card .lede {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.login-card form { display: grid; gap: 14px; margin-top: 22px; }
.login-card label { font-size: 0.8rem; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.login-card input[type="password"], .login-card input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--stroke-2);
  background: rgba(0,0,0,0.28);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.login-card input:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, white 0%);
  box-shadow: 0 0 0 4px rgba(110, 231, 255, 0.15);
}
.primary {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #071018;
  background: linear-gradient(135deg, #6ee7ff, #8b7bff);
  box-shadow: 0 10px 28px rgba(139, 123, 255, 0.28);
  transition: transform .18s ease, filter .18s ease;
}
.primary:hover { filter: brightness(1.05); }
.primary:active { transform: scale(0.98); }
.primary:disabled { opacity: 0.55; cursor: default; }
.error {
  color: #ffd0d8;
  background: rgba(255, 92, 122, 0.14);
  border: 1px solid rgba(255, 92, 122, 0.3);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.9rem;
}
.people {
  display: flex;
  gap: 8px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.people .chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke);
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}
.people img { width: 22px; height: 22px; border-radius: 50%; }

/* ——— Shell ——— */
.shell {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 0;
}
.sidebar {
  display: flex;
  flex-direction: column;
  padding: calc(18px + var(--safe-t)) 16px 16px;
  border-right: 1px solid var(--stroke);
  background: rgba(8, 9, 16, 0.4);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}
.sidebar .brand { margin: 4px 6px 20px; }
.member-list { display: flex; flex-direction: column; gap: 8px; flex: 1; overflow: auto; }
.member {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid transparent;
  transition: background .18s, border-color .18s;
}
.member:hover { background: rgba(255,255,255,0.04); border-color: var(--stroke); }
.member .meta { min-width: 0; }
.member .name { font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 6px; }
.member .role { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: #111;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.06), 0 0 0 4px transparent;
}
.avatar img { width: 100%; height: 100%; display: block; }
.avatar.lucas { box-shadow: 0 0 0 2px rgba(62,199,255,0.25), 0 0 16px rgba(62,199,255,0.18); }
.avatar.grok { box-shadow: 0 0 0 2px rgba(255,176,32,0.28), 0 0 16px rgba(255,176,32,0.16); }
.avatar.alfa { box-shadow: 0 0 0 2px rgba(183,148,246,0.28), 0 0 16px rgba(183,148,246,0.16); }
.avatar.charlie { box-shadow: 0 0 0 2px rgba(255,122,89,0.28), 0 0 16px rgba(255,122,89,0.16); }
.avatar.codex { box-shadow: 0 0 0 2px rgba(52,211,153,0.28), 0 0 16px rgba(52,211,153,0.16); }
.avatar.sm { width: 34px; height: 34px; }

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 6px 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.chat {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  position: relative;
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-t)) 20px 14px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(8, 9, 16, 0.35);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.chat-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
}
.chat-head .sub { color: var(--muted); font-size: 0.82rem; }
.stack { display: flex; align-items: center; }
.stack .avatar { margin-left: -8px; width: 28px; height: 28px; }
.stack .avatar:first-child { margin-left: 0; }

.thread {
  min-height: 0;
  overflow: auto;
  padding: 22px 20px 12px;
  scroll-behavior: smooth;
}
.day {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0 16px;
}
.day span {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke);
}

.row {
  display: flex;
  gap: 10px;
  margin: 0 0 14px;
  max-width: 100%;
  animation: rise .35s ease both;
}
.row.mine { flex-direction: row-reverse; }
.row .col { min-width: 0; max-width: min(720px, 86%); }
.who {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 4px 4px;
  font-size: 0.78rem;
}
.row.mine .who { flex-direction: row-reverse; }
.who .name { font-weight: 700; }
.who .name.lucas { color: var(--lucas); }
.who .name.grok { color: var(--grok); }
.who .name.alfa { color: var(--alfa); }
.who .name.charlie { color: var(--charlie); }
.who .name.codex { color: var(--codex); }
.who .time { color: var(--faint); font-variant-numeric: tabular-nums; }

.bubble {
  padding: 12px 14px;
  border-radius: 18px 18px 18px 6px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  overflow: hidden;
}
.row.mine .bubble {
  border-radius: 18px 18px 6px 18px;
  background: linear-gradient(180deg, rgba(110,231,255,0.14), rgba(139,123,255,0.10));
  border-color: rgba(110, 231, 255, 0.16);
}
.body-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.body-text a { color: var(--accent); text-decoration: none; }
.body-text a:hover { text-decoration: underline; }
.body-text.collapsed { max-height: 12.5em; overflow: hidden; position: relative; }
.body-text.collapsed::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3em;
  background: linear-gradient(transparent, rgba(22, 24, 40, 0.95));
}
.more {
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
}

.atts { display: grid; gap: 8px; margin-top: 10px; }
.atts:first-child { margin-top: 0; }
.att-image {
  display: block;
  max-width: min(420px, 100%);
  max-height: 320px;
  border-radius: 14px;
  overflow: hidden;
  cursor: zoom-in;
  border: 1px solid var(--stroke);
  background: #000;
}
.att-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  max-height: 320px;
}

.audio-card, .file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--stroke);
  min-width: min(280px, 100%);
}
.audio-card audio { width: 100%; height: 36px; }
.file-card { text-decoration: none; color: inherit; }
.file-card:hover { border-color: var(--stroke-2); }
.file-ico {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(139,123,255,0.16);
  color: #c4b5fd;
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  flex: none;
}
.file-card .fn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .fs { color: var(--muted); font-size: 0.78rem; }

/* ——— Composer ——— */
.composer-wrap {
  padding: 8px 16px calc(14px + var(--safe-b));
}
.composer {
  border-radius: 22px;
  padding: 10px 10px 10px 12px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
  transition: border-color .18s, box-shadow .18s;
}
.composer.focus {
  border-color: rgba(110, 231, 255, 0.35);
  box-shadow: var(--shadow), 0 0 0 4px rgba(110, 231, 255, 0.08);
}
.composer.dragover {
  border-color: var(--accent);
  background: rgba(110, 231, 255, 0.08);
}
.pending { display: flex; gap: 8px; flex-wrap: wrap; }
.pend {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--stroke-2);
  background: rgba(0,0,0,0.3);
  max-width: 140px;
}
.pend img, .pend .pend-file, .pend audio { display: block; }
.pend img { width: 140px; height: 88px; object-fit: cover; }
.pend-file, .pend-audio {
  padding: 10px 28px 10px 10px;
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 180px;
}
.pend .x {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: white;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
}
.compose-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}
.compose-row textarea {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  max-height: 160px;
  padding: 10px 4px;
  min-height: 44px;
  line-height: 1.4;
}
.rec-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  color: #ffd0d8;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger);
  animation: pulse 1s infinite;
}
.send {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  color: #071018;
  background: linear-gradient(135deg, #6ee7ff, #8b7bff);
  box-shadow: 0 8px 20px rgba(139, 123, 255, 0.3);
  transition: transform .18s, filter .18s, opacity .18s;
}
.send:hover { filter: brightness(1.06); }
.send:active { transform: scale(0.96); }
.send:disabled { opacity: 0.4; box-shadow: none; cursor: default; }

/* ——— Lightbox ——— */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(16px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade .2s ease;
}
.lightbox img {
  max-width: min(1200px, 100%);
  max-height: 90vh;
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.lightbox .close {
  position: absolute;
  top: calc(12px + var(--safe-t));
  right: 16px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 50;
  background: var(--surface-2);
  border: 1px solid var(--stroke-2);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: rise .25s ease;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 64px 16px;
}
.empty h3 { margin: 0 0 6px; color: var(--text); letter-spacing: -0.03em; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .row .col { max-width: 92%; }
  .chat-head { padding-left: 16px; padding-right: 16px; }
  .thread { padding: 16px 12px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
