:root {
    --bg: #0e1013;
    --bg-2: #16191e;
    --bg-3: #1e232b;
    --line: #2a3038;
    --text: #e6e9ee;
    --muted: #8a94a3;
    --accent: #4f8cff;
    --accent-2: #2f6ae0;
    --user-bubble: #29405f;
    --agent-bubble: #1e232b;
    --ok: #35c47b;
    --off: #5b636e;
    --danger: #ff5b6a;
    --radius: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 360px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 28px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
input[type=email], input[type=password], input[type=text], textarea {
    background: var(--bg-3);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 15px;
    width: 100%;
    outline: none;
    font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--accent); }
.btn {
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 10px;
    padding: 11px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}
.btn:hover { background: var(--accent-2); }
.alert {
    background: rgba(255, 91, 106, .12);
    border: 1px solid rgba(255, 91, 106, .4);
    color: #ffbcc2;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* ---------- App shell ---------- */
.shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: 100vh;
}
.sidebar {
    background: var(--bg-2);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.sidebar-head {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand { font-weight: 700; letter-spacing: .3px; }
.brand small { color: var(--muted); font-weight: 400; }
.agent-list { overflow-y: auto; flex: 1; padding: 8px; }
.agent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--text);
}
.agent-item:hover { background: var(--bg-3); text-decoration: none; }
.agent-item.active { background: var(--bg-3); }
.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #34405a, #202634);
    display: grid; place-items: center;
    font-size: 18px;
    flex: none;
}
.agent-meta { min-width: 0; flex: 1; }
.agent-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-sub { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(53,196,123,.18); }
.sidebar-foot {
    border-top: 1px solid var(--line);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--muted);
}

/* ---------- Chat ---------- */
.chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background:
        radial-gradient(1200px 400px at 70% -10%, rgba(79,140,255,.06), transparent),
        var(--bg);
}
.chat-head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-2);
}
.chat-head .agent-name { font-size: 16px; }
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.msg { display: flex; max-width: 74%; }
.msg.user { align-self: flex-end; }
.msg.agent, .msg.system { align-self: flex-start; }
.bubble {
    padding: 10px 13px;
    border-radius: 14px;
    background: var(--agent-bubble);
    border: 1px solid var(--line);
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.45;
}
.msg.user .bubble { background: var(--user-bubble); border-color: transparent; }
.msg.system .bubble { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 13px; }
.bubble .meta { font-size: 11px; color: var(--muted); margin-top: 5px; display: flex; gap: 8px; }
.bubble.progress { opacity: .85; font-style: italic; }
.attach {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 13px;
    color: var(--text);
}
.attach img { max-width: 260px; max-height: 220px; border-radius: 8px; display: block; }

.composer {
    border-top: 1px solid var(--line);
    padding: 12px 16px;
    background: var(--bg-2);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.composer textarea {
    resize: none;
    max-height: 160px;
    min-height: 44px;
}
.composer .send { width: auto; padding: 11px 18px; }
.icon-btn {
    background: var(--bg-3);
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 10px;
    padding: 11px 13px;
    cursor: pointer;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
}
.icon-btn:hover { color: var(--text); }
.file-chip { font-size: 12px; color: var(--muted); padding: 0 4px; align-self: center; }

.empty {
    display: grid;
    place-items: center;
    height: 100vh;
    text-align: center;
    color: var(--muted);
    padding: 24px;
}
.empty code {
    background: var(--bg-3);
    border: 1px solid var(--line);
    padding: 2px 6px;
    border-radius: 6px;
    color: var(--text);
}
