:root {
    --red: #ce1126;
    --gold: #3cb043;
    --green: #3cb043;
    --ink: #0c0c10;
    --panel: #16161d;
    --panel-2: #1e1e28;
    --line: rgba(60, 176, 67, 0.22);
    --text: #f4f1ea;
    --muted: #b9b3a6;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: Outfit, system-ui, sans-serif;
    background: var(--ink);
    color: var(--text);
}

.app-body { background:
    radial-gradient(1200px 500px at 10% -10%, rgba(60, 176, 67, 0.18), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(0, 0, 0, 0.35), transparent 45%),
    var(--ink);
}

.app-shell {
    min-height: 100%;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.app-sidebar {
    background: rgba(12, 12, 16, 0.92);
    border-right: 1px solid var(--line);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: inherit;
    text-align: center;
}
.brand small { display: block; color: var(--muted); font-size: 0.75rem; }
.brand-mascot {
    width: 168px;
    height: 168px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--green);
    background: #0c0c10;
    display: block;
    margin: 0 auto;
}
.brand-tag {
    display: block;
    font-weight: 600;
    font-size: 0.82rem;
}

.side-nav { display: flex; flex-direction: column; gap: 0.35rem; }
.side-nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
}
.side-nav a.active, .side-nav a:hover {
    background: rgba(60, 176, 67, 0.14);
    color: var(--green);
}

.side-links {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.side-links a {
    color: var(--green);
    text-decoration: none;
    font-size: 0.85rem;
}
.side-links a:hover { text-decoration: underline; }
.side-user {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}
.side-user small { display: block; color: var(--muted); word-break: break-all; }

.app-main { min-width: 0; min-height: 100vh; }

.btn-gold, .nav-pills .nav-link.active {
    background: var(--green);
    color: #fff;
    border: 0;
    font-weight: 600;
}
.btn-gold:hover { background: #4cc954; color: #fff; }
.btn-outline-gold {
    border: 1px solid var(--green);
    color: var(--green);
}
.btn-outline-gold:hover { background: var(--green); color: #fff; }
.nav-pills .nav-link { color: var(--muted); border: 1px solid var(--line); }

.chat-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: 100vh;
}

.conv-pane {
    border-right: 1px solid var(--line);
    background: rgba(22, 22, 29, 0.7);
    display: flex;
    flex-direction: column;
    padding: 1rem;
}
.conv-head { display: flex; justify-content: space-between; align-items: center; }
.conv-head h2 { font-size: 1rem; margin: 0; }
.conv-search { margin: 0.85rem 0; }
.conv-list { overflow: auto; display: flex; flex-direction: column; gap: 0.4rem; }
.conv-item {
    text-align: left;
    background: var(--panel-2);
    border: 1px solid transparent;
    color: inherit;
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
}
.conv-item.active, .conv-item:hover { border-color: var(--gold); }
.conv-item small { display: block; color: var(--muted); font-size: 0.75rem; }

.chat-pane { display: flex; flex-direction: column; height: 100vh; }
.chat-top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 0.9rem 1.4rem;
    border-bottom: 1px solid var(--line);
}
.chat-top-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.chat-top-mascot {
    height: 48px;
    width: 48px;
    object-fit: cover;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--green);
}
.text-muted-gold { color: var(--muted); font-size: 0.9rem; }
.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid rgba(34, 197, 94, 0.45);
    color: #86efac;
    border-radius: 99px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.live-pill::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 1s infinite;
}
.live-pill.off {
    border-color: var(--line);
    color: var(--muted);
}
.live-pill.off::before { background: #6b7280; animation: none; }

.messages {
    flex: 1;
    overflow: auto;
    padding: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.welcome {
    margin: auto;
    max-width: 640px;
    text-align: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 2rem;
}
.welcome-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.welcome-mascot.speaking {
    box-shadow: 0 0 0 8px rgba(60, 176, 67, 0.25), 0 10px 32px rgba(60, 176, 67, 0.35);
    animation: pulse 1s infinite;
}
.composer.voice-only .composer-box {
    display: none;
}
.welcome.voice-only h2,
.welcome.voice-only p,
.welcome.voice-only .chips {
    display: none;
}
.composer.voice-only .composer-hint {
    text-align: center;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.chips button {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--gold);
    border-radius: 99px;
    padding: 0.4rem 0.8rem;
}

.msg-row {
    display: flex;
    gap: 0.65rem;
    align-items: flex-end;
    max-width: 100%;
}
.msg-row.user { justify-content: flex-end; }
.msg-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    border: 2px solid var(--green);
    flex-shrink: 0;
}
.bubble {
    max-width: min(720px, 82%);
    padding: 0.85rem 1rem;
    border-radius: 16px;
    line-height: 1.5;
    white-space: pre-wrap;
}
.bubble.user {
    margin-left: auto;
    background: var(--green);
    color: #fff;
}
.bubble.assistant {
    background: var(--panel-2);
    border: 1px solid var(--line);
}
.bubble a { color: #86efac; }
.bubble.typing {
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
    min-width: 64px;
}
.bubble.typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 1s infinite;
}
.bubble.typing span:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing span:nth-child(3) { animation-delay: 0.3s; }

.composer { padding: 0.9rem 1.2rem 1.2rem; }
.composer-box {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 0.55rem;
}
.composer-box textarea {
    resize: none;
    background: transparent;
    border: 0;
    color: inherit;
    padding: 0.55rem 0.7rem;
    outline: none;
}
.mic-btn, .send-btn {
    border: 0;
    border-radius: 12px;
    padding: 0.55rem 0.9rem;
}
.mic-btn { background: #2a2a36; color: var(--gold); }
.mic-btn.listening { background: var(--red); color: #fff; animation: pulse 1.2s infinite; }
.send-btn { background: var(--green); color: #fff; font-weight: 600; }
.composer-hint { display: block; margin-top: 0.45rem; color: var(--muted); font-size: 0.75rem; }

.voice-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gold);
    margin-bottom: 0.45rem;
}
.voice-status.d-none { display: none !important; }
.voice-status.listening-wake { color: var(--gold); }
.voice-status.listening-capture { color: #86efac; }
.pulse {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--green);
    animation: pulse 1s infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.6; }
}

.page-wrap { padding: 1.5rem 1.75rem 2.5rem; }
.page-hero h1 { margin-bottom: 0.25rem; }
.page-hero p { color: var(--muted); }
.stat-card, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1.2rem;
}
.stat-card small { color: var(--muted); display: block; }
.stat-card strong { font-size: 2rem; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(800px 400px at 20% 0%, rgba(60, 176, 67, 0.22), transparent),
        radial-gradient(700px 300px at 90% 100%, rgba(0, 0, 0, 0.4), transparent),
        var(--ink);
}
.welcome-mascot {
    width: 220px;
    height: 220px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--green);
    background: #0c0c10;
    box-shadow: 0 10px 32px rgba(60, 176, 67, 0.28);
    display: block;
    margin: 0 auto 0.5rem;
}
.auth-card {
    width: min(440px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 2rem;
}
.auth-card h1 { font-size: 1.5rem; }
.form-control, .form-select {
    background: #121218;
    border-color: #2c2c38;
    color: var(--text);
}
.form-control:focus, .form-select:focus {
    background: #121218;
    color: var(--text);
    border-color: var(--green);
    box-shadow: 0 0 0 0.2rem rgba(60, 176, 67, 0.18);
}
.table { --bs-table-bg: transparent; color: var(--text); }

@media (max-width: 960px) {
    .app-shell, .chat-layout { grid-template-columns: 1fr; }
    .app-sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
    .side-nav { flex-direction: row; flex-wrap: wrap; }
    .side-user { margin-top: 0; border: 0; width: 100%; flex-direction: row; justify-content: space-between; align-items: center; }
    .chat-pane, .app-main { min-height: auto; height: auto; }
    .chat-layout { height: auto; }
    .messages { min-height: 55vh; }
}
