:root {
    --bg-deep: #0b0c10; --bg-surface: #15161a; --bg-elevated: #1e1f24;
    --text-primary: #e8e9ec; --text-secondary: #a1a5ab; --accent: #3bceac;
    --accent-glow: rgba(59, 206, 172, 0.4); --border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(21, 22, 26, 0.6); --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 4px 12px rgba(0,0,0,0.3); --shadow-md: 0 8px 32px rgba(0,0,0,0.4);
    --font: 'Inter Tight', -apple-system, sans-serif;
    --sidebar-width: 320px; 
}

*{margin:0;padding:0;box-sizing:border-box;outline:none;}
body,html{font-family:var(--font);background:var(--bg-deep);color:var(--text-primary);height:100vh;overflow:hidden;line-height:1.6;font-size:15px;background-image:radial-gradient(ellipse at 20% 50%,rgba(59,206,172,0.03) 0%,transparent 50%),radial-gradient(ellipse at 80% 20%,rgba(59,206,172,0.02) 0%,transparent 50%)}
.screen{width:100%;height:100vh;position:relative;z-index:1}
.hidden{display:none!important}
.error-msg{color:#f87171;font-size:.85rem;margin-top:12px;text-align:center}

/* 로그인 & 가입 */
#loginScreen{position:relative;display:flex;align-items:center;justify-content:center;background:radial-gradient(circle at 30% 30%,#1e2a2a 0%,var(--bg-deep) 70%)}
.login-box{background:var(--glass-bg);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--glass-border);padding:48px 36px;border-radius:32px;text-align:center;box-shadow:var(--shadow-md),0 0 60px rgba(59,206,172,0.08);max-width:420px;width:90%;position:relative;z-index:1;overflow:hidden}
.login-glow{position:absolute;top:-50%;left:-50%;width:200%;height:200%;background:radial-gradient(circle at 50% 50%,rgba(59,206,172,0.15) 0%,transparent 60%);animation:rotateGlow 12s linear infinite;pointer-events:none}
@keyframes rotateGlow{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
.login-box h1{font-size:2.2rem;margin-bottom:12px;color:var(--accent);text-shadow:0 0 20px var(--accent-glow)}
.login-box p{color:var(--text-secondary);margin-bottom:28px}
.input-container{display:flex;flex-direction:column;gap:12px}
.login-box input{width:100%;padding:14px 18px;border:1px solid var(--border);border-radius:16px;font-size:1rem;background:rgba(255,255,255,0.05);color:var(--text-primary);transition:border .2s,box-shadow .2s}
.login-box input:focus{border-color:var(--accent);box-shadow:0 0 12px var(--accent-glow)}
.login-box button{background:var(--accent);color:var(--bg-deep);border:none;padding:14px 24px;border-radius:16px;font-size:1rem;font-weight:600;cursor:pointer;transition:background .2s,box-shadow .2s}
.login-box button:hover{background:#52e0be;box-shadow:0 0 20px var(--accent-glow)}

/* 아이콘 그리드 */
.icon-picker-label { font-size: 0.85rem; color: var(--text-secondary); text-align: left; margin-top: 4px; }
.icon-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 20px; max-height: 150px; overflow-y: auto; padding: 4px; scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }
.icon-grid::-webkit-scrollbar { width: 6px; } .icon-grid::-webkit-scrollbar-thumb { background: rgba(59,206,172,0.5); border-radius: 6px; }
.icon-item { background: rgba(255,255,255,0.05); border: 1px solid var(--border); border-radius: 12px; padding: 12px; font-size: 1.5rem; color: var(--text-secondary); cursor: pointer; transition: all 0.2s; display:flex; justify-content:center; align-items:center; }
.icon-item:hover { background: rgba(59,206,172,0.15); border-color: var(--accent); color: var(--text-primary); transform: scale(1.05); }
.icon-item.selected { background: var(--accent); border-color: var(--accent); color: var(--bg-deep); transform: scale(1.1); box-shadow: 0 0 12px var(--accent-glow); }

/* 토글 스위치 */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); border-radius: 20px; transition: .3s; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: var(--text-secondary); border-radius: 50%; transition: .3s; }
input:checked + .slider { background-color: #f87171; }
input:checked + .slider:before { transform: translateX(16px); background-color: #fff; }

/* 메인 구조 및 사이드바 */
#mainScreen{display:flex}
.sidebar { 
    width: var(--sidebar-width); background: var(--glass-bg); backdrop-filter: blur(24px); 
    -webkit-backdrop-filter: blur(24px); border-right: 1px solid var(--glass-border); 
    display: flex; flex-direction: column; transition: width 0.3s cubic-bezier(0.2, 0, 0, 1); 
    z-index: 20; position: relative; box-shadow: 4px 0 20px rgba(0,0,0,0.3); 
}
.sidebar.collapsed { width: 72px !important; }

.sidebar-resizer { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 100; background: transparent; transition: background 0.2s; }
.sidebar-resizer:hover, .sidebar-resizer.active { background: var(--accent); opacity: 0.5; }
.sidebar.collapsed .sidebar-resizer { display: none; }

/* === 대화방 리스트 검색창 === */
.thread-search-container {
    position: static;
    margin: 12px 20px 8px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    padding: 0;
    box-shadow: none;
    max-height: 80px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, margin 0.3s ease, padding 0.3s ease;
}

.thread-search-container.hidden { max-height: 0; opacity: 0; margin: 0; padding: 0; }

.thread-search-container input {
    width: 100%; padding: 12px 14px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--glass-border);
    border-radius: 12px; color: var(--text-primary); font-family: var(--font); font-size: 0.95rem;
    outline: none !important; -webkit-appearance: none; appearance: none; box-shadow: none;
    filter: drop-shadow(0 0 6px rgba(59, 206, 172, 0.2)) drop-shadow(0 0 14px rgba(59, 206, 172, 0.08));
    transition: border 0.2s ease, filter 0.35s ease, background 0.25s ease;
}

.thread-search-container input:focus {
    border-color: var(--accent); background: rgba(255, 255, 255, 0.1);
    filter: drop-shadow(0 0 10px rgba(59, 206, 172, 0.3)) drop-shadow(0 0 22px rgba(59, 206, 172, 0.15));
    outline: none !important;
}

/* 사이드바 내부 요소 */
.sidebar-header { height: 72px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); overflow: hidden; white-space: nowrap; }
.sidebar-header h2 { font-size: 1.3rem; font-weight: 700; color: var(--accent); margin: 0; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.header-actions { display: flex; gap: 6px; }
.header-actions button { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,0.05); border: 1px solid transparent; color: var(--accent); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
.header-actions button:hover { background: var(--accent); color: var(--bg-deep); box-shadow: 0 0 12px var(--accent-glow); }

.thread-list { flex: 1; overflow-y: auto; padding: 12px 20px; }
.thread-group-header { padding: 16px 12px 6px; font-size: 0.75rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

.empty-thread-message { transition: opacity 0.3s ease; opacity: 1; white-space: nowrap; }

.thread-item { 
    padding: 12px 14px; border-radius: 12px; cursor: grab; margin-bottom: 4px; display: flex; 
    justify-content: space-between; align-items: center; color: var(--text-primary); 
    border: 1px solid transparent; font-size: 0.95rem; white-space: nowrap; overflow: hidden; 
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s, background 0.2s, border-color 0.2s;
    background: transparent;
}
.thread-item:hover { background: rgba(255,255,255,0.04); border-color: var(--border); }
.thread-item.active { background: rgba(59,206,172,0.12); border-color: var(--accent); font-weight: 500; }

.thread-item:active { cursor: grabbing; transform: scale(0.96); background: rgba(255,255,255,0.08); border-color: var(--accent); }
.thread-item.dragging { opacity: 0.7; transform: scale(1.03) rotate(1deg); box-shadow: 0 12px 24px rgba(0,0,0,0.5); border-color: var(--accent); z-index: 100; position: relative; background: var(--bg-surface); }

.thread-item.drag-over-top { border-top: 2px solid var(--accent); margin-top: 10px; padding-top: 14px; background: rgba(59, 206, 172, 0.05); }
.thread-item.drag-over-bottom { border-bottom: 2px solid var(--accent); margin-bottom: 10px; padding-bottom: 14px; background: rgba(59, 206, 172, 0.05); }

.thread-title { flex: 1; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.thread-item .delete-thread { visibility: hidden; background: none; border: none; color: #9ca3af; cursor: pointer; font-size: 0.9rem; padding: 4px; z-index: 10; }
.thread-item:hover .delete-thread { visibility: visible; }
.thread-icon { display: none; } 

.sidebar-footer { padding: 16px 20px 20px; border-top: 1px solid var(--glass-border); display: flex; flex-direction: column; gap: 8px; overflow: hidden; white-space: nowrap; }
.sidebar-footer button:not(.pc-sys-prompt-btn), .sidebar-footer div { background: none; border: none; padding: 10px 14px; border-radius: 12px; cursor: pointer; color: var(--text-secondary); display: flex; align-items: center; gap: 10px; font-size: 0.9rem; transition: all 0.2s; }
.sidebar-footer button:not(.pc-sys-prompt-btn):hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
#userNameDisplay { overflow: hidden; text-overflow: ellipsis; max-width: 200px; display: inline-block; vertical-align: middle; }

.pc-sys-prompt-btn {
    background: rgba(255,255,255,0.05) !important; border: 1px solid rgba(255,255,255,0.15) !important; 
    color: var(--text-primary) !important; padding: 12px !important; border-radius: 12px !important; 
    width: 100%; margin-top: 10px; cursor: pointer; display: flex; align-items: center; gap: 8px; 
    justify-content: center; font-size: 0.9rem; transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow: hidden; white-space: nowrap;
}
.pc-sys-prompt-btn:hover { border-color: var(--accent) !important; background: rgba(255,255,255,0.1) !important; }

/* 사이드바 접힘 상태 */
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar-header h2 span { display: none; }
.sidebar.collapsed .header-actions { display: none; }
.sidebar.collapsed .thread-list { padding: 12px 8px; overflow-x: hidden; }
.sidebar.collapsed .thread-search-container { display: none !important; }
.sidebar.collapsed .thread-group-header { display: none; }
.sidebar.collapsed .thread-title { display: none; }
.sidebar.collapsed .empty-thread-message { opacity: 0; pointer-events: none; height: 0; overflow: hidden; padding: 0; margin: 0; }

.sidebar.collapsed .pc-sys-prompt-btn { width: 44px; height: 44px; padding: 0 !important; margin: 10px auto 0; }
.sidebar.collapsed .pc-sys-prompt-btn span { display: none; }

.sidebar.collapsed .thread-item { 
    width: 44px; height: 44px; padding: 0; justify-content: center; align-items: center; 
    border-radius: 50%; margin: 8px auto; border: 1px solid var(--border); position: relative; 
}
.sidebar.collapsed .thread-icon { 
    display: block; color: var(--accent); font-size: 1.1rem; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; pointer-events: none;
}

.sidebar.collapsed .thread-pin-btn {
    position: absolute; top: -6px; right: -6px; background: var(--bg-elevated); border: 1px solid var(--glass-border); border-radius: 50%;
    width: 22px; height: 22px; display: flex !important; align-items: center; justify-content: center;
    font-size: 0.65rem; padding: 0; z-index: 10; transform: rotate(45deg); transition: transform 0.2s, color 0.2s, opacity 0.2s, border-color 0.2s;
}
.sidebar.collapsed .thread-pin-btn:not(.pinned) { opacity: 0; pointer-events: none; }
.sidebar.collapsed .thread-item:hover .thread-pin-btn:not(.pinned) { opacity: 0.6; pointer-events: auto; transform: rotate(0deg); }
.sidebar.collapsed .thread-pin-btn.pinned { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 8px rgba(59,206,172,0.3); opacity: 1; transform: rotate(45deg); }
.sidebar.collapsed .thread-item .delete-thread { display: none !important; }

.sidebar.collapsed .sidebar-footer { padding: 12px 4px; align-items: center; overflow: hidden; white-space: nowrap; }
.sidebar.collapsed .sidebar-footer span { display: none; }
.sidebar.collapsed .sidebar-footer div { font-size: 0; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.sidebar.collapsed .sidebar-footer i { font-size: 1.2rem; }
.sidebar.collapsed .sidebar-footer button:not(.pc-sys-prompt-btn) { width: 44px; height: 44px; justify-content: center; padding: 0; margin: 0 auto; font-size: 1.2rem; }

/* 메인 뷰 분할 컨테이너 (position: relative 필수) */
.main-content { flex: 1; display: flex; overflow: hidden; position: relative; }
.chat-container { flex: 1; display: flex; flex-direction: column; position: relative; border-right: 1px solid var(--border); transition: flex 0.3s ease, opacity 0.3s ease; }
.chat-container:last-child { border-right: none; }

.chat-container.inactive .bubble { opacity: 0.7; filter: blur(0.5px); transition: opacity 0.3s, filter 0.3s; }
.chat-container.inactive .bubble:hover { opacity: 0.9; filter: blur(0); }
.chat-container.hidden { display: none; }

/* 💡 화면 분할 교체 버튼 스타일 */
.swap-views-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.swap-views-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translate(-50%, -50%) scale(1.15);
}
.swap-views-btn:active {
    transform: translate(-50%, -50%) scale(0.9);
}
.swap-views-btn.hidden { 
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.5);
}

/* 채팅 헤더 & 도구 */
.chat-header {
    padding: 15.5px 24px; border-bottom: 1px solid var(--accent);
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(26, 27, 30, 0.55); backdrop-filter: blur(24px) saturate(120%);
    -webkit-backdrop-filter: blur(24px) saturate(120%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); 
    min-height: 72px; position: relative; z-index: 6; transition: background 0.2s ease, backdrop-filter 0.2s ease;
}
.chat-header::after {
    content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 1px;
    box-shadow: 0 0 15px 1px var(--accent-glow); pointer-events: none;
}
.chat-header h3 { flex: 1; font-size: 1.1rem; font-weight: 500; color: var(--text-primary); margin: 0; line-height: 1.2; }
.header-tools { display: flex; gap: 8px; align-items: center; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--text-secondary); padding: 8px; border-radius: 50%; transition: all .2s; }
.icon-btn:hover { color: var(--accent); background: rgba(255,255,255,0.06); }
.split-view-btn { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); border-radius: 8px; padding: 6px 12px; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.2s; font-size: 0.85rem; }
.split-view-btn:hover { color: var(--accent); border-color: var(--accent); }

/* 검색 레이어 */
.search-dimmer{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.3);z-index:9}
.search-dimmer.active{display:block}
.search-overlay { display: none; position: absolute; top: 70px; left: 50%; transform: translateX(-50%); width: 60%; max-width: 500px; background: var(--glass-bg); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); border: 1px solid var(--glass-border); border-radius: 20px; padding: 16px; z-index: 10; box-shadow: var(--shadow-md); }
.search-overlay.active{display:block}
.search-overlay input { width: 100%; padding: 14px 18px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255, 255, 255, 0.05); color: var(--text-primary); font-family: var(--font); font-size: 1rem; outline: none; transition: border 0.2s; box-shadow: none; }
.search-overlay input:focus{border-color:var(--accent);}
.search-overlay-buttons{display:flex;gap:8px;margin-top:10px;justify-content:flex-end}
.search-overlay-buttons button{background:rgba(255,255,255,0.05);border:1px solid var(--border);color:var(--text-secondary);padding:8px 14px;border-radius:12px;cursor:pointer;transition:all .2s}
.search-overlay-buttons button:hover{color:var(--accent);border-color:var(--accent)}
.search-highlight{background:rgba(59,206,172,0.35);border-radius:3px;padding:1px 2px}

/* 채팅 메시지 영역 */
.chat-messages { flex: 1; overflow-y: auto; padding: 32px 48px 160px; display: flex; flex-direction: column; gap: 24px; background: transparent; position: relative; max-width: 1100px; margin: 0 auto; width: 100%; scrollbar-width: thin; scrollbar-color: rgba(59, 206, 172, 0.3) transparent; }
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(59, 206, 172, 0.3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

.welcome-message { text-align: center; color: var(--text-secondary); font-size: 1.1rem; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 100%; padding: 0 24px; }
.welcome-message h2 { color: var(--accent); margin-bottom: 14px; font-size: 2.8rem; }
#chatView2 .welcome-message h2 { font-size: 2rem; color: var(--text-secondary); opacity: 0.6;}

.message { display: flex; gap: 16px; max-width: 85%; animation: fadeSlideIn .3s ease; position: relative; z-index: 1; min-width: 0; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.assistant { align-self: flex-start; }

.message .avatar { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; flex-shrink: 0; }
.message.user .avatar { background: var(--accent); color: var(--bg-deep); box-shadow: 0 0 12px var(--accent-glow); }
.message.assistant .avatar { background: var(--bg-elevated); color: var(--accent); border: 1px solid var(--border); }

.message-content { display: flex; flex-direction: column; min-width: 0; max-width: calc(100% - 54px); width: 100%; }
.message.user .message-content { align-items: flex-end; }
.message.assistant .message-content { align-items: flex-start; }

.message .bubble { padding: 16px 22px; border-radius: 24px; font-size: 0.95rem; line-height: 1.6; word-break: break-word; overflow-wrap: anywhere; color: var(--text-primary); position: relative; backdrop-filter: blur(12px); box-sizing: border-box; max-width: 100%; overflow-x: auto; }
.message .bubble > *:last-child { margin-bottom: 0 !important; }

.message .bubble p { margin: 1em 0; }
.message .bubble p:first-of-type { margin-top: 0; }
.message .bubble p:last-of-type { margin-bottom: 0; }
.message .bubble ul, .message .bubble ol { margin: 1em 0; padding-left: 28px; }
.message .bubble li { margin-bottom: 6px; }
.message .bubble li > p { margin: 0; }
.message .bubble h1, .message .bubble h2, .message .bubble h3, .message .bubble h4 { margin: 1em 0 0.5em; line-height: 1.3; }
.message .bubble hr { margin: 1.5em 0; border: none; border-top: 1px solid var(--border); }
.message .bubble a:not(.citation-chip) { color: var(--accent); text-decoration: underline; }
.message .bubble strong { font-weight: 700 !important; }

.message .bubble blockquote{border-left:3px solid var(--accent);padding-left:14px;margin:8px 0;color:var(--text-secondary);font-style:italic}
.message .bubble table{border-collapse:collapse;margin:10px 0;width:100%; display:block; overflow-x:auto;}
.message .bubble th,.message .bubble td{border:1px solid var(--border);padding:8px 12px;text-align:left}
.message .bubble th{background:rgba(59,206,172,0.1)}
.message.user .bubble{background:linear-gradient(135deg,rgba(15,76,58,0.9) 0%,rgba(8,38,28,0.8) 100%);border:1px solid rgba(59,206,172,0.3);color:#fff;border-bottom-right-radius:8px;border-bottom-left-radius:24px;}
.message.assistant .bubble{background:linear-gradient(135deg,rgba(37,38,42,0.7) 0%,rgba(30,31,35,0.7) 100%);border:1px solid var(--glass-border);border-bottom-left-radius:8px;border-bottom-right-radius:24px;overflow:hidden}
.message.assistant .bubble::after{content:'';position:absolute;top:-50%;left:-50%;width:200%;height:200%;background:radial-gradient(circle at 30% 30%,rgba(59,206,172,0.06) 0%,transparent 60%);pointer-events:none}
.message img{max-width:300px;border-radius:16px;margin-top:8px;cursor:zoom-in;}

.message-footer { display: flex; justify-content: flex-end; align-items: center; width: 100%; margin-top: 6px; }
.message-actions { display: flex; gap: 6px; }
.message.user .message-actions { align-self: flex-start; }
.copy-message-btn, .delete-message-btn, .regenerate-message-btn, .edit-message-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: .9rem; border-radius: 6px; transition: all .2s; }
.copy-message-btn:hover, .regenerate-message-btn:hover, .edit-message-btn:hover { color: var(--accent); background: rgba(255,255,255,0.05); }
.delete-message-btn:hover { color: #f87171; background: rgba(248,113,113,0.1); }

/* 코드 블록 */
.code-wrapper { background: #282c34; border-radius: 12px; margin: 12px 0; border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); overflow: hidden; }
.code-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px; background: #21252b; border-bottom: 1px solid rgba(255,255,255,0.05); }
.code-lang { color: var(--text-secondary); font-size: 0.75rem; font-family: 'Fira Code', monospace; }
.code-wrapper .code-copy-btn { background: transparent; border: 1px solid transparent; color: var(--text-secondary); padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; cursor: pointer; display: flex; align-items: center; gap: 4px; transition: color 0.2s; font-family: var(--font); }
.code-wrapper .code-copy-btn:hover { color: var(--accent); }
.code-wrapper pre { margin: 0; padding: 16px; overflow-x: auto; background: transparent; }
.code-wrapper code { font-family: 'Fira Code', monospace; font-size: 0.85rem; line-height: 1.5; }

/* 입력창 & 도구 */
.chat-input-area { position: absolute; bottom: 0; left: 0; right: 0; padding: 40px 48px 24px; background: linear-gradient(to top, var(--bg-deep) 40%, rgba(15, 15, 18, 0.7) 65%, transparent 100%); z-index: 5; pointer-events: none; }
.chat-input-area > * { pointer-events: auto; }
.input-wrapper { max-width: 1100px; margin: 0 auto; position: relative; }
.chat-toolbar{display:flex;gap:8px;margin-bottom:8px}
.tool-btn{background:rgba(26,27,30,0.65);border:1px solid var(--glass-border);color:var(--text-secondary);padding:8px 16px;border-radius:20px;cursor:pointer;font-size:.8rem;font-weight:500;transition:all .2s ease;display:flex;align-items:center;gap:6px;}
.tool-btn:hover{border-color:var(--accent);color:var(--text-primary);background:rgba(59,206,172,0.1)}
.tool-btn.active{background:var(--accent);border-color:var(--accent);color:var(--bg-deep);font-weight:600;}
.input-row{display:flex;gap:12px;align-items:flex-end;background:var(--glass-bg);backdrop-filter:blur(20px);border-radius:28px;padding:10px 12px 10px 24px;border:1px solid var(--glass-border);transition:border .2s,box-shadow .2s,background .2s;min-height:64px;box-shadow:var(--shadow-md);}
.input-row:focus-within{border-color:var(--accent);box-shadow:0 0 30px var(--accent-glow);background:rgba(26,27,30,0.4)}
.input-row textarea { flex: 1; border: none; background: transparent; resize: none; outline: none; font-size: 1.05rem; font-family: inherit; padding: 16px 0; color: var(--text-primary); max-height: 200px; line-height: 1.5; will-change: scroll-position; }

#messageInput::-webkit-scrollbar { width: 10px; }
#messageInput::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.03); border-radius: 10px; margin: 0; }
#messageInput::-webkit-scrollbar-thumb { background: rgba(59, 206, 172, 0.45); border-radius: 10px; min-height: 40px; }
#messageInput::-webkit-scrollbar-thumb:hover { background: rgba(59, 206, 172, 0.75); box-shadow: 0 0 8px rgba(59, 206, 172, 0.4); }

#sendBtn { background: var(--accent); color: var(--bg-deep); border: none; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; transition: all .2s; box-shadow: 0 0 16px var(--accent-glow); margin-bottom: 6px; margin-right: 12px; display:flex; align-items:center; justify-content:center;}
#sendBtn:disabled{background:#3a3b3e;box-shadow:none;cursor:not-allowed;color:rgba(255,255,255,0.4);}
#sendBtn:hover:not(:disabled){transform:scale(1.05)}
#micBtn { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; margin-right: 4px; transition: all 0.2s; }
#micBtn.recording { color: #f87171; background: rgba(248, 113, 113, 0.1); animation: pulseMic 1.5s infinite; }

.scroll-bottom-btn { position: absolute; bottom: 170px; right: 40px; width: 40px; height: 40px; border-radius: 50%; background: rgba(59, 206, 172, 0.1); color: var(--accent); border: 1px solid rgba(59, 206, 172, 0.3); cursor: pointer; font-size: 1.1rem; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 100; transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.scroll-top-btn { position: absolute; bottom: 224px; right: 40px; width: 40px; height: 40px; border-radius: 50%; background: rgba(59, 206, 172, 0.1); color: var(--accent); border: 1px solid rgba(59, 206, 172, 0.3); cursor: pointer; font-size: 1.1rem; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 100; transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.scroll-bottom-btn:hover, .scroll-top-btn:hover { background: var(--accent); color: var(--bg-deep); box-shadow: 0 4px 12px rgba(0,0,0,0.3), 0 0 15px var(--accent-glow); transform: translateY(-2px); }
.scroll-bottom-btn.hidden, .scroll-top-btn.hidden { opacity: 0; pointer-events: none; transform: translateY(10px); }

/* 모달, 테이블, 기타 */
.modal{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.6);backdrop-filter:blur(8px);display:flex;align-items:center;justify-content:center;z-index:100}
.modal-content{background:var(--glass-bg);backdrop-filter:blur(24px);border:1px solid var(--glass-border);padding:32px;border-radius:28px;width:90%;max-width:440px;color:var(--text-primary);box-shadow:var(--shadow-md)}
.modal-content.admin-content { max-width: 600px; } 
.modal-content h2{color:var(--accent);margin-bottom:20px;font-size:1.3rem; text-align: center;}
.modal-content input{width:100%;padding:12px 16px;border:1px solid var(--border);border-radius:14px;margin-bottom:18px;background:rgba(255,255,255,0.05);color:var(--text-primary);transition:border .2s}
.modal-content input:focus{border-color:var(--accent)}
.modal-close-btn,.modal-action-btn{padding:12px 28px;border:1px solid var(--border);border-radius:16px;cursor:pointer;background:rgba(255,255,255,0.05);color:var(--text-primary);font-weight:500;font-size:.95rem;transition:all .2s;margin-top:12px;width:100%}
.modal-action-btn{background:var(--accent);border-color:var(--accent);color:var(--bg-deep);font-weight:600}
.modal-action-btn:hover{background:#52e0be}
.admin-section { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.admin-section h3 { margin-bottom: 12px; color: var(--accent); }
.model-setting { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.model-setting select { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-surface); color: var(--text-primary); outline: none; }

.modal-content.large-content { max-width: 800px; width: 90%; padding: 30px; }
.table-wrapper { max-height: 55vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; background: rgba(0, 0, 0, 0.2); }
.usage-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; text-align: left; }
.usage-table th, .usage-table td { border: 1px solid var(--border); padding: 12px 14px; }
.usage-table th { background: #1a1b1e; color: var(--accent); font-weight: 600; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 4px rgba(0,0,0,0.3); }

/* PWA 커서 */
body{cursor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 22 22'%3E%3Cpath d='M2 2l7 17 3-6 6-3z' fill='%233bceac' stroke='%2352e0be' stroke-width='1'/%3E%3C/svg%3E") 2 2,auto}
button,a,input,textarea,.thread-item,.icon-btn,label,.tool-btn,.modal-close-btn,.modal-action-btn{cursor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 22 22'%3E%3Cpath d='M2 2l7 17 3-6 6-3z' fill='%233bceac' stroke='%2352e0be' stroke-width='1'/%3E%3C/svg%3E") 2 2,pointer}

/* 감성 불꽃 로딩 */
.campfire-loader { position: relative; width: 24px; height: 24px; display: flex; justify-content: center; align-items: flex-end; }
.campfire-flame { position: absolute; bottom: 4px; width: 12px; height: 16px; background: var(--accent); border-radius: 50% 50% 20% 20%; animation: flicker 0.6s infinite alternate; }
@keyframes flicker { 0% { transform: scaleY(1) rotate(-3deg); opacity: 0.8; } 100% { transform: scaleY(1.2) rotate(3deg); opacity: 1; } }
.citation-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: rgba(26, 27, 30, 0.5); border: 1px solid var(--glass-border); border-radius: 12px; color: var(--accent) !important; text-decoration: none !important; font-size: 0.8rem; font-weight: 500; transition: all 0.2s ease; margin: 0 4px; }
.citation-chip:hover { background: rgba(59, 206, 172, 0.15); border-color: rgba(59, 206, 172, 0.4); transform: translateY(-1px); }

/* 추론 패널 */
.thinking-panel-container { max-width: 100%; box-sizing: border-box; min-width: 140px; margin-bottom: 8px; border: none; border-radius: 10px; background: transparent; overflow: hidden; }
.thinking-toggle-btn { width: 100%; padding: 8px 14px; background: rgba(59, 206, 172, 0.08); border: none; color: var(--accent); font-size: 0.8rem; cursor: pointer; display: flex; align-items: center; gap: 6px; justify-content: flex-start; border-radius: 10px; }
.thinking-toggle-btn:not(.expanded) { width: auto; white-space: normal; word-break: break-word; padding: 10px 16px; font-size: 0.85rem; justify-content: flex-start; border-radius: 10px; margin-right: auto; }
.thinking-content { padding: 12px 16px; font-size: 0.8rem; color: var(--text-secondary); max-height: 300px; overflow-y: auto; overflow-x: auto; line-height: 1.6; background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 0 0 10px 10px; margin-top: 0; overflow-x: auto; word-break: break-word; overflow-wrap: anywhere; }
.thinking-content ul, .thinking-content ol { padding-left: 20px; margin: 8px 0; }
.thinking-content li { margin-bottom: 4px; }
.thinking-content p { margin: 8px 0; }
.thinking-panel-container.expanded { background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.thinking-panel-container.expanded .thinking-toggle-btn { border-radius: 10px 10px 0 0; border-bottom: none; width: 100%; }
.thinking-panel-container.expanded .thinking-content { margin-top: 0; border-radius: 0 0 10px 10px; background: none; border: none; border-top: 1px solid rgba(255, 255, 255, 0.1); }

/* 토스트 메시지 */
.toast-container { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); z-index: 10000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: rgba(26, 27, 30, 0.85); border: 1px solid var(--glass-border); padding: 12px 24px; border-radius: 20px; font-size: 0.9rem; animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-20px); } }

.date-divider { display: flex; align-items: center; gap: 12px; padding: 16px 0; color: var(--text-secondary); font-size: 0.8rem; opacity: 0.7; }
.date-divider::before, .date-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.date-divider span { white-space: nowrap; padding: 0 8px; }

/* 사이드바 스크롤바 */
.thread-list::-webkit-scrollbar { width: 6px; }
.thread-list::-webkit-scrollbar-track { background: transparent; }
.thread-list::-webkit-scrollbar-thumb { background: rgba(59, 206, 172, 0.2); border-radius: 10px; }
.thread-list::-webkit-scrollbar-thumb:hover { background: rgba(59, 206, 172, 0.4); }

/* 드래그 오버레이 */
.drag-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 9999; display: flex; align-items: center; justify-content: center; pointer-events: none; opacity: 0; transition: opacity 0.25s ease; }
.drag-overlay.active { opacity: 1; }
.drag-overlay-content { text-align: center; color: var(--text-primary); }
.drag-icon { font-size: 4rem; color: var(--accent); margin-bottom: 16px; text-shadow: 0 0 30px var(--accent-glow); animation: floatUpDown 1.6s ease-in-out infinite; }
@keyframes floatUpDown { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.preview-container { display: none; justify-content: center; align-items: center; margin-bottom: 12px; padding: 16px; background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--glass-border); border-radius: 20px; box-shadow: var(--shadow-md); min-height: 100px; }
.preview-container img { max-width: 90%; max-height: 400px; width: auto; height: auto; object-fit: contain; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); display: block; }
.drag-overlay-content p { font-size: 1.2rem; color: var(--text-secondary); letter-spacing: 0.5px; }

/* 관리자 버튼 */
.sidebar-footer .admin-only { display: none; visibility: hidden; opacity: 0; max-height: 0; margin: 0; padding: 0; border: none; overflow: hidden; transition: opacity 0.2s, visibility 0.2s, max-height 0.2s, margin 0.2s, padding 0.2s; }
.sidebar-footer .admin-only.show { display: flex !important; visibility: visible; opacity: 1; max-height: 50px; margin: 8px 0; padding: 10px 14px; }

/* 로그인 / 가입 UI 추가 제어 */
.auth-form { transition: all 0.3s ease; }
.auth-form.hidden { display: none !important; opacity: 0; pointer-events: none; }
.auth-toggle-text { margin-top: 16px; font-size: 0.85rem; color: var(--text-secondary); cursor: pointer; text-decoration: underline; transition: color 0.2s; }
.auth-toggle-text:hover { color: var(--accent); }

/* 이모지 픽커 */
.emoji-picker-container { display: flex !important; flex-wrap: wrap !important; justify-content: space-between !important; gap: 8px !important; margin-bottom: 16px; background: rgba(0,0,0,0.2); padding: 12px; border-radius: 12px; border: 1px solid var(--border); box-sizing: border-box !important; width: 100% !important; }
.emoji-btn { width: calc(20% - 8px) !important; aspect-ratio: 1; padding: 0; background: transparent; border: 1px solid transparent; color: var(--text-secondary); font-size: 1.3rem; border-radius: 10px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.emoji-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.emoji-btn.selected { background: rgba(59, 206, 172, 0.2); border-color: var(--accent); color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); transform: scale(1.1); }

/* 관리자 스위치 */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .3s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: var(--text-secondary); transition: .3s; border-radius: 50%; }
input:checked + .slider { background-color: rgba(248, 113, 113, 0.3); border: 1px solid #f87171; }
input:checked + .slider:before { transform: translateX(20px); background-color: #f87171; box-shadow: 0 0 8px rgba(248, 113, 113, 0.8); }

/* 유저 프로필 표기 */
.user-profile-badge { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.user-profile-badge i { font-size: 1.2rem; background: rgba(59,206,172,0.1); color: var(--accent); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }

/* 초대 가입 차단 */
.auth-toggle-text, #loginScreen .auth-toggle-text, .login-box .auth-toggle-text, [onclick*="toggleAuthMode"], [onclick*="showRegister"] { display: none !important; visibility: hidden !important; opacity: 0 !important; pointer-events: none !important; height: 0 !important; margin: 0 !important; padding: 0 !important; }
#registerForm { display: none !important; }
#registerForm:not(.hidden) { display: block !important; }
.login-box p#loginSubtitle { margin-bottom: 20px; }