@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

body {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background-color: #f8f7f4;
}

.message {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.welcome-message h1 {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-weight: 700;
    color: #2d2d2d;
}

.welcome-message p {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-weight: 400;
    color: #666;
}

#userInput {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: #faf0e6;
    border-bottom: 1px solid #e5e5e5;
    height: 40px;
    padding: 0 0.5rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    will-change: transform;
}

.top-bar .logo img {
    margin-top: -4px;
}
.top-bar .logo span {
    margin-left: -6px;
}

.top-bar-left, .top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.top-bar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.top-bar .logo {
    display: flex;
    align-items: center;
    gap: 0rem;
    color: #2d2d2d;
    font-weight: 600;
    font-size: 1.1rem;
}

.top-bar .logo a {
    display: flex;
    align-items: center;
    gap: 0rem;
    text-decoration: none;
    color: inherit;
}

.top-bar .logo a img {
    margin-top: 4px;
}

.top-bar .logo a span {
    margin-left: -8px;
}

.top-bar .logo:hover {
    opacity: 0.8;
}

.top-bar-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    background: #f8f7f4;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    will-change: transform;
}

.top-bar-button:hover {
    background: #f0f0f0;
    color: #2d2d2d;
    transform: translateY(-1px);
}

.chat-history-sidebar {
    position: fixed;
    top: 40px;
    right: -300px;
    width: 300px;
    height: calc(100vh - 40px);
    background: #fff;
    border-left: 1px solid #e5e5e5;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 998;
    overflow-y: auto;
    padding: 1.5rem;
    visibility: hidden;
    opacity: 0;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.05);
    will-change: transform, opacity;
}

.chat-history-sidebar.active {
    right: 0;
    visibility: visible;
    opacity: 1;
}

.chat-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 1rem 0 2rem 0;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e5e5e5;
}

.chat-history-header h2 {
    font-size: 1.25rem;
    color: #2d2d2d;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.chat-date-group {
    margin-bottom: 2rem;
    background: #fff;
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid #e5e5e5;
}

.chat-date-label {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e5e5e5;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: #f8f7f4;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e5e5e5;
    will-change: transform;
}

.chat-item:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.chat-item.active {
    background: #f0f0f0;
    border-color: #d1d1d1;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #2d2d2d;
}

.chat-item:hover .chat-item-title,
.chat-item.active .chat-item-title {
    color: #2d2d2d;
}

.chat-item-time {
    font-size: 0.75rem;
    color: #666;
}

.chat-item:hover .chat-item-time,
.chat-item.active .chat-item-time {
    color: #666;
}

.chat-item-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chat-item:hover .chat-item-actions {
    opacity: 1;
}

.chat-item-button {
    padding: 0.25rem;
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chat-item-button:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    height: calc(100vh - 40px);
    margin-top: 40px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
    background-color: #f8f7f4;
}

.main-content.sidebar-active {
    padding-right: calc(300px + 1rem);
}

.chat-container {
    flex: 1;
    background: #fff;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 80px;
    border-radius: 10px;
    overflow-y: auto;
    mask-image: -webkit-radial-gradient(white, black);
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.main-content.sidebar-active .chat-container {
    margin-right: 0;
}

.welcome-message {
    text-align: center;
    padding: 2rem;
}

.welcome-message h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #2d2d2d;
}

.welcome-message p {
    color: #666;
    font-size: 1.1rem;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 85%;
    line-height: 1.5;
    animation: fadeIn 0.2s ease-out;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
    backface-visibility: hidden;
    perspective: 1000px;
    transform: translateZ(0);
}

.user-message {
    background: #f0f0f0;
    color: #2d2d2d;
    margin-left: auto;
    margin-right: 0;
    border-bottom-right-radius: 4px;
    font-size: 0.88rem;
    border: 1px solid #e5e5e5;
}

.main-content.sidebar-active .user-message {
    margin-right: 0;
}

.ai-message {
    white-space: pre-wrap;
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    line-height: 1.6;
    padding: 1rem 1.25rem;
    background: #f8f7f4;
    border: 1px solid #e5e5e5;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    color: #2d2d2d;
    font-size: 0.88rem;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #f8f7f4;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    margin-right: auto;
    animation: fadeIn 0.2s ease-out;
    will-change: transform, opacity;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #666;
    border-radius: 50%;
    display: inline-block;
    animation: blink 1.4s infinite both;
    will-change: opacity;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

.input-container {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 20px;
    z-index: 999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: min(800px, 90%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    will-change: transform;
}

.main-content.sidebar-active .input-container {
    width: min(800px, calc(90% - 300px));
    transform: translateX(calc(-50% - 150px));
}

#userInput {
    flex: 1;
    padding: 0.75rem 1rem;
    background: #f8f7f4;
    border: 1px solid #e5e5e5;
    border-radius: 16px;
    color: #2d2d2d;
    font-size: 0.9375rem;
    resize: none;
    min-height: 40px;
    max-height: 150px;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#userInput:focus {
    outline: none;
    border-color: #d1d1d1;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

#sendButton {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.25rem;
    background: #2d2d2d;
    border: none;
    border-radius: 14px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 42px;
    white-space: nowrap;
    will-change: transform;
}

#sendButton:hover {
    background: #1a1a1a;
    transform: translateY(-1px);
}

#sendButton:active {
    transform: translateY(0);
}

.chat-container::-webkit-scrollbar,
.chat-history-sidebar::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track,
.chat-history-sidebar::-webkit-scrollbar-track {
    background: #f8f7f4;
}

.chat-container::-webkit-scrollbar-thumb,
.chat-history-sidebar::-webkit-scrollbar-thumb {
    background: #d1d1d1;
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover,
.chat-history-sidebar::-webkit-scrollbar-thumb:hover {
    background: #b1b1b1;
}

.bullet-point {
    padding: 0.25rem 0;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.list-item {
    padding: 0.25rem 0 0.25rem 1.5rem;
}

.section-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.section-spacing {
    height: 0.75rem;
}

@media (max-width: 768px) {
    .chat-history-sidebar {
        width: 100%;
        right: -100%;
        z-index: 1000;
    }

    .main-content.sidebar-active {
        margin-right: 0;
        opacity: 0.5;
        pointer-events: none;
    }

    .main-content.sidebar-active .input-container {
        right: 1rem;
        opacity: 0.5;
        pointer-events: none;
    }

    .top-bar {
        padding: 0.375rem 0.75rem;
    }

    .main-content {
        padding: 0.75rem;
    }

    .chat-container {
        padding: 1rem;
    }

    .message {
        max-width: 90%;
        padding: 0.875rem 1rem;
    }

    .welcome-message h1 {
        font-size: 1.5rem;
    }

    .welcome-message p {
        font-size: 1rem;
    }

    .input-container {
        width: calc(100% - 2rem);
        padding: 0.625rem;
    }

    .main-content.sidebar-active .input-container {
        width: calc(100% - 2rem);
        transform: translateX(-50%);
    }

    #userInput {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }

    #sendButton {
        padding: 0 1rem;
        min-height: 38px;
    }
}