*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 15px;
    background: #f5f6f8;
    color: #1a1a1a;
    min-height: 100vh;
}

/* Header */
.site-header {
    background: #1e3a5f;
    color: #fff;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Auth card (login / register) */
.auth-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 52px);
    padding: 24px;
}

.auth-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,.10);
    padding: 36px 40px;
    width: 100%;
    max-width: 380px;
}

.auth-card h2 {
    font-size: 20px;
    margin-bottom: 24px;
    color: #1e3a5f;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #444;
}

.form-group input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
}

.form-group input:focus {
    border-color: #1e3a5f;
}

.btn-primary {
    display: block;
    width: 100%;
    padding: 10px;
    background: #1e3a5f;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background .15s;
}

.btn-primary:hover { background: #16304f; }
.btn-primary:disabled { background: #9aa8b5; cursor: not-allowed; }

.auth-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: #1e3a5f;
    text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }

/* Error / success blocks */
.msg-error {
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin-top: 16px;
    display: none;
}
.msg-error.visible { display: block; }

/* Chat layout */
.chat-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-topbar {
    background: #1e3a5f;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 12px 20px;
    gap: 12px;
    flex-shrink: 0;
}

.chat-topbar .title {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
}

.chat-topbar .username {
    font-size: 13px;
    opacity: .8;
}

.btn-logout {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 5px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.25); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Bubbles */
.bubble {
    max-width: 72%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}

.bubble-user {
    align-self: flex-end;
    background: #1e3a5f;
    color: #fff;
    border-bottom-right-radius: 3px;
}

.bubble-assistant {
    align-self: flex-start;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #e4e7ec;
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.bubble-meta {
    font-size: 11px;
    opacity: .55;
    margin-top: 4px;
}

.bubble-assistant .bubble-meta { text-align: left; }
.bubble-user .bubble-meta { text-align: right; color: #c5d5e8; }

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #d0d5dd;
    border-top-color: #1e3a5f;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Input bar */
.chat-inputbar {
    background: #fff;
    border-top: 1px solid #e4e7ec;
    padding: 14px 16px;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 9px 14px;
    border: 1.5px solid #d0d5dd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    height: 42px;
    max-height: 120px;
    outline: none;
    transition: border-color .15s;
    overflow-y: auto;
}
.chat-input:focus { border-color: #1e3a5f; }

.btn-send {
    padding: 9px 20px;
    background: #1e3a5f;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s;
}
.btn-send:hover { background: #16304f; }
.btn-send:disabled { background: #9aa8b5; cursor: not-allowed; }

/* Markdown rendering in assistant bubbles */
.bubble-assistant { white-space: normal; }
.bubble-assistant pre { background: #f4f6f8; border-radius: 5px; padding: 8px 12px; overflow-x: auto; margin: 6px 0; }
.bubble-assistant code { background: #f4f6f8; border-radius: 3px; padding: 1px 4px; font-size: 13px; }
.bubble-assistant pre code { background: none; padding: 0; }
.bubble-assistant ul, .bubble-assistant ol { padding-left: 20px; margin: 4px 0; }
.bubble-assistant h3 { font-size: 15px; font-weight: 600; margin: 6px 0 2px; }
