/* ============================================================
   ÓRBITA · sistema visual web
   Identidade transcrita da marca: planeta violeta + anel, campo
   estelar (cosmos), superfícies Grafite e destaque em par violeta→azul.
   ============================================================ */
:root {
  /* Destaque da marca (tema "Órbita") */
  --ac: #9B87FF;
  --ac-hover: #B3A4FF;
  --ac2: #5AA9FF;
  --ac-deep: #6A4FE0;
  --ac-ink: #0F0B24;
  --ac-soft: rgba(155, 135, 255, .14);
  --ac-border: rgba(155, 135, 255, .28);
  --ac-ring: rgba(155, 135, 255, .30);
  --grad: linear-gradient(135deg, var(--ac), var(--ac2));

  /* Superfícies Grafite (neutras frias) */
  --bg: #07051A;
  --panel: #0C0A18;
  --surface: #14122A;
  --raised: #1D1A38;
  --line: #262347;
  --line-strong: #34305C;
  --text: #ECECF6;
  --dim: #B6B4CC;
  --muted: #8A88A6;

  /* Semânticos */
  --success: #86EFAC;
  --success-soft: rgba(134, 239, 172, .14);
  --danger: #FF5D6B;
  --danger-soft: rgba(252, 165, 165, .14);
  --warning: #FCD9A8;
  --info: #A5D8FF;
  --offline: #7B7F8B;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .55);
  --rail-w: 76px;
  --side-w: 264px;
  --members-w: 248px;
  --head-h: 56px;
  --font: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}
button { font-family: inherit; color: inherit; }
input, textarea { font-family: inherit; }
[hidden] { display: none !important; }

/* ---------- Scrollbars na linguagem da marca ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--ac-deep), var(--line-strong));
  border-radius: 8px; border: 3px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ac); background-clip: padding-box; border: 3px solid transparent; }

/* ---------- Fundo cosmos ---------- */
.cosmos { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background: radial-gradient(120% 90% at 50% -10%, #17123A 0%, var(--bg) 55%); }
.halo { position: absolute; border-radius: 50%; filter: blur(10px); }
.halo-a { width: 64vmax; height: 64vmax; left: -18vmax; top: -28vmax;
  background: radial-gradient(circle, rgba(155,135,255,.16), transparent 62%); }
.halo-b { width: 52vmax; height: 52vmax; right: -16vmax; top: -18vmax;
  background: radial-gradient(circle, rgba(90,169,255,.13), transparent 60%); }
.starfield { position: absolute; inset: 0; }
.starfield i { position: absolute; border-radius: 50%; background: #fff; animation: twinkle 5s ease-in-out infinite; }
.starfield i.tint { background: #C9B5FF; }
@keyframes twinkle { 0%,100% { opacity: .18; } 50% { opacity: .6; } }
.grain { position: absolute; inset: 0; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E"); }

/* ---------- Botões / campos ---------- */
.btn { border: 0; cursor: pointer; border-radius: var(--radius-sm); font-weight: 600;
  padding: 11px 18px; font-size: 14px; transition: transform .12s ease, box-shadow .2s, background .2s, filter .2s; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--grad); color: var(--ac-ink); box-shadow: 0 6px 22px rgba(106,79,224,.35); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 28px rgba(106,79,224,.5); }
.btn-block { width: 100%; }
.btn-ghost { background: var(--raised); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--line); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(255,93,107,.3); }
.btn-voice { background: var(--success-soft); color: var(--success); border: 1px solid rgba(134,239,172,.3); padding: 8px 14px; }
.btn-voice:hover { background: rgba(134,239,172,.22); }
.btn-send { background: var(--grad); color: var(--ac-ink); width: 40px; height: 40px; padding: 0; border-radius: 12px; font-size: 16px; }
.icon-btn { background: transparent; border: 0; cursor: pointer; color: var(--muted); width: 34px; height: 34px;
  border-radius: 9px; font-size: 16px; display: inline-grid; place-items: center; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.linklike { background: none; border: 0; color: var(--ac); cursor: pointer; font-size: 13px; margin-top: 14px; }
.linklike:hover { text-decoration: underline; }
.field { display: block; margin-bottom: 14px; text-align: left; }
.field span { display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--dim); margin-bottom: 6px; }
.field input { width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 15px; outline: none; transition: border .15s, box-shadow .15s; }
.field input:focus { border-color: var(--ac); box-shadow: 0 0 0 3px var(--ac-ring); }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(15,11,36,.3); border-top-color: var(--ac-ink);
  border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Autenticação ---------- */
.auth-view { position: relative; z-index: 1; height: 100%; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.auth-card { width: min(420px, 100%); background: linear-gradient(180deg, rgba(20,18,42,.92), rgba(12,10,24,.94));
  border: 1px solid var(--line); border-radius: 22px; padding: 36px 34px; box-shadow: var(--shadow);
  backdrop-filter: blur(14px); text-align: center; position: relative; }
.auth-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; border-radius: 22px 22px 0 0;
  background: linear-gradient(90deg, transparent, var(--ac) 42%, var(--ac2) 58%, transparent); }
.auth-wordmark { height: 44px; margin-bottom: 6px; }
.auth-tagline { color: var(--dim); font-size: 14px; line-height: 1.5; margin: 6px 0 22px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface); padding: 5px; border-radius: 12px; margin-bottom: 22px; }
.auth-tab { border: 0; background: transparent; color: var(--muted); padding: 9px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; }
.auth-tab.active { background: var(--grad); color: var(--ac-ink); }
.auth-error { color: var(--danger); background: var(--danger-soft); border: 1px solid rgba(255,93,107,.3);
  border-radius: 9px; padding: 10px; font-size: 13px; margin: 0 0 14px; }
.auth-foot { color: var(--muted); font-size: 12px; margin: 18px 0 0; }
.reveal { animation: rise .5s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---------- Layout do app ---------- */
.app-view { position: relative; z-index: 1; height: 100%; display: grid;
  grid-template-columns: var(--rail-w) var(--side-w) 1fr; grid-template-rows: 100%; }
.app-view.with-members { grid-template-columns: var(--rail-w) var(--side-w) 1fr var(--members-w); }

/* Trilho de comunidades */
.server-rail { background: rgba(7,5,20,.7); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  align-items: center; padding: 12px 0; gap: 10px; overflow-y: auto; }
.rail-btn { width: 50px; height: 50px; border-radius: 16px; border: 0; cursor: pointer; background: var(--surface);
  color: var(--text); display: grid; place-items: center; font-size: 20px; font-weight: 700; position: relative;
  transition: border-radius .18s, background .18s, transform .12s; overflow: hidden; }
.rail-btn:hover { border-radius: 14px; background: var(--ac-deep); transform: translateY(-1px); }
.rail-btn.active { background: var(--grad); color: var(--ac-ink); border-radius: 14px; }
.rail-btn.active::before { content: ""; position: absolute; left: -13px; top: 50%; translate: 0 -50%; width: 4px; height: 26px; border-radius: 4px; background: var(--ac); }
.rail-home img { width: 30px; height: 30px; }
.rail-add { background: transparent; border: 1px dashed var(--line-strong); color: var(--success); font-size: 24px; }
.rail-add:hover { background: var(--success-soft); border-color: var(--success); }
.rail-sep { width: 34px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--ac-border), transparent); }
.rail-list { display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* Sidebar */
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { height: var(--head-h); display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(155,135,255,.06); }
.sidebar-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 12px 10px; }
.cat-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; padding: 14px 8px 6px; }
.channel-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent;
  color: var(--dim); padding: 8px 10px; border-radius: 9px; cursor: pointer; font-size: 14.5px; transition: background .12s, color .12s; }
.channel-item:hover { background: var(--raised); color: var(--text); }
.channel-item.active { background: var(--ac-soft); color: var(--text); box-shadow: inset 2px 0 0 var(--ac); }
.channel-item .sym { color: var(--muted); font-size: 17px; width: 18px; text-align: center; }
.channel-item.active .sym { color: var(--ac); }
.channel-item .cname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Painel do usuário */
.user-panel { border-top: 1px solid var(--line); background: rgba(7,5,20,.6); padding: 10px; display: flex; align-items: center; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; background: transparent; border: 0; cursor: pointer;
  padding: 6px; border-radius: 10px; text-align: left; }
.user-chip:hover { background: var(--raised); }
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { font-size: 11px; color: var(--success); }
.user-actions { display: flex; gap: 2px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: var(--ac-ink); display: inline-grid;
  place-items: center; font-weight: 700; font-size: 14px; flex: none; background-size: cover; background-position: center; position: relative; }
.avatar.lg { width: 80px; height: 80px; font-size: 30px; }
.avatar .presence { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--success); border: 3px solid var(--panel); }

/* Principal */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: transparent; }
.channel-head { height: var(--head-h); flex: none; display: flex; align-items: center; gap: 10px; padding: 0 18px;
  border-bottom: 1px solid var(--line); background: rgba(12,10,24,.6); backdrop-filter: blur(8px); }
.channel-symbol { color: var(--muted); font-size: 22px; font-weight: 700; }
.channel-head-meta { min-width: 0; flex: 1; }
.channel-name { font-size: 16px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-topic { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-head-actions { display: flex; gap: 6px; align-items: center; }

/* Mensagens */
.messages { flex: 1; overflow-y: auto; padding: 18px 18px 8px; display: flex; flex-direction: column; gap: 2px; }
.msg { display: flex; gap: 12px; padding: 7px 10px; border-radius: 10px; position: relative; animation: msgin .25s ease; }
@keyframes msgin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg:hover { background: rgba(29,26,56,.5); }
.msg .avatar { width: 40px; height: 40px; font-size: 16px; margin-top: 2px; }
.msg-body { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 700; font-size: 14.5px; }
.msg-time { font-size: 11px; color: var(--muted); }
.msg-edited { font-size: 10px; color: var(--muted); }
.msg-content { margin: 2px 0 0; font-size: 14.5px; line-height: 1.45; color: var(--text); word-wrap: break-word; white-space: pre-wrap; }
.msg-content a { color: var(--ac2); }
.msg-reply { font-size: 12px; color: var(--muted); border-left: 2px solid var(--ac-border); padding-left: 8px; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-img { margin-top: 8px; max-width: 380px; max-height: 300px; border-radius: 12px; border: 1px solid var(--line); display: block; cursor: zoom-in; }
.msg-actions { position: absolute; top: -12px; right: 12px; display: none; gap: 2px; background: var(--raised);
  border: 1px solid var(--line); border-radius: 9px; padding: 2px; box-shadow: var(--shadow); }
.msg:hover .msg-actions { display: flex; }
.msg-actions .icon-btn { width: 28px; height: 28px; font-size: 13px; }
.reactions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--dim); border-radius: 9px; padding: 2px 8px;
  font-size: 12.5px; cursor: pointer; transition: background .12s, border .12s; }
.chip:hover { border-color: var(--ac); }
.chip.mine { background: var(--ac-soft); border-color: var(--ac-border); color: var(--text); }
.day-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; font-weight: 700; margin: 14px 4px 8px; }
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent); }
.empty-state { margin: auto; text-align: center; color: var(--muted); padding: 40px; }
.empty-state .big { font-size: 44px; margin-bottom: 10px; }
.empty-state h3 { color: var(--text); margin: 0 0 6px; }

/* Composer */
.composer-wrap { flex: none; padding: 0 18px 18px; }
.reply-bar, .attach-preview { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--raised); border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; padding: 8px 12px; font-size: 13px; color: var(--dim); }
.attach-preview img { max-height: 90px; border-radius: 8px; }
.composer { display: flex; align-items: flex-end; gap: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 8px; transition: border .15s, box-shadow .15s; }
.reply-bar + .composer, .attach-preview + .composer, .reply-bar + .attach-preview + .composer { border-radius: 0 0 14px 14px; }
.composer:focus-within { border-color: var(--ac-border); box-shadow: 0 0 0 3px var(--ac-ring); }
.composer textarea { flex: 1; resize: none; background: transparent; border: 0; outline: none; color: var(--text);
  font-size: 14.5px; line-height: 1.4; max-height: 160px; padding: 9px 4px; }
.composer-add { font-size: 20px; }

/* Voz */
.voice-panel { flex: none; margin: 12px 18px 0; background: linear-gradient(180deg, rgba(20,18,42,.9), rgba(12,10,24,.9));
  border: 1px solid var(--ac-border); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.voice-status { display: flex; align-items: center; gap: 8px; color: var(--success); font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.voice-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 10px var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.voice-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 10px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px; transition: border .2s, box-shadow .2s; }
.voice-tile.speaking { border-color: var(--success); box-shadow: 0 0 0 2px var(--success-soft), 0 0 18px rgba(134,239,172,.25); }
.voice-tile .vname { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.voice-tile .vmute { font-size: 11px; color: var(--muted); }
.voice-controls { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.voice-ctrl { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--raised); cursor: pointer; font-size: 18px; transition: background .15s, transform .12s; }
.voice-ctrl:hover { background: var(--line); transform: translateY(-1px); }
.voice-ctrl.off { background: var(--danger-soft); border-color: rgba(255,93,107,.4); }
.voice-leave { background: var(--danger); border-color: var(--danger); color: #2A0508; }
.voice-leave:hover { filter: brightness(1.1); background: var(--danger); }

/* Membros */
.members { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.members-title { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 18px 16px 8px; margin: 0; }
.members-scroll { flex: 1; overflow-y: auto; padding: 0 10px 16px; }
.member-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; cursor: pointer; }
.member-item:hover { background: var(--raised); }
.member-item .avatar { width: 32px; height: 32px; font-size: 13px; }
.member-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Modais */
.modal-scrim { position: fixed; inset: 0; z-index: 50; background: rgba(4,2,12,.7); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: min(480px, 100%); max-height: 86vh; overflow-y: auto; background: linear-gradient(180deg, var(--surface), var(--panel));
  border: 1px solid var(--line-strong); border-radius: 20px; padding: 26px; box-shadow: var(--shadow); animation: rise .3s cubic-bezier(.2,.8,.2,1); }
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal .sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.profile-banner { height: 110px; border-radius: 14px; background: var(--grad); margin: -26px -26px 0; background-size: cover; background-position: center; }
.profile-head { display: flex; align-items: flex-end; gap: 14px; margin: -34px 0 16px; padding: 0 6px; }
.profile-head .avatar { border: 5px solid var(--panel); }
.profile-name { font-size: 20px; font-weight: 800; }
.profile-user { color: var(--muted); font-size: 13px; }
.profile-bio { color: var(--dim); font-size: 14px; line-height: 1.5; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-grid button { border: 0; background: transparent; font-size: 22px; padding: 6px; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: var(--raised); }

/* Toasts */
.toast-stack { position: fixed; bottom: 20px; left: 50%; translate: -50% 0; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--raised); border: 1px solid var(--line-strong); border-left: 3px solid var(--ac); color: var(--text);
  border-radius: 12px; padding: 12px 18px; font-size: 14px; box-shadow: var(--shadow); animation: rise .3s ease; max-width: 90vw; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

.only-mobile { display: none; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .app-view.with-members { grid-template-columns: var(--rail-w) var(--side-w) 1fr; }
  .members { position: fixed; right: 0; top: 0; bottom: 0; width: var(--members-w); z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 820px) {
  :root { --side-w: 240px; }
  .app-view, .app-view.with-members { grid-template-columns: var(--rail-w) 1fr; }
  .sidebar { position: fixed; left: var(--rail-w); top: 0; bottom: 0; width: var(--side-w); z-index: 25; box-shadow: var(--shadow);
    transform: translateX(-110%); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
  .app-view.sidebar-open .sidebar { transform: none; }
  .only-mobile { display: inline-grid; }
  .channel-topic { display: none; }
}
@media (max-width: 560px) {
  :root { --rail-w: 62px; }
  .rail-btn { width: 42px; height: 42px; }
  .messages { padding: 12px 10px 6px; }
  .composer-wrap { padding: 0 10px 10px; }
  .msg-img { max-width: 100%; }
  .auth-card { padding: 28px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}