:root {
    --bg: #0d0f14;
    --bg2: #15181f;
    --surface: #1b1f29;
    --border: #2a2f3b;
    --text: #e8eaf0;
    --text2: #9aa1b2;
    --accent: #5b8def;
    --accent-dim: #2d4269;
    --error: #e5484d;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    overflow: hidden;
}

.view { height: 100%; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
#login-view {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box {
    width: 320px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.login-box h1 {
    margin: 0 0 2px;
    font-size: 2rem;
    font-weight: 600;
    text-align: center;
}
.subtitle {
    margin: 0 0 14px;
    color: var(--text2);
    text-align: center;
}
input[type="email"], input[type="password"], input[type="text"] {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    width: 100%;
    outline: none;
}
input:focus { border-color: var(--accent); }

.password-field { position: relative; }
.password-field input { padding-right: 40px; }
.password-field .icon-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.1); }
.primary-btn:disabled { opacity: 0.5; cursor: default; }

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    padding: 6px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text2);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }

.error-text { color: var(--error); font-size: 13px; margin: 0; }

.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Main app ---------- */
#main-view {
    display: flex;
    flex-direction: column;
    max-width: 720px;
    margin: 0 auto;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 8px;
    flex-shrink: 0;
}
.topbar h2 { margin: 0; font-size: 1.4rem; font-weight: 500; }

/* Top-right hamburger menu -- modeled on CryptoSkyscrapers' account
   dropdown (anchored popup, role-scoped items, Logout last/distinct),
   same pattern already shipped on the Android/Electron clients. This is
   the web client's ONLY navigation (no persistent bottom tab bar here --
   a top menu is the natural idiom in a browser, same reasoning
   CryptoSkyscrapers itself uses). */
.menu-wrap { position: relative; }
.menu-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 170px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    z-index: 10;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    font-size: 13.5px;
    padding: 9px 10px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}
.menu-item:hover { background: var(--surface); }
.menu-item-icon { font-size: 15px; width: 18px; text-align: center; }
.menu-item-danger { color: var(--error); }
.menu-item-danger:hover { background: rgba(229, 72, 77, 0.12); }

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.bubble {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}
.eva-image {
    display: block;
    width: 100%;
    max-width: 320px;
    margin-top: 8px;
    border-radius: 10px;
    background: var(--accent-dim);
}
.bubble.user {
    align-self: flex-end;
    background: var(--accent-dim);
    color: var(--text);
    border-bottom-right-radius: 4px;
}
.bubble.eva {
    align-self: flex-start;
    background: var(--surface);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.status-text {
    text-align: center;
    color: var(--text2);
    font-size: 12px;
    margin: 0 0 4px;
}

.composer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 14px;
    flex-shrink: 0;
}
.composer input { flex: 1; }
.mic-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
}
.mic-btn.recording { background: var(--error); }

.coming-soon {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text2);
    padding: 24px;
    text-align: center;
}

/* ---------- Admin ---------- */
.subtabbar {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.subtab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text2);
    padding: 10px 4px;
    cursor: pointer;
    font-size: 13px;
}
.subtab-btn.selected { color: var(--accent); font-weight: 600; }

.admin-users {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.user-row {
    background: var(--surface);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.user-row .user-info {
    min-width: 0;
    flex: 1;
}
.user-row .user-email {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-row .user-status { color: var(--text2); font-size: 12px; }
.user-row .user-status.locked { color: var(--error); }
.user-row .user-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.role-select {
    background: var(--bg2);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 13px;
}
.toggle {
    width: 38px; height: 22px;
    border-radius: 11px;
    background: var(--border);
    position: relative;
    cursor: pointer;
    border: none;
    flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: white;
    transition: left 0.15s;
}
.toggle.on::after { left: 18px; }

/* ---------- Thinking bubble + typewriter reveal (2026-11-17) ---------- */
.bubble.thinking {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text2);
}
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.35;
    animation: eva-dot 1.2s infinite ease-in-out;
}
.thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes eva-dot {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
    40% { transform: translateY(-4px); opacity: 1; }
}
.thinking-label {
    font-size: 13px;
    background: linear-gradient(90deg, var(--text2) 0%, var(--text) 50%, var(--text2) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: eva-shimmer 1.8s linear infinite;
}
@keyframes eva-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}
.typing::after {
    content: '▍';
    margin-left: 1px;
    color: var(--accent);
    animation: eva-caret 0.8s steps(1) infinite;
}
@keyframes eva-caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .thinking-dots i, .thinking-label, .typing::after { animation: none; }
    .thinking-label { color: var(--text2); background: none; }
}
