/* RCG Assistant - Rose Communications Group brand */
:root {
  --blue: #2a206f;
  --blue-700: #352a86;
  --blue-900: #1c1550;
  --teal: #6498be;
  --teal-ink: #3f739a;
  --purple: #b079ad;
  --purple-ink: #8a4f87;

  --bg: #f6f5fb;
  --surface: #ffffff;
  --line: #e6e3f1;
  --line-strong: #d6d2e8;
  --ink: #1b1740;
  --ink-2: #3d3966;
  --muted: #6c6890;
  --tint-blue: #efedf8;
  --tint-teal: #eaf2f8;
  --tint-purple: #f6eef5;
  --danger: #c0364a;
  --danger-tint: #fcecee;
  --ok: #2f7d5b;
  --ok-tint: #e8f5ee;

  --font-title: "Gilroy", "Urbanist", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 21, 80, .06), 0 4px 16px rgba(28, 21, 80, .05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
h1, h2, h3, .title-font { font-family: var(--font-title); letter-spacing: -.01em; }
h1 { font-weight: 800; font-size: 26px; margin: 0 0 4px; color: var(--blue); }
h2 { font-weight: 800; font-size: 18px; margin: 0 0 12px; color: var(--blue); }
h3 { font-weight: 700; font-size: 15px; margin: 0 0 8px; }
.subtitle { font-family: var(--font-title); font-weight: 300; color: var(--muted); margin: 0 0 20px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px;
  font: 600 14px/1 var(--font-body); cursor: pointer; text-decoration: none;
  background: var(--blue); color: #fff; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--blue-700); }
.btn.secondary { background: var(--surface); color: var(--blue); border-color: var(--line-strong); }
.btn.secondary:hover { border-color: var(--blue); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--tint-blue); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #efc4cb; }
.btn.danger:hover { background: var(--danger-tint); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin: 0 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; font: 15px/1.4 var(--font-body); color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(100, 152, 190, .25);
}
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }
.row.top { align-items: flex-start; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- flash ---------- */
.flashes { margin: 0 0 16px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 10px; font-size: 14px; border: 1px solid; }
.flash.ok { background: var(--ok-tint); border-color: #bfe2cf; color: var(--ok); }
.flash.error { background: var(--danger-tint); border-color: #f1c5cc; color: var(--danger); }

/* ---------- auth pages ---------- */
.auth { min-height: 100%; display: grid; grid-template-columns: minmax(340px, 5fr) 7fr; background: var(--surface); }
.auth-side {
  position: relative; overflow: hidden; color: #fff; padding: 44px 48px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  background:
    radial-gradient(520px 420px at 110% -10%, rgba(100, 152, 190, .55), transparent 62%),
    radial-gradient(480px 420px at -20% 110%, rgba(176, 121, 173, .5), transparent 62%),
    var(--blue);
}
.auth-side .logo { width: 210px; display: block; }
.auth-side h2 { color: #fff; font-size: 34px; line-height: 1.15; font-weight: 800; margin: 0 0 14px; max-width: 12em; }
.auth-side p { color: rgba(255, 255, 255, .8); font-size: 16px; margin: 0 0 26px; max-width: 26em; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; color: rgba(255, 255, 255, .92); }
.auth-points svg { width: 20px; height: 20px; margin-top: 1px; color: #a9d0ea; }
.auth-side .side-foot { font-size: 12.5px; color: rgba(255, 255, 255, .6); margin: 0; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 28px; margin: 0 0 6px; }
.auth-card .subtitle { font-size: 15.5px; margin: 0 0 24px; line-height: 1.45; }
.auth-card .subtitle b { color: var(--ink-2); font-weight: 600; word-break: break-all; }
.auth-card input[type=text], .auth-card input[type=email], .auth-card input[type=password] { padding: 12px 14px; font-size: 16px; }
.auth-card .btn { width: 100%; padding: 13px; margin-top: 8px; font-size: 15px; }
.auth-steps { display: flex; gap: 8px; align-items: center; margin: 0 0 22px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-steps span { display: inline-flex; align-items: center; gap: 8px; }
.auth-steps i {
  font-style: normal; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line-strong); font-size: 12px;
}
.auth-steps .on { color: var(--blue); }
.auth-steps .on i, .auth-steps .done i { background: var(--blue); border-color: var(--blue); color: #fff; }
.auth-steps .bar { flex: 0 0 28px; height: 1px; background: var(--line-strong); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px !important; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer;
  font: 600 13px/1 var(--font-body); color: var(--teal-ink); padding: 8px; border-radius: 8px;
}
.pw-toggle:hover { background: var(--tint-teal); }
.code-input {
  text-align: center; letter-spacing: .5em; font-size: 26px !important; font-weight: 700; padding-left: .5em !important;
  font-variant-numeric: tabular-nums; color: var(--blue) !important;
}
.auth-alt {
  margin-top: 26px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.auth-alt b { display: block; font-size: 14.5px; color: var(--ink); }
.auth-alt span { font-size: 13px; color: var(--muted); }
.auth-alt .btn { width: auto; margin: 0; padding: 9px 14px; font-size: 13.5px; white-space: nowrap; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; font-size: 13.5px; }
.auth-links a, .auth-forgot { color: var(--teal-ink); font-weight: 600; text-decoration: none; }
.auth-links a:hover, .auth-forgot:hover { text-decoration: underline; }
.auth-forgot { font-size: 13px; float: right; }
.auth-foot { font-size: 12.5px; color: var(--muted); margin-top: 22px; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-side { padding: 20px 24px; gap: 0; }
  .auth-side .logo { width: 170px; }
  .auth-side .side-body, .auth-side .side-foot { display: none; }
  .auth-main { padding: 28px 20px 40px; place-items: start center; }
}

/* ---------- page shell (account/admin) ---------- */
.topbar {
  background: var(--blue); color: #fff; position: sticky; top: 0; z-index: 20;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 20px; height: 62px; }
.topbar .logo { height: 30px; display: block; }
.topbar .spacer { flex: 1; }
.topbar a.top-link {
  color: rgba(255, 255, 255, .85); text-decoration: none; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px;
}
.topbar a.top-link:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.subnav { background: var(--blue-900); }
.subnav-inner { max-width: 1240px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; }
.subnav a {
  color: rgba(255, 255, 255, .72); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 12px 12px 10px; border-bottom: 3px solid transparent; white-space: nowrap;
}
.subnav a:hover { color: #fff; }
.subnav a.on { color: #fff; border-bottom-color: var(--teal); }
.page { max-width: 1240px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .subtitle { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.kpi.teal::before { background: var(--teal); }
.kpi.purple::before { background: var(--purple); }
.kpi .label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .value { font-family: var(--font-title); font-weight: 800; font-size: 28px; color: var(--blue); margin-top: 4px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th {
  text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.t th.num { text-align: right; }
table.t td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #faf9fd; }
table.t a { font-weight: 600; text-decoration: none; }
table.t a:hover { text-decoration: underline; }

.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--tint-blue); color: var(--blue); }
.pill.teal { background: var(--tint-teal); color: var(--teal-ink); }
.pill.purple { background: var(--tint-purple); color: var(--purple-ink); }
.pill.grey { background: #eeedf3; color: var(--muted); }
.pill.red { background: var(--danger-tint); color: var(--danger); }
.pill.green { background: var(--ok-tint); color: var(--ok); }

.bar-meter { height: 6px; background: var(--tint-blue); border-radius: 99px; overflow: hidden; min-width: 80px; margin-top: 6px; }
.bar-meter > span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.bar-meter.warn > span { background: var(--purple); }
.bar-meter.over > span { background: var(--danger); }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.seg a.on { background: var(--blue); color: #fff; }

pre.log { background: #15113a; color: #d9d6f2; padding: 14px 16px; border-radius: 10px; max-height: 420px; overflow: auto; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; margin: 0; }

/* chart */
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: 240px; display: block; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 12.5px;
  padding: 8px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px));
  opacity: 0; transition: opacity .1s; box-shadow: var(--shadow);
}
.chart-tip b { font-weight: 700; }

/* Q&A list (feedback / gaps) */
.qa { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fff; }
.qa + .qa { margin-top: 12px; }
.qa .q { font-weight: 700; color: var(--blue); margin-bottom: 6px; }
.qa .meta { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.qa .a { font-size: 14px; color: var(--ink-2); max-height: 180px; overflow: hidden; position: relative; }
.qa .a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 40px; background: linear-gradient(transparent, #fff); }
.qa .comment { margin-top: 8px; padding: 8px 12px; background: var(--danger-tint); border-radius: 8px; font-size: 14px; }

/* transcript (admin chat view) */
.transcript { display: grid; gap: 14px; }
.tmsg { border-radius: 14px; padding: 12px 16px; }
.tmsg.user { background: var(--blue); color: #fff; margin-left: 12%; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.tmsg.assistant { background: #fff; border: 1px solid var(--line); margin-right: 12%; border-bottom-left-radius: 4px; }
.tmsg .tmeta { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- markdown ---------- */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md a { color: var(--blue); font-weight: 600; text-decoration-color: rgba(42, 32, 111, .35); text-underline-offset: 2px; }
.md a:hover { text-decoration-color: var(--blue); }
.md strong { color: var(--ink); }
.md h1, .md h2, .md h3, .md h4 { font-size: 16px; margin: 14px 0 6px; color: var(--blue); }
.md code { background: var(--tint-blue); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.md pre { background: #15113a; color: #e7e5f7; padding: 12px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; color: inherit; }
.md table { border-collapse: collapse; margin: 6px 0 12px; font-size: 14px; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.md th { background: var(--tint-blue); color: var(--blue); font-weight: 700; }
.md blockquote { margin: 0 0 10px; padding: 4px 12px; border-left: 3px solid var(--purple); color: var(--ink-2); background: var(--tint-purple); border-radius: 0 8px 8px 0; }

/* ============================================================ CHAT */
body.chat-body { overflow: hidden; }
.app { display: grid; grid-template-columns: 284px 1fr; height: 100vh; height: 100dvh; }

.sidebar { background: var(--blue); color: #fff; display: flex; flex-direction: column; min-height: 0; position: relative; }
.sidebar::after { /* subtle brand glow */
  content: ""; position: absolute; inset: auto 0 0 0; height: 220px; pointer-events: none;
  background: radial-gradient(260px 160px at 20% 120%, rgba(176, 121, 173, .35), transparent 70%),
              radial-gradient(240px 160px at 90% 110%, rgba(100, 152, 190, .3), transparent 70%);
}
.sb-head { padding: 20px 18px 14px; display: flex; align-items: center; justify-content: space-between; }
.sb-head img { height: 34px; display: block; }
.sb-close { display: none; background: none; border: 0; color: #fff; cursor: pointer; padding: 6px; }
.sb-new {
  margin: 0 14px 12px; display: flex; align-items: center; gap: 10px; justify-content: center;
  background: #fff; color: var(--blue); border: 0; border-radius: 12px; padding: 11px 14px;
  font: 700 14px/1 var(--font-body); cursor: pointer; transition: transform .1s, box-shadow .15s;
}
.sb-new:hover { box-shadow: 0 0 0 3px rgba(100, 152, 190, .45); }
.sb-new:active { transform: scale(.98); }
.sb-search { margin: 0 14px 10px; position: relative; }
.sb-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; opacity: .6; }
.sb-search input {
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); color: #fff;
  padding: 8px 10px 8px 34px; font-size: 14px; border-radius: 10px;
}
.sb-search input::placeholder { color: rgba(255, 255, 255, .55); }
.sb-search input:focus { border-color: var(--teal); box-shadow: none; background: rgba(255, 255, 255, .12); }
.sb-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; min-height: 0; position: relative; z-index: 1; }
.sb-list::-webkit-scrollbar { width: 8px; }
.sb-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 8px; }
.sb-group { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: rgba(255, 255, 255, .5); padding: 14px 10px 6px; }
.sb-item {
  display: flex; align-items: center; gap: 4px; border-radius: 9px; color: rgba(255, 255, 255, .86);
  text-decoration: none; font-size: 14px; position: relative;
}
.sb-item a { flex: 1; min-width: 0; padding: 8px 10px; color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-item:hover { background: rgba(255, 255, 255, .08); }
.sb-item.on { background: rgba(255, 255, 255, .14); color: #fff; }
.sb-item.on::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--teal); }
.sb-item .acts { display: none; gap: 2px; padding-right: 4px; }
.sb-item:hover .acts, .sb-item.on .acts { display: flex; }
.sb-item .acts button { background: none; border: 0; color: rgba(255, 255, 255, .7); padding: 5px; border-radius: 6px; cursor: pointer; display: flex; }
.sb-item .acts button:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.sb-item .acts svg { width: 15px; height: 15px; }
.sb-empty { color: rgba(255, 255, 255, .55); font-size: 13.5px; padding: 12px 10px; }
.sb-foot { border-top: 1px solid rgba(255, 255, 255, .1); padding: 12px 14px 14px; position: relative; z-index: 1; }
.sb-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--purple); color: #fff; font: 800 13px/1 var(--font-title);
}
.sb-user .who { min-width: 0; }
.sb-user .who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user .who span { display: block; font-size: 12px; color: rgba(255, 255, 255, .6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-links { display: flex; gap: 4px; }
.sb-links a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 8px 4px; border-radius: 9px; white-space: nowrap;
  color: rgba(255, 255, 255, .8); text-decoration: none; font-size: 12px; font-weight: 600; background: rgba(255, 255, 255, .06);
}
.sb-links a:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.sb-links svg { width: 15px; height: 15px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.main-head {
  height: 58px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 20px;
  border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px);
}
.main-head .menu { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--blue); }
.main-head .mark { display: none; height: 26px; }
.chat-title {
  font: 700 16px/1.2 var(--font-title); color: var(--blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; min-width: 0; flex: 1; background: transparent;
}
.chat-title[contenteditable=true] { border-color: var(--teal); background: #fff; outline: none; }

.scroller { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; }
.thread { max-width: 820px; margin: 0 auto; padding: 28px 24px 24px; }

.msg { display: flex; gap: 12px; margin-bottom: 22px; animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--blue); color: #fff; padding: 11px 16px; border-radius: 18px 18px 4px 18px;
  max-width: 78%; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 2px 8px rgba(42, 32, 111, .18);
}
.msg.bot .av { width: 32px; height: 32px; flex: none; border-radius: 50%; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; margin-top: 2px; }
.msg.bot .av img { width: 20px; }
.msg.bot .body { min-width: 0; flex: 1; }
.msg.bot .bubble {
  background: #fff; border: 1px solid var(--line); padding: 14px 18px; border-radius: 4px 18px 18px 18px;
  box-shadow: var(--shadow); word-wrap: break-word;
}
.msg.bot.error .bubble { border-color: #f1c5cc; background: var(--danger-tint); color: var(--danger); }
.sources { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line-strong); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sources .lbl { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-right: 2px; display: flex; align-items: center; gap: 5px; }
.sources .lbl svg { width: 14px; height: 14px; }
.sources a {
  font-size: 12.5px; text-decoration: none; color: var(--teal-ink); background: var(--tint-teal);
  padding: 3px 9px; border-radius: 99px; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sources a:hover { background: #dcebf5; }
.mem-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12.5px; font-weight: 600;
  color: var(--purple-ink); background: var(--tint-purple); padding: 4px 10px; border-radius: 99px;
}
.mem-chip svg { width: 14px; height: 14px; }
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; min-height: 30px; }
.msg-actions button {
  background: none; border: 0; color: var(--muted); padding: 6px; border-radius: 8px; cursor: pointer; display: flex;
  transition: color .15s, background .15s;
}
.msg-actions button:hover { background: var(--tint-blue); color: var(--blue); }
.msg-actions button.on.up { color: var(--ok); background: var(--ok-tint); }
.msg-actions button.on.down { color: var(--danger); background: var(--danger-tint); }
.msg-actions svg { width: 16px; height: 16px; }
.msg-actions .cost { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fb-box { margin-top: 6px; display: flex; gap: 8px; }
.fb-box input { font-size: 14px; padding: 8px 10px; }

/* thinking indicator: the three brand bubbles */
.typing { display: inline-flex; gap: 6px; align-items: center; padding: 6px 2px; }
.typing span { width: 9px; height: 9px; border-radius: 50% 50% 50% 0; animation: bob 1.1s infinite ease-in-out; }
.typing span:nth-child(1) { background: var(--teal); }
.typing span:nth-child(2) { background: var(--blue); animation-delay: .15s; border-radius: 50% 0 50% 50%; }
.typing span:nth-child(3) { background: var(--purple); animation-delay: .3s; border-radius: 0 50% 50% 50%; }
@keyframes bob { 0%, 60%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-5px); opacity: 1; } }
.typing-label { font-size: 13px; color: var(--muted); margin-left: 8px; }

/* empty state */
.welcome { max-width: 720px; margin: 0 auto; padding: 9vh 24px 24px; text-align: center; }
.welcome img { width: 76px; margin-bottom: 18px; }
.welcome h1 { font-size: 30px; }
.welcome .subtitle { margin-bottom: 28px; }
.suggest { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }
.suggest button {
  font: 14.5px/1.4 var(--font-body); color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px 14px 18px; cursor: pointer; position: relative; overflow: hidden; text-align: left;
  box-shadow: var(--shadow); transition: border-color .15s, transform .1s;
}
.suggest button::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.suggest button:nth-child(2)::before { background: var(--teal); }
.suggest button:nth-child(3)::before { background: var(--purple); }
.suggest button:nth-child(4)::before { background: var(--blue-700); }
.suggest button:hover { border-color: var(--teal); }
.suggest button:active { transform: scale(.99); }
.suggest button small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }

/* composer */
.composer-wrap { flex: none; padding: 10px 24px 14px; background: linear-gradient(rgba(246, 245, 251, 0), var(--bg) 30%); }
.composer {
  max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: #fff;
  border: 1px solid var(--line-strong); border-radius: 18px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(100, 152, 190, .18), var(--shadow); }
.composer textarea {
  flex: 1; border: 0; resize: none; padding: 8px 0; font: 15.5px/1.45 var(--font-body); max-height: 220px;
  background: transparent; box-shadow: none !important;
}
.send {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--blue); color: #fff; cursor: pointer;
  display: grid; place-items: center; flex: none; transition: background .15s, transform .1s;
}
.send:hover { background: var(--blue-700); }
.send:active { transform: scale(.95); }
.send:disabled { background: #c9c5dd; cursor: default; }
.composer-note { max-width: 820px; margin: 8px auto 0; font-size: 12px; color: var(--muted); text-align: center; }

.sb-overlay { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 290px; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  .app.sb-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .app.sb-open .sb-overlay { display: block; position: fixed; inset: 0; background: rgba(20, 15, 60, .35); z-index: 40; }
  .sb-close { display: block; }
  .main-head { padding: 0 12px; }
  .main-head .menu { display: flex; }
  .main-head .mark { display: block; }
  .thread { padding: 20px 14px; }
  .composer-wrap { padding: 8px 12px 12px; }
  .suggest { grid-template-columns: 1fr; }
  .welcome { padding-top: 6vh; }
  .welcome h1 { font-size: 24px; }
  .msg.user .bubble { max-width: 88%; }
  .tmsg.user { margin-left: 0; } .tmsg.assistant { margin-right: 0; }
}
