/* ChatFlow design system
   ----------------------
   One token layer, consumed by every component. Light is the default; dark is a
   token swap under prefers-color-scheme plus an explicit [data-theme] override
   so the in-app toggle wins in both directions. */

:root {
  /* Neutrals: a single hue-consistent ramp keeps surfaces from looking muddy */
  --gray-0:  #ffffff;
  --gray-25: #fcfcfd;
  --gray-50: #f7f8fa;
  --gray-100:#eef0f4;
  --gray-200:#e2e5ec;
  --gray-300:#cbd0da;
  --gray-400:#9aa2b1;
  --gray-500:#6b7383;
  --gray-600:#4d5462;
  --gray-700:#373d49;
  --gray-800:#242932;
  --gray-900:#161a21;
  --gray-950:#0e1116;

  --brand-50:  #eef3ff;
  --brand-100: #dbe5ff;
  --brand-300: #a3b8ff;
  --brand-500: #4f6bed;
  --brand-600: #3f56d4;
  --brand-700: #3345ad;

  --green-100:#dcfce7; --green-500:#16a34a; --green-600:#15803d;
  --amber-100:#fef3c7; --amber-500:#d97706; --amber-600:#b45309;
  --red-100:  #fee2e2; --red-500:  #dc2626; --red-600:  #b91c1c;

  /* Semantic tokens */
  --bg:            var(--gray-50);
  --bg-raised:     var(--gray-0);
  --bg-sunken:     var(--gray-100);
  --bg-hover:      var(--gray-100);
  --bg-active:     var(--brand-50);
  --border:        var(--gray-200);
  --border-strong: var(--gray-300);
  --text:          var(--gray-900);
  --text-muted:    var(--gray-500);
  --text-subtle:   var(--gray-400);
  --text-inverse:  var(--gray-0);

  --accent:        var(--brand-500);
  --accent-hover:  var(--brand-600);
  --accent-soft:   var(--brand-50);
  --accent-text:   var(--brand-700);

  --success:       var(--green-600);
  --success-soft:  var(--green-100);
  --warning:       var(--amber-600);
  --warning-soft:  var(--amber-100);
  --danger:        var(--red-600);
  --danger-soft:   var(--red-100);

  /* Type scale (1.2 ratio), spacing scale (4px base) */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --text-xs:  0.75rem;
  --text-sm:  0.8125rem;
  --text-base:0.9375rem;
  --text-md:  1rem;
  --text-lg:  1.125rem;
  --text-xl:  1.375rem;
  --text-2xl: 1.75rem;

  --space-1: 0.25rem; --space-2: 0.5rem;  --space-3: 0.75rem;
  --space-4: 1rem;    --space-5: 1.5rem;  --space-6: 2rem;
  --space-7: 2.5rem;  --space-8: 3rem;

  --radius-sm: 5px; --radius: 8px; --radius-lg: 12px; --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(16, 20, 28, 0.06);
  --shadow:    0 2px 6px rgba(16, 20, 28, 0.08),
               0 1px 2px rgba(16, 20, 28, 0.05);
  --shadow-lg: 0 12px 32px rgba(16, 20, 28, 0.14);

  --sidebar-width: 236px;
  --header-height: 56px;
  --transition: 140ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            var(--gray-950);
    --bg-raised:     var(--gray-900);
    --bg-sunken:     #0a0d12;
    --bg-hover:      var(--gray-800);
    --bg-active:     rgba(79, 107, 237, 0.16);
    --border:        #262c36;
    --border-strong: #333a46;
    --text:          var(--gray-50);
    --text-muted:    var(--gray-400);
    --text-subtle:   var(--gray-500);
    --accent:        #7b92ff;
    --accent-hover:  #93a6ff;
    --accent-soft:   rgba(79, 107, 237, 0.18);
    --accent-text:   #a3b8ff;
    --success:       #4ade80;
    --success-soft:  rgba(22, 163, 74, 0.18);
    --warning:       #fbbf24;
    --warning-soft:  rgba(217, 119, 6, 0.18);
    --danger:        #f87171;
    --danger-soft:   rgba(220, 38, 38, 0.18);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow:    0 2px 8px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  }
}

[data-theme="dark"] {
  --bg:            var(--gray-950);
  --bg-raised:     var(--gray-900);
  --bg-sunken:     #0a0d12;
  --bg-hover:      var(--gray-800);
  --bg-active:     rgba(79, 107, 237, 0.16);
  --border:        #262c36;
  --border-strong: #333a46;
  --text:          var(--gray-50);
  --text-muted:    var(--gray-400);
  --text-subtle:   var(--gray-500);
  --accent:        #7b92ff;
  --accent-hover:  #93a6ff;
  --accent-soft:   rgba(79, 107, 237, 0.18);
  --accent-text:   #a3b8ff;
  --success:       #4ade80;
  --success-soft:  rgba(22, 163, 74, 0.18);
  --warning:       #fbbf24;
  --warning-soft:  rgba(217, 119, 6, 0.18);
  --danger:        #f87171;
  --danger-soft:   rgba(220, 38, 38, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 2px 8px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* ---------- reset ---------- */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

h1, h2, h3, h4 { line-height: 1.25; font-weight: 600; letter-spacing: -0.011em; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

/* ---------- layout ---------- */

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4);
  font-weight: 650;
  font-size: var(--text-md);
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--border);
}

.sidebar__mark {
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: grid; place-items: center;
  font-size: var(--text-sm); font-weight: 700;
  flex-shrink: 0;
}

.sidebar__nav { padding: var(--space-3) var(--space-2); display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: var(--text-base);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--bg-active); color: var(--accent-text); font-weight: 550; }
.nav-item__icon {
  display: grid; place-items: center;
  width: 17px; height: 17px; flex-shrink: 0;
  opacity: 0.75;
}
.nav-item[aria-current="page"] .nav-item__icon { opacity: 1; }
.icon { display: block; }
.btn--icon { padding: var(--space-1); min-width: 30px; }
.nav-item__badge {
  margin-left: auto;
  background: var(--accent); color: #fff;
  font-size: var(--text-xs); font-weight: 600;
  padding: 1px var(--space-2); border-radius: var(--radius-full);
}

.sidebar__footer { padding: var(--space-3); border-top: 1px solid var(--border); }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--header-height);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  position: sticky; top: 0; z-index: 10;
}
.topbar__title { font-size: var(--text-md); font-weight: 600; }

.content { padding: var(--space-6); flex: 1; }
.content--flush { padding: 0; }
.container { max-width: 1180px; }
.container--narrow { max-width: 680px; }

/* ---------- components ---------- */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
}
.card__title { font-size: var(--text-md); font-weight: 600; }
.card__body { padding: var(--space-5); }
.card__footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { padding: var(--space-5); }
.stat__label {
  font-size: var(--text-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-subtle);
}
.stat__value {
  font-size: var(--text-2xl); font-weight: 650;
  letter-spacing: -0.02em; margin-top: var(--space-2);
  font-variant-numeric: tabular-nums;
}
.stat__meta { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-1); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--text-base); font-weight: 550;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--secondary { background: var(--bg-raised); border-color: var(--border-strong); color: var(--text); }
.btn--secondary:hover:not(:disabled) { background: var(--bg-hover); }
.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { min-height: 30px; padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }
.btn--block { width: 100%; }

.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600;
  line-height: 1.4;
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger); }
.badge--neutral { background: var(--bg-sunken); color: var(--text-muted); }
.badge--accent  { background: var(--accent-soft); color: var(--accent-text); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot--success { background: var(--success); }
.dot--warning { background: var(--warning); }
.dot--danger  { background: var(--danger); }
.dot--neutral { background: var(--text-subtle); }

/* forms */
.field { margin-bottom: var(--space-4); }
.field__label { display: block; font-size: var(--text-sm); font-weight: 550; margin-bottom: var(--space-2); }
.field__hint { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-2); }
.field__error { font-size: var(--text-sm); color: var(--danger); margin-top: var(--space-2); }

.input, .textarea, .select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  min-height: 38px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }

.checkbox { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-2) 0; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; margin-top: 3px; accent-color: var(--accent); flex-shrink: 0; }
.checkbox__label { font-weight: 500; }
.checkbox__hint { font-size: var(--text-sm); color: var(--text-muted); }

/* alerts */
.alert {
  display: flex; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: var(--text-base);
  margin-bottom: var(--space-4);
}
.alert--error   { background: var(--danger-soft);  border-color: var(--danger);  color: var(--danger); }
.alert--success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.alert--warning { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }
.alert--info    { background: var(--accent-soft);  border-color: var(--accent);  color: var(--accent-text); }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.table th {
  text-align: left; font-size: var(--text-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-subtle);
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border);
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-hover); }
.table-wrap { overflow-x: auto; }

/* empty states -- honest, not decorative */
.empty { text-align: center; padding: var(--space-8) var(--space-5); }
.empty__icon {
  display: flex; justify-content: center;
  color: var(--text-subtle); opacity: 0.7;
  margin-bottom: var(--space-3);
}
.empty__title { font-weight: 600; margin-bottom: var(--space-2); }
.empty__text { color: var(--text-muted); max-width: 42ch; margin: 0 auto var(--space-4); }

/* auth pages */
.auth {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: var(--space-5);
  background: var(--bg);
}
.auth__card { width: 100%; max-width: 400px; }
.auth__brand {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.02em;
  margin-bottom: var(--space-5);
}
.auth__title { text-align: center; margin-bottom: var(--space-1); }
.auth__subtitle { text-align: center; color: var(--text-muted); margin-bottom: var(--space-5); font-size: var(--text-base); }
.auth__footer { text-align: center; margin-top: var(--space-5); font-size: var(--text-base); color: var(--text-muted); }

/* utilities */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack--sm { gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* HTMX: show progress without layout shift */
.htmx-indicator { opacity: 0; transition: opacity var(--transition); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width);
    transform: translateX(-100%); transition: transform var(--transition); z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .sidebar[data-open="true"] { transform: none; }
  .content { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- connections ---------- */

.connection {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.connection__main {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap;
}
.connection__avatar {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  object-fit: cover; flex-shrink: 0; background: var(--bg-sunken);
}
.connection__avatar--fallback {
  display: grid; place-items: center; color: var(--text-muted);
}
.connection__meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-3); margin: 0;
  padding-top: var(--space-3); border-top: 1px solid var(--border);
}
.connection__meta dt {
  font-size: var(--text-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-subtle); margin-bottom: 2px;
}
.connection__meta dd {
  margin: 0; font-size: var(--text-sm);
  display: flex; align-items: center; gap: var(--space-2);
}

.code-block {
  display: block; font-family: var(--font-mono); font-size: var(--text-sm);
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-3);
  overflow-x: auto; white-space: nowrap; margin-top: var(--space-3);
}

/* ---------- inbox ---------- */

/* Three panes that each scroll independently, so the composer stays put and
   the thread list never drags the page. */
.inbox {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  height: calc(100vh - var(--header-height));
  min-height: 0;
}

.inbox__list {
  border-right: 1px solid var(--border);
  background: var(--bg-raised);
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}

.inbox__filters {
  display: flex; gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.chip {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  font-size: var(--text-sm); font-weight: 550;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.chip:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.chip--active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.chip--active:hover { background: var(--accent-hover); color: #fff; }

.thread-list { list-style: none; margin: 0; padding: var(--space-2); overflow-y: auto; flex: 1; }

.thread {
  display: flex; gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius);
  color: inherit;
  transition: background var(--transition);
}
.thread:hover { background: var(--bg-hover); text-decoration: none; }
.thread--active { background: var(--bg-active); }

.thread__avatar {
  position: relative;
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-weight: 600; font-size: var(--text-base);
  color: var(--text-muted);
}
.thread__platform {
  position: absolute; right: -3px; bottom: -3px;
  width: 17px; height: 17px; border-radius: var(--radius-full);
  display: grid; place-items: center;
  color: #fff; border: 2px solid var(--bg-raised);
}
.thread__platform--facebook  { background: #0866ff; }
.thread__platform--instagram { background: linear-gradient(45deg, #f09433, #dc2743, #bc1888); }

.thread__body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.thread__top { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; }
.thread__name { font-weight: 550; }
.thread__time { font-size: var(--text-xs); color: var(--text-subtle); flex-shrink: 0; }
.thread__preview { font-size: var(--text-sm); color: var(--text-muted); }
.thread__meta { display: flex; align-items: center; gap: var(--space-2); margin-top: 2px; }
.thread__unread {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--accent); color: #fff;
  font-size: var(--text-xs); font-weight: 650;
  display: grid; place-items: center;
}

.inbox__thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.thread-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  flex-wrap: wrap;
}

.thread-messages {
  flex: 1; overflow-y: auto;
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3);
  background: var(--bg);
}

.msg { display: flex; }
.msg--in  { justify-content: flex-start; }
.msg--out { justify-content: flex-end; }

.msg__bubble {
  max-width: min(72%, 560px);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.msg--out .msg__bubble { background: var(--accent); border-color: var(--accent); color: #fff; }
.msg--out .msg__bubble .msg__meta { color: rgba(255, 255, 255, 0.75); }
.msg__bubble--ai { background: var(--accent); border-color: var(--accent); }
.msg__bubble--system {
  background: var(--warning-soft); border-color: var(--warning); color: var(--warning);
}
.msg--out .msg__bubble--system .msg__meta { color: var(--warning); }
.msg__bubble--error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.msg--out .msg__bubble--error .msg__meta { color: var(--danger); }

/* Customer text is untrusted; pre-wrap preserves their formatting without
   letting long strings break the layout. */
.msg__text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg__attachments { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.msg__meta {
  display: flex; align-items: center; gap: var(--space-2);
  margin-top: var(--space-2);
  font-size: var(--text-xs); color: var(--text-subtle);
}
.msg__tag { font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.msg__error { margin-top: var(--space-2); font-size: var(--text-xs); opacity: 0.9; }

.composer {
  display: flex; gap: var(--space-3); align-items: flex-end;
  padding: var(--space-4) var(--space-5) var(--space-2);
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
}
.composer__input {
  flex: 1; resize: none;
  min-height: 40px; max-height: 180px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  line-height: 1.5;
}
.composer__input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer__note { padding: 0 var(--space-5) var(--space-3); background: var(--bg-raised); margin: 0; }

@media (max-width: 860px) {
  .inbox { grid-template-columns: 1fr; }
  /* On a phone, show one pane at a time: the thread if one is open. */
  .inbox__thread:not(:empty) ~ .inbox__list { display: none; }
}
