/* Orbit Connect — glassmorphism design system */
:root {
  --bg-1: #0b1020; --bg-2: #1a1640; --blob-1: #6d5dfc; --blob-2: #22d3ee; --blob-3: #f472b6;
  --glass: rgba(255,255,255,0.07); --glass-strong: rgba(255,255,255,0.12); --glass-hover: rgba(255,255,255,0.14);
  --border: rgba(255,255,255,0.14); --border-strong: rgba(255,255,255,0.24);
  --text: #eef1ff; --text-2: rgba(238,241,255,0.72); --text-3: rgba(238,241,255,0.5);
  --accent: #8b7bff; --accent-2: #22d3ee; --accent-text: #fff; --danger: #ff5d7a; --ok: #34d399; --warn: #fbbf24;
  --shadow: 0 8px 32px rgba(0,0,0,0.35); --blur: blur(22px) saturate(160%);
  --radius: 18px; --radius-sm: 12px; --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}
[data-theme="light"] {
  --bg-1: #eef1ff; --bg-2: #fdf2ff; --blob-1: #a5b4fc; --blob-2: #67e8f9; --blob-3: #f9a8d4;
  --glass: rgba(255,255,255,0.55); --glass-strong: rgba(255,255,255,0.72); --glass-hover: rgba(255,255,255,0.85);
  --border: rgba(255,255,255,0.75); --border-strong: rgba(120,120,170,0.25);
  --text: #171a33; --text-2: rgba(23,26,51,0.72); --text-3: rgba(23,26,51,0.5);
  --accent: #6355f6; --shadow: 0 8px 32px rgba(80,80,160,0.18);
}
[data-reduce-glass="1"] { --blur: none; --glass: rgba(30,32,60,0.92); --glass-strong: rgba(40,42,75,0.96); }
[data-theme="light"][data-reduce-glass="1"] { --glass: rgba(255,255,255,0.95); --glass-strong: #fff; }

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
html, body { height: 100dvh; }
body {
  font-family: var(--font); color: var(--text); font-size: 14.5px; line-height: 1.45;
  background: radial-gradient(1200px 800px at 10% -10%, var(--bg-2), transparent 60%), var(--bg-1);
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
.bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-blobs i { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55; animation: float 26s ease-in-out infinite; }
.bg-blobs i:nth-child(1) { width: 520px; height: 520px; background: var(--blob-1); left: -120px; top: 10%; }
.bg-blobs i:nth-child(2) { width: 420px; height: 420px; background: var(--blob-2); right: -100px; top: -80px; animation-delay: -8s; opacity: .35; }
.bg-blobs i:nth-child(3) { width: 460px; height: 460px; background: var(--blob-3); right: 20%; bottom: -200px; animation-delay: -16s; opacity: .3; }
@keyframes float { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px,-30px) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .bg-blobs i { animation: none; } }

.glass { background: var(--glass); border: 1px solid var(--border); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); border-radius: var(--radius); }
.glass-strong { background: var(--glass-strong); }
a { color: var(--accent-2); }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--glass-strong); padding: 9px 14px; border-radius: 12px; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { background: var(--glass-hover); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #6d5dfc 60%, var(--accent-2)); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 6px 20px rgba(109,93,252,.35); }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text-2); transition: .15s; }
.icon-btn:hover { background: var(--glass-hover); color: var(--text); border-color: var(--border); }
.icon-btn.active { background: var(--glass-strong); color: var(--text); border-color: var(--border); }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.input, textarea.input, select.input { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,0.06); outline: none; transition: .15s; }
[data-theme="light"] .input { background: rgba(255,255,255,0.7); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,123,255,.25); }
select.input option { color: #111; }

.avatar { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; position: relative; text-shadow: 0 1px 2px rgba(0,0,0,.2); }
.avatar.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 11px; }
.avatar.lg { width: 72px; height: 72px; border-radius: 22px; font-size: 26px; }
.avatar .dot { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; background: #6b7280; border: 2px solid var(--bg-1); }
.avatar .dot.on { background: var(--ok); }
.avatar.ai { background: conic-gradient(from 180deg, #8b7bff, #22d3ee, #f472b6, #8b7bff); }

.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }

/* ---------- auth ---------- */
.auth-wrap { height: 100%; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(420px, 100%); padding: 34px 30px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.logo { width: 44px; height: 44px; border-radius: 14px; background: conic-gradient(from 200deg, #8b7bff, #22d3ee, #f472b6, #8b7bff); display: grid; place-items: center; box-shadow: 0 6px 24px rgba(109,93,252,.45); }
.logo::after { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 5px rgba(255,255,255,.25); }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.brand p { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 68px 280px 1fr; gap: 12px; height: 100%; padding: 12px; }
.rail { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; }
.rail .logo { width: 40px; height: 40px; margin-bottom: 10px; }
.rail .spacer { flex: 1; }
.rail .icon-btn { width: 44px; height: 44px; position: relative; }
.rail .icon-btn .badge { position: absolute; top: -4px; right: -4px; transform: scale(.85); }
.sidebar { display: flex; flex-direction: column; overflow: hidden; }
.sidebar-head { padding: 16px 16px 10px; display: flex; align-items: center; justify-content: space-between; }
.sidebar-head h2 { margin: 0; font-size: 17px; }
.search { margin: 0 12px 8px; }
.list { overflow-y: auto; padding: 4px 8px 12px; flex: 1; }
.section-title { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 6px; color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; cursor: pointer; color: var(--text-2); transition: .12s; }
.item:hover { background: var(--glass-hover); color: var(--text); }
.item.active { background: var(--glass-strong); color: var(--text); border: 1px solid var(--border); padding: 7px 9px; }
.item.unread { color: var(--text); font-weight: 600; }
.item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .hash { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--glass-strong); color: var(--text-2); font-weight: 700; flex: none; }
.me-card { margin: 8px; padding: 10px; display: flex; align-items: center; gap: 10px; border-radius: 14px; background: var(--glass-strong); border: 1px solid var(--border); cursor: pointer; }
.me-card .who { flex: 1; min-width: 0; }
.me-card .who b { display: block; font-size: 13.5px; }
.me-card .who span { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.main { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.main-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.main-head .title { flex: 1; min-width: 0; }
.main-head h3 { margin: 0; font-size: 16.5px; display: flex; align-items: center; gap: 8px; }
.main-head .topic { color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main-head .actions { display: flex; gap: 6px; }
.back-btn { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.msg { display: flex; gap: 12px; padding: 6px 8px; border-radius: 12px; position: relative; }
.msg:hover { background: rgba(255,255,255,0.04); }
.msg.cont { padding-top: 1px; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg .content { flex: 1; min-width: 0; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg .meta b { font-size: 14px; }
.msg .meta time { font-size: 11.5px; color: var(--text-3); }
.msg .body { word-wrap: break-word; overflow-wrap: anywhere; color: var(--text); }
.msg .body p { margin: 0 0 6px; } .msg .body p:last-child { margin-bottom: 0; }
.msg .body ul, .msg .body ol { margin: 4px 0 6px; padding-left: 20px; }
.msg .body code { background: rgba(0,0,0,.25); padding: 1px 5px; border-radius: 6px; font-size: 13px; }
.msg .body pre { background: rgba(0,0,0,.3); padding: 10px 12px; border-radius: 10px; overflow-x: auto; }
.msg.ai .body { background: linear-gradient(135deg, rgba(139,123,255,.14), rgba(34,211,238,.08)); border: 1px solid rgba(139,123,255,.3); border-radius: 14px; padding: 10px 14px; }
.msg.system { justify-content: center; color: var(--text-3); font-size: 12.5px; padding: 8px; }
.msg .tools { position: absolute; right: 10px; top: -10px; display: none; }
.msg:hover .tools { display: flex; }
.day-sep { text-align: center; color: var(--text-3); font-size: 12px; margin: 14px 0 6px; display: flex; align-items: center; gap: 12px; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.file-card { display: inline-flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--border); text-decoration: none; color: var(--text); max-width: 360px; margin-top: 4px; }
.file-card img { max-width: 320px; max-height: 240px; border-radius: 10px; display: block; }
.meet-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: linear-gradient(135deg, rgba(139,123,255,.18), rgba(34,211,238,.1)); border: 1px solid rgba(139,123,255,.35); max-width: 420px; margin-top: 4px; }
.meet-card .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: #fff; }
.typing { height: 20px; padding: 0 24px; font-size: 12px; color: var(--text-3); }
.composer { margin: 0 14px 14px; padding: 8px; display: flex; align-items: flex-end; gap: 6px; border-radius: 16px; background: var(--glass-strong); border: 1px solid var(--border); }
.composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer textarea { flex: 1; border: 0; background: transparent; outline: none; resize: none; max-height: 180px; padding: 9px 6px; min-height: 22px; }
.composer .btn.primary { padding: 9px 12px; }
.empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--text-3); padding: 30px; }
.empty h3 { color: var(--text); margin: 14px 0 6px; }

/* panels / pages */
.page { padding: 20px 22px; overflow-y: auto; flex: 1; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { padding: 16px; border-radius: 16px; background: var(--glass-strong); border: 1px solid var(--border); }
.card h4 { margin: 0 0 4px; font-size: 15px; }
.card .row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.table th { color: var(--text-3); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; background: var(--glass-strong); border: 1px solid var(--border); }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); }

/* modal & toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(5,8,20,.45); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { width: min(520px, 100%); max-height: 88vh; overflow-y: auto; padding: 24px; background: var(--glass-strong); }
.modal.wide { width: min(760px, 100%); }
.modal h3 { margin: 0 0 16px; font-size: 18px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toasts { position: fixed; right: 18px; top: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast { padding: 12px 16px; min-width: 260px; max-width: 360px; animation: slide .2s; background: var(--glass-strong); }
.toast.call { padding: 16px; display: flex; flex-direction: column; gap: 12px; border-color: rgba(139,123,255,.6); box-shadow: 0 0 0 1px rgba(139,123,255,.3), 0 12px 40px rgba(109,93,252,.4); }
.toast.call .row { display: flex; gap: 8px; }
.ring { animation: ring 1.2s infinite; }
@keyframes ring { 0%,100% { transform: rotate(0); } 10%,30% { transform: rotate(-12deg); } 20%,40% { transform: rotate(12deg); } 50% { transform: rotate(0); } }
@keyframes fade { from { opacity: 0; } } @keyframes slide { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- mobile ---------- */
.mobile-nav { display: none; }
@media (max-width: 860px) {
  body { font-size: 15px; }
  .app { grid-template-columns: 1fr; padding: 8px 8px 74px; gap: 8px; }
  .rail { display: none; }
  .app.show-main .sidebar { display: none; }
  .app:not(.show-main) .main { display: none; }
  .back-btn { display: inline-grid; }
  .main-head { padding: 10px 12px; }
  .messages { padding: 12px 8px; }
  .composer { margin: 0 6px 8px; }
  .mobile-nav { display: flex; position: fixed; left: 8px; right: 8px; bottom: 8px; height: 60px; justify-content: space-around; align-items: center; z-index: 20; }
  .mobile-nav .icon-btn { width: 54px; height: 46px; flex-direction: column; font-size: 10.5px; gap: 2px; display: flex; align-items: center; justify-content: center; position: relative; }
  .mobile-nav .badge { position: absolute; top: 0; right: 4px; transform: scale(.8); }
  .app.show-main { padding-bottom: 8px; }
  .app.show-main ~ .mobile-nav { display: none; }
  .toasts { left: 10px; right: 10px; top: 10px; }
  .toast { max-width: none; }
  .file-card img { max-width: 100%; }
}
