@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;900&family=Poppins:wght@300;400;500;600;700&family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

:root {
    --bg-main: #f8f7f4;
    /* Athlan light cream/off-white */
    --bg-sidebar: #f0efea;
    /* Slightly darker clean sidebar */
    --bg-input: #ffffff;
    --text-primary: #0f0f10;
    /* Dark charcoal for text */
    --text-secondary: #5d6675;
    --border-color: rgba(0, 0, 0, 0.06);
    --accent-color: #ff9f1c;
    /* Athlan Orange */
    --accent-purple: #ff6b00;
    /* Darker orange/coral accent */
    --user-msg-bg: rgba(255, 159, 28, 0.06);
    /* Light orange glass */
    --ai-msg-bg: transparent;
    --card-bg: #ffffff;
    --glow-shadow: 0 0 20px rgba(255, 159, 28, 0.2);
    --transition: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    --glass-border: rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Poppins', 'Noto Sans KR', sans-serif;
    background-color: var(--bg-main);
    background-image:
        radial-gradient(circle at 15% 15%, rgba(255, 159, 28, 0.06) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(255, 107, 0, 0.05) 0%, transparent 40%),
        linear-gradient(to bottom, #f8f7f4 0%, #f0efea 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    display: flex;
    height: 100dvh;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--glass-border);
    transition: width 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
}

.sidebar-inner {
    width: 280px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar.hidden {
    width: 0;
    border-right-width: 0;
}

.sidebar-header {
    padding: 15px 20px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 10px 20px;
}

.sidebar-logo {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 0 5px var(--accent-color));
}

.sidebar-brand-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 1px;
    color: var(--text-primary);
}

.btn-primary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-purple) 100%);
    color: #ffffff;
    border: none;
    padding: 12px 15px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(255, 159, 28, 0.2);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(255, 159, 28, 0.35);
    transform: translateY(-2px);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 5px 15px 20px 15px;
}

.sidebar-category {
    margin-bottom: 25px;
}

.sidebar-category-header {
    padding: 20px 10px 8px 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: #303030;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 1;
    border-bottom: 1px solid rgba(255, 159, 28, 0.2);
    margin-bottom: 10px;
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 2px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 2px 14px;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    margin-bottom: 4px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.history-item .icon-sm {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0;
    transition: var(--transition);
}

.history-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
    color: var(--text-primary);
    border-color: rgba(0, 0, 0, 0.02);
}

.history-item:hover .icon-sm {
    color: var(--accent-color);
    transform: scale(1.1);
}

.history-item.active {
    background: rgba(255, 159, 28, 0.08);
    color: var(--accent-color);
    border: 1px solid rgba(255, 159, 28, 0.15);
    font-weight: 600;
    box-shadow: none;
}

.history-item.active .icon-sm {
    color: var(--accent-color);
    filter: drop-shadow(0 0 2px var(--accent-color));
}

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 190px;
}

.delete-btn {
    display: none;
    color: var(--text-secondary);
    width: 14px;
    height: 14px;
    margin-left: auto;
    transition: color 0.2s;
}

.history-item:hover .delete-btn {
    display: block;
}

.delete-btn:hover {
    color: #ff4a4a;
}


/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.topbar {
    display: flex;
    align-items: center;
    padding: 15px 24px;
    background: rgba(248, 247, 244, 0.6);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 90;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.04);
    color: var(--accent-color);
}

/* Custom Model Selector */
.custom-model-selector {
    position: relative;
    display: inline-block;
    margin-left: 10px;
}

.model-trigger-btn {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 10px;
    transition: var(--transition);
    outline: none;
}

.model-trigger-btn:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 12px rgba(255, 159, 28, 0.15);
    background: rgba(255, 159, 28, 0.03);
}

.model-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 159, 28, 0.15);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    width: 320px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 200;
}

.model-dropdown-menu.active {
    display: flex;
    animation: popupFadeInDown 0.2s ease forwards;
}

/* Model Dropdown Items */
.model-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    width: 100%;
    color: var(--text-primary);
    transition: var(--transition);
    position: relative;
    font-family: inherit;
    outline: none;
}

.model-option:hover {
    background-color: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.05);
}

.model-option.premium {
    background: linear-gradient(135deg, rgba(255, 159, 28, 0.03) 0%, rgba(255, 107, 0, 0.03) 100%);
    border-color: rgba(255, 159, 28, 0.15);
}

.model-option.premium:hover {
    background: linear-gradient(135deg, rgba(255, 159, 28, 0.06) 0%, rgba(255, 107, 0, 0.06) 100%);
    border-color: rgba(255, 159, 28, 0.25);
}

.model-option-icon {
    margin-top: 2px;
    color: var(--accent-color);
    display: flex;
}

.model-option-icon svg {
    width: 16px;
    height: 16px;
}

.model-option-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.model-option-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.model-option-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: keep-all;
}

.model-selected-check {
    width: 16px;
    height: 16px;
    color: var(--accent-color);
    display: none;
    margin-top: 4px;
    position: absolute;
    right: 12px;
}

.model-option.selected .model-selected-check {
    display: flex;
}

.model-upsell-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 12px;
    border: 1px solid rgba(0, 240, 255, 0.3);
    background: rgba(0, 240, 255, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Layout Structures */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: all 0.5s ease;
}

.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.chat-wrapper::-webkit-scrollbar {
    width: 6px;
}

.chat-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.chat-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Empty State logic */
.main-content.is-empty .chat-wrapper {
    display: none;
}

.main-content.is-empty .main-area {
    overflow: visible;
    justify-content: center;
    align-items: center;
}

.main-content:not(.is-empty) .welcome-message {
    display: none;
}

.main-content:not(.is-empty) .main-area {
    justify-content: flex-end;
}

/* Chat Area */
.chat-container {
    padding: 20px 0;
    display: flex;
    justify-content: center;
    width: 100%;
}

.main-content.is-empty {
    justify-content: center;
    position: relative;
    height: 100vh;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 220px;
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
}

.welcome-message {
    text-align: center;
    padding: 0 20px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.welcome-message p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
    padding: 0 25px;
    word-break: keep-all;
}

.welcome-logo {
    width: 140px;
    height: auto;
    margin-bottom: 40px;
    filter: drop-shadow(0 0 15px rgba(255, 159, 28, 0.25));
}

.welcome-message h1 {
    font-family: 'Orbitron', 'Noto Sans KR', sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 15px;
}

.message {
    display: flex;
    gap: 16px;
    line-height: 1.8;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}



.user .message-avatar {
    background-color: rgb(39 160 248 / 10%);
    border: 1px solid rgb(24 147 221 / 30%);
    color: #074f98;
    box-shadow: 0 0 10px rgb(188 188 188 / 15%);
}

.user .message-avatar svg {
    width: 18px;
    height: 18px;
}

.ai .message-avatar {
    background-color: #ff9f1c;
    color: #ffffff;
    border: 1px solid rgba(156, 91, 3, 0.2);
    box-shadow: 0 0 10px rgba(255, 159, 28, 0.2);
}

.ai .message-avatar svg {
    width: 18px;
    height: 18px;
}

.message-content {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 16px;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: 15px;
    min-width: 0;
}

.user .message-content {
    background: var(--user-msg-bg);
    border: 1px solid rgba(188, 44, 255, 0.2);
    box-shadow: 0 0 12px rgba(188, 44, 255, 0.05);
    border-radius: 16px 16px 0 16px;
}

.ai .message-content {
    background-color: transparent;
    padding: 8px 0;
}

/* Markdown typography inside AI message */
.prose {
    color: var(--text-primary);
}

.prose p {
    margin-bottom: 1em;
}

.prose p:last-child {
    margin-bottom: 0;
}

.code-block-wrapper {
    margin: 1.5em 0;
    border-radius: 12px;
    background-color: #0f1015;
    /* Maintain high-contrast dark block for code styling */
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    color: #94a3b8;
    font-size: 13px;
    background-color: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.code-header-left svg {
    width: 14px;
    height: 14px;
    color: var(--accent-color);
}

.code-header .code-lang {
    text-transform: capitalize;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.code-header .copy-code-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    transition: var(--transition);
    outline: none;
    position: relative;
}

.code-header .copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-color);
}

.code-header .copy-code-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 5px;
    background-color: #f0efea;
    border: 1px solid rgba(255, 159, 28, 0.3);
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 10;
}

.code-header .copy-code-btn:hover::after {
    opacity: 1;
    visibility: visible;
}

.code-header .copy-code-btn svg {
    width: 14px;
    height: 14px;
}

.prose pre {
    background-color: transparent;
    padding: 16px;
    overflow-x: auto;
    margin: 0;
    line-height: 23px;
}

.prose code {
    font-family: 'Courier New', Courier, monospace;
    background-color: rgba(255, 159, 28, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--accent-purple);
    border: 1px solid rgba(255, 159, 28, 0.15);
}

.prose pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.9em;
    color: #e2e8f0;
    border: none;
}

.prose ul,
.prose ol {
    padding-left: 20px;
    margin-bottom: 1em;
}

.prose hr {
    border: none;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
    margin: 28px 0;
}

/* Action Menu Dropdown */
.action-menu-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 2px;
}

.action-toggle-btn {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--glass-border);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

.action-toggle-btn:hover {
    background: rgba(255, 159, 28, 0.08);
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(255, 159, 28, 0.15);
}

.action-toggle-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-toggle-btn.active svg {
    transform: rotate(45deg);
    color: var(--accent-color);
}

.action-dropdown {
    position: absolute;
    left: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 159, 28, 0.15);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    width: 270px;
    padding: 8px 0;
    display: none;
    flex-direction: column;
    z-index: 9999;
}

.action-dropdown.active {
    display: flex;
}

/* 상태별 오픈 방향 및 애니메이션 */
.main-content.is-empty .action-dropdown {
    top: calc(100% + 15px);
    bottom: auto;
}

.main-content.is-empty .action-dropdown.active {
    animation: popupFadeInDown 0.2s ease forwards;
}

.main-content:not(.is-empty) .action-dropdown {
    bottom: calc(100% + 15px);
    top: auto;
}

.main-content:not(.is-empty) .action-dropdown.active {
    animation: popupFadeInUp 0.2s ease forwards;
}

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

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

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

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

.action-item {
    background: transparent;
    border: none;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 18px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14.5px;
    transition: var(--transition);
    text-align: left;
    font-family: inherit;
    outline: none;
}

.action-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.action-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--accent-color);
}

.action-item-disabled {
    color: #8f9bb3;
    cursor: default;
}

.action-item-disabled:hover {
    background-color: transparent;
}

.action-item-disabled svg {
    color: #8f9bb3;
}

.action-item-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.action-item-text .sub-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 3px;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--glass-border);
    margin: 8px 18px;
}

.has-submenu {
    justify-content: space-between;
    position: relative;
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;
}

.submenu-trigger {
    display: flex;
    align-items: center;
    gap: 14px;
}

.has-submenu .icon-sm {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.action-sub-dropdown {
    position: absolute;
    left: 100%;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 159, 28, 0.15);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    width: 160px;
    padding: 8px 0;
    display: none;
    flex-direction: column;
    z-index: 101;
}

/* 메인 박스가아래로 열릴 때는 서브 메뉴도 부모(더보기 줄) 위쪽 끝선에 맞춤 */
.main-content.is-empty .action-sub-dropdown {
    top: -10px;
    bottom: auto;
}

.main-content.is-empty .has-submenu:hover .action-sub-dropdown {
    display: flex;
    animation: popupFadeInDown 0.2s ease forwards;
}

/* 640px 이하 모바일용 레이아웃 분기 처리 */
@media (max-width: 640px) {

    /* 1. 모바일 환경 더 보기 병합화 */
    .submenu-trigger,
    .has-submenu>.icon-sm {
        display: none !important;
    }

    .has-submenu {
        padding: 0 !important;
        background: transparent !important;
        cursor: default;
    }

    .has-submenu:hover {
        background: transparent !important;
    }

    .action-sub-dropdown {
        position: static !important;
        display: flex !important;
        width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        left: auto !important;
        top: auto !important;
        bottom: auto !important;
        animation: none !important;
    }

    .action-sub-dropdown .action-item {
        padding-left: 18px !important;
    }

    /* 2. 모바일 환경 입력창 바닥에 고정 (채팅이 없더라도) */
    .main-content.is-empty .main-area {
        display: block;
        height: 100%;
    }

    .main-content.is-empty .welcome-message {
        position: fixed;
        top: 35vh;
        /* 입력창 높이 변화에 영향받지 않도록 화면 기준 고정 */
        left: 0;
        right: 0;
        margin: 0;
        z-index: 10;
    }

    /* 모바일에서는 입력창이 바닥에 있으므로 액션메뉴도 무조건 위로 열림 */
    .main-content.is-empty .action-dropdown {
        top: auto !important;
        bottom: calc(100% + 15px) !important;
    }

    .main-content.is-empty .action-dropdown.active {
        animation: popupFadeInUp 0.2s ease forwards !important;
    }
}

/* 메인 박스가 위로 열릴 때는 서브 메뉴도 부모(더보기 줄) 아래쪽 끝선에 맞춤 */
.main-content:not(.is-empty) .action-sub-dropdown {
    bottom: -10px;
    top: auto;
}

.main-content:not(.is-empty) .has-submenu:hover .action-sub-dropdown {
    display: flex;
    animation: popupFadeInUp 0.2s ease forwards;
}

/* Input Area */
.input-section {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 55px 20px 15px 20px;
    background: linear-gradient(180deg, rgba(248, 247, 244, 0) 0%, rgba(248, 247, 244, 0.8) 30px, #f8f7f4 100%);
    z-index: 100;
}

/* PC 초기 화면 전용 레이아웃: 위에서 아래로 흐르는 중앙 정렬 */
@media (min-width: 769px) {
    .main-content.is-empty .input-section {
        position: absolute;
        top: 25vh;
        bottom: auto;
    }

    .main-content.is-empty .welcome-message {
        margin-bottom: 40px;
    }
}

.input-container {
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    padding: 15px 15px 50px 15px;
    position: relative;
    min-height: 100px;
    max-height: 400px;
    transition: var(--transition);
    width: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}

.input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04), 0 0 15px rgba(255, 159, 28, 0.15);
}

.input-wrapper.drag-active {
    border-color: var(--accent-color);
    background-color: rgba(255, 159, 28, 0.03);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04), 0 0 20px rgba(255, 159, 28, 0.25);
}

#chat-input:focus {
    outline: none;
}

#chat-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 15px 0;
    font-size: 16px;
    resize: none;
    line-height: 1.6;
    overflow-y: auto;
    min-height: 50px;
}

#chat-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
    font-size: 15px;
}

/* 버튼들을 박스 하단에 고정 */
.input-wrapper>.action-menu-container {
    position: absolute;
    left: 15px;
    bottom: 12px;
}

.input-wrapper>.send-btn {
    position: absolute;
    right: 15px;
    bottom: 12px;
}

@media (max-width: 768px) {
    .input-wrapper {
        min-height: 110px;
        padding: 12px 12px 45px 12px;
        border-radius: 16px;
    }

    #chat-input {
        font-size: 15px;
        min-height: 50px;
    }

    #chat-input::placeholder {
        font-size: 13px;
        line-height: 15px;
    }
}

#chat-input::-webkit-scrollbar {
    width: 5px;
}

#chat-input::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
}

.send-btn {
    background-color: var(--accent-color);
    color: #ffffff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(255, 159, 28, 0.25);
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 6px 15px rgba(255, 159, 28, 0.4);
}

.send-btn:disabled {
    opacity: 0.35;
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

.disclaimer {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    padding-bottom: env(safe-area-inset-bottom, 20px);
    text-align: center;
}

/* PC 환경 기본 단축키 안내 */
.disclaimer::after {
    content: "(줄 바꿈 : Shift + Enter)";
    display: block;
    margin-top: 3px;
    opacity: 0.7;
}

/* 모바일 환경 단축키 안내 변경 */
@media (max-width: 768px) {
    .disclaimer::after {
        content: "(줄 바꿈 : Enter)";
    }
}

/* Loading Dots */
.dots-loading {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 10px 0;
}

.dots-loading span {
    width: 6px;
    height: 6px;
    background-color: var(--text-primary);
    border-radius: 50%;
    animation: flash 1.4s infinite ease-in-out both;
}

.dots-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.dots-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes flash {

    0%,
    80%,
    100% {
        opacity: 0.2;
    }

    40% {
        opacity: 1;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 900;
    /* 입력창(100)보다 높게 설정하여 완벽히 덮음 */
    transition: opacity 0.3s;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-main);
    position: relative;
    transition: margin-left 0.3s;
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1000;
        /* 오버레이(900)보다 높게 설정하여 최상단에 위치 */
        height: 100%;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        transition: transform 0.3s ease;
        transform: translateX(0);
    }

    .sidebar.hidden {
        width: 260px;
        /* 모바일에서는 컨텐츠가 찌그러지지 않고 영역이 유지된 채로 슬라이딩 */
        transform: translateX(-100%);
    }

    .message-content {
        max-width: 100%;
        /* 화면 꽉 차게 변경 */
        font-size: 14px;
    }

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

    .welcome-logo {
        width: 120px;
        margin-bottom: 30px;
    }

    .input-wrapper {
        border-radius: 14px;
        padding: 8px 10px 8px 14px;
    }

    #chat-input {
        font-size: 14px;
    }

    .send-btn {
        width: 28px;
        height: 28px;
    }
}

/* 450px 이하 모바일 전용 (아이디 생략) */
@media (max-width: 450px) {
    .user-id-domain {
        display: none;
    }
}

/* 태블릿 비율 이하 (1120px) 사용성 보정 */
@media (max-width: 1200px) {
    .input-wrapper {
        margin-bottom: 0;
        /* 태블릿에서는 하단 마진을 삭제하여 아래로 최대한 내림 */
    }
}

/* Image Preview Styles */
.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 15px 0 15px;
    width: 100%;
}

.image-preview-container:empty {
    display: none;
}

.image-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background-color: #fff;
    flex-shrink: 0;
    animation: fadeIn 0.3s ease;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    transition: background 0.2s;
}

.image-preview-item .remove-btn:hover {
    background: rgba(255, 0, 0, 0.7);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Update input-wrapper for preview */
.input-wrapper {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 850px !important;
    min-height: 52px;
}



.input-wrapper>.action-menu-container {
    position: absolute;
    left: 10px;
    bottom: 9px;
}

.input-wrapper>textarea {
    display: block !important;
    width: 100% !important;
    padding-left: 55px !important;
    padding-right: 55px !important;
    padding-top: 14px !important;
    padding-bottom: 14px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    background: transparent !important;
}

.input-wrapper>.send-btn {
    position: absolute;
    right: 10px;
    bottom: 9px;
}

/* Chat Attached Image Styles */
.message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-attached-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid var(--border-color);
}

.chat-attached-image:hover {
    transform: scale(1.02);
}

/* Suggestion Links */
.suggestion-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    background-color: rgba(59, 130, 246, 0.05);
    transition: all 0.2s ease;
    border: 1px dashed var(--accent-color);
    display: inline-block;
    margin: 2px 0;
}

.suggestion-link:hover {
    background-color: var(--accent-color);
    color: #ffffff;
    border-style: solid;
}

/* Dots Loading Animation */
.dots-loading {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 0;
}

.dots-loading span {
    width: 8px;
    height: 8px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    display: inline-block;
    animation: dots-pulse 1.4s infinite ease-in-out both;
}

.dots-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.dots-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes dots-pulse {

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

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

/* Mermaid Custom Styles */
.mermaid-container {
    margin: 1.5em 0;
    border-radius: 16px;
    background-color: #ffffff;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.mermaid {
    display: flex;
    justify-content: center;
    padding: 25px;
    background: #ffffff;
}

/* Override Mermaid default styles to match the premium look */
.mermaid svg {
    max-width: 100% !important;
    height: auto !important;
}

/* Node Styling */
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node polygon,
.mermaid .node path {
    fill: #f9fafb !important;
    stroke: #e4e4e7 !important;
    stroke-width: 1px !important;
}

/* Label Styling */
.mermaid .node .label {
    color: #18181b !important;
    font-weight: 500 !important;
    font-family: 'Inter', sans-serif !important;
}

/* Edge Styling */
.mermaid .edgePath .path {
    stroke: #a1a1aa !important;
    stroke-width: 1.5px !important;
}

.mermaid .marker {
    fill: #a1a1aa !important;
    stroke: none !important;
}

.mermaid .edgeLabel {
    background-color: #ffffff !important;
    color: #71717a !important;
    font-size: 12px !important;
}

/* Mermaid Custom Styles */
.mermaid-container {
    margin: 1.5em 0;
    border-radius: 16px;
    background-color: #ffffff;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.mermaid {
    display: flex;
    justify-content: center;
    padding: 25px;
    background: #ffffff;
}

/* Override Mermaid default styles to match the premium look */
.mermaid svg {
    max-width: 100% !important;
    height: auto !important;
}

/* Node Styling */
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node polygon,
.mermaid .node path {
    fill: #f9fafb !important;
    stroke: #e4e4e7 !important;
    stroke-width: 1px !important;
}

/* Label Styling */
.mermaid .node .label {
    color: #18181b !important;
    font-weight: 500 !important;
    font-family: 'Inter', sans-serif !important;
}

/* Edge Styling */
.mermaid .edgePath .path {
    stroke: #a1a1aa !important;
    stroke-width: 1.5px !important;
}

.mermaid .marker {
    fill: #a1a1aa !important;
    stroke: none !important;
}

.mermaid .edgeLabel {
    background-color: #ffffff !important;
    color: #71717a !important;
    font-size: 12px !important;
}

/* Floating Scroll to Top Button */
.scroll-to-top-btn {
    position: fixed;
    bottom: 125px;
    right: 25px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ffffff;
    color: #ff9f1c;
    border: 1px solid #ff9f1c;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-to-top-btn svg {
    width: 20px;
    height: 20px;
}

.scroll-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top-btn:hover {
    background-color: var(--accent-color);
    color: #ffffff;
    border-color: var(--accent-color);
    box-shadow: 0 6px 20px rgba(255, 159, 28, 0.25);
    transform: translateY(-3px);
}

@media (max-width: 768px) {
    .scroll-to-top-btn {
        bottom: 130px;
        right: 15px;
        width: 34px;
        height: 34px;
    }
    .scroll-to-top-btn svg {
        width: 17px;
        height: 17px;
    }
}