* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: #212121;
    color: #ececec;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: 270px;
    background: #171717;
    border-right: 1px solid #2f2f2f;
    display: flex;
    flex-direction: column;
    padding: 12px;
}

.brand {
    font-size: 18px;
    font-weight: 700;
    padding: 12px;
    margin-bottom: 10px;
}

.new-chat {
    border: 1px solid #3f3f3f;
    background: transparent;
    color: #ececec;
    padding: 12px;
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 16px;
}

.new-chat:hover {
    background: #2a2a2a;
}

.history-title {
    color: #999;
    font-size: 13px;
    margin: 10px 0;
    padding-left: 4px;
}

#conversationList {
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.history-item {
    border-radius: 8px;
    color: #cfcfcf;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 4px;

    display: flex;
    align-items: center;
    gap: 6px;
}

.history-item-title {
    flex: 1;
    min-width: 0;
    padding: 10px 6px 10px 10px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delete-chat-btn {
    width: 32px;
    height: 32px;

    margin-right: 5px;

    border: none;
    border-radius: 7px;

    background: transparent;
    color: #aaa;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 15px;
}

.delete-chat-btn:hover {
    background: #454545;
    color: #ffffff;
}

.history-item:hover {
    background: #2a2a2a;
}

.history-item.active {
    background: #303030;
    color: #ffffff;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #212121;
}

.topbar {
    height: 56px;
    border-bottom: 1px solid #2f2f2f;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    font-size: 16px;
    font-weight: 600;
}

.status {
    font-size: 13px;
    color: #aaa;
    font-weight: 400;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px 20px 150px;
}

.welcome {
    max-width: 760px;
    margin: 110px auto 0;
    text-align: center;
}

.welcome h1 {
    font-size: 34px;
    margin-bottom: 10px;
    font-weight: 650;
}

.welcome p {
    color: #aaa;
    font-size: 16px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 760px;
    margin: 30px auto;
}

.card {
    border: 1px solid #3a3a3a;
    border-radius: 14px;
    padding: 16px;
    color: #ccc;
    cursor: pointer;
    text-align: left;
}

.card:hover {
    background: #2a2a2a;
}

.message {
    max-width: 820px;
    margin: 0 auto 28px;
    display: flex;
    gap: 12px;
    line-height: 1.65;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message.user .avatar {
    order: 2;
}

.message.user .message-content {
    order: 1;
    background: #303030;
    border: 1px solid #3f3f3f;
    border-radius: 18px 18px 4px 18px;
    padding: 12px 16px;
    max-width: 70%;
}

.message.assistant .message-content {
    background: transparent;
    padding: 0;
    max-width: 75%;
}

.file-message {
    max-width: 820px;
    margin: 0 auto 20px;

    display: flex;
    justify-content: flex-end;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 10px;

    max-width: 340px;

    background: #303030;
    border: 1px solid #444;
    border-radius: 14px;

    padding: 10px 12px;
}

.file-card-icon {
    width: 36px;
    height: 36px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #3a3a3a;
    border-radius: 8px;

    color: #ececec;
}

.file-card-info {
    min-width: 0;
}

.file-card-name {
    font-size: 14px;
    font-weight: 600;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-card-type {
    margin-top: 2px;

    font-size: 11px;
    color: #aaa;

    text-transform: uppercase;
}

.rag-sources {
    max-width: 820px;
    margin: -12px auto 28px;
    padding-left: 46px;
}

.rag-sources-title {
    color: #aaa;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
}

.rag-source-item {
    display: inline-block;

    background: #2a2a2a;
    border: 1px solid #3f3f3f;
    border-radius: 9px;

    padding: 6px 9px;
    margin: 3px 5px 3px 0;

    color: #ccc;
    font-size: 12px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
}

.user-avatar {
    background: #5a4fcf;
}

.bot-avatar {
    background: #10a37f;
}

.message-content {
    color: #ececec;
    font-size: 16px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.tool-progress {
    max-width: 820px;
    margin: 0 auto 14px;
    display: flex;
    justify-content: flex-start;
}

.tool-progress-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #2a2a2a;
    border: 1px solid #3f3f3f;
    color: #cfcfcf;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
}

.approval-btn {
    border: 1px solid #555;
    background: #303030;
    color: #ececec;
    padding: 7px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}

.approval-btn:hover {
    background: #3d3d3d;
}

.approval-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.tool-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid #555;
    border-top: 2px solid #10a37f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.tool-check {
    color: #10a37f;
    font-weight: bold;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.input-area {
    position: fixed;
    bottom: 0;
    left: 270px;
    right: 0;
    background: linear-gradient(to top, #212121 82%, transparent);
    padding: 24px 20px;
}

.input-wrapper {
    max-width: 820px;
    margin: 0 auto;
    background: #303030;
    border: 1px solid #444;
    border-radius: 18px;
    display: flex;
    align-items: flex-end;
    padding: 12px;
    box-shadow: 0 0 18px rgba(0, 0, 0, 0.25);
}

.attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: #cfcfcf;
    cursor: pointer;
    font-size: 20px;
    margin-right: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: #3a3a3a;
    color: #ffffff;
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: #ececec;
    font-size: 16px;
    min-height: 30px;
    max-height: 170px;
    line-height: 1.5;
    padding: 7px;
}

textarea::placeholder {
    color: #aaa;
}

.model-select {
    height: 40px;
    max-width: 135px;
    background: #262626;
    color: #ececec;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 0 8px;
    margin-left: 8px;
    outline: none;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
}

.model-select:hover {
    background: #333333;
}

.model-select option {
    background: #262626;
    color: #ececec;
}

.language-select {
    height: 40px;
    width: 58px;

    background: #262626;
    color: #ececec;

    border: 1px solid #444;
    border-radius: 12px;

    padding: 0 8px;
    margin-left: 8px;

    outline: none;
    font-size: 13px;
    cursor: pointer;

    flex-shrink: 0;
}

.language-select:hover {
    background: #333333;
}

.language-select option {
    background: #262626;
    color: #ececec;
}

.mic-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: #cfcfcf;
    cursor: pointer;
    font-size: 18px;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mic-btn:hover {
    background: #3a3a3a;
    color: #ffffff;
}

.mic-btn.recording {
    background: #ef4444;
    color: #ffffff;
    animation: pulseMic 1.2s infinite;
}

@keyframes pulseMic {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: #ececec;
    color: #111;
    cursor: pointer;
    font-size: 18px;
    margin-left: 8px;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #ffffff;
}

.send-btn:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
}

.notice {
    color: #aaa;
    font-size: 12px;
    max-width: 820px;
    margin: 8px auto 0;
    text-align: center;
}

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

    .input-area {
        left: 0;
    }

    .cards {
        grid-template-columns: 1fr;
    }

    .message.user .message-content,
    .message.assistant .message-content {
        max-width: 82%;
    }

    .model-select {
        max-width: 95px;
        font-size: 11px;
        padding: 0 6px;
    }

    .mic-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
        margin-left: 6px;
    }
}