/* The clean layout, messages screens (Basecamp 10492667707). Every selector here starts
   with html[data-layout="clean"]; see docs/clean-layout.md.

   A list of people beside the conversation it opens, like a mail app; on a
   phone the list is the page and a conversation opens on its own, fitted to
   the screen so the reply box is always in reach (public/clean-messages.js
   draws it). The shared pieces (cards, tabs, lamps, the peek, the white
   button) are clean.css's own. */

html[data-layout="clean"] .cl-msg { display: flex; flex-direction: column; gap: 14px; }

/* The one line that holds the page while the messages arrive, while a
   conversation opens, and while a sign-in or Billing hand-off happens. */
html[data-layout="clean"] .cl-msg-line,
html[data-layout="clean"] .cl-msg > .panel-line {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 18px 22px; font-size: 16.5px; color: var(--ink-2);
}
html[data-layout="clean"] .cl-msg > .panel-line .pl-label { color: var(--ink-2); }
html[data-layout="clean"] .cl-msg > .panel-line .lamp { width: 9px; height: 9px; border: 0; border-radius: 2px; background: var(--amber); }

html[data-layout="clean"] .cl-msg-split { display: flex; flex-direction: column; gap: 14px; min-height: 0; }

/* ---------- the list of people ---------- */
html[data-layout="clean"] .cl-msg-list { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
html[data-layout="clean"] .cl-msg-row {
  flex: none; display: flex; flex-direction: column; gap: 5px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 14px 18px; text-decoration: none; color: var(--ink);
  transition: background-color .15s, border-color .15s;
  -webkit-touch-callout: none;
}
html[data-layout="clean"] .cl-msg-row:hover { background: var(--paper-4); border-color: var(--cl-line); color: var(--ink); }
html[data-layout="clean"] .cl-msg-row-top { display: flex; align-items: center; gap: 12px; min-height: 22px; }
html[data-layout="clean"] .cl-msg-row-top .cl-label { font-size: 11px; letter-spacing: 0.1em; }
html[data-layout="clean"] .cl-msg-when {
  margin-left: auto;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
html[data-layout="clean"] .cl-msg-name { font-size: 18px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
html[data-layout="clean"] .cl-msg-preview {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  font-size: 15.5px; line-height: 1.4; color: var(--ink-2); overflow-wrap: anywhere;
}
html[data-layout="clean"] .cl-msg-row.unread .cl-msg-preview { color: var(--ink); font-weight: 600; }
html[data-layout="clean"] .cl-msg-state { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 22px; font-size: 14.5px; color: var(--ink-2); }
html[data-layout="clean"] .cl-msg-new {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--accent); color: #fffdf7; border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
html[data-layout="clean"] .cl-msg-clear { display: flex; flex-direction: row; align-items: center; gap: 10px; }
html[data-layout="clean"] .cl-msg-note {
  flex: none; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px;
  padding: 14px 18px; font-size: 15.5px; color: var(--ink-2);
}
html[data-layout="clean"] .cl-msg-note-say { display: flex; align-items: flex-start; gap: 10px; }
html[data-layout="clean"] .cl-msg-note-say .cl-lamp { margin-top: 7px; }
/* The texting prompt, at the top of the page while texting is not on. */
html[data-layout="clean"] .cl-msg-texting[hidden] { display: none; }
html[data-layout="clean"] .cl-msg-texting > .cl-card { margin: 0; }
html[data-layout="clean"] .cl-msg-setup { padding: 16px 20px; font-size: 16px; color: var(--ink-2); }
html[data-layout="clean"] .cl-msg-setup b { color: var(--ink); font-weight: 700; }
html[data-layout="clean"] .cl-msg-setup .cl-msg-note-say { flex: 1 1 320px; line-height: 1.45; }
html[data-layout="clean"] .cl-msg-setup .cl-btn2 { flex: none; }
/* With no one to show there is nothing to filter. */
html[data-layout="clean"] .cl-msg.is-empty .cl-tabs { display: none; }
html[data-layout="clean"] .cl-msg .cl-empty-act { flex-direction: row; }

/* ---------- one conversation ---------- */
html[data-layout="clean"] .cl-msg-pane { display: none; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
html[data-layout="clean"] .cl-msg-pane > .cl-card { flex: none; }
html[data-layout="clean"] .cl-msg-pane > .cl-msg-sheet { flex: 1 1 auto; min-height: 0; padding: 0; overflow: hidden; }
html[data-layout="clean"] .cl-msg-head {
  flex: none; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 18px;
  padding: 14px 18px 12px; border-bottom: 1px solid var(--rule-soft);
}
html[data-layout="clean"] .cl-msg-who { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
html[data-layout="clean"] .cl-msg-standing { display: flex; align-items: center; gap: 8px; min-height: 18px; }
/* The person's name is the card's name, not a section break: the global h2
   draws a dashed rule over itself and is mono caps. */
html[data-layout="clean"] .cl-msg-title {
  font-family: var(--font-text); text-transform: none; color: var(--ink);
  font-size: 22px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2;
  margin: 0; padding: 0; border-top: 0; overflow-wrap: anywhere;
}
html[data-layout="clean"] .cl-msg-contact { font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
html[data-layout="clean"] .cl-msg-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
html[data-layout="clean"] .cl-msg-acts .cl-btn2 { gap: 8px; padding: 8px 14px; font-size: 15px; }
html[data-layout="clean"] .cl-msg-acts svg { width: 16px; height: 16px; }

/* The messages. Theirs sit left on a soft grey; the owner's sit right in an
   outlined white, and every one says in words whose it is and what it was. */
html[data-layout="clean"] .cl-msg-log {
  flex: 1 1 auto; min-height: 96px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px 18px 18px; outline-offset: -3px;
}
html[data-layout="clean"] .cl-msg-log > * { flex: none; }
/* A short conversation sits at the foot, beside the reply box. */
html[data-layout="clean"] .cl-msg-log > :first-child { margin-top: auto; }
html[data-layout="clean"] .cl-msg-none { margin: auto; padding: 24px 8px; text-align: center; font-size: 16.5px; color: var(--muted); }
html[data-layout="clean"] .cl-msg-day { display: flex; align-items: center; gap: 12px; }
html[data-layout="clean"] .cl-msg-day::before,
html[data-layout="clean"] .cl-msg-day::after { content: ""; flex: 1 1 0; height: 1px; background: var(--rule-soft); }
html[data-layout="clean"] .cl-msg-day .cl-label { font-size: 11px; letter-spacing: 0.1em; }
html[data-layout="clean"] .cl-msg-item {
  align-self: flex-start; max-width: 88%; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
}
html[data-layout="clean"] .cl-msg-item.out { align-self: flex-end; align-items: flex-end; }
html[data-layout="clean"] .cl-msg-meta {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
html[data-layout="clean"] .cl-msg-meta svg { flex: none; width: 14px; height: 14px; }
html[data-layout="clean"] .cl-msg-time::before { content: "\00b7"; margin-right: 6px; }
html[data-layout="clean"] .cl-msg-bubble {
  box-sizing: border-box; max-width: 100%;
  display: flex; flex-direction: column; gap: 8px;
  padding: 11px 15px; border: 1px solid transparent; border-radius: 16px 16px 16px 4px;
  background: var(--paper-4); color: var(--ink);
  font-size: 17px; line-height: 1.45;
}
html[data-layout="clean"] .cl-msg-item.out .cl-msg-bubble { background: var(--surface); border-color: var(--cl-line); border-radius: 16px 16px 4px 16px; }
/* An email is a sheet of paper, a text is a bubble. */
html[data-layout="clean"] .cl-msg-item.email .cl-msg-bubble { border-radius: 6px; padding: 13px 16px; }
html[data-layout="clean"] .cl-msg-item.call .cl-msg-bubble { background: none; border-color: var(--rule); border-radius: 6px; }
html[data-layout="clean"] .cl-msg-subj { font-weight: 700; overflow-wrap: anywhere; }
/* Who else an email went to, said in words under its subject. */
html[data-layout="clean"] .cl-msg-cc { margin-top: -4px; font-size: 14.5px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
/* Small actions with an icon and one word: Reply on an email, and New email,
   Reply and CC in the reply box. The full sentence is their hover words. */
html[data-layout="clean"] .cl-msg-mini {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 8px;
  background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer;
  font-family: var(--font-text); font-size: 14.5px; font-weight: 600; letter-spacing: normal; text-transform: none;
  color: var(--ink-2); transition: background-color .15s, color .15s;
}
html[data-layout="clean"] .cl-msg-mini:hover { background: var(--paper-4); color: var(--ink); }
html[data-layout="clean"] .cl-msg-mini:focus-visible { border-color: var(--ink); }
html[data-layout="clean"] .cl-msg-mini[hidden] { display: none; }
html[data-layout="clean"] .cl-msg-mini svg { flex: none; width: 15px; height: 15px; }
html[data-layout="clean"] .cl-msg-meta .cl-msg-mini { margin-left: 4px; min-height: 26px; padding: 0 6px; }
html[data-layout="clean"] .cl-msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
html[data-layout="clean"] .cl-msg-media { display: flex; flex-wrap: wrap; gap: 6px; }
html[data-layout="clean"] .cl-msg-media img { display: block; max-width: min(220px, 100%); max-height: 220px; border: 1px solid var(--rule); border-radius: 8px; }
html[data-layout="clean"] .cl-msg-bubble audio { display: block; width: 280px; max-width: 100%; height: 40px; }
html[data-layout="clean"] .cl-msg-said > summary {
  padding: 4px 0; font-family: var(--font-text); font-size: 15px; font-weight: 600; letter-spacing: normal; text-transform: none;
  color: var(--ink-2);
}
html[data-layout="clean"] .cl-msg-said > summary:hover { color: var(--ink); }
html[data-layout="clean"] .cl-msg-said > div { padding-top: 6px; white-space: pre-wrap; font-size: 15.5px; line-height: 1.5; color: var(--ink-2); }
/* A send that did not go: said in words under it, never by colour alone. */
html[data-layout="clean"] .cl-msg-item.failed .cl-msg-bubble { border: 1px dashed var(--accent); background: var(--surface); color: var(--ink-2); }
html[data-layout="clean"] .cl-msg-fail {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  font-size: 15px; line-height: 1.4; color: var(--accent-deep);
}
html[data-layout="clean"] .cl-msg-fail b { font-weight: 700; }
html[data-layout="clean"] .cl-msg-fail-say { display: flex; align-items: flex-start; gap: 8px; }
html[data-layout="clean"] .cl-msg-fail-say .cl-mark { margin-top: 1px; }
html[data-layout="clean"] .cl-msg-fail .cl-quiet { min-height: 32px; font-size: 15px; }
html[data-layout="clean"] .cl-msg-warn { display: flex; align-items: baseline; gap: 8px; max-width: 34em; font-size: 14.5px; line-height: 1.4; color: var(--warn); }

/* The reply box, at the foot of the conversation. */
html[data-layout="clean"] .cl-msg-compose {
  flex: none; display: flex; flex-direction: column; gap: 10px; margin: 0;
  padding: 12px 18px 16px; border-top: 1px solid var(--rule); background: var(--surface);
}
html[data-layout="clean"] .cl-msg-channels {
  align-self: flex-start; display: inline-flex; gap: 2px; padding: 3px;
  background: var(--paper-2); border-radius: 8px;
}
html[data-layout="clean"] .cl-msg-ch {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 14px;
  background: none; border: 0; border-radius: 6px; cursor: pointer;
  font-family: var(--font-text); font-size: 15px; font-weight: 600; color: var(--ink-2);
  transition: background-color .15s, color .15s;
}
html[data-layout="clean"] .cl-msg-ch svg { width: 16px; height: 16px; }
html[data-layout="clean"] .cl-msg-ch:hover { color: var(--ink); }
html[data-layout="clean"] .cl-msg-ch.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(23, 20, 15, 0.2); }
html[data-layout="clean"] .cl-msg-mail { display: flex; flex-direction: column; gap: 8px; }
html[data-layout="clean"] .cl-msg-mail[hidden] { display: none; }
html[data-layout="clean"] .cl-msg-subject { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0; }
html[data-layout="clean"] .cl-msg-subject[hidden] { display: none; }
html[data-layout="clean"] .cl-msg-subject > .cl-label { flex: 0 0 5.2em; }
/* Replying: the subject is fixed, "Re:" and the email it answers. */
html[data-layout="clean"] .cl-msg-re {
  flex: 1 1 160px; min-width: 0; font-size: 16px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html[data-layout="clean"] .cl-msg-re[hidden],
html[data-layout="clean"] .cl-msg-subject input[hidden] { display: none; }
html[data-layout="clean"] .cl-msg-minis { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-left: auto; }
html[data-layout="clean"] .cl-msg-subject input,
html[data-layout="clean"] .cl-msg-compose textarea {
  box-sizing: border-box; width: 100%; min-width: 0; margin: 0;
  font-family: var(--font-text); font-size: 17px; line-height: 1.45; color: var(--ink);
  background: var(--surface); border: 1px solid var(--cl-line); border-radius: var(--radius-btn);
  padding: 10px 12px;
}
html[data-layout="clean"] .cl-msg-subject input { flex: 1 1 auto; width: auto; padding: 8px 12px; }
html[data-layout="clean"] .cl-msg-compose textarea { display: block; resize: none; min-height: 48px; max-height: 180px; }
html[data-layout="clean"] .cl-msg-subject input:focus,
html[data-layout="clean"] .cl-msg-compose textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--hover); }
html[data-layout="clean"] .cl-msg-send { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
html[data-layout="clean"] .cl-msg-hint { flex: 1 1 130px; min-width: 0; font-size: 14.5px; line-height: 1.4; color: var(--muted); }
html[data-layout="clean"] .cl-msg-compose.shut { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding-top: 16px; }
html[data-layout="clean"] .cl-msg-shut { flex: 1 1 260px; display: flex; align-items: baseline; gap: 10px; font-size: 16px; line-height: 1.45; color: var(--ink-2); }

/* ---------- the peek: the latest messages with one person ---------- */
html[data-layout="clean"] .cl-msg-peek:not(.sheet) .cl-peek-card { pointer-events: none; padding-bottom: 18px; }
html[data-layout="clean"] .cl-msg-peek .cl-peek-title { margin-bottom: 12px; }
html[data-layout="clean"] .cl-msg-peek-body { display: flex; flex-direction: column; gap: 8px; }
html[data-layout="clean"] .cl-msg-peek-item {
  display: flex; flex-direction: column; gap: 3px;
  padding: 9px 12px; border: 1px solid transparent; border-radius: 10px; background: var(--paper-4);
}
html[data-layout="clean"] .cl-msg-peek-item.out { background: none; border-color: var(--cl-line); }
html[data-layout="clean"] .cl-msg-peek-item .cl-label { font-size: 10.5px; letter-spacing: 0.08em; }
html[data-layout="clean"] .cl-msg-peek-subj { font-size: 15.5px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
html[data-layout="clean"] .cl-msg-peek-text {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden;
  font-size: 16px; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere;
}
html[data-layout="clean"] .cl-msg-peek-wait { margin: 0; font-size: 16px; color: var(--muted); }
html[data-layout="clean"] .cl-msg-peek.sheet .btn { display: flex; margin-top: 16px; }

/* On a phone the page is the list, or one conversation when its address is
   open. The conversation is exactly the screen: the messages take what the
   head and the reply box leave and scroll inside themselves. */
html[data-layout="clean"] .view:has(.cl-msg.has-detail) { padding-bottom: calc(86px + var(--safe-b)); }
html[data-layout="clean"] .cl-msg.has-detail { height: calc(100dvh - 108px - var(--safe-b)); min-height: 380px; gap: 0; }
html[data-layout="clean"] .cl-msg.has-detail .cl-msg-list,
html[data-layout="clean"] .cl-msg.has-detail .cl-tabs,
html[data-layout="clean"] .cl-msg.has-detail .cl-msg-texting,
html[data-layout="clean"] .cl-msg.has-detail .cl-page-head { display: none; }
html[data-layout="clean"] .cl-msg.has-detail .cl-msg-split { flex: 1 1 auto; }
html[data-layout="clean"] .cl-msg.has-detail .cl-msg-pane { display: flex; flex: 1 1 auto; }
html[data-layout="clean"] .cl-msg.has-detail .cl-back { display: inline-flex; align-self: flex-start; flex: none; }

/* On a phone the tabs already carry the count; the title has the line to itself. */
@media (max-width: 599.98px) {
  html[data-layout="clean"] .cl-msg .cl-page-sum { display: none; }
  html[data-layout="clean"] .cl-msg-compose textarea { max-height: 124px; }
  /* A small phone keeps as much of the screen as it can for the messages. */
  html[data-layout="clean"] .cl-msg-head { padding: 12px 16px 8px; gap: 2px 18px; }
  html[data-layout="clean"] .cl-msg-acts .cl-quiet { min-height: 34px; }
  html[data-layout="clean"] .cl-msg-log { padding: 14px 16px 16px; }
  html[data-layout="clean"] .cl-msg-compose { padding: 10px 16px 12px; gap: 8px; }
  html[data-layout="clean"] .cl-msg-hint { flex-basis: 96px; }
}
@media (min-width: 900px) {
  html[data-layout="clean"] .view:has(.cl-msg),
  html[data-layout="clean"] .view:has(.cl-msg.has-detail) { max-width: 1160px; padding: 32px 40px 32px; }
  html[data-layout="clean"] .cl-msg { gap: 20px; }
  html[data-layout="clean"] .cl-msg.has-detail { height: calc(100dvh - 64px); gap: 0; }
}
/* Side by side: the page is exactly the window. The list scrolls in its
   column, the messages scroll in theirs, and the reply box stays put. */
@media (min-width: 1000px) {
  html[data-layout="clean"] .cl-msg,
  html[data-layout="clean"] .cl-msg.has-detail { height: calc(100dvh - 64px); min-height: 520px; gap: 20px; }
  html[data-layout="clean"] .cl-msg.is-empty { height: auto; min-height: 0; }
  html[data-layout="clean"] .cl-msg-split {
    flex: 1 1 auto;
    display: grid; grid-template-columns: minmax(250px, min(360px, 38%)) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
    gap: 24px; align-items: stretch;
  }
  html[data-layout="clean"] .cl-msg.is-empty .cl-msg-split { display: block; max-width: 640px; }
  html[data-layout="clean"] .cl-msg-list { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; margin-right: -10px; padding-right: 10px; }
  html[data-layout="clean"] .cl-msg-pane,
  html[data-layout="clean"] .cl-msg.has-detail .cl-msg-pane { display: flex; }
  html[data-layout="clean"] .cl-msg.is-empty .cl-msg-pane { display: none; }
  html[data-layout="clean"] .cl-msg.has-detail .cl-msg-list { display: flex; }
  html[data-layout="clean"] .cl-msg.has-detail .cl-tabs { display: flex; }
  html[data-layout="clean"] .cl-msg.has-detail .cl-msg-texting:not([hidden]) { display: block; }
  html[data-layout="clean"] .cl-msg.has-detail .cl-page-head { display: flex; }
  html[data-layout="clean"] .cl-msg.has-detail .cl-back { display: none; }
  html[data-layout="clean"] .cl-msg-row.on { border: 2px solid var(--ink); padding: 13px 17px; background: var(--surface); }
  html[data-layout="clean"] .cl-msg-head { padding: 16px 24px 14px; }
  html[data-layout="clean"] .cl-msg-title { font-size: 24px; }
  html[data-layout="clean"] .cl-msg-log { padding: 18px 24px 20px; }
  html[data-layout="clean"] .cl-msg-item { max-width: 72%; }
  html[data-layout="clean"] .cl-msg-compose { padding: 14px 24px 18px; }
}
