/* MFL Team — internal messaging + Brandon. Same palette and tokens as the MFL Inbox
   (navy #093c44, gold #f8b600, orange #f58f47) so the two apps read as one family.
   Kept self-contained on purpose: a change to the Inbox's CSS can't break this app. */
:root {
  --navy: #093c44;
  --gold: #f8b600;
  --orange: #f58f47;
  --cream: #fff8ec;
  --bg: #eef1f2;
  --card: #ffffff;
  --line: #dbe2e4;
  --ink: #10262b;
  --muted: #6b7a7e;
  --in-bubble: #ffffff;
  --out-bubble: #cfe9ea;
  --brandon-bubble: #fff8ec;
  --accent-surface: var(--navy);
  --badge-bg: var(--orange);
  --active-row: #fbecc9;
  --input-bd: var(--line);
  --field-bg: #fff;
  --danger: #b91c1c;
  --danger-fg: #fff;
  --ok: #2f7d4a;
  --needs: #c2410c;
  --needs-bg: #fff1e6;
  --code-bg: #f2f5f6;
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
:root[data-theme="dark"] {
  --navy: #7fb3bd;
  --gold: #f8c134;
  --orange: #f9a765;
  --cream: #222b34;
  --bg: #14191f;
  --card: #1c232b;
  --line: #313c47;
  --ink: #e7edf2;
  --muted: #9db0bf;
  --in-bubble: #232c35;
  --out-bubble: #1b3a26;
  --brandon-bubble: #2a2619;
  --accent-surface: #4a3320;
  --badge-bg: #e2600f;
  --active-row: #38301f;
  --input-bd: #5a9b74;
  --field-bg: #14191f;
  --danger: #f19a9a;
  --danger-fg: #2a1113;
  --ok: #7fd19b;
  --needs: #ffb27a;
  --needs-bg: #3a2616;
  --code-bg: #14191f;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { overscroll-behavior-y: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); font-size: 13.5px; }
[hidden] { display: none !important; }
.screen { display: flex; flex-direction: column; height: 100dvh; }

#panes { display: contents; }
#panes.hide-panes { display: none !important; }
.thread-placeholder { display: none; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 15px; }
.thread-placeholder .ph-ico { font-size: 44px; opacity: .85; }

@media (min-width: 900px) {
  #panes { display: flex; flex-direction: row; height: 100dvh; }
  #list-screen { width: 400px; flex: none; border-right: 1px solid var(--line); }
  #thread-screen { flex: 1; min-width: 0; }
  #back-btn { display: none; }
  #thread-screen.no-thread > *:not(.thread-placeholder) { display: none; }
  #thread-screen.no-thread .thread-placeholder { display: flex; }
  .conv.active { background: var(--active-row); }
  .post { max-width: 70%; }
  .sheet { align-items: center; justify-content: center; }
  .sheet-card { max-width: 520px; border-radius: 18px; border: 1px solid var(--line); }
}

/* App bar */
.appbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent-surface); color: #fff;
  padding: calc(var(--sat) + 12px) 16px 12px;
  position: sticky; top: 0; z-index: 5;
}
.appbar-title { font-weight: 800; font-size: 18px; letter-spacing: .3px; flex: 1; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer; flex: none;
  background: var(--gold); color: var(--accent-surface); font-weight: 800; font-size: 13px;
}
.iconbtn {
  background: transparent; border: none; color: #fff; font-size: 24px; line-height: 1;
  width: 40px; height: 40px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; border-radius: 8px; flex: none;
}
.iconbtn:active { background: rgba(255,255,255,.12); }
.brandon-pill {
  border: 0; border-radius: 999px; padding: 4px 10px 4px 8px; font-family: inherit; font-size: 11.5px; font-weight: 700;
  background: rgba(255,255,255,.16); color: #fff; cursor: default; display: inline-flex; align-items: center; gap: 6px;
}
.brandon-pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #9aa5a8; }
.brandon-pill.online::before { background: #4ade80; }
.brandon-pill.offline { background: rgba(255,59,48,.26); }

/* Filters */
.list-controls { background: var(--accent-surface); padding: 0 12px 10px; }
.filters { display: flex; gap: 4px; background: rgba(255,255,255,.10); padding: 4px; border-radius: 12px; }
.seg {
  flex: 1; border: none; background: transparent; color: rgba(255,255,255,.82);
  font-family: inherit; font-weight: 600; font-size: 13px; padding: 8px 4px;
  border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.seg.active { background: #fff; color: #093c44; }
.seg .seg-count { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: var(--badge-bg); color: #fff; font-size: 11px; line-height: 18px; }

/* Banners */
.notif-banner { display: flex; align-items: center; gap: 10px; background: var(--cream); color: var(--navy); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.notif-banner.warn { background: var(--needs-bg); color: var(--needs); }
.notif-text { flex: 1; font-size: 13.5px; font-weight: 600; }
.notif-enable { border: none; background: var(--accent-surface); color: #fff; font-family: inherit; font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.notif-dismiss { border: none; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 6px; }

/* List */
.list-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.conv-list { list-style: none; margin: 0; padding: 0; }
.group-head { padding: 14px 16px 6px; font-size: 11.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); background: var(--bg); }
.conv {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--card); border-bottom: 1px solid var(--line); cursor: pointer;
}
.conv.needs { box-shadow: inset 4px 0 0 var(--needs); }
.conv-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: var(--cream); color: var(--navy); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.conv-avatar.bot { background: var(--accent-surface); color: var(--gold); font-size: 18px; }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-name { font-weight: 700; font-size: 15px; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 12px; color: var(--muted); flex: none; }
.conv-sub { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 3px; }
.conv-preview { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-preview.unread { color: var(--ink); font-weight: 600; }
.conv-meta { display: flex; gap: 6px; align-items: center; margin-top: 5px; flex-wrap: wrap; }
.badge { background: var(--badge-bg); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 999px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.empty { padding: 40px 20px; text-align: center; font-size: 14px; }
.loading { padding: 20px; text-align: center; font-size: 14px; }

/* Status chips */
.status-chip { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .2px; border-radius: 999px; padding: 3px 9px; background: var(--cream); color: var(--navy); white-space: nowrap; }
.status-chip.needs { background: var(--needs-bg); color: var(--needs); }
.status-chip.working { background: rgba(248,182,0,.18); color: #8a6100; }
.status-chip.done { background: rgba(47,125,74,.14); color: var(--ok); }
.status-chip.muted { background: transparent; color: var(--muted); border: 1px solid var(--line); }
:root[data-theme="dark"] .status-chip.working { color: var(--gold); }
/* On the dark app bar, chips need solid fills to stay readable. */
.thread-appbar .status-chip { border: 0; background: rgba(255,255,255,.18); color: #fff; }
.thread-appbar .status-chip.needs { background: #fff1e6; color: #c2410c; }
.thread-appbar .status-chip.working { background: #f8b600; color: #093c44; }
.thread-appbar .status-chip.done { background: #d9f2e1; color: #1f5f36; }

/* Thread */
.thread-head { flex: 1; min-width: 0; }
.thread-name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-sub { font-size: 12px; color: rgba(255,255,255,.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 12px 14px; }
.messages { display: flex; flex-direction: column; gap: 8px; }
.day-sep { text-align: center; font-size: 11.5px; color: var(--muted); margin: 10px 0 2px; }
.post { position: relative; max-width: 86%; padding: 9px 12px; border-radius: 16px; font-size: 15px; line-height: 1.42; overflow-wrap: anywhere; }
.post.in { align-self: flex-start; background: var(--in-bubble); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.post.bot { background: var(--brandon-bubble); }
.post.out { align-self: flex-end; background: var(--out-bubble); border-bottom-right-radius: 5px; }
.post.pending { opacity: .6; }
.post.system { align-self: center; max-width: 92%; background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 13px; text-align: center; border-radius: 12px; }
.post-author { font-size: 12px; font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.post-body { white-space: pre-wrap; }
.post-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--code-bg); border-radius: 5px; padding: 1px 4px; }
.post-body pre { white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--code-bg); border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.post-body pre code { background: none; padding: 0; }
.post-body a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.post-body .h { font-weight: 800; }
.post-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.post-meta .via { margin-left: 4px; }
.post-copy { border: 0; background: none; color: var(--muted); font-size: 11px; cursor: pointer; padding: 0 0 0 6px; font-family: inherit; }

/* Approval bar */
.approval-bar { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--needs-bg); border-top: 1px solid var(--line); }
.approval-text { flex: 1; font-size: 13.5px; font-weight: 600; color: var(--needs); }
.approval-actions { display: flex; gap: 8px; }
.btn-pill { border: none; background: var(--accent-surface); color: #fff; font-family: inherit; font-weight: 700; font-size: 14px; padding: 9px 16px; border-radius: 999px; cursor: pointer; }
.btn-pill.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-pill:disabled { opacity: .5; }

/* Composer */
.composer { flex: none; background: var(--card); border-top: 1px solid var(--line); padding: 8px 10px calc(var(--sab) + 8px); display: flex; flex-direction: column; gap: 6px; }
.composer-main { display: flex; align-items: flex-end; gap: 8px; }
#composer-text, #new-text {
  flex: 1; resize: none; font-family: inherit; font-size: 15px; line-height: 1.35; color: var(--ink);
  background: var(--field-bg); border: 1.5px solid var(--input-bd); border-radius: 18px; padding: 9px 14px; max-height: 160px;
}
#new-text { border-radius: 12px; max-height: none; width: 100%; }
.composer-send { flex: none; border: none; background: var(--accent-surface); color: #fff; font-family: inherit; font-weight: 700; font-size: 14px; padding: 10px 16px; border-radius: 999px; cursor: pointer; }
.composer-send:disabled { opacity: .5; }
.composer-error { color: var(--danger); font-size: 12.5px; }
.composer-note { color: var(--muted); font-size: 12.5px; }

/* Sign-in */
.signin { align-items: center; justify-content: center; background: var(--accent-surface); }
.signin-card { text-align: center; color: #fff; padding: 24px; max-width: 340px; }
.signin-card h1 { margin: 12px 0 6px; font-weight: 800; }
.signin-card .muted { color: rgba(255,255,255,.8); margin-bottom: 22px; }
.signin-card strong { color: var(--gold); }
#gsi-button { display: flex; justify-content: center; min-height: 44px; }

/* Sheets */
.btn { font-family: inherit; font-weight: 600; font-size: 15px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--navy); padding: 13px; cursor: pointer; width: 100%; text-align: center; text-decoration: none; display: block; }
.btn.primary { background: var(--accent-surface); color: #fff; border-color: var(--accent-surface); }
.btn.danger { background: var(--danger); color: var(--danger-fg); border-color: var(--danger); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn:disabled { opacity: .6; cursor: default; }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; z-index: 20; }
.sheet-card { background: var(--card); color: var(--ink); border-top: 1px solid var(--line); width: 100%; border-radius: 18px 18px 0 0; padding: 20px 18px calc(var(--sab) + 20px); display: flex; flex-direction: column; gap: 10px; max-height: 92dvh; overflow-y: auto; }
.sheet-title { font-weight: 800; font-size: 17px; }
#new-form { display: flex; flex-direction: column; gap: 10px; }
.new-choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; gap: 12px; align-items: center; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); padding: 12px; cursor: pointer; font-family: inherit; }
.choice-ico { font-size: 22px; width: 36px; text-align: center; }
.choice-title { font-weight: 700; font-size: 15px; }
.choice-sub { font-size: 12.5px; color: var(--muted); }
.people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.people-list button { display: flex; gap: 12px; align-items: center; width: 100%; border: 0; background: transparent; color: var(--ink); padding: 9px 4px; cursor: pointer; font-family: inherit; text-align: left; border-radius: 10px; }
.people-list button:active { background: var(--active-row); }
.pref-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; font-size: .95rem; cursor: pointer; }
.pref-row input { width: 20px; height: 20px; accent-color: var(--navy); }
