* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #21253a;
    --border: #2d3147;
    --accent: #6c63ff;
    --accent2: #4ecdc4;
    --text: #e2e8f0;
    --muted: #64748b;
    --danger: #ef4444;
    --success: #22c55e;
}

body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', Tahoma, sans-serif; min-height: 100vh; }

/* ---- Auth ---- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, #1a1344 0%, #0f1117 70%); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
    padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 25px 60px rgba(0,0,0,0.5); }
.auth-logo { text-align: center; margin-bottom: 28px; }
.logo-icon { font-size: 40px; margin-bottom: 8px; }
.auth-logo h1 { font-size: 24px; color: var(--accent); }
.auth-logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.auth-tabs { display: flex; margin-bottom: 24px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.tab { flex: 1; text-align: center; padding: 10px; text-decoration: none; color: var(--muted); font-size: 14px; transition: 0.2s; }
.tab.active { background: var(--accent); color: #fff; }
label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
input { width: 100%; padding: 11px 14px; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 14px; }
input:focus { outline: none; border-color: var(--accent); }
button[type=submit], .btn-primary {
    width: 100%; padding: 12px; margin-top: 20px; background: var(--accent);
    color: #fff; border: none; border-radius: 10px; font-size: 15px; cursor: pointer; transition: 0.2s; }
button:hover { opacity: 0.9; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert.error { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.alert.success { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }

/* ---- Navbar ---- */
.navbar { background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 14px 24px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 50; }
.nav-brand { font-weight: bold; color: var(--accent); font-size: 17px; }
.nav-links a { color: var(--muted); text-decoration: none; margin-right: 18px; font-size: 14px; transition: 0.2s; }
.nav-links a:hover { color: var(--text); }
.nav-user { color: var(--text); font-size: 13px; margin-right: 18px; }

/* ---- Layout ---- */
.layout { display: grid; grid-template-columns: 280px 1fr; height: calc(100vh - 53px); overflow: hidden; }
.sidebar { border-left: 1px solid var(--border); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.card h3 { font-size: 13px; color: var(--muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.muted { color: var(--muted); font-size: 13px; }
a { color: var(--accent); }

.device-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.device-item:last-child { border: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.device-item.online .dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.device-item.offline .dot { background: var(--muted); }
.device-item strong { display: block; font-size: 13px; }
.device-item small { color: var(--muted); font-size: 11px; }

.file-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 0;
    border-bottom: 1px solid var(--border); font-size: 13px; }
.btn-xs { background: var(--surface2); border: 1px solid var(--border); color: var(--text);
    padding: 3px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; text-decoration: none; }

/* ---- Chat ---- */
.chat-area { display: flex; flex-direction: column; overflow: hidden; }
.chat-box { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.chat-welcome { text-align: center; margin: auto; opacity: 0.6; }
.welcome-icon { font-size: 48px; margin-bottom: 12px; }

.msg { display: flex; }
.msg-user { justify-content: flex-start; }
.msg-ai { justify-content: flex-end; }
.bubble { max-width: 75%; padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.6; }
.msg-user .bubble { background: var(--surface2); border: 1px solid var(--border); border-radius: 16px 16px 16px 4px; }
.msg-ai .bubble { background: linear-gradient(135deg, #2d1f7a, #1a3a5c); border-radius: 16px 16px 4px 16px; }
pre { background: #0d0d1a; border: 1px solid var(--border); border-radius: 8px; padding: 12px;
    overflow-x: auto; margin: 8px 0; font-size: 13px; }
code { background: rgba(108,99,255,0.2); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
pre code { background: none; padding: 0; }

.system-notice { background: rgba(108,99,255,0.1); border: 1px solid rgba(108,99,255,0.3);
    border-radius: 10px; padding: 10px 14px; font-size: 13px; color: #a5b4fc; }

.chat-input-area { padding: 16px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
textarea { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px;
    color: var(--text); padding: 12px 16px; font-size: 14px; resize: none; font-family: inherit; }
textarea:focus { outline: none; border-color: var(--accent); }
#sendBtn { background: var(--accent); color: #fff; border: none; padding: 12px 22px;
    border-radius: 12px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.typing { animation: blink 0.8s infinite; }
@keyframes blink { 0%,100% { opacity:1 } 50% { opacity:0 } }
.err { color: var(--danger); }

/* ---- Connect page ---- */
.connect-page { max-width: 780px; margin: 32px auto; padding: 0 20px; }
.connect-page h1 { font-size: 24px; margin-bottom: 8px; }
.lead { color: var(--muted); margin-bottom: 28px; }
.token-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.token-box label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.token-row { display: flex; gap: 10px; align-items: center; }
.token-row code { flex: 1; background: var(--surface2); padding: 10px 14px; border-radius: 8px; font-size: 13px;
    word-break: break-all; border: 1px solid var(--border); }
.token-row button { background: var(--accent); color:#fff; border:none; padding:10px 18px; border-radius:8px; cursor:pointer; }
.token-box small { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; }
.install-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 20px; margin-bottom: 16px; }
.install-card h2 { font-size: 16px; margin-bottom: 10px; }
.code-block { position: relative; }
.code-block pre { background: #0a0a14; border: 1px solid var(--border); border-radius: 8px;
    padding: 14px; font-size: 12px; overflow-x: auto; color: #a5f3fc; white-space: pre-wrap; word-break: break-all; }
.code-block button { position: absolute; top: 8px; left: 8px; background: var(--surface2);
    border: 1px solid var(--border); color: var(--text); padding: 4px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.btn-outline { display: inline-block; padding: 8px 18px; border: 1px solid var(--accent); color: var(--accent);
    border-radius: 8px; text-decoration: none; font-size: 13px; margin-top: 8px; }

@media (max-width: 768px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { display: none; }
}
