/* chat.css */
body {
    background: #0a0e17;
    /* 딥 다크 테마 유지 */
    margin: 0;
    overflow-x: hidden;
    overflow-y: hidden;
    /* 챗 스크롤은 내부 창구에서 수행 */
}

.chat-layout {
    max-width: 1000px;
    width: min(1000px, calc(100vw - 40px));
    margin: 0 auto;
    height: calc(100dvh - 72px);
    max-height: calc(100dvh - 72px);
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: rgba(14, 20, 31, 0.7);
    border: 1px solid rgba(0, 210, 255, 0.15);
    border-top: none;
    border-radius: 0 0 16px 16px;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.chat-header {
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.3);
    text-align: center;
}

.chat-header h2 {
    margin: 0 0 8px 0;
    font-size: 1.3rem;
    color: #fff;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.chat-header h2 i {
    color: #5ce1e6;
}

.chat-header p {
    margin: 0;
    font-size: 0.85rem;
    color: #aaa;
}

.status-indicator {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #888;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.offline {
    background: #e74c3c;
    box-shadow: 0 0 8px #e74c3c;
}

.status-dot.online {
    background: #2ecc71;
    box-shadow: 0 0 8px #2ecc71;
}

/* === 채팅 보드 패널 === */
.chat-window {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 30px 25px 96px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

.chat-window::-webkit-scrollbar {
    width: 6px;
}

.chat-window::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* === 메세지 셀 공통 === */
.chat-message {
    display: flex;
    gap: 15px;
    max-width: 85%;
    min-width: 0;
    width: fit-content;
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    width: fit-content;
}

.chat-message.ai {
    align-self: flex-start;
    width: 85%;
}

.chat-message.welcome-message {
    width: min(980px, 100%);
    max-width: min(980px, 96%);
}

.chat-message.welcome-message .avatar {
    margin-top: 4px;
}

/* === 아바타 원 === */
.chat-message .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 210, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 1px solid rgba(0, 210, 255, 0.3);
    flex-shrink: 0;
}

.chat-message.user .avatar {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* === 말풍선 텍스트 === */
.chat-message .bubble {
    background: rgba(255, 255, 255, 0.04);
    padding: 16px 22px;
    border-radius: 0 16px 16px 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #eaeaea;
    border: 1px solid rgba(255, 255, 255, 0.08);
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: keep-all;
    box-sizing: border-box;
    flex: 1;
}

.chat-message.user .bubble {
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.15) 0%, rgba(58, 123, 213, 0.15) 100%);
    border-radius: 16px 0 16px 16px;
    border-color: rgba(0, 210, 255, 0.3);
}

/* === 마크다운 요소를 위한 내부 스타일링 === */
.chat-message .bubble h1,
.chat-message .bubble h2,
.chat-message .bubble h3 {
    margin-top: 0;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

.chat-message .bubble p {
    margin-top: 0;
}

.chat-message .bubble strong {
    color: #00d2ff;
}

.chat-message .bubble table {
    width: 100%;
    max-width: 100%;
    display: block;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.9rem;
}

.chat-message .bubble th,
.chat-message .bubble td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    text-align: left;
}

.chat-message .bubble th {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

/* === 샘플 버튼 리스트 === */
.example-list {
    list-style: none;
    padding: 0;
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.example-list li {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    color: #00d2ff;
    border: 1px solid rgba(0, 210, 255, 0.2);
    transition: 0.2s;
}

.example-list li:hover {
    background: rgba(0, 210, 255, 0.15);
    transform: translateX(5px);
}

/* === 입력 폼 바텀 패널 === */
.chat-input-wrapper {
    padding: 15px 25px 25px 25px;
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.4);
    align-items: flex-end;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #fff;
    padding: 14px 18px;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    resize: none;
    line-height: 1.5;
    max-height: 150px;
    transition: 0.3s border-color;
}

#chat-input:focus {
    border-color: #00d2ff;
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.1);
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

#chat-send-btn {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #00d2ff;
    color: #000;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s transform, 0.2s background;
    flex-shrink: 0;
}

#chat-send-btn:hover {
    background: #5ce1e6;
    transform: scale(1.05);
}

/* === 로딩 애니메이션 === */
.loading-overlay {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loading-overlay.hidden {
    display: none;
}

.loading-text {
    font-size: 0.85rem;
    color: #00d2ff;
    font-weight: 600;
}

.dots-wrapper {
    display: flex;
    gap: 5px;
}

.dots-wrapper .dot {
    width: 6px;
    height: 6px;
    background: #00d2ff;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dots-wrapper .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dots-wrapper .dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* === 검색 계획(Planning) 박스 스타일 (Revised) === */
.intent-box {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 210, 255, 0.2);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 22px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(0, 210, 255, 0.05);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.intent-box:hover {
    border-color: rgba(0, 210, 255, 0.4);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(0, 210, 255, 0.1);
}

.intent-box::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #00d2ff, #3a7bd5);
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.6);
}

.intent-header {
    color: #00d2ff;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.intent-header i {
    font-size: 1rem;
    filter: drop-shadow(0 0 5px rgba(0, 210, 255, 0.6));
}

.intent-content {
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.7;
    font-size: 0.92rem;
}

.plan-text {
    white-space: pre-line;
}

.analyzing-text {
    color: #888;
    font-style: italic;
    animation: pulse 1.5s infinite;
}

.planner-progress,
.planner-event-list,
.iteration-container,
.iteration-box {
    display: none !important;
}

.planner-event-list {
    display: grid;
    gap: 7px;
    margin: 12px 0 0;
    padding: 10px 0 0;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    list-style: none;
}

.planner-event {
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.78rem;
    line-height: 1.35;
}

.planner-event-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #94a3b8;
}

.planner-event-planning .planner-event-dot,
.planner-event-status .planner-event-dot {
    background: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.planner-event-needs_gather .planner-event-dot,
.planner-event-gather .planner-event-dot {
    background: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.planner-event-ready .planner-event-dot,
.planner-event-done .planner-event-dot,
.planner-event-guard .planner-event-dot {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

.planner-event-failed .planner-event-dot {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.planner-event-text {
    overflow-wrap: anywhere;
}

.planner-event-time {
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.7rem;
    white-space: nowrap;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* Legacy .plan-box (Fallback) */
.plan-box {
    background: rgba(0, 210, 255, 0.05);
    border: 1px dashed rgba(0, 210, 255, 0.3);
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 15px;
    font-size: 0.85rem;
}

/* === 모드 셀렉터 드롭다운 === */
.mode-selector-wrapper {
    position: relative;
    flex-shrink: 0;
}

.mode-selector-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #ccc;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    height: 52px;
    box-sizing: border-box;
}

.mode-selector-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 210, 255, 0.3);
}

.mode-selector-btn.deep-active {
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(168, 85, 247, 0.08);
    color: #c084fc;
}

.mode-chevron {
    opacity: 0.5;
    transition: transform 0.2s;
}

.mode-dropdown {
    position: absolute;
    bottom: 60px;
    left: 0;
    background: #1a1f2e;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 6px;
    min-width: 240px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 100;
    animation: dropIn 0.15s ease;
}

/* === 드롭다운 고급 설정 영역 스타일 === */
.dropdown-settings {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 8px;
    padding: 12px 10px 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setting-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-row label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.setting-row label i {
    color: #00d2ff;
}

.dropdown-select, .dropdown-input {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #eaeaea;
    padding: 8px 12px;
    font-size: 0.82rem;
    outline: none;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.dropdown-select:focus, .dropdown-input:focus {
    border-color: #00d2ff;
    box-shadow: 0 0 8px rgba(0, 210, 255, 0.2);
    background: rgba(0, 0, 0, 0.5);
}

.dropdown-select option {
    background: #1a1f2e;
    color: #eaeaea;
}

.mode-dropdown.hidden {
    display: none;
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.mode-option:hover {
    background: rgba(255, 255, 255, 0.06);
}

.mode-option.selected {
    background: rgba(0, 210, 255, 0.08);
}

.mode-opt-icon {
    font-size: 1.2rem;
    width: 28px;
    text-align: center;
}

.mode-opt-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.mode-opt-name {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
}

.mode-opt-desc {
    color: #888;
    font-size: 0.75rem;
}

.mode-check {
    color: #00d2ff;
    font-weight: 800;
    font-size: 1rem;
}

.mode-check.hidden {
    display: none;
}

/* === Deep Analysis 배지 === */
.deep-badge {
    display: inline-block;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(139, 92, 246, 0.15));
    border: 1px solid rgba(168, 85, 247, 0.4);
    color: #c084fc;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.bubble-header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    width: 100%;
}

.monitor-link-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #aaa;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.monitor-link-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 242, 254, 0.3);
}

.delete-turn-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ff5555;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.delete-turn-btn:hover {
    background: #ff3333;
    color: white;
    border-color: #ff3333;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(255, 51, 51, 0.3);
}

/* === Iteration 진행 박스 === */
.iteration-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.iteration-box {
    background: rgba(168, 85, 247, 0.06);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
    font-size: 0.82rem;
    animation: fadeIn 0.3s ease;
}

.iter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.iter-label {
    color: #c084fc;
    font-weight: 600;
}

.iter-score {
    font-weight: 800;
    font-size: 0.9rem;
}

.iter-bar-wrapper {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    margin-bottom: 8px;
    overflow: hidden;
}

.iter-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.iter-review {
    color: #aaa;
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 4px;
}

.iter-needs {
    color: #f39c12;
    font-size: 0.78rem;
    margin-top: 4px;
}

.iter-length {
    color: #666;
    font-size: 0.75rem;
    margin-top: 4px;
}

/* === Quality 평가 패널 === */
.quality-container {
    margin-top: 12px;
}

/* ─── Markdown Content Styles (.text-container & .message-content) ─── */
.text-container, .message-content {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.7;
    font-size: 0.95rem;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: keep-all;
    box-sizing: border-box;
}

.text-container > *, .message-content > * {
    max-width: 100%;
}

.text-container p, .text-container li,
.message-content p, .message-content li {
    overflow-wrap: anywhere;
}

.text-container pre, .message-content pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
}

.text-container code, .message-content code {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.text-container h1, .message-content h1 {
    font-size: 1.4rem;
    margin: 1.5rem 0 1rem 0;
    color: #00d2ff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.5rem;
    font-weight: 800;
}

.text-container h2, .message-content h2 {
    font-size: 1.2rem;
    margin: 1.3rem 0 0.8rem 0;
    color: #5ce1e6;
    font-weight: 700;
}

.text-container h3, .message-content h3 {
    font-size: 1.1rem;
    margin: 1.1rem 0 0.5rem 0;
    color: #fff;
    font-weight: 600;
}

.text-container p, .message-content p {
    margin-bottom: 1.2rem;
}

.text-container ul, .text-container ol, 
.message-content ul, .message-content ol {
    margin-bottom: 1.2rem;
    padding-left: 1.8rem;
}

.text-container li, .message-content li {
    margin-bottom: 0.5rem;
    position: relative;
}

.text-container strong, .message-content strong {
    color: #00d2ff;
    font-weight: 700;
}

.text-container blockquote, .message-content blockquote {
    border-left: 4px solid #00d2ff;
    padding-left: 1rem;
    margin: 1rem 0;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    background: rgba(0, 210, 255, 0.05);
    padding: 10px 15px;
    border-radius: 0 8px 8px 0;
}

.quality-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s;
}

.quality-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.quality-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.quality-title {
    color: #ccc;
    font-size: 0.82rem;
    font-weight: 600;
    flex: 1;
}

.quality-score-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.quality-toggle {
    color: #666;
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.quality-box.expanded .quality-toggle {
    transform: rotate(180deg);
}

.quality-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 14px;
}

.quality-box.expanded .quality-body {
    max-height: 300px;
    padding: 0 14px 12px 14px;
}

.quality-bar-wrapper {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    margin-bottom: 10px;
    overflow: hidden;
}

.quality-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease;
}

.quality-review {
    color: #aaa;
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 6px;
}

.quality-review strong {
    color: #ccc;
}

.quality-needs {
    color: #999;
    font-size: 0.78rem;
    line-height: 1.4;
}

.quality-needs strong {
    color: #bbb;
}

/* hidden 유틸리티 */
.hidden {
    display: none !important;
}

/* --- Request Cancellation Stop Button Styles --- */
#chat-send-btn.stop-mode {
    background: #ff4a4a !important;
    color: #fff !important;
    box-shadow: 0 0 15px rgba(255, 74, 74, 0.4) !important;
}
#chat-send-btn.stop-mode:hover {
    background: #ff6b6b !important;
    transform: scale(1.05);
}
.warning-msg {
    animation: fadeIn 0.4s ease forwards;
}

/* === Settings Modal === */
.modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.7); display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 1; transition: opacity 0.3s; backdrop-filter: blur(5px); }
.modal.hidden { display: none; opacity: 0; }
.modal-content { background: #1a1f2e; border: 1px solid rgba(0,210,255,0.3); border-radius: 12px; width: 450px; max-width: 90%; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.8); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { margin: 0; color: #fff; font-size: 1.2rem; }
.close-modal { font-size: 1.5rem; color: #aaa; cursor: pointer; transition: color 0.2s; }
.close-modal:hover { color: #fff; }
.setting-group { margin-bottom: 20px; }
.setting-group h3 { color: #00d2ff; font-size: 0.95rem; margin-bottom: 8px; }
.setting-desc { font-size: 0.8rem; color: #aaa; margin-bottom: 12px; }
.module-toggles { display: flex; flex-direction: column; gap: 8px; }
.toggle-label { display: flex; align-items: center; gap: 8px; color: #eaeaea; font-size: 0.85rem; cursor: pointer; }
.toggle-label input { accent-color: #00d2ff; }
.api-key-input-wrapper { display: flex; gap: 8px; }
#customApiKey { flex: 1; padding: 10px 12px; border: 1px solid rgba(255,255,255,0.2); border-radius: 8px; background: rgba(0,0,0,0.3); color: #fff; outline: none; }
#customApiKey:focus { border-color: #00d2ff; }
.setting-note { font-size: 0.75rem; color: #888; margin-top: 8px; line-height: 1.4; }
.modal-footer { display: flex; justify-content: flex-end; margin-top: 20px; }
.primary-btn { background: #00d2ff; color: #000; border: none; padding: 10px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.primary-btn:hover { background: #5ce1e6; }

/* === Pro/Enterprise 전용 수집된 소스 박스 === */
.sources-container {
    background: rgba(14, 20, 31, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 210, 255, 0.2);
    border-radius: 12px;
    margin-bottom: 22px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 0 12px rgba(0, 210, 255, 0.03);
    overflow: hidden;
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sources-container:hover {
    border-color: rgba(0, 210, 255, 0.3);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 0 18px rgba(0, 210, 255, 0.05);
}

.sources-container.hidden {
    display: none !important;
}

.sources-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    font-size: 0.85rem;
    color: #00d2ff;
    font-weight: 700;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.3);
    user-select: none;
    transition: background 0.25s, color 0.25s;
    box-sizing: border-box;
    letter-spacing: 0.5px;
}

.sources-header:hover {
    background: rgba(0, 210, 255, 0.08);
    color: #5ce1e6;
}

.sources-header .chevron {
    font-size: 0.7rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: rgba(0, 210, 255, 0.7);
}

.sources-container.expanded .sources-header .chevron {
    transform: rotate(180deg);
    color: #00d2ff;
}

.sources-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 18px;
    max-height: 0;
    opacity: 0;
    overflow-y: auto;
    border-top: 1px solid transparent;
    background: rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
                padding 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s ease,
                border-color 0.3s ease;
}

.sources-container.expanded .sources-content {
    max-height: 320px;
    padding: 16px 18px;
    opacity: 1;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Custom Scrollbar for Sources UI */
.sources-content::-webkit-scrollbar,
.source-item-body::-webkit-scrollbar {
    width: 6px;
}

.sources-content::-webkit-scrollbar-track,
.source-item-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.sources-content::-webkit-scrollbar-thumb,
.source-item-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    transition: background 0.2s;
}

.sources-content::-webkit-scrollbar-thumb:hover,
.source-item-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 210, 255, 0.4);
}

.source-item {
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    box-sizing: border-box;
    transition: border-color 0.25s, background-color 0.25s, box-shadow 0.25s;
}

.source-item:hover {
    border-color: rgba(0, 210, 255, 0.25);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.source-item-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
    box-sizing: border-box;
    user-select: none;
}

.source-item-title:hover {
    color: #fff;
}

.source-item-title i {
    font-size: 0.8rem;
    margin-right: 8px;
    color: rgba(0, 210, 255, 0.6);
    transition: color 0.2s;
}

.source-item-title:hover i {
    color: #00d2ff;
}

.source-item-title .source-meta-tag {
    font-size: 0.68rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 700;
    margin-left: 10px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.source-item-title .tag-dart {
    background: rgba(0, 210, 255, 0.1);
    color: #5ce1e6;
    border: 1px solid rgba(0, 210, 255, 0.25);
}

.source-item-title .tag-internet {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.source-item-title .tag-generic {
    background: rgba(255, 255, 255, 0.05);
    color: #aaa;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.source-item-body {
    max-height: 0;
    opacity: 0;
    padding: 0 14px;
    background: rgba(10, 15, 26, 0.8);
    border-top: 1px solid transparent;
    font-size: 0.82rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Inter', sans-serif;
    overflow-y: auto;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                padding 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s ease,
                border-color 0.3s ease;
}

.source-item-body p {
    margin-bottom: 0.8rem;
}
.source-item-body p:last-child {
    margin-bottom: 0;
}
.source-item-body a {
    color: #00d2ff;
    text-decoration: underline;
    transition: color 0.2s;
}
.source-item-body a:hover {
    color: #5ce1e6;
}
.source-item-body h3 {
    font-size: 0.95rem;
    color: #fff;
    margin: 12px 0 8px 0;
    font-weight: 600;
}
.source-item-body ul, .source-item-body ol {
    margin-bottom: 8px;
    padding-left: 1.2rem;
}
.source-item-body li {
    margin-bottom: 4px;
}

.source-item.expanded .source-item-body {
    max-height: 200px;
    opacity: 1;
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* === Credits Toggle Switch === */
.credits-toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px 16px;
    border-radius: 12px;
    box-sizing: border-box;
    width: 100%;
}

.credits-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.credits-label i {
    color: #eab308;
}

.credit-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.credit-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.credit-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border-radius: 24px;
}

.credit-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.credit-switch input:checked + .credit-slider {
    background-color: #00d2ff;
}

.credit-switch input:checked + .credit-slider:before {
    transform: translateX(20px);
}

.credits-status-desc {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.2s;
}

.credits-status-desc.active {
    color: #00d2ff;
    font-weight: bold;
}

/* === User-facing module guide === */
.user-guide-strip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.82rem;
}

.guide-link-btn {
    border: 1px solid rgba(0, 210, 255, 0.35);
    background: rgba(0, 210, 255, 0.1);
    color: #5ce1e6;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
}

.guide-link-btn:hover {
    background: rgba(0, 210, 255, 0.18);
}

.quick-guide-note {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.82rem;
    line-height: 1.5;
}

.welcome-guide h3 {
    margin: 2px 0 8px;
    color: #fff;
    font-size: 1.12rem;
    line-height: 1.32;
    border-bottom: 0;
    padding-bottom: 0;
}

.welcome-guide p {
    margin: 0;
    color: rgba(255,255,255,0.68);
    font-size: 0.86rem;
    line-height: 1.55;
}

.welcome-kicker,
.example-block-title {
    color: #5ce1e6;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    margin-bottom: 6px;
}

.welcome-headline-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.guide-link-btn.compact {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 13px;
    margin-top: 0;
}

.starter-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 16px 0;
    align-items: start;
}

.starter-panel > div {
    padding: 0;
}

.quick-start-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.quick-start-head strong {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 0.86rem;
}

.quick-start-head strong::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #5ce1e6;
    box-shadow: 0 0 10px rgba(92, 225, 230, 0.45);
}

.quick-start-head span {
    color: rgba(255,255,255,0.52);
    font-size: 0.75rem;
    line-height: 1.35;
    text-align: right;
}

.quick-question-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.quick-question-grid button {
    min-height: 46px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.5);
    color: rgba(255,255,255,0.86);
    border-radius: 8px;
    padding: 11px 12px;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}

.quick-question-grid button:hover {
    color: #fff;
    background: rgba(0, 210, 255, 0.1);
    border-color: rgba(0, 210, 255, 0.24);
}

.ask-better-note {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.72);
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 9px 12px;
    border: 0;
    border-left: 3px solid rgba(92, 225, 230, 0.75);
    border-radius: 8px;
    background: rgba(0, 210, 255, 0.055);
}

.ask-better-note i {
    color: #5ce1e6;
    margin-top: 0;
}

.ask-better-note strong {
    color: #fff;
    font-weight: 700;
}

.module-tabs-panel {
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    background: transparent;
    border-radius: 8px;
    padding: 16px 0 0;
}

.module-tabs-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 12px;
}

.module-tabs-head strong {
    color: #fff;
    font-size: 0.9rem;
}

.module-tabs-head span {
    color: rgba(255,255,255,0.64);
    font-size: 0.78rem;
    line-height: 1.4;
    text-align: right;
}

.module-evidence-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.module-evidence-grid section {
    border: 1px solid rgba(92, 225, 230, 0.16);
    background: rgba(15, 23, 42, 0.62);
    color: rgba(255,255,255,0.72);
    border-radius: 8px;
    padding: 13px 14px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
    min-height: 76px;
    align-items: center;
}

.module-evidence-grid i {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #5ce1e6;
    background: rgba(0, 210, 255, 0.12);
    border: 1px solid rgba(92, 225, 230, 0.18);
    margin-top: 0;
}

.module-evidence-grid strong {
    display: block;
    color: #fff;
    font-size: 0.84rem;
    margin-bottom: 4px;
}

.module-evidence-grid span {
    display: block;
    color: rgba(255,255,255,0.68);
    font-size: 0.76rem;
    line-height: 1.45;
}

.service-help-modal {
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    width: 90%;
    max-width: 760px;
    max-height: 88vh;
    overflow-y: auto;
    padding: 1.6rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.help-module-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.help-module-list section {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 14px;
    background: rgba(255,255,255,0.04);
}

.help-module-list h3 {
    margin: 0 0 8px 0;
    color: #fff;
    font-size: 0.98rem;
}

.help-module-list p {
    margin: 0 0 10px 0;
    color: rgba(255,255,255,0.72);
    font-size: 0.84rem;
    line-height: 1.5;
}

.help-module-list small {
    display: block;
    color: #5ce1e6;
    font-size: 0.78rem;
    line-height: 1.45;
}

.module-help-card {
    align-items: flex-start;
}

.module-help-card span {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.module-help-card small {
    color: rgba(255,255,255,0.52);
    font-size: 0.72rem;
    line-height: 1.35;
}

@media (max-width: 720px) {
    .chat-layout {
        width: 100vw;
        margin: 0;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .chat-window {
        padding-bottom: 104px;
    }

    .help-module-list {
        grid-template-columns: 1fr;
    }

    .user-guide-strip {
        align-items: stretch;
    }

    .welcome-headline-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .module-tabs-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .guide-link-btn.compact {
        width: 100%;
        justify-content: center;
    }

    .module-tabs-head span {
        text-align: left;
    }

    .quick-start-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .quick-start-head span {
        text-align: left;
    }

    .starter-panel {
        grid-template-columns: 1fr;
    }

    .module-evidence-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quick-question-grid {
        grid-template-columns: 1fr;
    }

    .quick-question-grid button {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .module-evidence-grid {
        grid-template-columns: 1fr;
    }
}
