@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;0,700;1,500&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #e9e1d3;          /* warm paper */
  --bg2: #e3dac9;
  --panel: #f5efe4;       /* cards */
  --panel2: #fcf8f0;      /* inputs / raised */
  --border: rgba(92,79,63,.18);
  --border2: rgba(92,79,63,.32);
  --text: #17191d;        /* ink */
  --ink2: #3c372f;
  --muted: #6f6555;
  --faint: #9a9080;
  --accent: #8a5a2f;      /* bronze */
  --accent-strong: #6f4622;
  --accent-dim: rgba(138,90,47,.40);
  --hot: #b3492d;         /* terracotta */
  --warm: #a9711f;        /* ochre */
  --cold: #857c6f;        /* taupe */
  --green: #5f7548;       /* olive */
  --red: #b3492d;
  --axis: #9a9080;
  --shadow: 0 6px 22px rgba(70,55,38,.10);
  --shadow-lg: 0 14px 40px rgba(70,55,38,.14);
  --radius: 14px;
  --font-sans: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --z-header: 30;
  --z-nav: 30;
  --z-toast: 50;
  --nav-h: 64px;
  font-synthesis: none;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: radial-gradient(1100px 560px at 82% -12%, #f2ecdf 0%, var(--bg) 58%);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
svg { display: block; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- layout ---- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  background: linear-gradient(180deg, #f1eadc, var(--bg));
  border-right: 1px solid var(--border);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand .dot {
  width: 34px; height: 34px; border-radius: 9px; flex: none; overflow: hidden;
  background: #fbf7ef;
  box-shadow: 0 4px 12px rgba(122,82,48,.26);
  display: grid; place-items: center; color: #f6efe2;
}
.brand .dot svg { width: 16px; height: 16px; }
.brand .dot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand b { font-family: var(--font-serif); font-size: 21px; letter-spacing: .2px; font-weight: 600; color: var(--text); }
.brand span { color: var(--accent); font-weight: 600; }

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.nav button {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 11px 12px; border-radius: 10px; font-size: 14.5px; font-weight: 500;
  min-height: 44px;
  transition: background-color .15s, color .15s, border-color .15s;
  text-align: left; position: relative;
}
.nav button .ic { flex: none; width: 18px; height: 18px; }
.nav button .lbl { flex: 1; }
.nav button:hover { background: rgba(122,82,48,.07); color: var(--text); }
.nav button.active { background: var(--panel2); color: var(--accent-strong); border-color: var(--border2); font-weight: 600; box-shadow: 0 1px 0 rgba(122,82,48,.06); }
.nav .badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 20px;
  background: var(--accent); color: #f6efe2; font-size: 12px; font-weight: 600;
  font-family: var(--font-mono);
  display: inline-flex; align-items: center; justify-content: center;
}
.nav .badge.zero { background: rgba(92,79,63,.14); color: var(--faint); }
.sidebar .spacer { flex: 1; }
.sidebar .foot { color: var(--faint); font-size: 12px; padding: 8px; display: flex; align-items: center; gap: 10px; }
.sidebar .foot #lastsync { font-family: var(--font-mono); font-size: 11.5px; }
.sidebar .foot button {
  background: none; border: none; color: var(--faint); padding: 6px 2px;
  display: flex; align-items: center; gap: 6px; min-height: 32px;
}
.sidebar .foot button:hover { color: var(--accent); }
.sidebar .foot button .ic { width: 15px; height: 15px; }

.main { padding: 30px 34px 60px; max-width: 1000px; }
.head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; gap: 12px; }
.head h1 { font-family: var(--font-serif); font-size: 32px; margin: 0; font-weight: 600; letter-spacing: .2px; line-height: 1.1; }
.head .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.head .refresh {
  background: var(--panel2); border: 1px solid var(--border2); color: var(--muted);
  padding: 9px 14px; border-radius: 9px; font-size: 13px; min-height: 40px;
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  transition: color .15s, border-color .15s, background-color .15s;
}
.head .refresh .ic { width: 15px; height: 15px; }
.head .refresh:hover { color: var(--accent-strong); border-color: var(--accent-dim); }

/* ---- reply cards ---- */
.cards { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cold); }
.card.hot::before { background: var(--hot); }
.card.warm::before { background: var(--warm); }
.card.cold::before { background: var(--cold); }
.card .top { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px 21px; flex-wrap: wrap; }
.pill {
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 6px; border: 1px solid transparent;
}
.pill.hot { background: rgba(179,73,45,.10); color: #9c3f26; border-color: rgba(179,73,45,.28); }
.pill.warm { background: rgba(169,113,31,.12); color: #8a5c17; border-color: rgba(169,113,31,.3); }
.pill.cold { background: rgba(133,124,111,.14); color: #6a6255; border-color: rgba(133,124,111,.3); }
.pill.live { background: rgba(111,127,74,.14); color: #4f5c36; border-color: rgba(111,127,74,.34); }
.pill.off { background: rgba(169,113,31,.12); color: #8a5c17; border-color: rgba(169,113,31,.3); }

/* sending status panel (Statistika) */
.send-card h3 { margin-bottom: 2px; }
.send-row { padding: 13px 0; border-top: 1px solid var(--border); }
.send-row:first-of-type { border-top: 0; padding-top: 6px; }
.send-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.send-head b { font-size: 15px; font-weight: 600; }
.send-bar { height: 8px; border-radius: 5px; background: #ded4c2; overflow: hidden; }
.send-bar i { display: block; height: 100%; border-radius: 5px; transition: width .4s ease; }
.send-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 9px; color: var(--muted); font-size: 12.5px; font-family: var(--font-mono); }
.send-meta .warn { color: #9c3f26; font-weight: 600; }
.who { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.who b { font-size: 15px; font-weight: 600; }
.who small { color: var(--muted); font-size: 12.5px; }
.top .cat { margin-left: auto; color: var(--faint); font-size: 11px; font-weight: 500; letter-spacing: .5px; font-family: var(--font-mono); }
.top .time { color: var(--faint); font-size: 11.5px; font-family: var(--font-mono); }

.their { margin: 4px 18px 14px 21px; padding: 12px 15px; background: rgba(122,82,48,.05); border: 1px solid var(--border); border-left: 3px solid var(--accent-dim); border-radius: 10px; color: var(--ink2); font-size: 14px; white-space: pre-wrap; }
.their .lbl, .draft-lbl { display: block; color: var(--faint); font-size: 10.5px; font-weight: 600; letter-spacing: .7px; text-transform: uppercase; margin-bottom: 7px; font-family: var(--font-mono); }
.draftwrap { margin: 0 18px 14px 21px; }
.draft-lbl { margin-left: 2px; }
textarea.draft {
  width: 100%; min-height: 118px; resize: vertical; background: var(--panel2);
  color: var(--text); border: 1px solid var(--border2); border-radius: 10px;
  padding: 13px 15px; font-family: var(--font-sans); font-size: 14.5px; line-height: 1.6;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
textarea.draft[readonly] { background: rgba(122,82,48,.045); border-color: var(--border); cursor: default; color: var(--ink2); }
textarea.draft:not([readonly]):focus, textarea.draft.editing:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138,90,47,.14); }
textarea.draft.editing { background: var(--panel2); border-color: var(--accent-dim); }
.empty-draft { margin: 0 18px 12px 21px; color: var(--muted); font-style: italic; font-size: 13.5px; }
.err { margin: 0 18px 12px 21px; color: var(--red); font-size: 13px; display: flex; align-items: flex-start; gap: 7px; }
.err .ic { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; padding: 2px 18px 16px 21px; align-items: center; }
.btn {
  border: 1px solid var(--border2); background: var(--panel2); color: var(--text);
  padding: 10px 16px; border-radius: 9px; font-size: 14px; font-weight: 600;
  min-height: 44px; transition: border-color .15s, filter .15s, background-color .15s, color .15s;
}
.btn:hover { border-color: var(--accent-dim); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.approve { background: linear-gradient(180deg, #9c6a3b, var(--accent)); border-color: var(--accent-strong); color: #f7f0e3; }
.btn.approve:hover { filter: brightness(1.06); }
.btn.edit { background: transparent; color: var(--accent-strong); border-color: var(--accent-dim); }
.btn.edit:hover { background: rgba(122,82,48,.08); }
.btn.reject { background: transparent; color: var(--red); border-color: rgba(179,73,45,.32); }
.btn.reject:hover { background: rgba(179,73,45,.08); }
.btn.ghost { background: transparent; color: var(--muted); }
.actions .edited { margin-left: auto; color: var(--warm); font-size: 12px; font-weight: 600; font-family: var(--font-mono); }

/* ---- empty ---- */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty .big { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--accent); }

/* ---- leads table ---- */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--faint); padding: 13px 15px; border-bottom: 1px solid var(--border); font-weight: 600; font-family: var(--font-mono); }
.table td { padding: 13px 15px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(122,82,48,.04); }
.table td.mono, .table td .mono { font-family: var(--font-mono); font-size: 13px; }
.warmth-select {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border2);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; min-height: 40px;
}
.filters { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.filters button { background: var(--panel2); border: 1px solid var(--border2); color: var(--muted); padding: 9px 15px; border-radius: 20px; font-size: 13px; min-height: 40px; transition: background-color .15s, color .15s, border-color .15s; }
.filters button.active { background: var(--accent); color: #f7f0e3; border-color: var(--accent-strong); }

/* ---- stats: KPI tiles ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.kpi::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, var(--accent), transparent); opacity: .7; }
.kpi-l { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; font-weight: 500; margin-bottom: 10px; font-family: var(--font-mono); }
.kpi-v { font-family: var(--font-mono); font-size: 29px; font-weight: 600; letter-spacing: -.5px; line-height: 1; color: var(--text); }
.kpi-v .u { font-size: 15px; color: var(--faint); }
.kpi-v small { font-family: var(--font-sans); font-size: 13px; color: var(--muted); font-weight: 500; }

/* ---- chart cards ---- */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(272px, 1fr)); gap: 16px; }
.chartcard { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px 19px 19px; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: box-shadow .15s; }
.chartcard:hover { box-shadow: var(--shadow-lg); }
.chartcard.wide { grid-column: span 2; }
.chartcard h3 { margin: 0 0 15px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 500; font-family: var(--font-mono); }
.chart { width: 100%; height: auto; display: block; }
.chart.gauge, .chart.donut { max-width: 208px; margin: 4px auto 0; }
.g-big { font-family: var(--font-mono); font-size: 26px; font-weight: 600; fill: var(--text); }
.donut .g-big { font-size: 24px; }
.g-sub { font-size: 10.5px; fill: var(--muted); letter-spacing: .6px; font-family: var(--font-mono); }
.c-val { font-family: var(--font-mono); font-size: 12px; font-weight: 600; fill: var(--text); }
.c-lbl { font-size: 10.5px; fill: var(--axis); font-family: var(--font-mono); }
.cc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 13px; color: var(--muted); font-size: 12.5px; }
.cc-foot b { font-family: var(--font-mono); color: var(--accent-strong); }
.cc-note { color: var(--faint); font-size: 12.5px; font-style: italic; margin-top: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 15px; margin-top: 15px; }
.lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.lg i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg b { font-family: var(--font-mono); color: var(--text); font-weight: 600; margin-left: 3px; }

.hbars { display: flex; flex-direction: column; gap: 13px; margin-top: 4px; }
.hbar { display: grid; grid-template-columns: 78px 1fr 42px; align-items: center; gap: 10px; font-size: 13px; }
.hb-l { color: var(--muted); }
.hb-track { height: 10px; background: rgba(92,79,63,.12); border-radius: 8px; overflow: hidden; }
.hb-track i { display: block; height: 100%; border-radius: 8px; transition: width .5s ease; min-width: 3px; }
.hb-v { font-family: var(--font-mono); text-align: right; color: var(--text); font-weight: 600; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 38px 34px; width: 100%; max-width: 348px; box-shadow: var(--shadow-lg);
}
.login .brand { justify-content: center; padding-bottom: 24px; }
.login .brand b { font-size: 24px; }
.login input {
  width: 100%; background: var(--panel2); border: 1px solid var(--border2); color: var(--text);
  padding: 13px 15px; border-radius: 10px; font-size: 16px; margin-bottom: 12px; min-height: 46px;
}
.login input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138,90,47,.14); }
.login button { width: 100%; background: linear-gradient(180deg, #9c6a3b, var(--accent)); border: none; color: #f7f0e3; padding: 13px; border-radius: 10px; font-size: 15px; font-weight: 600; min-height: 46px; }
.login button:hover { filter: brightness(1.06); }
.login .msg { color: var(--red); font-size: 13px; text-align: center; min-height: 18px; margin-top: 8px; }

/* ---- toast ---- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: var(--z-toast); max-width: calc(100vw - 32px); }
.toast { background: var(--panel2); border: 1px solid var(--border2); border-left: 3px solid var(--green); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; color: var(--text); animation: slidein .2s; }
.toast.err { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.hidden { display: none !important; }
.loading { color: var(--muted); padding: 40px; text-align: center; }

/* ==================================================================
   Mobile — sidebar becomes a fixed top bar + fixed bottom tab bar
   ================================================================== */
@media (max-width: 860px) {
  html { font-size: 16px; }
  .app { display: block; }

  .sidebar {
    position: fixed; top: 0; left: 0; right: 0; height: auto;
    flex-direction: row; align-items: center; justify-content: space-between;
    padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
    border-right: none; border-bottom: 1px solid var(--border);
    z-index: var(--z-header);
    padding-top: max(10px, env(safe-area-inset-top));
    background: #f1eadc;
  }
  .sidebar .brand { padding: 0; }
  .sidebar .spacer { display: none; }
  .sidebar .foot { padding: 0; }
  .sidebar .foot #lastsync { display: none; }

  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    flex-direction: row; justify-content: space-around; align-items: stretch;
    margin-top: 0; gap: 2px;
    background: #f1eadc;
    border-top: 1px solid var(--border);
    padding: 6px max(6px, env(safe-area-inset-left)) max(6px, env(safe-area-inset-bottom));
    z-index: var(--z-nav);
    box-shadow: 0 -4px 20px rgba(70,55,38,.06);
  }
  .nav button {
    flex: 1; flex-direction: column; gap: 3px; justify-content: center;
    padding: 8px 4px; font-size: 11px; min-height: 56px; text-align: center;
  }
  .nav button.active { box-shadow: none; }
  .nav button .ic { width: 21px; height: 21px; }
  .nav .badge {
    position: absolute; top: 2px; right: 18%; min-width: 17px; height: 17px; font-size: 10.5px; padding: 0 4px;
  }

  .main { padding: calc(60px + env(safe-area-inset-top)) 16px calc(84px + env(safe-area-inset-bottom)); max-width: 100%; }
  .head { flex-wrap: wrap; }
  .head h1 { font-size: 26px; }
  .head .refresh span.lbl-text { display: none; }
  .head .refresh { padding: 10px; }

  .their, .draftwrap, .actions, .empty-draft, .err { margin-left: 15px; margin-right: 15px; }
  textarea.draft { font-size: 16px; }
  .btn { flex: 1 1 auto; }

  /* leads table -> stacked cards */
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 15px; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: none; }
  .table td { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: none; padding: 5px 0; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--faint); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; text-align: left; font-family: var(--font-mono); }
  .table td:first-child { padding-top: 2px; }

  .charts-grid { grid-template-columns: 1fr; }
  .chartcard.wide { grid-column: auto; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .chart.gauge, .chart.donut { max-width: 200px; }
}

@media (max-width: 420px) {
  .head .refresh span.lbl-text { display: none; }
  .kpis { grid-template-columns: 1fr; }
}

/* ---- conversations list ---- */
.convos { display: flex; flex-direction: column; gap: 12px; }
.convo {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px; min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.convo:hover { box-shadow: var(--shadow-lg); border-color: var(--accent-dim); }
.convo .cv-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.convo .cv-main b { font-size: 15px; font-weight: 600; }
.convo .cv-main small { color: var(--muted); font-size: 12.5px; }
.convo .cv-subj { color: var(--ink2); font-size: 13px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo .cv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.convo .cv-meta .cat { color: var(--faint); font-size: 10.5px; letter-spacing: .5px; font-family: var(--font-mono); }
.convo .cv-meta .time { color: var(--faint); font-size: 11.5px; font-family: var(--font-mono); }

/* ---- thread modal ---- */
.modal-back {
  position: fixed; inset: 0; z-index: var(--z-toast);
  background: rgba(40,30,18,.34); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 24px; animation: fadein .15s;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg); border: 1px solid var(--border2); border-radius: 16px;
  width: 100%; max-width: 560px; max-height: 82vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.modal-head b { font-family: var(--font-serif); font-size: 19px; font-weight: 600; }
.modal-x { background: none; border: none; color: var(--muted); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; }
.modal-x svg { width: 18px; height: 18px; }
.modal-x:hover { background: rgba(122,82,48,.08); color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

.bubble { max-width: 82%; padding: 11px 14px; border-radius: 14px; }
.bubble .bub-meta { font-size: 10.5px; color: var(--faint); font-family: var(--font-mono); margin-bottom: 5px; letter-spacing: .3px; }
.bubble .bub-text { color: var(--text); font-size: 14px; line-height: 1.55; word-break: break-word; }
.bubble.in { align-self: flex-start; background: var(--panel2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.bubble.out { align-self: flex-end; background: linear-gradient(180deg, #f0e4d0, #ecdcc2); border: 1px solid var(--accent-dim); border-bottom-right-radius: 5px; }
.bubble.out .bub-meta { color: var(--accent-strong); }

@media (max-width: 860px) {
  .modal-back { padding: 0; place-items: stretch; }
  .modal { max-width: 100%; max-height: 100%; border-radius: 0; }
  .convo .cv-subj { max-width: 58vw; }
}

