:root {
    --bg: #0b0f14;
    --bg-elevated: #121820;
    --bg-soft: #18212c;
    --border: #243041;
    --text: #e7eef7;
    --muted: #93a4b8;
    --accent: #3ecf8e;
    --accent-2: #2b8cff;
    --danger: #ff5c7a;
    --user: #1b3a55;
    --assistant: #151c26;
    --radius: 18px;
    --font: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(46, 140, 255, 0.18), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(62, 207, 142, 0.12), transparent 55%),
        var(--bg);
    color: var(--text);
    font-family: var(--font);
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 15, 20, 0.85);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 24px rgba(62, 207, 142, 0.35);
}

.brand strong { display: block; font-size: 1.05rem; letter-spacing: 0.02em; }
.brand small { color: var(--muted); }

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
}

.user-chip {
    font-size: 0.8rem;
    color: #b7c6d8;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
}

.app-shell {
    flex: 1;
    display: flex;
    min-height: 0;
}

.chat-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    width: min(1200px, 100%);
    margin: 0 auto;
    min-height: calc(100vh - 70px);
}

.sidebar {
    padding: 1.25rem 1rem;
    border-right: 1px solid var(--border);
    background: rgba(18, 24, 32, 0.65);
}

.sidebar h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #93a4b8;
    margin: 0 0 0.75rem;
}

.example {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    border-radius: 12px;
    padding: 0.65rem 0.75rem;
    font-size: 0.86rem;
    transition: border-color .2s, transform .15s;
}

.example:hover {
    border-color: var(--accent-2);
    transform: translateY(-1px);
}

.sidebar-note {
    margin-top: 1rem;
    font-size: 0.78rem;
    color: #8091a6;
    line-height: 1.4;
}

.chat-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.msg {
    display: flex;
    animation: rise .25s ease;
}

.msg.user { justify-content: flex-end; }
.msg.assistant { justify-content: flex-start; }

.bubble {
    max-width: min(720px, 92%);
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid var(--border);
}

.msg.user .bubble {
    background: linear-gradient(160deg, #1c4668, #16344c);
    border-bottom-right-radius: 6px;
}

.msg.assistant .bubble {
    background: var(--assistant);
    border-bottom-left-radius: 6px;
}

.bubble .meta {
    display: block;
    margin-top: 0.55rem;
    font-size: 0.75rem;
    color: #8ea0b5;
}

.bubble pre {
    margin: 0.6rem 0 0;
    padding: 0.65rem;
    border-radius: 10px;
    background: #0d131a;
    overflow-x: auto;
    font-size: 0.78rem;
}

.composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.65rem;
    padding: 0.9rem 1.25rem 1.25rem;
    border-top: 1px solid var(--border);
    background: rgba(11, 15, 20, 0.9);
}

.composer-main {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

.attach-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: #93a4b8;
}

.attach-btn {
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    background: var(--bg-soft);
}

#fileInput {
    display: none;
}

.btn-clear-file {
    border: none;
    background: transparent;
    color: #ff8fa3;
    font-size: 0.8rem;
}

.details-tech {
    margin-top: 0.55rem;
    font-size: 0.78rem;
    color: #8ea0b5;
}

.details-tech summary {
    cursor: pointer;
    user-select: none;
}

.confirm-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.panel-result {
    margin: 0.5rem 0 1rem;
    font-size: 0.8rem;
    color: #b7c6d8;
}

.action-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.chip {
    border: 1px solid var(--border);
    background: linear-gradient(160deg, #1a2736, #121a24);
    color: var(--text);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
}

.chip:hover {
    border-color: var(--accent);
}


.composer textarea {
    resize: none;
    min-height: 48px;
    max-height: 160px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 0.8rem 0.95rem;
    outline: none;
    width: 100%;
}

.composer textarea:focus {
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(43, 140, 255, 0.2);
}

.btn-send {
    background: linear-gradient(135deg, var(--accent), #2bb673);
    border: none;
    color: #062014;
    font-weight: 700;
    border-radius: 14px;
    padding: 0 1.1rem;
    min-width: 96px;
}

.btn-send:disabled {
    opacity: 0.5;
}

.modal-content {
    background: #15202b;
    color: var(--text);
    border: 1px solid var(--border);
}

.modal-header, .modal-footer {
    border-color: var(--border);
}

.form-control {
    background: #0f1620;
    border-color: var(--border);
    color: var(--text);
}

.form-control:focus {
    background: #0f1620;
    color: var(--text);
    border-color: var(--accent-2);
    box-shadow: 0 0 0 0.2rem rgba(43, 140, 255, 0.2);
}

.btn-close {
    filter: invert(1);
}

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
    .chat-layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }
}
