:root {
    --bg-body: #050505;
    --bg-sidebar: #000000;
    --bg-surface: #121212;
    --text-main: #ececec;
    --text-muted: #737373;
    --border: #262626;
    --accent: #ff0000;
    --accent-hover: #cc0000;
    --accent-glow: rgba(255, 0, 0, 0.4);
    --danger: #ef4444;
    --code-bg: #0d1117;
    --c-kwd: #ff7b72;
    --c-str: #a5d6ff;
    --c-num: #79c0ff;
    --c-com: #8b949e;
    --c-typ: #d2a8ff;
    --c-def: #d2a8ff;
    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-stack);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, width 0.3s ease;
    z-index: 20;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 25;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    color: var(--text-main);
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.sidebar:not(.collapsed) ~ .sidebar-toggle {
    left: 300px;
}

.sidebar:not(.collapsed) ~ .main-content {
    margin-left: 280px;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-weight: 700;
    letter-spacing: -0.5px;
    font-size: 1.1rem;
    color: var(--accent);
}

.version-badge {
    background: rgba(255, 0, 0, 0.2);
    color: var(--accent);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.version-select {
    background: #1a1a1a;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.version-select:hover {
    border-color: var(--accent);
    color: var(--text-main);
}

.new-chat-btn {
    width: 90%;
    margin: 1rem auto;
    padding: 0.75rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.new-chat-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem;
}

.history-item {
    padding: 0.8rem 1rem;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: 0.2s;
}

.history-item:hover {
    background: var(--bg-surface);
    color: var(--text-main);
}

.history-item.active {
    background: #1a1a1a;
    color: var(--text-main);
    font-weight: 500;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.clear-btn {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s;
}

.clear-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

#chat-feed {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    scroll-behavior: smooth;
}

#chat-feed::-webkit-scrollbar {
    width: 6px;
}

#chat-feed::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.msg-row {
    width: 100%;
    max-width: 800px;
    display: flex;
    margin-bottom: 2rem;
    animation: fadeUp 0.3s ease forwards;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-row.user {
    justify-content: flex-end;
}

.msg-content {
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.msg-row.user .msg-content {
    background: #262626;
    padding: 0.75rem 1.25rem;
    border-radius: 18px;
    border-top-right-radius: 4px;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.msg-row.bot .msg-content {
    width: 100%;
    padding-left: 1rem;
}

.msg-content p {
    margin-bottom: 0.8rem;
}

.msg-content strong {
    color: #fff;
    font-weight: 600;
}

.msg-content ul,
.msg-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
    color: #ccc;
}

.msg-content :not(pre)>code {
    background: rgba(255, 255, 255, 0.1);
    color: #ff7b72;
    font-family: 'Menlo', monospace;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.85em;
}

.code-wrapper {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 1rem 0;
    overflow: hidden;
    font-family: 'Menlo', monospace;
    font-size: 0.9em;
}

.code-header {
    background: #161b22;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #30363d;
    user-select: none;
}

.lang-tag {
    font-size: 0.75rem;
    color: #8b949e;
    text-transform: uppercase;
    font-weight: 600;
}

.copy-btn {
    background: transparent;
    border: none;
    color: #8b949e;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.copy-btn:hover {
    color: #fff;
}

.code-wrapper pre {
    padding: 1rem;
    overflow-x: auto;
    margin: 0;
    color: #e6edf3;
}

.tok-kwd {
    color: var(--c-kwd);
}

.tok-str {
    color: var(--c-str);
}

.tok-num {
    color: var(--c-num);
}

.tok-com {
    color: var(--c-com);
    font-style: italic;
}

.tok-typ {
    color: var(--c-typ);
}

.input-wrapper {
    padding: 1rem;
    display: flex;
    justify-content: center;
    background: linear-gradient(to top, var(--bg-body) 60%, transparent);
    z-index: 10;
}

.input-container {
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 6px;
    border-radius: 9999px;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 600px;
}

.input-container .model-label {
    background: rgba(255, 0, 0, 0.2);
    color: #ff0000;
    padding: 10px 18px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.input-container input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 16px;
    flex: 1;
    padding: 0 4px;
    min-width: 0;
}

.input-container input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#send-btn {
    background: #ff0000;
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.2s;
    align-self: flex-end;
}

#send-btn:hover {
    background: #cc0000;
    transform: scale(1.05);
}

#send-btn:active {
    transform: scale(0.95);
}

#send-btn svg {
    width: 20px;
    height: 20px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: #18181b;
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.open .modal-box {
    transform: scale(1);
}

.modal-box h3 {
    margin-bottom: 0.5rem;
    color: #fff;
}

.modal-box p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-modal {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancel {
    background: #27272a;
    color: #fff;
}

.btn-confirm {
    background: var(--danger);
    color: #fff;
}

.typing {
    display: flex;
    gap: 4px;
    padding: 10px 0;
}

.dot {
    width: 5px;
    height: 5px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .sidebar-toggle {
        display: none;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .input-container {
        border-radius: 9999px;
        max-width: 90%;
    }

    .input-container .model-label {
        padding: 6px 12px;
        font-size: 12px;
    }

    #send-btn {
        width: 36px;
        height: 36px;
    }
}

/* Settings Modal Styles */
.setting-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.setting-group label {
    display: block;
    color: #fff;
    margin-bottom: 0.8rem;
    font-weight: 500;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.slider-container input[type=range] {
    flex: 1;
    accent-color: var(--accent);
    cursor: pointer;
}

.setting-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.8rem;
    line-height: 1.4;
}