:root {
  --navy:    #0D1B2A;
  --blue:    #1A5276;
  --mid:     #2471A3;
  --sky:     #3498DB;
  --light:   #EBF5FB;
  --teal:    #0E9488;
  --green:   #16A34A;
  --green-l: #DCFCE7;
  --amber:   #D97706;
  --amber-l: #FEF3C7;
  --red:     #DC2626;
  --red-l:   #FEE2E2;
  --gray-l:  #F7F9FC;
  --gray-1:  #F1F4F8;
  --gray-2:  #E2E8F0;
  --gray-3:  #CBD5E1;
  --gray-4:  #94A3B8;
  --gray-5:  #64748B;
  --gray-7:  #334155;
  --white:   #FFFFFF;

  --bubble-me:    #1A5276;
  --bubble-me-t:  #FFFFFF;
  --bubble-you:   #FFFFFF;
  --bubble-you-t: #1E293B;

  --panel-l: 280px;
  --panel-r: 300px;
  --header-h: 60px;
  --input-h:  80px;
  --r: 16px;
  --font-d: 'Gmarket Sans', 'Noto Sans KR', sans-serif;
  --font-b: 'Noto Sans KR', sans-serif;
  --shadow-sm: 0 1px 4px rgba(13,27,42,.07);
  --shadow:    0 4px 16px rgba(13,27,42,.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { font-family: var(--font-b); background: var(--gray-l); color: var(--navy); display: flex; -webkit-font-smoothing: antialiased; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-2); border-radius: 2px; }

/* ─── LEFT PANEL — 채팅방 목록 ─── */
.rooms-panel {
  width: var(--panel-l);
  min-width: var(--panel-l);
  background: var(--white);
  border-right: 1px solid var(--gray-2);
  display: flex; flex-direction: column;
  height: 100vh; flex-shrink: 0;
}

.rooms-header { padding: 16px 18px 12px; border-bottom: 1px solid var(--gray-2); background: var(--navy); }
.rh-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.rh-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.rh-logo-box { width: 32px; height: 32px; border-radius: 9px; background: var(--blue); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.rh-logo-text { font-family: var(--font-d); font-size: 15px; font-weight: 700; color: var(--white); }
.rh-new-btn { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.1); border: none; cursor: pointer; font-size: 17px; display: flex; align-items: center; justify-content: center; color: var(--white); }

.rh-user { display: flex; align-items: center; gap: 10px; }
.rh-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--sky), var(--teal)); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.rh-name  { font-size: 13px; font-weight: 700; color: var(--white); }
.rh-plan  { font-size: 11px; color: rgba(255,255,255,.45); margin-top: 1px; }
.rh-status { margin-left: auto; display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: rgba(255,255,255,.6); }
.rh-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ADE80; }

.rooms-search { padding: 12px 16px; border-bottom: 1px solid var(--gray-1); }
.search-input-wrap { position: relative; }
.search-input-wrap span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 15px; color: var(--gray-4); }
.search-input { width: 100%; padding: 8px 10px 8px 32px; border: 1.5px solid var(--gray-2); border-radius: 10px; font-family: var(--font-b); font-size: 13px; color: var(--gray-7); background: var(--gray-l); transition: border-color .18s; }
.search-input:focus { outline: none; border-color: var(--sky); background: var(--white); }

.rooms-list { flex: 1; overflow-y: auto; }
.room-section-label { padding: 10px 18px 4px; font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--gray-4); }
.room-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; cursor: pointer; transition: background .15s; position: relative; border-bottom: 1px solid var(--gray-1); }
.room-item:hover { background: var(--gray-l); }
.room-item.active { background: var(--light); }
.room-item.active::before { content:''; position:absolute; left:0; top:0; bottom:0; width:3px; background:var(--sky); border-radius:0 2px 2px 0; }
.ri-avatar { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; position: relative; }
.ri-online { position: absolute; bottom: 1px; right: 1px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); border: 2px solid var(--white); }
.ri-info { flex: 1; min-width: 0; }
.ri-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.ri-name { font-size: 13px; font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.ri-time { font-size: 11px; color: var(--gray-4); flex-shrink: 0; }
.ri-preview { font-size: 12px; color: var(--gray-5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 3px; }
.ri-field { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 100px; }
.ri-unread { min-width: 18px; height: 18px; border-radius: 100px; background: var(--blue); color: var(--white); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px; }

/* ─── CENTER — 채팅 대화창 ─── */
.chat-panel { flex: 1; display: flex; flex-direction: column; height: 100vh; min-width: 0; background: var(--gray-l); position: relative; }

.chat-header { height: var(--header-h); background: var(--white); border-bottom: 1px solid var(--gray-2); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; flex-shrink: 0; box-shadow: var(--shadow-sm); z-index: 10; }
.ch-left { display: flex; align-items: center; gap: 12px; }
.ch-avatar { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; background: var(--light); border: 2px solid var(--gray-2); flex-shrink: 0; position: relative; }
.ch-online { position: absolute; bottom: 0; right: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--green); border: 2px solid var(--white); }
.ch-name { font-family: var(--font-d); font-size: 15px; font-weight: 700; color: var(--navy); }
.ch-sub  { font-size: 12px; color: var(--gray-4); margin-top: 1px; display: flex; align-items: center; gap: 6px; }
.ch-typing { color: var(--sky); font-weight: 600; }
.ch-right { display: flex; align-items: center; gap: 6px; }
.ch-btn { width: 36px; height: 36px; border-radius: 10px; background: var(--gray-1); border: none; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; color: var(--gray-5); transition: background .18s; }
.ch-btn:hover { background: var(--gray-2); color: var(--navy); }

.date-divider { display: flex; align-items: center; gap: 10px; padding: 12px 20px; flex-shrink: 0; }
.date-divider::before, .date-divider::after { content:''; flex:1; height:1px; background:var(--gray-2); }
.date-label { font-size: 11px; font-weight: 700; color: var(--gray-4); white-space: nowrap; background: var(--gray-l); padding: 4px 12px; border: 1px solid var(--gray-2); border-radius: 100px; }

.chat-messages { flex: 1; overflow-y: auto; padding: 8px 20px 12px; display: flex; flex-direction: column; gap: 2px; }

.sys-msg { text-align: center; margin: 8px 0; }
.sys-msg span { display: inline-block; background: var(--white); border: 1px solid var(--gray-2); color: var(--gray-5); font-size: 12px; font-weight: 500; padding: 6px 14px; border-radius: 100px; }

.msg-row { display: flex; gap: 8px; margin-bottom: 2px; align-items: flex-end; }
.msg-row.me { flex-direction: row-reverse; }
.msg-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; background: var(--light); flex-shrink: 0; }
.msg-avatar.invisible { visibility: hidden; }
.msg-group { display: flex; flex-direction: column; gap: 3px; max-width: 68%; }
.msg-row.me .msg-group { align-items: flex-end; }
.msg-row.you .msg-group { align-items: flex-start; }
.msg-meta-top { font-size: 11px; color: var(--gray-4); margin-bottom: 4px; padding: 0 4px; }

.bubble { padding: 10px 14px; border-radius: 18px; font-size: 14px; line-height: 1.65; word-break: break-word; position: relative; max-width: 100%; }
.bubble.me { background: var(--bubble-me); color: var(--bubble-me-t); border-bottom-right-radius: 5px; }
.bubble.you { background: var(--bubble-you); color: var(--bubble-you-t); border-bottom-left-radius: 5px; box-shadow: var(--shadow-sm); border: 1px solid var(--gray-2); }

.msg-time-read { display: flex; align-items: center; gap: 4px; margin-top: 3px; padding: 0 4px; }
.msg-row.me .msg-time-read { justify-content: flex-end; }
.msg-time { font-size: 11px; color: var(--gray-4); }
.msg-read { font-size: 11px; color: var(--sky); font-weight: 600; }

.file-bubble { display: flex; align-items: center; gap: 10px; background: var(--white); border: 1.5px solid var(--gray-2); border-radius: 14px; padding: 11px 14px; cursor: pointer; transition: all .18s; max-width: 260px; }
.file-bubble:hover { border-color: var(--sky); background: var(--light); }
.file-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--light); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.file-name { font-size: 13px; font-weight: 700; color: var(--navy); }
.file-dl { font-size: 11px; color: var(--sky); font-weight: 600; margin-top: 2px; }

.img-bubble { border-radius: 14px; overflow: hidden; max-width: 220px; cursor: pointer; border: 1px solid var(--gray-2); margin-top: 4px; }
.img-placeholder { width: 220px; height: 150px; background: linear-gradient(135deg, var(--light), var(--gray-2)); display: flex; align-items: center; justify-content: center; font-size: 36px; }

.typing-row { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.typing-bubble { background: var(--white); border: 1px solid var(--gray-2); border-radius: 18px; border-bottom-left-radius: 5px; padding: 12px 16px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 4px; }
.typing-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gray-3); animation: typingBounce 1.2s infinite ease-in-out; }
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes typingBounce { 0%,80%,100% { transform: translateY(0); background: var(--gray-3); } 40% { transform: translateY(-6px); background: var(--sky); } }

.chat-input-wrap { background: var(--white); border-top: 1px solid var(--gray-2); padding: 10px 16px 14px; flex-shrink: 0; }
.attach-preview { display: none; align-items: center; gap: 8px; padding: 8px 10px; background: var(--gray-l); border: 1px solid var(--gray-2); border-radius: 10px; margin-bottom: 8px; }
.attach-preview.show { display: flex; }
.ap-name { font-size: 12px; font-weight: 700; color: var(--navy); flex: 1; }
.ap-remove { background: none; border: none; color: var(--gray-4); cursor: pointer; font-size: 16px; }

.chat-input-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-input-actions { display: flex; gap: 4px; flex-shrink: 0; }
.input-action-btn { width: 36px; height: 36px; border-radius: 10px; border: none; background: var(--gray-1); cursor: pointer; font-size: 17px; display: flex; align-items: center; justify-content: center; transition: all .18s; color: var(--gray-5); }
.chat-textarea { width: 100%; min-height: 40px; max-height: 120px; resize: none; overflow-y: auto; border: 1.5px solid var(--gray-2); border-radius: 14px; padding: 10px 14px; font-family: var(--font-b); font-size: 14px; color: var(--navy); line-height: 1.5; background: var(--gray-l); transition: border-color .18s; }
.chat-textarea:focus { outline: none; border-color: var(--sky); background: var(--white); }
.send-btn { width: 40px; height: 40px; border-radius: 12px; border: none; background: var(--blue); color: var(--white); cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .22s cubic-bezier(.34,1.56,.64,1); }
.send-btn:disabled { background: var(--gray-2); color: var(--gray-4); cursor: not-allowed; }

.quick-replies { display: none; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.quick-replies.show { display: flex; }
.qr-btn { padding: 6px 12px; border-radius: 100px; border: 1.5px solid var(--gray-2); background: var(--white); font-family: var(--font-b); font-size: 12px; font-weight: 600; color: var(--gray-7); cursor: pointer; transition: all .18s; }
.qr-btn:hover { border-color: var(--blue); background: var(--light); color: var(--blue); }

/* ─── RIGHT PANEL — 컨텍스트 ─── */
.context-panel { width: var(--panel-r); min-width: var(--panel-r); background: var(--white); border-left: 1px solid var(--gray-2); height: 100vh; display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; }
.cp-header { padding: 16px 18px 12px; border-bottom: 1px solid var(--gray-2); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; position: sticky; top: 0; background: var(--white); z-index: 5; }
.cp-title { font-family: var(--font-d); font-size: 14px; font-weight: 700; color: var(--navy); }
.cp-close { width: 28px; height: 28px; border-radius: 8px; background: var(--gray-1); border: none; cursor: pointer; }

.cp-expert { padding: 16px 18px; border-bottom: 1px solid var(--gray-1); }
.cp-exp-card { background: var(--gray-l); border: 1px solid var(--gray-2); border-radius: 14px; padding: 14px; }
.cp-exp-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cp-exp-ava { width: 46px; height: 46px; border-radius: 50%; background: var(--light); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; position: relative; border: 2px solid var(--gray-2); }
.cp-exp-online { position: absolute; bottom: 1px; right: 1px; width: 11px; height: 11px; border-radius: 50%; background: var(--green); border: 2px solid var(--white); }
.cp-exp-name { font-size: 14px; font-weight: 700; color: var(--navy); }
.cp-exp-field{ font-size: 12px; color: var(--gray-5); margin-top: 2px; }
.cp-exp-verified { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--green); margin-top: 4px; }
.cp-exp-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1px; background: var(--gray-2); border-radius: 10px; overflow: hidden; }
.ces { background: var(--white); padding: 8px 4px; text-align: center; }
.ces-v { font-family: var(--font-d); font-size: 15px; font-weight: 700; color: var(--navy); }
.ces-l { font-size: 10px; color: var(--gray-4); }
.cp-exp-btns { display: flex; gap: 6px; margin-top: 10px; }
.cp-exp-btn { flex: 1; padding: 8px 6px; border-radius: 9px; font-family: var(--font-b); font-size: 12px; font-weight: 700; cursor: pointer; transition: all .18s; border: none; text-align: center; text-decoration: none; }
.cp-exp-btn.outline { background: var(--white); color: var(--blue); border: 1.5px solid var(--blue); }
.cp-exp-btn.solid  { background: var(--blue); color: var(--white); }

.cp-section { padding: 14px 18px; border-bottom: 1px solid var(--gray-1); }
.cp-section-title { font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--gray-4); margin-bottom: 10px; }
.cp-question-box { background: var(--gray-l); border: 1px solid var(--gray-2); border-radius: 12px; padding: 13px 14px; }
.cp-q-field-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 100px; background: var(--light); color: var(--blue); margin-bottom: 8px; }
.cp-q-title { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.cp-q-body  { font-size: 12px; color: var(--gray-5); line-height: 1.7; }
.cp-q-meta  { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--gray-2); }
.cp-q-urgent { font-size: 11px; font-weight: 700; color: var(--red); background: var(--red-l); padding: 2px 8px; border-radius: 100px; }
.cp-q-date   { font-size: 11px; color: var(--gray-4); }

.cp-attach-list { display: flex; flex-direction: column; gap: 6px; }
.cp-attach-item { display: flex; align-items: center; gap: 8px; background: var(--gray-l); border: 1px solid var(--gray-2); border-radius: 9px; padding: 8px 10px; cursor: pointer; transition: all .18s; }
.cp-attach-item:hover { background: var(--light); border-color: var(--sky); }
.cp-attach-icon { font-size: 18px; }
.cp-attach-name { font-size: 12px; font-weight: 600; color: var(--navy); flex: 1; }
.cp-attach-size { font-size: 11px; color: var(--gray-4); }

.cp-status-bar { padding: 14px 18px; border-bottom: 1px solid var(--gray-1); }
.cp-status-steps { display: flex; flex-direction: column; }
.cp-step { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; }
.cp-step-dot { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.cp-step-dot.done   { background: var(--blue); color: var(--white); }
.cp-step-dot.active { background: var(--white); border: 2.5px solid var(--sky); color: var(--sky); }
.cp-step-dot.wait   { background: var(--gray-1); border: 2px solid var(--gray-2); color: var(--gray-4); }
.cp-step-text { font-size: 12px; }
.cp-step-label { font-weight: 700; color: var(--navy); }
.cp-step-label.active { color: var(--sky); }
.cp-step-time  { color: var(--gray-4); font-size: 11px; margin-top: 2px; }
.cp-step-line  { width: 1.5px; height: 14px; background: var(--gray-2); margin: 0 0 0 10px; }
.cp-step-line.done { background: var(--blue); }

.cp-actions { padding: 14px 18px; }
.cp-complete-btn { width: 100%; padding: 13px; border-radius: 12px; border: none; background: linear-gradient(135deg, var(--blue), var(--mid)); color: var(--white); font-family: var(--font-b); font-size: 14px; font-weight: 700; cursor: pointer; transition: all .22s cubic-bezier(.34,1.56,.64,1); display: flex; align-items: center; justify-content: center; gap: 6px; }
.cp-report-btn { width: 100%; padding: 10px; border-radius: 10px; border: 1.5px solid var(--gray-2); background: var(--white); color: var(--gray-5); font-family: var(--font-b); font-size: 13px; cursor: pointer; margin-top: 8px; transition: background .18s; }

/* ══ 모달 ══ */
.overlay { position: fixed; inset: 0; background: rgba(13,27,42,.45); backdrop-filter: blur(5px); z-index: 500; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .22s; }
.overlay.show { opacity: 1; pointer-events: all; }
.modal { background: var(--white); border-radius: 20px; width: 480px; max-width: 94vw; box-shadow: 0 24px 70px rgba(13,27,42,.2); transform: scale(.95) translateY(12px); transition: transform .28s cubic-bezier(.34,1.56,.64,1); overflow: hidden; }
.overlay.show .modal { transform: scale(1) translateY(0); }
.modal-head { padding: 22px 24px 14px; border-bottom: 1px solid var(--gray-1); display: flex; justify-content: space-between; align-items: flex-start; }
.modal-title { font-family: var(--font-d); font-size: 17px; font-weight: 700; color: var(--navy); }
.modal-x { width: 30px; height: 30px; border-radius: 8px; background: var(--gray-1); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--gray-5); }
.modal-body { padding: 20px 24px; }
.modal-stars { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.modal-star { font-size: 36px; cursor: pointer; color: var(--gray-3); transition: all .15s; }
.modal-star.active { color: #F59E0B; }
.modal-textarea { width: 100%; border: 1.5px solid var(--gray-2); border-radius: 10px; padding: 12px 14px; font-family: var(--font-b); font-size: 14px; color: var(--navy); resize: none; height: 100px; background: var(--gray-l); transition: border-color .18s; }
.modal-foot { display: flex; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--gray-1); }
.modal-cancel  { flex: 1; padding: 13px; border-radius: 10px; border: 1.5px solid var(--gray-2); background: var(--white); font-family: var(--font-b); font-size: 14px; cursor: pointer; color: var(--gray-7); }
.modal-submit  { flex: 2; padding: 13px; border-radius: 10px; border: none; background: var(--green); color: var(--white); font-family: var(--font-b); font-size: 14px; font-weight: 700; cursor: pointer; transition: all .22s cubic-bezier(.34,1.56,.64,1); }

.toast { position: fixed; bottom: 20px; left: calc(var(--panel-l) + 20px); background: var(--navy); color: var(--white); padding: 12px 18px; border-radius: 12px; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; box-shadow: 0 8px 32px rgba(13,27,42,.25); transform: translateY(70px); opacity: 0; transition: all .32s cubic-bezier(.34,1.56,.64,1); z-index: 600; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1100px) { .context-panel { display: none; } .toast { left: 20px; right: 20px; } }
@media (max-width: 720px)  { .rooms-panel   { display: none; } }

@keyframes msgInChat { from{opacity:0;transform:translateY(8px);} to{opacity:1;transform:none;} }
.msg-row { animation: msgInChat .25s ease both; }
