/* ============================================================
   Inbox — 3 pane layout
   ============================================================ */
.inbox {
  display: grid;
  grid-template-columns: 340px 1fr 320px;
  height: 100%;
  min-height: 0;
}

/* ---- Pane 1: conversation list ---- */
.convlist { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.convlist-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.convlist-head .row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.convlist-head h2 { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.filter-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.filter-tab {
  flex: 1; padding: 6px 8px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--txt-500);
  transition: all .18s; text-align: center;
}
.filter-tab.active { background: var(--surface); color: var(--txt-900); box-shadow: var(--shadow-sm); }
.filter-tab .count { color: var(--txt-300); font-weight: 700; margin-left: 3px; }

.convlist-scroll { flex: 1; overflow-y: auto; padding: 6px; }

.conv {
  display: flex; gap: 12px; padding: 12px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s; position: relative; width: 100%; text-align: left;
}
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--violet-50); }
.conv.active::after { content:''; position:absolute; left:0; top:10px; bottom:10px; width:3px; border-radius:99px; background: var(--violet-500); }
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 700; font-size: 13.5px; color: var(--txt-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11.5px; color: var(--txt-300); font-weight: 600; flex: 0 0 auto; }
.conv-handle { font-size: 11.5px; color: var(--txt-300); font-weight: 600; }
.conv-preview { font-size: 12.5px; color: var(--txt-500); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.conv.unread .conv-name { color: var(--txt-900); }
.conv.unread .conv-preview { color: var(--txt-700); font-weight: 600; }
.conv-meta { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.stage-pill { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; letter-spacing: .2px; }

/* ---- Pane 2: thread ---- */
.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface-2); }
.thread-head {
  flex: 0 0 auto; padding: 13px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 13px; background: var(--surface);
}
.thread-head .who { flex: 1; min-width: 0; }
.thread-head .name { font-weight: 700; font-size: 15px; }
.thread-head .status { font-size: 12px; color: var(--txt-500); display: flex; align-items: center; gap: 6px; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px var(--mint-bg); }

.thread-scroll { flex: 1; overflow-y: auto; padding: 26px 30px; display: flex; flex-direction: column; gap: 4px; }

.day-sep { text-align: center; margin: 14px 0 18px; position: relative; }
.day-sep span { background: var(--surface-2); padding: 0 14px; font-size: 11.5px; font-weight: 700; color: var(--txt-300); letter-spacing: .3px; position: relative; z-index: 1; }
.day-sep::before { content:''; position:absolute; left:0; right:0; top:50%; height:1px; background: var(--line); }

.msg { display: flex; gap: 10px; max-width: 76%; margin-bottom: 12px; align-items: flex-end; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble { padding: 11px 15px; border-radius: 18px; font-size: 14px; line-height: 1.5; position: relative; }
.msg.in .msg-bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; color: var(--txt-900); box-shadow: var(--shadow-sm); }
.msg.out .msg-bubble { background: var(--violet-600); color: #fff; border-bottom-right-radius: 5px; box-shadow: var(--shadow-violet); }
.msg-meta { font-size: 11px; font-weight: 600; margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.msg.in .msg-meta { color: var(--txt-300); }
.msg.out .msg-meta { color: var(--txt-300); justify-content: flex-end; }
.msg.out .msg-meta .seen { color: var(--violet-400); }
.msg-stack { display: flex; flex-direction: column; }
.msg.out .msg-stack { align-items: flex-end; }
.msg .avatar { margin-bottom: 18px; }
.ai-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 800; color: var(--violet-400); letter-spacing: .3px; }
.ai-tag svg { width: 11px; height: 11px; }

.typing { display: flex; gap: 4px; align-items: center; padding: 13px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--txt-300); animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ---- Composer + AI ---- */
.composer { flex: 0 0 auto; border-top: 1px solid var(--line); background: var(--surface); padding: 14px 22px 16px; }

.ai-suggestions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ai-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.ai-head .lbl { font-size: 11.5px; font-weight: 800; letter-spacing: .4px; color: var(--violet-600); display: flex; align-items: center; gap: 6px; text-transform: uppercase; }
.ai-head .lbl svg { width: 14px; height: 14px; }
.ai-head .close { margin-left: auto; color: var(--txt-300); }
.ai-head .close:hover { color: var(--txt-700); }
.ai-card {
  background: var(--violet-50); border: 1px solid var(--violet-100); border-radius: 12px;
  padding: 11px 14px; font-size: 13.5px; color: var(--txt-900); cursor: pointer;
  transition: all .16s var(--ease); position: relative; line-height: 1.45;
  animation: aiPop .4s var(--ease) backwards; width: 100%; text-align: left;
}
.ai-card:hover { background: #fff; border-color: var(--violet-400); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.ai-card .intent { display: block; font-size: 10.5px; font-weight: 800; color: var(--violet-500); letter-spacing: .3px; margin-bottom: 4px; text-transform: uppercase; }
.ai-card .use { position: absolute; right: 12px; bottom: 11px; opacity: 0; transition: opacity .15s; font-size: 11.5px; font-weight: 700; color: var(--violet-600); display: flex; align-items: center; gap: 4px; }
.ai-card:hover .use { opacity: 1; }
@keyframes aiPop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.ai-thinking { display: flex; align-items: center; gap: 11px; padding: 14px; background: var(--violet-50); border: 1px solid var(--violet-100); border-radius: 12px; margin-bottom: 12px; }
.ai-thinking .spin { width: 18px; height: 18px; border: 2.5px solid var(--violet-100); border-top-color: var(--violet-500); border-radius: 50%; animation: spin .7s linear infinite; }
.ai-thinking span { font-size: 13px; font-weight: 600; color: var(--violet-600); }
@keyframes spin { to { transform: rotate(360deg); } }

.composer-box {
  border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface);
  transition: border-color .2s, box-shadow .2s; overflow: hidden;
}
.composer-box:focus-within { border-color: var(--violet-400); box-shadow: 0 0 0 3px var(--violet-50); }
.composer-from { display: flex; gap: 4px; padding: 8px 10px 0; }
.composer-from .from-tab { font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 99px; color: var(--txt-500); background: var(--surface-2); border: 1px solid var(--line); transition: all .15s; }
.composer-from .from-tab.active { background: var(--violet-50); color: var(--violet-600); border-color: var(--violet-400); }
.ai-suggestions.ai-error { background: var(--rose-bg); border: 1px solid #f3c7d2; border-radius: 12px; padding: 12px 14px; }
.composer-box textarea {
  width: 100%; border: none; outline: none; resize: none; padding: 13px 16px 4px;
  font-size: 14px; line-height: 1.5; max-height: 140px; background: none; color: var(--txt-900);
}
.composer-box textarea::placeholder { color: var(--txt-300); }
.composer-tools { display: flex; align-items: center; gap: 6px; padding: 6px 10px 9px; }
.composer-tools .tool { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--txt-500); transition: all .15s; }
.composer-tools .tool:hover { background: var(--surface-2); color: var(--txt-900); }
.composer-tools .tool svg { width: 18px; height: 18px; }
.composer-tools .spacer { flex: 1; }

.tone-select {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--txt-500);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}
.tone-select select { border: none; background: none; outline: none; font-weight: 700; color: var(--violet-600); cursor: pointer; }
.tone-select svg { width: 14px; height: 14px; color: var(--violet-500); }

.send-btn { background: var(--violet-600); color: #fff; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; box-shadow: var(--shadow-violet); transition: transform .12s, background .2s; }
.send-btn:hover { background: var(--violet-500); }
.send-btn:disabled { background: #6f6687; box-shadow: none; opacity: .72; }
.send-btn:disabled:hover { background: #6f6687; }
.send-btn:active { transform: scale(.92); }
.send-btn svg { width: 18px; height: 18px; }
.delivery-warning { max-width: 220px; font-size: 11px; line-height: 1.25; color: var(--txt-700); font-weight: 700; }

.suggest-btn {
  display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13px;
  padding: 8px 14px; border-radius: 10px; color: var(--violet-600); background: var(--violet-50);
  border: 1px solid var(--violet-100); transition: all .16s;
}
.suggest-btn:hover { background: var(--violet-100); }
.suggest-btn svg { width: 16px; height: 16px; }

/* ---- Pane 3: context ---- */
.context { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; min-height: 0; }
.ctx-hero { padding: 26px 22px 20px; text-align: center; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--violet-50), transparent); }
.ctx-hero .avatar { margin: 0 auto 12px; }
.ctx-hero h3 { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.ctx-hero .role { font-size: 12.5px; color: var(--txt-500); margin-top: 2px; }
.ctx-hero .links { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.ctx-link { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--txt-500); transition: all .15s; }
.ctx-link:hover { color: var(--violet-600); border-color: var(--violet-100); background: var(--violet-50); }
.ctx-link svg { width: 16px; height: 16px; }

.ctx-section { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.ctx-section h4 { font-size: 11px; font-weight: 800; letter-spacing: .5px; color: var(--txt-300); text-transform: uppercase; margin-bottom: 12px; }
.ctx-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 13px; }
.ctx-row .k { color: var(--txt-500); }
.ctx-row .v { font-weight: 700; color: var(--txt-900); }

.deal-stage { margin-top: 4px; }
.stage-track { display: flex; gap: 4px; margin: 12px 0 8px; }
.stage-step { flex: 1; height: 5px; border-radius: 99px; background: var(--line-strong); transition: background .3s; }
.stage-step.done { background: var(--violet-500); }
.stage-label { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--txt-300); }
.stage-current { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--violet-600); }
.deal-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.deal-value small { font-size: 13px; color: var(--txt-500); font-weight: 600; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 4px 6px 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--txt-700); }
.tag-x { font-size: 14px; line-height: 1; color: var(--txt-300); width: 15px; height: 15px; border-radius: 50%; display: grid; place-items: center; }
.tag-x:hover { background: var(--rose-bg); color: var(--rose); }
.tag-add { width: 26px; height: 26px; border-radius: 99px; display: grid; place-items: center; border: 1px dashed var(--line-strong); color: var(--txt-500); }
.tag-add:hover { border-color: var(--violet-400); color: var(--violet-600); background: var(--violet-50); }
.tag-add svg { width: 13px; height: 13px; }

.note { background: var(--amber-bg); border: 1px solid #f4e3c0; border-radius: 10px; padding: 11px 13px; font-size: 12.5px; color: #8a5a0e; line-height: 1.5; }
.note-edit { width: 100%; resize: vertical; min-height: 64px; font-family: var(--font-body); outline: none; transition: border-color .2s, box-shadow .2s; }
.note-edit:focus { border-color: #e6b94e; box-shadow: 0 0 0 3px rgba(245,165,36,.14); }
.note-edit::placeholder { color: #b89456; }
.note-hint { font-size: 10.5px; font-weight: 600; color: var(--txt-300); margin-top: 5px; }

.sys-note { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--txt-500); background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 5px 14px; margin: 8px auto; width: fit-content; max-width: 90%; }

.empty-thread { display: grid; place-items: center; height: 100%; text-align: center; color: var(--txt-300); }
.empty-thread svg { width: 56px; height: 56px; margin-bottom: 14px; opacity: .5; }
.empty-thread h3 { font-family: var(--font-display); color: var(--txt-500); font-weight: 700; font-size: 17px; }
