/* ============================================================
   inbox-crm.css — the Inbox as a CRM (Nelson only)
   Same family as the Studio dashboard: ink chrome (top bar +
   conversation list) around a warm paper work surface. Anton for
   names and numbers, Plex Sans Condensed for UI, Familjen Grotesk
   for what clients wrote, IBM Plex Mono for small labels.
   Loads after inbox.css (which still styles the Pitches screens).
   ============================================================ */

:root {
  --font-display: "Anton", "Impact", sans-serif;
  --font-ui: "IBM Plex Sans Condensed", "Arial Narrow", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --faint: #8a857b; /* clears 4.5:1 on the ink chrome */

  --ink: #0b0b0d;
  --ink-2: #151518;
  --ink-3: #1d1d21;
  --ink-line: rgba(244, 241, 234, 0.08);
  --ink-edge: rgba(244, 241, 234, 0.22);

  --paper: #f5f2eb;
  --card: #fbf9f5;
  --paper-2: #ece8e0;
  --paper-ink: #131315;
  --paper-muted: #5e5950;
  --paper-faint: #736d62;
  --paper-line: #e5e0d6;
  --paper-edge: #d6d0c4;
  --gold-ink: #7a5a0e;
  --green-ink: #1d7a50;
  --red-ink: #b3261e;

  --bar-h: 60px;
  --list-w: 372px;
  --side-w: 344px;
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

html { scroll-behavior: auto; } /* landing on the newest message must be instant, not a glide */
.inbox-pages { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 12px; color: var(--muted); font: 13px var(--font-ui); }
.inbox-pages button:disabled { opacity: .45; cursor: default; }
body { background: var(--ink); font-size: 15px; }
body::after { display: none; } /* the film grain belongs to the marketing page */
.sr-only { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font-family: var(--font-mono); font-size: 0.68rem; border: 1px solid var(--ink-edge); border-radius: 4px; padding: 0.05em 0.4em; color: var(--muted); }

/* shared wordmark (same as Studio) */
.wordmark { font-family: var(--font-display); font-size: 1.45rem; line-height: 1; letter-spacing: 0.005em; color: var(--text); white-space: nowrap; }
.wordmark i { font-style: normal; color: var(--gold); padding: 0 0.04em; }
.crm-tag { font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.42em; text-transform: uppercase; color: var(--text); padding-left: 0.9rem; border-left: 1px solid var(--ink-edge); line-height: 1.9; }

/* buttons in the UI voice */
.btn { font-family: var(--font-ui); font-weight: 600; font-size: 0.95rem; letter-spacing: 0.01em; height: 40px; padding: 0 1.2em; }
.btn-sm { height: 34px; font-size: 0.88rem; padding: 0 0.95em; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.btn-ink, .work .btn-ink { background: var(--paper-ink); color: var(--paper); border: 1px solid var(--paper-ink); text-decoration: none; }

/* ---------------- sign in ---------------- */
.crm-login { max-width: 380px; margin: 16vh auto 0; padding: 0 1.2rem; display: grid; gap: 0.75rem; }
.crm-login-mark { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1.4rem; }
.crm-login form { display: grid; gap: 0.5rem; }
.crm-login label { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 0.4rem; }
.crm-login input { background: var(--ink-2); border: 1px solid var(--ink-edge); border-radius: 8px; color: var(--text); padding: 0.75rem 0.9rem; font: 16px var(--font-ui); }
.crm-login input:focus { outline: none; border-color: var(--gold); }
.crm-login .btn { width: 100%; margin-top: 0.6rem; }
.crm-login-or { display: flex; align-items: center; gap: 12px; color: var(--faint); font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; }
.crm-login-or span { flex: 1; height: 1px; background: var(--ink-edge); }

/* ---------------- top bar ---------------- */
.crm-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1.25rem;
  min-height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) clamp(14px, 2vw, 28px) 0;
  background: var(--ink); border-bottom: 1px solid var(--ink-line);
}
.crm-bar[hidden] { display: none; }
.crm-brand { display: flex; align-items: center; gap: 0.9rem; color: var(--text); flex-shrink: 0; }
.crm-stats { display: flex; align-items: stretch; margin-left: auto; }
button.crm-stat { background: none; border-top: 0; border-right: 0; border-bottom: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: transform 0.12s var(--ease); }
button.crm-stat:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { button.crm-stat:hover > span { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; } }
.crm-stat { display: flex; align-items: center; gap: 0.6rem; padding: 0 clamp(0.8rem, 1.15vw, 1.5rem); border-left: 1px solid var(--ink-edge); min-height: 36px; }
.crm-stat b { font-family: var(--font-display); font-weight: 400; font-size: 1.95rem; line-height: 1; color: var(--gold); font-variant-numeric: tabular-nums; }
.crm-stat > span { font-family: var(--font-ui); font-size: 0.84rem; color: var(--text); white-space: nowrap; }
.crm-stat.zero b { color: var(--faint); }
.crm-stats .lbl-short, .crm-stats .n-short, .lstats .lbl-long, .lstats .n-long { display: none; }

.crm-nav { display: flex; align-items: center; gap: 1.2rem; margin-left: clamp(0.5rem, 1.6vw, 2.5rem); flex-shrink: 0; }
.crm-stats:empty + .crm-nav { margin-left: auto; }
.crm-nav a { display: inline-flex; align-items: center; gap: 0.3rem; font-family: var(--font-ui); font-weight: 500; font-size: 0.9rem; color: var(--text); background: none; border: 0; padding: 0.4rem 0; transition: color 0.15s var(--ease); }
.crm-nav a svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.crm-nav a.on { color: var(--gold); }
.crm-alerts {
  display: inline-flex; align-items: center; gap: 0.4rem; height: 34px; padding: 0 0.85rem;
  border: 1px solid rgba(233, 185, 73, 0.55); border-radius: 999px; background: transparent; color: var(--gold);
  font: 600 0.84rem var(--font-ui); transition: border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.12s var(--ease);
}
.crm-alerts svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.crm-alerts.on { border-color: var(--ink-edge); color: var(--text); }
.crm-alerts.on svg { color: var(--gold); }
.crm-alerts:active, .lfilters button:active, .tchip:active, .icon-btn:active { transform: scale(0.97); }
.crm-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: var(--ink); font: 700 0.8rem var(--font-ui); letter-spacing: 0.02em; }
@media (hover: hover) and (pointer: fine) {
  .crm-nav a:hover, .lpane-foot a:hover, .lpane-foot .linkish:hover { color: var(--gold); }
  .crm-alerts:hover { border-color: var(--gold); }
}

/* ---------------- the CRM shell ---------------- */
#crmView:not([hidden]) {
  display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr);
  height: calc(100dvh - var(--bar-h) - env(safe-area-inset-top)); min-height: 0;
}

/* ---------------- conversation list (ink) ---------------- */
.lpane { display: flex; flex-direction: column; min-height: 0; background: var(--ink); color-scheme: dark; }
.lpane-head { padding: 1rem 1.25rem 0.85rem; border-bottom: 1px solid var(--ink-line); }
.lpane-title { display: flex; align-items: baseline; gap: 0.7rem; }
.lpane-title h1 { font-family: var(--font-display); font-weight: 400; font-size: 1.9rem; line-height: 1; text-transform: uppercase; letter-spacing: 0.01em; margin: 0; }
.lpane-count { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.crm-note { margin: 0.8rem 0 0; padding: 0.7rem 0.85rem; border: 1px solid var(--ink-edge); border-radius: 8px; background: var(--ink-2); color: var(--text); font: 0.88rem/1.45 var(--font-ui); }
.lstats { display: none; }

.lsearch { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.85rem; padding: 0 0.8rem; height: 38px; background: var(--ink-2); border: 1px solid var(--ink-edge); border-radius: 8px; transition: border-color 0.15s var(--ease); }
.lsearch:focus-within { border-color: var(--gold); }
.lsearch svg { width: 17px; height: 17px; flex-shrink: 0; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; }
.lsearch input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: none; color: var(--text); font: 0.95rem var(--font-ui); }
.lsearch input::placeholder { color: var(--muted); }
.lsearch input::-webkit-search-cancel-button { filter: invert(0.7); }
.lsearch:focus-within kbd { display: none; }

.lfilters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.8rem; }
.lfilters button, .lf-pitches {
  display: inline-flex; align-items: center; gap: 0.45em; min-height: 30px; padding: 0 0.85em;
  background: transparent; border: 1px solid var(--ink-edge); border-radius: 999px; color: var(--text);
  font-family: var(--font-mono); font-weight: 500; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.12s var(--ease);
}
.lfilters button span { color: var(--muted); font-weight: 400; }
.lfilters button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 600; }
.lfilters button[aria-pressed="true"] span { color: rgba(11, 11, 13, 0.74); }
.lf-pitches { display: none; border-style: dashed; color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .lfilters button:not([aria-pressed="true"]):hover { border-color: var(--gold); } }

.llist { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.lgroup { position: sticky; top: 0; z-index: 1; margin: 0; padding: 0.85rem 1.25rem 0.4rem; background: var(--ink); font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); }

.crow {
  position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 0.85rem;
  padding: 0.75rem 1.25rem 0.8rem; border-bottom: 1px solid var(--ink-line); color: var(--text);
  transition: background 0.15s var(--ease);
}
.crow:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; border-radius: 0; }
.crow.is-sel { background: rgba(233, 185, 73, 0.16); }
.crow.is-sel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--gold); }
@media (hover: hover) and (pointer: fine) { .crow:not(.is-sel):hover { background: var(--ink-2); } }
.crow:active { background: var(--ink-2); }

.mono-av { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--ink-2); border: 1px solid var(--ink-edge); color: var(--text); font: 600 0.84rem var(--font-ui); letter-spacing: 0.04em; }
.crow.is-waiting .mono-av::after { content: ""; position: absolute; top: -1px; right: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--ink); }
.crow.is-sel .mono-av::after { box-shadow: 0 0 0 2px #2b2618; }

.crow-main { display: grid; gap: 0.12rem; min-width: 0; }
.crow-top, .crow-mid { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; min-width: 0; }
.crow-top { align-items: baseline; }
.crow-name { font: 500 1rem/1.3 var(--font-ui); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow.is-waiting .crow-name { font-weight: 700; }
.crow-ago { flex: none; font-family: var(--font-mono); font-size: 0.7rem; color: var(--faint); }
.crow.is-waiting .crow-ago { color: var(--text); }
.crow.is-sel .crow-ago, .crow.is-sel .crow-what { color: var(--muted); }
.crow.is-sel .st-dim { color: var(--muted); }
.crow-what { font: 0.86rem/1.35 var(--font-ui); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.crow-due { color: var(--gold); }
.crow-line { font: 0.9rem/1.4 var(--font-body); color: rgba(244, 241, 234, 0.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow.is-waiting .crow-line { color: var(--text); }

/* stage chip (same shapes as Studio) */
.st {
  display: inline-flex; align-items: center; flex: none; height: 22px; padding: 0 0.75em; border-radius: 999px;
  border: 1.5px solid rgba(244, 241, 234, 0.5); color: var(--text);
  font: 600 0.64rem var(--font-ui); letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap;
}
.st-quoted { border-style: dashed; }
.st-gold { border-color: var(--gold); color: var(--gold); }
.st-green { border-color: var(--green); color: var(--green); }
.st-dim { border-color: var(--ink-edge); color: var(--faint); }

.crow-sk { display: grid; grid-template-columns: 40px 1fr; gap: 0.85rem; padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--ink-line); }
.crow-sk i { width: 40px; height: 40px; border-radius: 50%; background: var(--ink-2); }
.crow-sk span { display: grid; gap: 0.5rem; padding-top: 0.2rem; }
.crow-sk b { display: block; height: 9px; border-radius: 5px; background: var(--ink-2); width: 58%; }
.crow-sk b:nth-child(2) { width: 38%; } .crow-sk b:nth-child(3) { width: 86%; }
@media (prefers-reduced-motion: no-preference) {
  .crow-sk i, .crow-sk b, .thread-sk i { animation: sk 1.1s var(--ease) infinite alternate; }
}
@keyframes sk { from { opacity: 1; } to { opacity: 0.45; } }

.lempty { padding: 3rem 1.5rem; text-align: center; color: var(--muted); font: 0.95rem/1.5 var(--font-ui); }
.lempty p { margin: 0 0 0.3rem; }
.lempty .lempty-big { font-family: var(--font-display); font-size: 1.7rem; text-transform: uppercase; color: var(--text); }
.lempty .btn { margin-top: 0.9rem; }
.lpane-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.65rem 1.3rem; padding: 0.75rem 1.25rem; border-top: 1px solid var(--ink-line); }
.lpane-foot a, .lpane-foot .linkish { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.35rem 0; background: none; border: 0; text-decoration: none; font: 500 0.86rem var(--font-ui); color: var(--muted); transition: color 0.15s var(--ease); }
.lpane-foot svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lpane-foot .linkish { margin-left: auto; }

/* ---------------- work surface (paper) ---------------- */
.work {
  /* the shared components read these, so they all turn paper in here */
  --bg: var(--paper); --bg-2: var(--card); --line: var(--paper-edge); --line-soft: var(--paper-line);
  --text: var(--paper-ink); --muted: var(--paper-muted); --faint: var(--paper-faint); --red: var(--red-ink);
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--paper); color: var(--paper-ink); border-top-left-radius: 22px; overflow: hidden;
}
.work ::selection { background: var(--gold); color: var(--paper-ink); }
.work :focus-visible { outline: 2px solid var(--paper-ink); outline-offset: 2px; }
.work a { color: var(--paper-ink); }
.work kbd { border-color: var(--paper-edge); color: var(--paper-muted); }
.work .btn-ghost { border: 1.5px solid var(--paper-ink); color: var(--paper-ink); background: transparent; }
.work .btn-gold { color: var(--paper-ink); }
@media (hover: hover) and (pointer: fine) {
  .work .btn-ghost:hover { background: var(--paper-ink); color: var(--paper); border-color: var(--paper-ink); }
  .work .btn-gold:hover { background: #f2c75d; }
  .work .btn-ink:hover { background: #2a2a2e; }
}
.work .st { border-color: var(--paper-edge); color: var(--paper-ink); background: var(--card); }
.work .st-gold { color: var(--gold-ink); border-color: #dcbd6e; background: #fbf0d4; }
.work .st-green { color: var(--green-ink); border-color: #9ed4bb; background: #e7f4ed; }
.work .st-dim { color: var(--paper-faint); }

.work-empty { margin: auto; text-align: center; padding: 2rem; }
.work-empty-tag { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--paper-faint); }
.work-empty p { margin: 0.6rem 0 0; font: 0.9rem var(--font-ui); color: var(--paper-muted); }

.whead {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "id acts"; align-items: end; gap: 0.5rem 1.5rem;
  padding: 1.2rem clamp(1rem, 2.2vw, 2rem) 1rem; border-bottom: 1px solid var(--paper-edge);
}
.whead-id { grid-area: id; min-width: 0; }
.whead-acts { grid-area: acts; }
.wtabs { grid-area: tabs; }

.wbar { display: none; }
.lbl { white-space: nowrap; }
.crumb { margin: 0; font-family: var(--font-mono); font-weight: 500; font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--paper-ink); }
.crumb span { color: var(--paper-faint); padding: 0 0.35em; }
.whead h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(2.2rem, 3.6vw, 3.2rem); line-height: 0.98; text-transform: uppercase; letter-spacing: 0.005em; margin: 0.3rem 0 0.35rem; overflow-wrap: anywhere; }
.whead h2.long { font-size: clamp(1.8rem, 2.8vw, 2.5rem); }
.whead h2:focus { outline: none; }
.wsub { margin: 0; font: 1rem var(--font-ui); color: var(--paper-ink); }
.wsub span { color: var(--paper-faint); padding: 0 0.45em; }
.wsub b { font-weight: inherit; white-space: nowrap; }
.whead-acts { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; justify-content: flex-end; padding-bottom: 0.2rem; }
.wstage .st { height: 34px; padding: 0 1em; font-size: 0.72rem; }
.wtabs { display: none; }

.wbody { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.conv { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

/* the thread */
.thread { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1rem clamp(1rem, 2.2vw, 2rem) 1.5rem; display: flex; flex-direction: column; gap: 0.6rem; }
.tday { display: flex; align-items: center; gap: 0.9rem; margin: 0.9rem 0 0.3rem; font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--paper-faint); }
.tday::before, .tday::after { content: ""; flex: 1; height: 1px; background: var(--paper-line); }

.brief { align-self: stretch; max-width: 680px; background: var(--card); border: 1px solid var(--paper-line); border-radius: 14px; padding: 1rem 1.2rem 1.1rem; }
.brief-tag { margin: 0; font-family: var(--font-mono); font-weight: 500; font-size: 0.6875rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-ink); }
.brief h3 { margin: 0.35rem 0 0.5rem; font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; line-height: 1.05; text-transform: uppercase; letter-spacing: 0.01em; }
.brief-body { margin: 0; font: 1rem/1.55 var(--font-body); white-space: pre-wrap; overflow-wrap: anywhere; max-width: 65ch; }
.brief-none { color: var(--paper-muted); }
.brief dl { display: flex; flex-wrap: wrap; gap: 0.6rem 2rem; margin: 0.85rem 0 0; padding-top: 0.75rem; border-top: 1px solid var(--paper-line); }
.brief dt, .facts dt, .money span, .stage-sel span { font-family: var(--font-mono); font-weight: 500; font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--paper-muted); }
.brief dd { margin: 0.15rem 0 0; font: 0.95rem var(--font-ui); }

.bub { max-width: min(560px, 84%); padding: 0.75rem 1rem 0.6rem; border-radius: 16px; }
.bub p { margin: 0; font: 0.98rem/1.55 var(--font-body); white-space: pre-wrap; overflow-wrap: anywhere; }
.bub > span { display: block; margin-top: 0.45rem; font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.12em; text-transform: uppercase; }
.bub.theirs { align-self: flex-start; background: var(--paper-2); border-bottom-left-radius: 5px; }
.bub.theirs > span { color: var(--paper-muted); }
.bub.mine { align-self: flex-end; background: var(--paper-ink); color: var(--paper); border-bottom-right-radius: 5px; }
.bub.mine > span { color: rgba(245, 242, 235, 0.62); }
.bub.mine ::selection { background: var(--gold); color: var(--paper-ink); }

.tev { align-self: center; margin: 0.2rem 0; }
.tev span { display: inline-block; padding: 0.3rem 0.85rem; border: 1px solid var(--paper-edge); border-radius: 999px; font-family: var(--font-mono); font-weight: 500; font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--paper-muted); background: var(--card); text-align: center; }
.tev-money span { color: var(--gold-ink); border-color: #dcbd6e; background: #fbf0d4; }
.tev-good span { color: var(--green-ink); border-color: #9ed4bb; background: #e7f4ed; }
.tev-bad span { color: var(--red-ink); border-color: #e7aaa5; background: #fbebea; }

.thread-sk { display: grid; gap: 0.8rem; padding-top: 1rem; }
.thread-sk i { display: block; height: 72px; width: 62%; border-radius: 14px; background: var(--paper-2); }
.thread-sk i:first-child { width: 100%; max-width: 680px; height: 130px; background: var(--card); border: 1px solid var(--paper-line); }
.thread-sk i.r { justify-self: end; width: 48%; }

/* the reply box */
.composer { flex: none; padding: 0.85rem clamp(1rem, 2.2vw, 2rem) 1rem; background: var(--card); border-top: 1px solid var(--paper-edge); }
.composer-head { display: flex; align-items: center; gap: 0.5rem 1rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.composer-label { font-family: var(--font-mono); font-weight: 600; font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; }
.tpls { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tchip { height: 30px; padding: 0 0.8em; border-radius: 999px; border: 1px solid var(--paper-edge); background: transparent; color: var(--paper-ink); font: 600 0.84rem var(--font-ui); transition: border-color 0.15s var(--ease), background 0.15s var(--ease), transform 0.12s var(--ease); }
.tchip[aria-pressed="true"] { background: var(--paper-ink); border-color: var(--paper-ink); color: var(--paper); }
@media (hover: hover) and (pointer: fine) { .tchip:hover { border-color: var(--paper-ink); } }
#draft, #noteBox {
  display: block; width: 100%; box-sizing: border-box; background: #fffdf9; color: var(--paper-ink);
  border: 1px solid var(--paper-edge); border-radius: 10px; padding: 0.8rem 0.95rem; font: 16px/1.55 var(--font-body); resize: vertical;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
#draft { height: clamp(104px, 19vh, 220px); }
#draft:focus, #noteBox:focus { outline: none; border-color: var(--paper-ink); box-shadow: 0 0 0 3px rgba(233, 185, 73, 0.32); }
#draft[readonly] { color: var(--paper-muted); }
.work .ib-err { color: var(--red-ink); font: 0.88rem var(--font-ui); min-height: 0; margin: 0.4rem 0 0; }
.work .ib-err:empty { display: none; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.7rem; }
.composer-count { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--paper-faint); }
.composer-acts { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
#sendBtn { height: 42px; padding: 0 1.3em; font-weight: 700; font-size: 1rem; position: relative; overflow: hidden; isolation: isolate; }
/* a pending send shows its 5 seconds filling in, so Undo is obviously still possible */
#sendBtn.is-pending { opacity: 1; background: var(--gold); }
#sendBtn.is-pending::before { content: ""; position: absolute; inset: 0; z-index: -1; background: rgba(19, 19, 21, 0.16); transform-origin: left; animation: sendfill 5s linear var(--send-elapsed, 0s) forwards; }
@keyframes sendfill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.crm-sent-it { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0 0 0.8rem; padding: 0.7rem 0.9rem; border: 1px dashed var(--gold-ink); border-radius: 10px; font: 0.92rem var(--font-ui); }
.work .linkish { color: var(--paper-muted); font-family: var(--font-ui); }

/* ---------------- client & deal ---------------- */
.side { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1rem clamp(1rem, 1.6vw, 1.25rem) 2rem; }
.scard { background: var(--card); border: 1px solid var(--paper-line); border-radius: 12px; padding: 0.85rem 1rem 1rem; margin-bottom: 0.8rem; container-type: inline-size; }
.scard > header { display: flex; align-items: center; gap: 0.6rem; padding-bottom: 0.6rem; margin-bottom: 0.75rem; border-bottom: 1px solid var(--paper-line); }
.scard .num { display: grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; background: var(--gold); color: var(--paper-ink); font: 600 0.6875rem var(--font-mono); }
.scard h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.15rem; line-height: 1; text-transform: uppercase; letter-spacing: 0.01em; }

.who { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.8rem; }
.mono-av.big { width: 46px; height: 46px; flex: none; background: var(--gold); border-color: var(--gold); color: var(--paper-ink); font-size: 0.95rem; }
.who > div > b { display: block; font: 600 1.05rem/1.25 var(--font-ui); overflow-wrap: anywhere; }
.who > div > span { display: block; font: 0.86rem/1.35 var(--font-ui); color: var(--paper-muted); }
.clines { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.clines li { display: flex; align-items: center; gap: 0.55rem; min-height: 36px; font: 0.95rem var(--font-ui); }
.clines li > svg { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--paper-muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.clines a { flex: 1; min-width: 0; overflow-wrap: anywhere; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .clines a:hover { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; } }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--paper-muted); transition: border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.12s var(--ease); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { border-color: var(--paper-edge); color: var(--paper-ink); } }

.stage-sel { display: grid; gap: 0.3rem; margin-bottom: 0.9rem; }
.stage-sel select {
  appearance: none; height: 40px; padding: 0 2.4rem 0 0.9rem; cursor: pointer;
  background: #fffdf9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23131315' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 0.9rem center;
  border: 1px solid var(--paper-edge); border-radius: 8px; color: var(--paper-ink); font: 600 1rem var(--font-ui);
}
.stage-sel select:focus { outline: none; border-color: var(--paper-ink); box-shadow: 0 0 0 3px rgba(233, 185, 73, 0.32); }

.money { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.2rem 0.75rem; margin-bottom: 0.9rem; }
.money b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.money b.ok { color: var(--green-ink); }
.money b.due { color: var(--gold-ink); }
.money .bar { grid-column: 1 / -1; height: 6px; margin-top: 0.5rem; border-radius: 999px; background: var(--paper-line); overflow: hidden; }
.money .bar i { display: block; height: 100%; background: var(--gold); transform-origin: left; }
.side-none { margin: 0 0 0.8rem; font: 0.92rem var(--font-ui); color: var(--paper-muted); }

.facts { margin: 0; }
.facts div { display: grid; grid-template-columns: 6.4rem minmax(0, 1fr); gap: 0.6rem; padding: 0.5rem 0; border-top: 1px solid var(--paper-line); }
.facts dt { padding-top: 0.2rem; }
.facts dd { margin: 0; font: 0.95rem/1.4 var(--font-ui); overflow-wrap: anywhere; }
@container (max-width: 260px) { .facts div { grid-template-columns: 1fr; gap: 0.1rem; } }

.slist { list-style: none; margin: 0; padding: 0; }
.slist li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.1rem 0.6rem; padding: 0.55rem 0; border-top: 1px solid var(--paper-line); }
.slist li:first-child { border-top: 0; padding-top: 0; }
.slist b { font: 600 0.95rem var(--font-ui); }
.slist a { text-decoration: none; }
.slist span { grid-column: 1; font: 0.86rem var(--font-ui); color: var(--paper-muted); }
.slist .st, .slist em { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.slist .st { height: 22px; font-size: 0.64rem; }
.slist em { font: 600 0.64rem var(--font-ui); font-style: normal; letter-spacing: 0.1em; text-transform: uppercase; color: var(--paper-muted); }
.slist em.pill-confirmed, .slist em.pill-completed { color: var(--green-ink); }

#noteBox { min-height: 96px; font-size: 15px; }
.note-acts { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-top: 0.55rem; }
#noteState { font: 0.84rem var(--font-ui); color: var(--paper-muted); }
.slinks { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.work #noteSave[disabled] { opacity: 1; background: transparent; color: var(--paper-faint); border-color: var(--paper-edge); }
.side-none a { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }

/* ---------------- pitches keep their dark sheet under the new bar ---------------- */
.crm-pitches { --bg: var(--ink); max-width: 720px; }
.crm-pitches .ib-bar { top: calc(var(--bar-h) + env(safe-area-inset-top)); }
.crm-pitches .ib-brand { font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; letter-spacing: 0.02em; }
.crm-toast { font-family: var(--font-ui); background: var(--paper-ink); color: var(--paper); border: 1px solid rgba(245, 242, 235, 0.16); box-shadow: 0 10px 28px rgba(11, 11, 13, 0.28); top: calc(var(--bar-h) + 10px + env(safe-area-inset-top)); }

.undo-bar {
  position: fixed; z-index: 60; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 1rem; max-width: calc(100vw - 32px); padding: 0.45rem 0.5rem 0.45rem 1.1rem;
  background: var(--paper-ink); color: var(--paper); border: 1px solid rgba(245, 242, 235, 0.16); border-radius: 999px;
  box-shadow: 0 12px 32px rgba(11, 11, 13, 0.35); font: 600 0.95rem var(--font-ui);
}
.undo-bar[hidden] { display: none; }
/* computers: bottom-left, clear of the reply box (like Gmail); phones: under the top bar, clear of the Send bar */
@media (min-width: 760px) {
  .undo-bar { left: 20px; transform: none; }
  .crm-toast { top: auto; bottom: 20px; left: 20px; transform: translateY(12px); }
  .crm-toast.show { transform: translateY(0); }
  body:has(#undoBar:not([hidden])) .crm-toast { bottom: 84px; }
}
@media (max-width: 759px) {
  .undo-bar { bottom: auto; top: calc(var(--bar-h) + 10px + env(safe-area-inset-top)); }
  body:has(#undoBar:not([hidden])) .crm-toast { top: calc(var(--bar-h) + 70px + env(safe-area-inset-top)); }
}
.undo-bar button { min-height: 40px; padding: 0 1.1rem; border: 0; border-radius: 999px; background: var(--gold); color: var(--paper-ink); font: 700 0.95rem var(--font-ui); transition: transform 0.12s var(--ease); }
.undo-bar button:active { transform: scale(0.97); }
.undo-bar button:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .undo-bar { transition: opacity 0.2s var(--ease), transform 0.2s var(--ease); }
  @starting-style { .undo-bar { opacity: 0; } }
}

/* ---------------- sizes ---------------- */
/* big screens: the client & deal column sits beside the thread */
@media (min-width: 1180px) {
  .wbody { grid-template-columns: minmax(0, 1fr) var(--side-w); }
  .side { border-left: 1px solid var(--paper-line); background: #f1ede5; }
}
/* tablets and small laptops: Messages | Client & deal tabs */
@media (max-width: 1179px) {
  .whead { grid-template-areas: "id id" "tabs acts"; align-items: center; padding-bottom: 0; }
  .whead-acts { padding-bottom: 0.35rem; }
  .wtabs { display: flex; gap: 1.4rem; margin-top: 0.2rem; }
  .wtabs button { position: relative; background: none; border: 0; padding: 0.6rem 0 0.75rem; font: 600 0.95rem var(--font-ui); color: var(--paper-muted); }
  .wtabs button[aria-selected="true"] { color: var(--paper-ink); }
  .wtabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--gold); }
  .wbody[data-tab="thread"] .side, .wbody[data-tab="side"] .conv { display: none; }
  .side { max-width: 640px; width: 100%; }
}
@media (max-width: 1439px) {
  .crm-stats { display: none; }
  .crm-stats + .crm-nav { margin-left: auto; }
  .lstats:not(:empty) { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0.85rem 0 0; border: 1px solid var(--ink-line); border-radius: 10px; }
  .lstats .crm-stat { flex-direction: column; align-items: flex-start; gap: 0.25rem; padding: 0.55rem 0.7rem; border-left: 1px solid var(--ink-line); min-height: 0; }
  .lstats .crm-stat:first-child { border-left: 0; }
  .lstats .crm-stat b { font-size: 1.45rem; }
  .lstats .crm-stat > span { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
}
/* The full-width fallback fonts are wider than Plex/Anton. Keep every tool
   visible on desktop while fonts load by giving the stats bounded columns. */
@media (min-width: 1440px) and (max-width: 1799px) {
  .crm-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); flex: 1; min-width: 0; }
  .crm-stats .crm-stat { min-width: 0; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0.2rem; padding: 0 0.8rem; }
  .crm-stats .crm-stat b { font-size: 1.5rem; }
  .crm-stats .crm-stat > span { font-size: 0.72rem; line-height: 1.2; white-space: normal; }
  .crm-stats .n-long { display: none; }
  .crm-stats .n-short { display: inline; }
}
@media (min-width: 760px) and (max-width: 959px), (max-width: 374px) {
  .lstats .crm-stat { padding: 0.5rem 0.55rem; }
  .lstats .crm-stat b { font-size: 1.15rem; }
  .lstats .crm-stat > span { letter-spacing: 0.04em; white-space: normal; line-height: 1.2; }
}
@media (max-width: 959px) and (min-width: 760px) {
  :root { --list-w: 320px; }
  .whead { grid-template-columns: minmax(0, 1fr); grid-template-areas: "id" "acts" "tabs"; }
  .whead-acts { justify-content: flex-start; }
}
/* The page title already identifies the Inbox. Drop the duplicate header tag
   before reducing navigation, including while wider fallback fonts are active. */
@media (max-width: 959px) {
  .crm-bar .crm-tag { display: none; }
  .crm-nav { gap: 0.9rem; }
}
/* short laptop screens: give the thread the height, not the header */
@media (min-width: 760px) and (max-height: 860px) {
  .whead { padding-top: 0.8rem; padding-bottom: 0.75rem; }
  .crumb { display: none; }
  .whead h2 { font-size: 2.2rem; margin-top: 0; }
  .whead h2.long { font-size: 1.85rem; }
  .lpane-title h1 { font-size: 1.6rem; }
  .composer { padding-top: 0.7rem; padding-bottom: 0.75rem; }
  .composer-head { margin-bottom: 0.45rem; }
  .composer-foot { margin-top: 0.5rem; }
}
@media (min-width: 760px) and (max-width: 1179px) and (max-height: 860px) { .whead { padding-bottom: 0; } }

/* phones: one screen at a time, the page scrolls (friendlier with the keyboard) */
@media (max-width: 759px) {
  .crm-bar { gap: 0.75rem; padding-left: 16px; padding-right: 12px; }
  .crm-bar .wordmark { font-size: 1.15rem; }
  .crm-bar .crm-tag { font-size: 0.62rem; letter-spacing: 0.3em; padding-left: 0.7rem; }
  .crm-nav { gap: 0.6rem; }
  .crm-nav a, .crm-avatar { display: none; }
  .crm-alerts { height: 36px; width: 36px; padding: 0; justify-content: center; }
  .crm-alerts span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

  #crmView:not([hidden]) { display: block; height: auto; }
  .crm[data-pane="list"] .work, .crm[data-pane="work"] .lpane { display: none; }
  .lpane { min-height: calc(100dvh - var(--bar-h) - env(safe-area-inset-top)); }
  .lpane-head { padding: 0.9rem 16px 0.8rem; }
  .lfilters { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .lfilters::-webkit-scrollbar { display: none; }
  .lfilters button, .lf-pitches { flex: none; min-height: 34px; }
  .lf-pitches { display: inline-flex; }
  .lsearch kbd { display: none; }
  .lsearch input { font-size: 16px; }
  .llist { overflow: visible; }
  .lgroup { top: calc(var(--bar-h) + env(safe-area-inset-top)); padding-left: 16px; }
  .crow { padding: 0.8rem 16px; }
  .lpane-foot { justify-content: center; gap: 1.5rem; padding: 1.75rem 16px calc(1.5rem + env(safe-area-inset-bottom)); border-top: 0; }
  .lpane-foot .linkish { margin-left: 0; }

  .work { border-radius: 20px 20px 0 0; overflow: clip; min-height: calc(100dvh - var(--bar-h) - env(safe-area-inset-top)); }
  .wbar {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.5rem;
    position: sticky; top: calc(var(--bar-h) + env(safe-area-inset-top)); z-index: 6;
    min-height: 52px; padding: 0.4rem 16px; background: var(--paper); border-radius: 20px 20px 0 0; border-bottom: 1px solid transparent;
    transition: border-color 0.15s var(--ease);
  }
  .wbar[hidden] { display: none; }
  .wbar.show-name { border-bottom-color: var(--paper-line); border-radius: 0; }
  .wbar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font: 600 1rem var(--font-ui); opacity: 0; transition: opacity 0.15s var(--ease); }
  .wbar.show-name .wbar-name { opacity: 1; }
  .whead { grid-template-columns: minmax(0, 1fr); grid-template-areas: "id" "acts" "tabs"; gap: 0.5rem; padding: 0.1rem 16px 0; border-radius: 0; }
  .whead-acts { justify-content: flex-start; padding-bottom: 0; }
  .whead-acts #markBtn { display: none; }
  .whead-acts:not(:has(.st)) { display: none; }
  .crumb { display: none; }
  .bub, .tev { scroll-margin-top: calc(var(--bar-h) + 64px + env(safe-area-inset-top)); }
  .wback { display: inline-flex; align-items: center; gap: 0.15rem; justify-self: start; margin-left: -0.4rem; padding: 0.35rem 0.4rem; background: none; border: 0; color: var(--paper-ink); font: 600 1rem var(--font-ui); }
  .wback svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .whead h2 { font-size: 2.1rem; margin-top: 0; }
  .whead h2.long { font-size: 1.7rem; }
  .whead-acts { gap: 0.5rem; }
  #studioBtn { display: none; }
  .wtabs { gap: 0; }
  .wtabs button { flex: 1; }
  .wbody { display: block; }
  .thread { overflow: visible; padding: 0.75rem 16px 1.25rem; }
  .bub { max-width: 88%; }
  .composer { position: relative; padding: 0.85rem 16px 0; border-radius: 18px 18px 0 0; }
  .tpls { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .tpls::-webkit-scrollbar { display: none; }
  .tchip { flex: none; height: 34px; }
  #draft { height: auto; min-height: 128px; max-height: 46dvh; field-sizing: content; }
  .composer-foot { position: sticky; bottom: 0; z-index: 2; margin: 0.6rem -16px 0; padding: 0.6rem 16px calc(0.7rem + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--paper-line); }
  .composer-count { display: none; }
  /* one row: round Call and Text, Send takes the rest */
  .composer-acts { flex: 1; flex-wrap: nowrap; gap: 0.5rem; }
  #callBtn, #smsBtn { width: 48px; height: 48px; padding: 0; border-radius: 50%; justify-content: center; flex: none; }
  #callBtn svg, #smsBtn svg { width: 19px; height: 19px; }
  #callBtn .lbl, #smsBtn .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .composer.is-pending #callBtn, .composer.is-pending #smsBtn { display: none; }
  .composer-acts #sendBtn { flex: 1; height: 48px; min-width: 0; }
  .composer-acts #undoSend { height: 48px; flex: none; }
  .side { overflow: visible; padding: 1rem 16px calc(2rem + env(safe-area-inset-bottom)); max-width: none; }
  .slinks { display: grid; }
  .slinks .btn { width: 100%; height: 44px; }
}

/* phones: thumbs, not cursors */
@media (max-width: 759px) {
  .lfilters button, .lf-pitches, .tchip { min-height: 40px; height: auto; }
  .work .btn-sm, .crm-alerts, .icon-btn { min-height: 44px; }
  .crm-alerts { width: 44px; }
  .icon-btn { width: 44px; }
  .wback { min-height: 44px; }
  .wtabs button { min-height: 44px; }
  .stage-sel select { height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  #sendBtn.is-pending::before { animation: none; transform: scaleX(1); }
  .crm-alerts, .lfilters button, .tchip, .icon-btn, .crow { transition: none; }
}
