/* ── Layout ──────────────────────────────────────────────── */
body { overflow: hidden }
.conv-wrap {
  height: calc(100vh - 78px); height: calc(100dvh - 78px);
  margin-top: 78px;
  overflow: hidden;
}

/* ── Scrim ───────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 12, 14, 0.42);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .22s;
}
.scrim[data-open="true"] { opacity: 1; pointer-events: auto; }

/* ── LEFT drawer ─────────────────────────────────────────── */
.conv-left {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 51;
  width: min(340px, 88vw);
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  transform: translateX(-103%);
  transition: transform .26s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 24px 60px -24px rgba(0,0,0,.28);
  overflow-x: hidden;
}
.conv-left[data-open="true"] { transform: translateX(0); }


/* ── Drawer chrome ───────────────────────────────────────── */
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); flex: none;
}
.drawer-head-title {
  font-family: var(--serif); font-weight: 400; font-size: 1.15rem; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.drawer-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.drawer-body::-webkit-scrollbar { width: 3px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* Bordered section cards */
.drawer-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
}
.drawer-section-hd {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3);
  background: var(--bg);
}
.drawer-section-bd { padding: 8px; border-radius: 0 0 10px 10px; }

.drawer-label {
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3);
  margin: 14px 0 5px; display: flex; justify-content: space-between; align-items: center;
}
.x-btn {
  width: 30px; height: 30px; border-radius: 7px;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
  transition: background .13s, color .13s; cursor: pointer;
}
.x-btn:hover { background: var(--bg-elev); color: var(--ink); }
.x-btn svg { width: 14px; height: 14px; }

/* ── Link list (sugs, history, pins) ─────────────────────── */
.link-list { display: flex; flex-direction: column; gap: 1px; }
.link-item {
  display: flex; align-items: flex-start; gap: 0.4rem; text-align: left;
  border: 0; background: transparent; color: var(--ink-2);
  padding: 7px 9px; border-radius: 7px;
  font-family: inherit; font-size: 12.5px; line-height: 1.4;
  cursor: pointer; transition: background .12s; width: 100%;
}
.link-item:hover { background: var(--bg-elev); color: var(--ink); }
.link-item .li-x {
  margin-left: auto; color: var(--ink-3); opacity: 0; flex: none;
  border: 0; background: transparent; padding: 0 2px; font-size: 13px; cursor: pointer; line-height: 1;
}
.link-item:hover .li-x { opacity: 1; }
.link-item .li-x:hover { color: var(--alarm, #c92a2a) !important; }

/* ── Left panel labels ───────────────────────────────────── */
.panel-lbl { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3) }
.aide-intro { font-family: var(--serif); font-size: 18px; line-height: 1.2; color: var(--ink); margin: 0 0 10px }
.hist-item {
  padding: 7px 9px; border-radius: 7px;
  border: 1px solid transparent;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; transition: background .12s, border-color .12s;
}
.hist-item:hover { background: var(--bg-elev); border-color: var(--line) }
.hist-item.active { background: var(--bg-elev); border-color: var(--line) }
.hist-txt { font-size: 12.5px; color: var(--ink-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.hist-item.active .hist-txt { color: var(--ink) }
.hist-d { font-family: var(--mono); font-size: 10px; color: var(--ink-3); flex-shrink: 0 }
.pinned-item { padding: 6px 8px; border-radius: 7px; font-size: 12px; color: var(--ink-2); cursor: pointer; transition: background .1s; display: flex; align-items: center; gap: 6px; }
.pinned-item:hover { background: var(--bg-elev); color: var(--ink) }
.pin-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer; color: var(--ink-3);
  padding: 2px 4px; border-radius: 4px; transition: color .1s, background .1s; line-height: 1;
}
.pin-btn:hover { color: var(--water); background: var(--bg-elev) }
.pin-rm-btn:hover { color: var(--alarm, #c92a2a) !important }
.sug-left-btn {
  display: block; width: 100%; text-align: left;
  padding: 7px 9px; border-radius: 7px;
  border: 1px solid transparent; background: none; cursor: pointer;
  font-size: 12.5px; color: var(--ink-2); font-family: inherit; line-height: 1.3;
  transition: background .12s, border-color .12s;
}
.sug-left-btn:hover { background: var(--bg-elev); border-color: var(--line); color: var(--ink) }
.sms-note {
  margin-top: auto; padding: 11px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg-elev);
}
.sms-note-lbl { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px }
.sms-note-body { font-size: 12px; color: var(--ink-2); line-height: 1.45; margin: 0 }
.sms-note-body span { font-family: var(--mono); color: var(--ink) }

/* ── CENTER panel ────────────────────────────────────────── */
.conv-center { display: flex; flex-direction: column; height: 100%; overflow: hidden }

/* Thread header */
.conv-thread-hdr {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.thread-hdr-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--bg-elev);
  border-radius: 8px; color: var(--ink-2); flex-shrink: 0;
  transition: border-color .15s, color .15s; cursor: pointer;
}
.thread-hdr-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.thread-title { font-family: var(--serif); font-size: 19px; color: var(--ink); line-height: 1.15 }
.thread-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px }
.thread-meta { display: flex; gap: 8px; align-items: center }


/* Conversation message list */
.conv-msgs {
  flex: 1; overflow-y: auto; padding: 24px clamp(20px,5vw,48px);
  display: flex; flex-direction: column; gap: 24px;
  scroll-behavior: smooth;
}
.conv-msgs::-webkit-scrollbar { width: 3px }
.conv-msgs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px }

/* ── Greeting / Welcome ──────────────────────────────────── */
.greet { margin-bottom: 0.5rem; }
.greet-kicker {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 12px;
}
.greet-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--water);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--water) 22%, transparent);
  flex-shrink: 0;
}
.greet-h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(1.7rem, 4.5vw, 2.4rem); line-height: 1.2;
  letter-spacing: -.005em; margin: 0 0 12px; color: var(--ink);
}
.greet-body { color: var(--ink-2); font-size: 14px; line-height: 1.55; margin: 0 0 14px; max-width: 54ch; }

/* Suggestion chip pills (greeting + welcome FU) — matches who-pill aesthetic */
.sugg-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sugg {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 5px;
  border: 1px solid var(--line); background: var(--bg-elev);
  border-radius: 999px;
  font-family: inherit; font-size: 12px; color: var(--ink); text-align: left;
  transition: border-color .15s;
  cursor: pointer;
}
.sugg:hover { border-color: var(--water); }
.sugg-glyph {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px;
  background: var(--bg-elev-2); flex-shrink: 0;
}

/* ── Messages ────────────────────────────────────────────── */
.msg-u { width: 100%; display: flex; flex-direction: column; align-items: flex-end }
.msg-b { width: 100% }
.bubble-u {
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: 16px 16px 4px 16px;
  padding: 11px 15px; font-size: 14px; color: var(--ink); line-height: 1.5;
}
.msg-time { font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin-top: 5px; text-align: right }

/* Bot message header */
.bot-head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.bot-ava {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  overflow: hidden;
}
.bot-ava img { display: block; width: 100%; height: 100%; border-radius: 6px; object-fit: cover; }
.bot-meta { display: flex; flex-direction: column; line-height: 1.25; }
.bot-meta b { font-size: 13px; font-weight: 700; color: var(--ink); }
.bot-meta span { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }

/* Legacy bot label (for compat) */
.msg-b-lbl { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--water); margin-bottom: 7px }

.reply-head { font-family: var(--serif); font-size: 22px; line-height: 1.22; color: var(--ink); margin-bottom: 9px }
.reply-head em { font-style: italic; color: var(--ink-2) }
.reply-body { font-size: 14px; color: var(--ink-2); line-height: 1.6; margin-bottom: 10px }
.reply-body strong, .reply-body .mono { color: var(--ink) }
.reply-advisory {
  font-size: 10.5px; color: var(--ink-3); line-height: 1.5;
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line-soft);
}
.reply-advisory em { font-style: italic; color: var(--ink-3) }

/* Source pins (pill chips per message) */
.src-pins { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 9px; }
.src-pin {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-2);
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  padding: 3px 8px; border-radius: 999px;
}
.src-pin i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.src-pin .age { color: var(--ink-3); }

/* Legacy source chips */
.src-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px }
.src-chip { font-family: var(--mono); font-size: 10.5px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-2) }

/* Follow-up chips inside bot answers */
.fu-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.fu-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font-family: var(--font); font-size: 12.5px; color: var(--ink-2);
  cursor: pointer; transition: border-color .15s, color .15s;
}
.fu-btn:hover { border-color: var(--water); color: var(--ink) }

/* Reply actions */
.reply-acts { display: flex; gap: 5px; margin-top: 8px; }
.reply-acts button {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); background: var(--bg-elev);
  color: var(--ink-3); border-radius: 999px;
  font-family: inherit; font-size: 11.5px; padding: 4px 10px;
  transition: color .15s, border-color .15s, background .15s; cursor: pointer;
}
.reply-acts button:hover { color: var(--water); border-color: var(--water); }
.reply-acts button svg { width: 12px; height: 12px; }
.reply-acts button[data-on="true"] { color: var(--water); border-color: var(--water); background: color-mix(in srgb, var(--water) 8%, transparent); }

/* Typing dots */
.typing {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 10px 14px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 12px; border-bottom-left-radius: 4px;
}
.typing span { width: 6px; height: 6px; background: var(--ink-3); border-radius: 50%; animation: bounce 1.2s infinite }
.typing span:nth-child(2) { animation-delay: .2s }
.typing span:nth-child(3) { animation-delay: .4s }
@keyframes bounce { 0%,80%,100% { transform: translateY(0); opacity: .35 } 40% { transform: translateY(-5px); opacity: 1 } }

/* Data panels (ECharts) */
.data-panel {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; margin-bottom: 14px;
}
.dp-lbl { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-bottom: 6px }
.data-panel-stats { border-left: 1px solid var(--line-soft); padding-left: 14px; display: flex; flex-direction: column; gap: 6px }
.dp-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3) }
.dp-row .v { font-family: var(--mono); color: var(--ink) }
.dp-row .warn { font-family: var(--mono); color: var(--dry) }

/* ── Composer ─────────────────────────────────────────────── */
.conv-composer {
  padding: 0 clamp(20px,5vw,48px) 16px;
  flex-shrink: 0;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 28%);
  padding-top: 12px;
}
.composer-inner {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-elev); border: 1.5px solid var(--line);
  border-radius: 16px; padding: 9px 11px;
  transition: border-color .2s;
  box-shadow: 0 4px 16px -8px rgba(0,0,0,.14);
}
.composer-inner:focus-within { border-color: var(--water) }
.composer-icon { color: var(--ink-3); flex-shrink: 0 }
.composer-ta {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--font); font-size: 14px; color: var(--ink);
  resize: none; min-height: 22px; max-height: 100px; line-height: 1.4;
}
.composer-ta::placeholder { color: var(--ink-3) }
.composer-r { display: flex; align-items: center; gap: 7px }
.composer-send {
  width: 34px; height: 34px; background: var(--water); border: none; border-radius: 10px;
  color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: opacity .15s, transform .12s; flex-shrink: 0;
}
.composer-send:hover { opacity: .88; transform: translateY(-1px); }
.composer-send:disabled { opacity: .3; cursor: not-allowed; transform: none; }
.composer-mic {
  width: 32px; height: 32px; background: transparent; border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all .15s;
}
.composer-mic:hover { border-color: var(--water); color: var(--water) }
.composer-mic.listening { border-color: var(--alarm, #c92a2a); color: var(--alarm, #c92a2a); animation: micpulse 1s infinite }
@keyframes micpulse { 0%,100% { opacity: 1 } 50% { opacity: .5 } }
.conv-disclaimer {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  margin-top: 7px; font-size: 10.5px; color: var(--ink-3); gap: 6px;
}
.conv-disclaimer .v { font-family: var(--mono) }
.quota-bar { font-family: var(--mono); font-size: 10px; color: var(--ink-3); white-space: nowrap; flex-shrink: 0 }
.quota-bar.quota-warn { color: var(--dry) }
.quota-bar.quota-full { color: var(--alarm, #c92a2a) }

/* ── RIGHT drawer specifics ──────────────────────────────── */
.ctx-persona { display: flex; align-items: center; gap: 10px }
.ctx-avatar {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 14px; color: var(--ink-2);
  font-family: var(--mono); flex-shrink: 0;
}
.ctx-name { font-size: 12.5px; color: var(--ink); line-height: 1.15 }
.ctx-role { font-size: 11px; color: var(--ink-3) }
.ctx-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3) }
.ctx-row .v { font-family: var(--mono); color: var(--ink) }
.src-live { display: flex; align-items: center; justify-content: space-between }
.src-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0 }
.src-name { font-size: 12px; color: var(--ink-2) }
.src-age { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3) }
.ctx-aside {
  padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: transparent;
}
.ctx-aside-lbl { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 5px }
.ctx-aside-body { font-size: 12px; color: var(--ink-2); line-height: 1.55; margin: 0 }
.conn-status { font-size: 10.5px; color: var(--ink-3); line-height: 1.5; margin-top: auto }
.conn-online { color: var(--water) }

/* ── ECharts chart grid ──────────────────────────────────── */
.conv-chart-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 4px }
.conv-chart-panel {
  flex: 1 1 200px; max-width: 340px;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
.conv-chart-panel.wide { flex: 1 1 340px; max-width: 520px }
.conv-chart-title {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 6px;
}
.conv-chart-canvas { width: 100%; height: 140px }
.conv-chart-panel.wide .conv-chart-canvas { height: 160px }



/* Markdown table inside bot replies */
.bm-md-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 8px 0; }
.bm-md-table th { text-align: left; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 4px 8px; border-bottom: 1px solid var(--line); }
.bm-md-table td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); }
.bm-md-table tr:last-child td { border-bottom: 0; }
mark.bm-hl { background: color-mix(in srgb, var(--dry) 15%, transparent); color: var(--dry); font-weight: 700; padding: 1px 4px; border-radius: 4px; }

/* ── Mobile nav section inside drawer (hidden on desktop) ─── */
.drawer-mobile-nav { display: none; }
.dmn-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; font-size: 13px; color: var(--ink-2);
  text-decoration: none; border-radius: 7px;
  transition: color .12s, background .12s;
}
.dmn-link:hover { color: var(--ink); background: var(--bg-elev-2); }

/* ── Responsive breakpoints ──────────────────────────────────── */

/* ≤1000px: chrome nav gone — thread hamburger hands off to chrome hamburger */
@media (max-width: 1000px) {
  .thread-hdr-btn { display: none; }
  .drawer-mobile-nav { display: block; }
}

/* ≤640px: chrome moves to top:10px — tighten conv-wrap clearance */
@media (max-width: 640px) {
  .conv-wrap {
    margin-top: 70px;
    height: calc(100vh - 70px);
    height: calc(100dvh - 70px);
  }
}

/* ≤768px: tighter layout for small screens */
@media (max-width: 768px) {
  .conv-thread-hdr { padding: 10px 14px; }
  .thread-title { font-size: 16px; }
  .conv-msgs { padding: 16px 14px; gap: 18px; }
  .conv-composer { padding: 0 14px 12px; padding-top: 10px; }
  .greet-h1 { font-size: clamp(1.4rem, 7vw, 2rem); }
  .greet-body { font-size: 13px; }
  .data-panel { grid-template-columns: 1fr; }
  .data-panel-stats { border-left: none; border-top: 1px solid var(--line-soft); padding-left: 0; padding-top: 10px; }
}
