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

:root {
    --background: #080d18;
    --sidebar: #0d1422;
    --surface: #121d2e;
    --border: #243247;
    --text: #edf3ff;
    --muted: #8493aa;
    --accent: #00d9ff;
}

body {
    font-family: Tahoma, Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
}

.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

/* SIDEBAR */
.sidebar {
    width: 260px;
    background: var(--sidebar);
    border-left: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.logo {
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 4px;
    color: var(--accent);
    text-align: center;
}

#newChat {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 14px;
    border-radius: 12px;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu button {
    text-align: right;
    background: transparent;
    color: var(--muted);
    padding: 13px;
    border-radius: 9px;
}

.menu button:hover {
    background: var(--surface);
    color: var(--accent);
}

.profile {
    margin-top: auto;
    color: var(--muted);
    font-size: 12px;
}

.status {
    display: inline-block;
    width: 9px;
    height: 9px;
    background: #00e676;
    border-radius: 50%;
    margin-left: 8px;
}

/* MAIN */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header {
    height: 70px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h2 {
    font-size: 19px;
}

.header span {
    color: var(--muted);
    font-size: 12px;
}

#menuButton {
    display: none;
    background: transparent;
    color: var(--text);
    font-size: 22px;
}

/* CHAT */
.chat {
    flex: 1;
    overflow-y: auto;
    padding: 30px 20px;
}

.welcome {
    text-align: center;
    margin: 12vh auto 0;
}

.core {
    width: 90px;
    height: 90px;
    margin: auto auto 25px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 48px;
    color: var(--accent);
    box-shadow: 0 0 35px #00d9ff30;
}

.welcome h1 {
    font-size: 25px;
    margin-bottom: 14px;
}

.welcome p {
    color: var(--muted);
    line-height: 2;
}

/* MESSAGE */
.message {
    max-width: 750px;
    margin: 18px auto;
    padding: 16px;
    border-radius: 14px;
    line-height: 2;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.user-message {
    background: #17334b;
}

.bot-message {
    background: var(--surface);
    border: 1px solid var(--border);
}

/* INPUT */
.input-area {
    max-width: 850px;
    width: calc(100% - 40px);
    margin: 15px auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 15px;
}

.input-area input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 15px;
    padding: 10px;
}

.input-area input::placeholder {
    color: var(--muted);
}

.input-area button {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: transparent;
    color: var(--accent);
    font-size: 22px;
}

#sendButton {
    background: var(--accent);
    color: #06111b;
}

footer {
    text-align: center;
    color: var(--muted);
    font-size: 10px;
    padding: 12px;
}

/* MOBILE */
@media (max-width: 700px) {
    .sidebar {
        display: none;
        position: fixed;
        z-index: 10;
        top: 0;
        bottom: 0;
        right: 0;
    }

    .sidebar.open {
        display: flex;
    }

    #menuButton {
        display: block;
    }

    .header {
        padding: 0 15px;
    }

    .welcome h1 {
        font-size: 21px;
    }

    .welcome {
        margin-top: 10vh;
    }
}

/* STATES */
.message.typing {
    color: var(--muted);
    animation: pulse 1.2s ease-in-out infinite;
}

.message.error {
    border-color: #ff5252;
    color: #ffb4b4;
}

#sendButton:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

@keyframes pulse {
    50% { opacity: 0.45; }
}

/* PANEL */
.panel {
    margin: auto;
    width: min(92vw, 480px);
    max-height: 88vh;
    overflow-y: auto;
    background: var(--sidebar);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
}

.panel::backdrop { background: #000a; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-head button {
    background: transparent;
    color: var(--muted);
    font-size: 20px;
}

.panel .hint {
    color: var(--muted);
    font-size: 13px;
    line-height: 2;
    margin-bottom: 14px;
}

.panel label { display: block; font-size: 13px; margin-bottom: 6px; }

.panel select,
.panel input[type="text"] {
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 12px;
}

.panel button.primary {
    width: 100%;
    background: var(--accent);
    color: #06111b;
    padding: 13px;
    border-radius: 10px;
    font-weight: bold;
}

.panel button:disabled { opacity: .45; cursor: not-allowed; }

.panel .row { display: flex; gap: 8px; align-items: flex-start; }
.panel .row input { margin-bottom: 0; }
.panel .row button {
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 14px;
    white-space: nowrap;
}

#memoryList { list-style: none; margin-bottom: 14px; }
#memoryList li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.8;
}
#memoryList li button { background: transparent; color: #ff7b7b; font-size: 16px; }
#memoryList .empty { color: var(--muted); justify-content: center; }

.progress { margin-top: 14px; }
.bar { height: 8px; background: var(--surface); border-radius: 8px; overflow: hidden; }
#progressBar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress small { display: block; color: var(--muted); margin-top: 6px; font-size: 11px; direction: ltr; text-align: left; }

.status-text { margin-top: 12px; font-size: 13px; color: var(--muted); line-height: 2; }

.danger-zone { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.danger-zone button {
    background: transparent;
    color: #ff7b7b;
    border: 1px solid #5a2a2a;
    border-radius: 10px;
    padding: 11px;
    font-size: 13px;
}
