:root {
    --bg: #070812;
    --card: rgba(255, 255, 255, .08);
    --stroke: rgba(255, 255, 255, .14);
    --text: rgba(255, 255, 255, .92);
    --muted: rgba(255, 255, 255, .65);
    --muted2: rgba(255, 255, 255, .45);
    --good: #33d6a6;
    --warn: #ffd166;
    --bad: #ff4d6d;
    --a: #8a2be2;
    --b: #00d4ff;
    --c: #ff3bd4;
    --shadow: 0 20px 60px rgba(0, 0, 0, .55);
    --r: 22px;
    --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

/* ── BACKGROUND scoped inside .bot-shell ── */
.bg-stage {
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
}

.bg-glass {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(0, 0, 0, .42), rgba(0, 0, 0, .62));
    backdrop-filter: blur(5px);
}

/* ── PRESENCE CANVAS ── */
#aiPresence {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: .45;
    mix-blend-mode: screen;
}

/* ── BOT SHELL ── */
.bot-shell {
    position: relative;
    z-index: 3;
    width: min(1260px, 97vw);
    height: min(760px, 94vh);
    margin: 3vh auto;
    border-radius: calc(var(--r) + 6px);
    border: 1px solid var(--stroke);
    background: transparent;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── HEADER ── */
.bot-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--stroke);
    background: linear-gradient(90deg, rgba(138, 43, 226, .3), rgba(0, 212, 255, .12), rgba(255, 59, 212, .18));
    flex-shrink: 0;
}

.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.brand-dot {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 18px;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .35), rgba(255, 255, 255, .08)),
        linear-gradient(135deg, rgba(0, 212, 255, .75), rgba(138, 43, 226, .9), rgba(255, 59, 212, .7));
    border: 1px solid rgba(255, 255, 255, .22);
}

.brand-title {
    font-weight: 900;
    font-size: 13px;
    line-height: 1.1;
}

.brand-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.hdr-center {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
}

.hdr-center::-webkit-scrollbar {
    display: none;
}

/* Model tabs */
.model-tabs {
    display: flex;
    gap: 5px;
}

.model-tab {
    padding: 7px 13px;
    border-radius: 20px;
    border: 1.5px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .06);
    color: rgba(255, 255, 255, .65);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s;
}

.model-tab:hover {
    border-color: rgba(138, 43, 226, .5);
    color: #fff;
}

.model-tab.active {
    background: linear-gradient(135deg, #7C3AED, #DB2777);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 3px 12px rgba(124, 58, 237, .5);
}

.hdr-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(0, 0, 0, .28);
    color: var(--text);
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, .12);
}

.icon-btn.danger:hover {
    background: rgba(255, 77, 109, .2);
    border-color: rgba(255, 77, 109, .4);
}

/* ── API PANEL ── */
.api-panel {
    position: relative;
    z-index: 2;
    display: flex;
    gap: 10px;
    padding: 8px 14px;
    background: rgba(0, 0, 0, .3);
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    flex-shrink: 0;
}

.api-input {
    flex: 1;
    background: rgba(255, 255, 255, .09);
    border: 1.5px solid rgba(255, 255, 255, .15);
    border-radius: 11px;
    padding: 9px 13px;
    color: #fff;
    font-size: 13px;
    transition: all .2s;
}

.api-input:focus {
    outline: none;
    border-color: rgba(138, 43, 226, .7);
    background: rgba(255, 255, 255, .12);
}

.api-input::placeholder {
    color: rgba(255, 255, 255, .35);
}

.api-save-btn {
    background: linear-gradient(135deg, #7C3AED, #6D28D9);
    border: none;
    border-radius: 11px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 9px 16px;
    cursor: pointer;
    transition: all .2s;
}

.api-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(124, 58, 237, .5);
}

/* ── BODY LAYOUT ── */
.bot-body {
    position: relative;
    z-index: 2;
    flex: 1;
    display: grid;
    grid-template-columns: 300px 1fr;
    overflow: hidden;
}

/* ── SIDEBAR ── */
.side {
    padding: 12px;
    border-right: 1px solid var(--stroke);
    background: rgba(0, 0, 0, .22);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(138, 43, 226, .3) transparent;
}

.side-card {
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--r);
    padding: 12px;
    margin-bottom: 10px;
}

.side-title {
    font-weight: 900;
    font-size: 12px;
    margin-bottom: 9px;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.side-hint {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.4;
    margin-top: 8px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, .16);
    background: rgba(0, 0, 0, .22);
    color: var(--text);
    cursor: pointer;
    transition: all .2s;
}

.chip:hover {
    background: rgba(255, 255, 255, .1);
}

.chip.active {
    border-color: rgba(0, 212, 255, .4);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, .1) inset;
    color: #fff;
}

.quick {
    display: grid;
    gap: 7px;
}

.qbtn {
    text-align: left;
    padding: 9px 11px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(0, 0, 0, .2);
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    transition: background .2s;
}

.qbtn:hover {
    background: rgba(255, 255, 255, .1);
}

.mini-form {
    display: grid;
    gap: 7px;
}

.input {
    width: 100%;
    border-radius: 13px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(0, 0, 0, .22);
    color: var(--text);
    padding: 9px 11px;
    outline: none;
    font-size: 13px;
    font-family: var(--font);
}

.input:focus {
    border-color: rgba(138, 43, 226, .5);
}

.mini-note {
    font-size: 11px;
    color: var(--muted2);
    line-height: 1.35;
}

/* ── CHAT AREA ── */
.chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#filePreviewArea {
    flex-shrink: 0;
}

.file-preview {
    background: rgba(124, 58, 237, .2);
    border: 1px solid rgba(124, 58, 237, .4);
    border-radius: 10px;
    padding: 7px 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, .8);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 14px 0;
}

.file-remove {
    cursor: pointer;
    color: rgba(220, 38, 38, .9);
    margin-left: auto;
    font-size: 15px;
}

.chat-stream {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(138, 43, 226, .3) transparent;
}

.chat-stream::-webkit-scrollbar {
    width: 4px;
}

.chat-stream::-webkit-scrollbar-thumb {
    background: rgba(138, 43, 226, .4);
    border-radius: 2px;
}

/* Messages */
.msg {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 9px;
    margin-bottom: 12px;
    align-items: flex-start;
    animation: msg-in .35s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.msg.me {
    grid-template-columns: 1fr 40px;
    direction: rtl;
}

.msg.me>* {
    direction: ltr;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .16);
    background: rgba(0, 0, 0, .2);
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 13px;
}

.msg.me .avatar {
    background: linear-gradient(135deg, rgba(0, 212, 255, .22), rgba(138, 43, 226, .22));
}

.msg.bot .avatar {
    background: linear-gradient(135deg, rgba(255, 59, 212, .22), rgba(255, 209, 102, .1));
}

.bubble {
    border-radius: 16px;
    padding: 11px 13px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(0, 0, 0, .18);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
    max-width: 85%;
}

.msg.me .bubble {
    background: rgba(124, 58, 237, .25);
    border-color: rgba(124, 58, 237, .35);
}

.bubble .meta {
    font-size: 10px;
    color: var(--muted2);
    margin-bottom: 5px;
}

.bubble .text {
    white-space: pre-wrap;
    font-size: 13.5px;
    line-height: 1.5;
    color: rgba(255, 255, 255, .95);
}

.bubble .text strong {
    color: #FFD700;
}

.bubble .text code {
    background: rgba(0, 0, 0, .4);
    padding: 2px 5px;
    border-radius: 5px;
    font-family: monospace;
    color: #00FFFF;
    font-size: 12px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .5);
    animation: typing-bounce 1.3s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: .15s;
}

.typing-dot:nth-child(3) {
    animation-delay: .3s;
}

@keyframes typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: .5;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ── COMPOSER ── */
.composer {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--stroke);
    background: rgba(0, 0, 0, .16);
    align-items: flex-end;
    flex-shrink: 0;
}

.attach-btn {
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 9px;
    transition: transform .2s;
    flex-shrink: 0;
    align-self: flex-end;
}

.attach-btn:hover {
    transform: scale(1.15) rotate(15deg);
}

.textarea {
    flex: 1;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(0, 0, 0, .22);
    color: var(--text);
    padding: 10px 12px;
    outline: none;
    resize: none;
    min-height: 40px;
    max-height: 130px;
    line-height: 1.4;
    font-family: var(--font);
    font-size: 14px;
    transition: border-color .2s;
}

.textarea:focus {
    border-color: rgba(138, 43, 226, .5);
}

.textarea::placeholder {
    color: rgba(255, 255, 255, .35);
}

.voice-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .16);
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    flex-shrink: 0;
}

.voice-btn:hover {
    background: rgba(255, 255, 255, .18);
}

.voice-btn.recording {
    background: rgba(220, 38, 38, .4);
    animation: rec-pulse 1.2s ease-in-out infinite;
}

@keyframes rec-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, .5);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(220, 38, 38, 0);
    }
}

.btn {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .16);
    background: rgba(255, 255, 255, .1);
    color: var(--text);
    padding: 9px 12px;
    cursor: pointer;
    font-weight: 900;
    transition: background .2s;
    flex-shrink: 0;
}

.btn:hover {
    background: rgba(255, 255, 255, .16);
}

.btn.primary {
    min-width: 48px;
    height: 40px;
    background: linear-gradient(135deg, rgba(0, 212, 255, .35), rgba(138, 43, 226, .4), rgba(255, 59, 212, .3));
    border-color: rgba(255, 255, 255, .2);
    font-size: 18px;
}

.btn.primary:hover {
    box-shadow: 0 4px 16px rgba(138, 43, 226, .4);
}

/* ── FOOTER LINE ── */
.footerline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--stroke);
    background: rgba(0, 0, 0, .14);
    font-size: 11px;
    color: var(--muted);
    flex-shrink: 0;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 99px;
    background: var(--good);
    box-shadow: 0 0 0 3px rgba(51, 214, 166, .12);
}

.dot.warn {
    background: var(--warn);
    box-shadow: 0 0 0 3px rgba(255, 209, 102, .12);
}

.dot.bad {
    background: var(--bad);
    box-shadow: 0 0 0 3px rgba(255, 77, 109, .12);
}

.spacer {
    flex: 1;
}

.tiny {
    color: var(--muted2);
}

.model-badge {
    color: rgba(167, 139, 250, .9);
    font-weight: 700;
}

/* ── MODALS ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, .82);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modal-fade .25s;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes modal-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-box {
    width: 100%;
    max-width: 500px;
    background: rgba(10, 5, 35, .98);
    backdrop-filter: blur(24px);
    border: 1.5px solid rgba(138, 43, 226, .45);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0, 0, 0, .85), 0 0 50px rgba(138, 43, 226, .25);
    animation: modal-scale .35s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes modal-scale {
    from {
        opacity: 0;
        transform: scale(.9) translateY(16px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    background: linear-gradient(135deg, rgba(124, 58, 237, .65), rgba(219, 39, 119, .45));
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.modal-title {
    color: #fff;
    font-size: 16px;
    font-weight: 800;
}

.modal-close {
    background: rgba(255, 255, 255, .18);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 14px;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255, 255, 255, .3);
    transform: rotate(90deg);
}

.modal-body {
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 65vh;
    overflow-y: auto;
}

.modal-body textarea,
.modal-body input,
.modal-select {
    width: 100%;
    background: rgba(255, 255, 255, .08);
    border: 1.5px solid rgba(255, 255, 255, .12);
    border-radius: 11px;
    padding: 12px 13px;
    color: #fff;
    font-size: 13px;
    resize: vertical;
    font-family: var(--font);
    transition: all .2s;
    cursor: pointer;
}

.modal-body textarea:focus,
.modal-body input:focus,
.modal-select:focus {
    outline: none;
    border-color: rgba(138, 43, 226, .65);
    background: rgba(255, 255, 255, .12);
}

.modal-body textarea::placeholder,
.modal-body input::placeholder {
    color: rgba(255, 255, 255, .35);
}

.modal-options {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.modal-options-label {
    color: rgba(255, 255, 255, .5);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    flex-shrink: 0;
}

.option-button {
    background: rgba(255, 255, 255, .08);
    border: 1.5px solid rgba(255, 255, 255, .14);
    border-radius: 18px;
    padding: 7px 14px;
    color: rgba(255, 255, 255, .65);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}

.option-button:hover {
    border-color: rgba(138, 43, 226, .5);
    color: #fff;
}

.option-button.active {
    background: linear-gradient(135deg, rgba(124, 58, 237, .65), rgba(219, 39, 119, .45));
    border-color: rgba(124, 58, 237, .6);
    color: #fff;
    box-shadow: 0 3px 10px rgba(124, 58, 237, .35);
}

.swap-btn {
    background: rgba(138, 43, 226, .3);
    border: 1px solid rgba(138, 43, 226, .5);
    border-radius: 11px;
    padding: 10px 14px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .2s;
}

.swap-btn:hover {
    background: rgba(138, 43, 226, .5);
}

.translate-result {
    background: rgba(51, 214, 166, .08);
    border: 1px solid rgba(51, 214, 166, .25);
    border-radius: 11px;
    padding: 13px;
    color: rgba(255, 255, 255, .9);
    font-size: 13px;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    justify-content: flex-end;
}

.modal-button {
    padding: 10px 20px;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}

.modal-button-cancel {
    background: rgba(255, 255, 255, .1);
    border: 1.5px solid rgba(255, 255, 255, .12);
    color: rgba(255, 255, 255, .7);
}

.modal-button-cancel:hover {
    background: rgba(255, 255, 255, .18);
    color: #fff;
}

.modal-button-primary {
    background: linear-gradient(135deg, #7C3AED, #DB2777);
    border: none;
    color: #fff;
    box-shadow: 0 3px 14px rgba(124, 58, 237, .45);
}

.modal-button-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 20px rgba(124, 58, 237, .65);
}

.modal-button-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

/* Settings */
.settings-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.settings-label {
    color: rgba(255, 255, 255, .55);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.settings-input {
    width: 100%;
    background: rgba(255, 255, 255, .08);
    border: 1.5px solid rgba(255, 255, 255, .12);
    border-radius: 11px;
    padding: 11px 13px;
    color: #fff;
    font-size: 13px;
    font-family: var(--font);
    transition: all .2s;
}

.settings-input:focus {
    outline: none;
    border-color: rgba(138, 43, 226, .65);
}

/* ── NOTIFICATION ── */
.s-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 20000;
    background: rgba(10, 5, 35, .97);
    backdrop-filter: blur(16px);
    border: 1.5px solid rgba(138, 43, 226, .45);
    border-radius: 14px;
    padding: 14px 18px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 32px rgba(0, 0, 0, .55);
    max-width: 340px;
    animation: notif-in .35s cubic-bezier(.34, 1.56, .64, 1);
    transition: all .3s;
}

.s-notification.hidden {
    opacity: 0;
    transform: translateX(380px);
    pointer-events: none;
}

@keyframes notif-in {
    from {
        opacity: 0;
        transform: translateX(380px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.s-notification.success {
    border-color: rgba(51, 214, 166, .5);
}

.s-notification.error {
    border-color: rgba(255, 77, 109, .5);
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .bot-shell {
        height: auto;
        min-height: 90vh;
    }

    .bot-body {
        grid-template-columns: 1fr;
    }

    .side {
        border-right: none;
        border-bottom: 1px solid var(--stroke);
    }

    .hdr-center {
        display: none;
    }
}