/* New compose & reply (Settings › General › Compose & reply = New).
   Desktop follows html.compose-lean (the saved preference). Duo drafts
   also use the mobile look through html.cl-mobile-lean until that draft closes.
   The signature and the quoted/forwarded message still live in the editor
   (drafts, AI writer, send all keep working); they are only HIDDEN here and
   shown as a card under the editor. js/compose-lean.src.js makes sure they
   go out with the message. */

/* ---------- shared: hide the signature and everything after it ---------- */
html.compose-lean #replyModal .note-editable [data-signature],
html.compose-lean #replyModal .note-editable [data-signature] ~ *,
html.compose-lean #replyEditor[contenteditable] [data-signature],
html.compose-lean #replyEditor[contenteditable] [data-signature] ~ *,
html:is(.compose-lean, .cl-mobile-lean) #cEditor [data-signature],
html:is(.compose-lean, .cl-mobile-lean) #cEditor [data-signature] ~ * { display: none !important; }

html:not(.compose-lean) .cl-only { display: none !important; }
html.cl-mobile-lean #composeSheet .cl-only { display: flex !important; }

/* ---------- desktop modal (design D) ---------- */
html.compose-lean #replyModal .modal-panel { max-width: 760px !important; border-radius: 20px; }
html.compose-lean #replyModal .modal-panel > div:first-child { border-bottom: 0; padding: 14px 16px 0 24px; }
html.compose-lean #replyModal .reply-brand-icon { display: none; }
html.compose-lean #replyModal .reply-title-text { font-size: var(--fs-sm, .8125rem); font-weight: 500; color: var(--text-muted); letter-spacing: 0; }
html.compose-lean #replyModal .modal-body { padding: 6px 24px 4px; }

html.compose-lean #replyModal .rcp-subject-card { border: 0; background: transparent; box-shadow: none; padding: 6px 0 0; border-top: 1px solid var(--surface-2); border-radius: 0; }
html.compose-lean #replyModal .rcp-subject-card .rcp-label { display: none; }
html.compose-lean #replyModal #replySubject { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; padding: 10px 0 2px; background: transparent; }
html.compose-lean #replyModal #replySubject::placeholder { color: var(--text-faint); }

html.compose-lean #replyModal .note-editor.note-frame { border: 0 !important; box-shadow: none !important; background: transparent; }
html.compose-lean #replyModal .note-statusbar { display: none !important; }
html.compose-lean #replyModal .note-toolbar { display: none; border: 0; background: var(--surface-2); border-radius: 12px; padding: 4px 6px; margin-bottom: 4px; }
html.compose-lean.cl-fmt #replyModal .note-toolbar { display: block; }
html.compose-lean #replyModal .note-editable {
  height: auto !important; min-height: 200px; max-height: 44vh; overflow-y: auto;
  padding: 8px 0 !important; font-size: 15px; line-height: 1.65; background: transparent !important;
}
html.compose-lean #replyModal .note-placeholder { padding: 8px 0 !important; font-size: 15px; }
html.compose-lean #replyEditor[contenteditable] { border: 0; padding: 8px 0; min-height: 200px; }

/* Empty-message hint: Summernote's own placeholder never shows because the
   (hidden) signature means the editor is never empty. Absolutely placed so
   the caret stays at the start of the line. */
html.compose-lean #replyModal .note-editable > p:first-child:has(+ [data-signature]):has(> br:only-child),
html:is(.compose-lean, .cl-mobile-lean) #cEditor > p:first-child:has(+ [data-signature]):has(> br:only-child) { position: relative; }
html.compose-lean #replyModal .note-editable > p:first-child:has(+ [data-signature]):has(> br:only-child)::before,
html:is(.compose-lean, .cl-mobile-lean) #cEditor > p:first-child:has(+ [data-signature]):has(> br:only-child)::before {
  content: 'Write your message…'; position: absolute; left: 0; top: 0; color: var(--text-faint); pointer-events: none;
}

html.compose-lean #replyModal .modal-panel > div:last-child { border-top: 1px solid var(--surface-2); padding: 12px 16px 14px 18px; }

/* Formatting toggle (Aa) + "added when sent" chips in the footer */
.cl-fmt-btn {
  height: 38px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent;
  color: var(--text-2); font-family: inherit; font-size: 15px; font-weight: 600; line-height: 1; cursor: pointer;
}
.cl-fmt-btn:hover { background: var(--surface-2); }
html.cl-fmt .cl-fmt-btn { background: var(--accent-soft); color: var(--accent); }
.cl-chips { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cl-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: 999px; font-family: inherit; font-size: 12px; font-weight: 500; line-height: 1; cursor: pointer; white-space: nowrap;
  border: 1px solid #bfdbfe; background: #eff6ff; color: #1d4ed8; transition: background .15s, color .15s, border-color .15s;
}
.cl-chip i { font-size: 11px; }
.cl-chip[hidden] { display: none; }
.cl-chip[aria-pressed="false"] { border-style: dashed; border-color: var(--border-strong); background: transparent; color: var(--text-muted); text-decoration: line-through; }
.dark .cl-chip { border-color: rgba(59,130,246,.35); background: rgba(59,130,246,.12); color: #93c5fd; }
.dark .cl-chip[aria-pressed="false"] { border-color: var(--border-strong); background: transparent; color: var(--text-muted); }

/* ---------- the earlier-message card ---------- */
.cl-quote {
  margin: 10px 0 8px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; transition: opacity .2s ease;
}
.cl-quote[hidden] { display: none; }
.cl-quote.is-off { opacity: .5; }
.cl-quote-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cl-quote-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: #0e7490; color: #fff; font-size: 12px; font-weight: 600;
}
.cl-quote-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cl-quote-who { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-quote-when { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-quote-off { font-size: 11px; font-weight: 500; color: var(--text-muted); background: var(--surface-2); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.cl-quote-off[hidden] { display: none; }
.cl-quote-more {
  height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--surface-2); color: var(--text-2);
  font-family: inherit; font-size: 12px; font-weight: 500; line-height: 1; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.cl-quote-more:hover { background: var(--surface-3); }
.cl-quote-body {
  position: relative; font-size: 13.5px; line-height: 1.55; color: var(--text-2); padding-left: 42px;
  max-height: 4.7em; overflow: hidden; overflow-wrap: anywhere;
}
.cl-quote-body::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1.6em;
  background: linear-gradient(to bottom, transparent, var(--surface)); pointer-events: none;
}
.cl-quote.is-open .cl-quote-body { max-height: 46vh; overflow-y: auto; }
.cl-quote.is-open .cl-quote-body::after { display: none; }
.cl-quote-body img { max-width: 100%; height: auto; }
.cl-quote-body blockquote { margin: 0; padding: 0; border: 0; background: none; }
.cl-quote-body table { max-width: 100%; }
/* Dark mode: the card is a clone of the editor's quote and keeps the sender's
   inline colours — Outlook writes color:rgb(0,0,0) on every line and sits
   signatures on white spans, so on the dark card that read black on navy
   (19/10/2026, "Re: Breakdown logged — TK467989"). The card is display-only
   (send reads the editor), so paint it in app colours; sent HTML is untouched.
   Backgrounds go too, else forced light text would land on a white span. */
.dark .cl-quote-body, .dark .cl-quote-body * {
  color: var(--text-2) !important; background-color: transparent !important; background-image: none !important;
}
.dark .cl-quote-body a { color: var(--accent) !important; }
.dark .cl-quote-body td, .dark .cl-quote-body th, .dark .cl-quote-body hr { border-color: var(--border) !important; }

/* ---------- phone sheet (design E) ---------- */
html:is(.compose-lean, .cl-mobile-lean) #composeSheet #cEditor {
  border: 0; background: transparent; padding: 12px 4px; font-size: 17px; line-height: 1.55; min-height: 180px;
}
html:is(.compose-lean, .cl-mobile-lean) #composeSheet #cEditor:focus, html:is(.compose-lean, .cl-mobile-lean) #composeSheet #cEditor:focus-visible { outline: none; box-shadow: none; border-color: transparent; }
html:is(.compose-lean, .cl-mobile-lean) #composeSheet .rcp-subject-card { border: 0; background: transparent; box-shadow: none; border-bottom: 1px solid var(--surface-2); border-radius: 0; padding-left: 4px; }
html:is(.compose-lean, .cl-mobile-lean) #composeSheet .rcp-subject-card .rcp-label { display: none; }
html:is(.compose-lean, .cl-mobile-lean) #composeSheet #cSubject { font-size: 18px; font-weight: 600; background: transparent; }
.cl-mobile-extras { display: flex; flex-direction: column; gap: 8px; padding: 0 2px 8px; }
.cl-mobile-extras .cl-note { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#composeSheet .cl-quote { margin: 2px 0 0; border-radius: 16px; background: var(--surface-2); border-color: var(--border); }
#composeSheet .cl-quote-body { padding-left: 0; font-size: 13px; }
#composeSheet .cl-quote-body::after { background: linear-gradient(to bottom, transparent, var(--surface-2)); }
#composeSheet .cl-quote-avatar { width: 24px; height: 24px; font-size: 10px; }
/* The phone sheet body is a fixed-height flex column with overflow hidden.
   "Show full message" grew the card (body up to 46vh) and it couldn't shrink,
   so #cEditorWrap was squeezed to 0, the editor spilled out underneath the
   card and taps hit the card — couldn't type (27/10/2026). Keep the editor a
   usable height and let the extras block shrink and scroll on its own. */
#composeSheet #cEditorWrap { min-height: auto; } /* never below the editor's own min-height */
#composeSheet .cl-mobile-extras { flex: 0 1 auto; min-height: 0; max-height: 45%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
#composeSheet .cl-quote.is-open .cl-quote-body { max-height: none; overflow: visible; }

@media (prefers-reduced-motion: reduce) { .cl-quote, .cl-chip { transition: none; } }

/* ---------- affordance: show where to click (Adam 08/10: too bare) ----------
   Subject = underline that darkens on hover and turns accent on focus.
   Message = soft tinted panel; border on hover; white + accent ring on focus. */
html.compose-lean #replyModal .rcp-subject-card {
  border-top: 0 !important; border-bottom: 1px solid var(--border-strong) !important;
  padding: 0 4px !important; transition: border-color .15s, background-color .15s;
}
html.compose-lean #replyModal .rcp-subject-card:hover { border-bottom-color: var(--text-faint) !important; }
html.compose-lean #replyModal .rcp-subject-card:focus-within { border-bottom: 2px solid var(--accent) !important; }
html.compose-lean #replyModal #replySubject::placeholder,
html:is(.compose-lean, .cl-mobile-lean) #composeSheet #cSubject::placeholder { color: var(--text-muted); }

html.compose-lean #replyModal .note-editor.note-frame {
  margin-top: 12px; border: 1px solid transparent !important; border-radius: 14px;
  background: var(--surface-2) !important; transition: border-color .15s, background-color .15s, box-shadow .15s;
  cursor: text;
}
html.compose-lean #replyModal .note-editor.note-frame:hover { border-color: var(--border-strong) !important; }
html.compose-lean #replyModal .note-editor.note-frame:focus-within {
  background: var(--surface) !important; border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-ring) !important;
}
html.compose-lean #replyModal .note-editable { padding: 12px 14px !important; }
html.compose-lean #replyModal .note-editable > p:first-child:has(+ [data-signature]):has(> br:only-child)::before,
html:is(.compose-lean, .cl-mobile-lean) #cEditor > p:first-child:has(+ [data-signature]):has(> br:only-child)::before { color: var(--text-muted); }
html.compose-lean #replyModal .note-toolbar { margin: 6px 6px 0; }

html:is(.compose-lean, .cl-mobile-lean) #composeSheet #cEditor {
  background: var(--surface-2); border: 1px solid transparent; border-radius: 14px; padding: 12px 14px;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
html:is(.compose-lean, .cl-mobile-lean) #composeSheet #cEditor:focus, html:is(.compose-lean, .cl-mobile-lean) #composeSheet #cEditor:focus-visible {
  background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); outline: none;
}
html:is(.compose-lean, .cl-mobile-lean) #composeSheet .rcp-subject-card { border-bottom: 1px solid var(--border-strong); }
html:is(.compose-lean, .cl-mobile-lean) #composeSheet .rcp-subject-card:focus-within { border-bottom: 2px solid var(--accent); }

/* Softer subject (Adam 08/10: "a bit harsh") — normal weight, lighter rule. */
html.compose-lean #replyModal #replySubject { font-size: 17px; font-weight: 500; letter-spacing: 0; padding: 10px 0 6px; }
html.compose-lean #replyModal .rcp-subject-card { border-bottom-color: var(--border) !important; }
html.compose-lean #replyModal .rcp-subject-card:hover { border-bottom-color: var(--border-strong) !important; }
html.compose-lean #replyModal .rcp-subject-card:focus-within { border-bottom: 1px solid var(--accent) !important; box-shadow: 0 1px 0 0 var(--accent); }
html.compose-lean #replyModal #replySubject::placeholder,
html:is(.compose-lean, .cl-mobile-lean) #composeSheet #cSubject::placeholder { color: var(--text-faint); font-weight: 400; }
html:is(.compose-lean, .cl-mobile-lean) #composeSheet #cSubject { font-size: 16px; font-weight: 500; }
html:is(.compose-lean, .cl-mobile-lean) #composeSheet .rcp-subject-card { border-bottom-color: var(--border); }
html:is(.compose-lean, .cl-mobile-lean) #composeSheet .rcp-subject-card:focus-within { border-bottom: 1px solid var(--accent); }

/* Tidy button (both looks on desktop; phone in New) */
.cl-tidy-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; margin-left: 4px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2);
  font-family: inherit; font-size: 12.5px; font-weight: 500; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.cl-tidy-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.cl-tidy-btn:disabled { opacity: .75; cursor: progress; }
.cl-tidy-btn i { font-size: 12px; color: var(--accent); }
#composeSheet .cl-tidy-btn { margin-left: auto; height: 30px; }

/* ---------- Tidy modal (js/compose-lean.src.js openTidy) ----------
   Built on the house .modal-root.modal-confirm; phone = bottom sheet. */
.tidy-modal .modal-panel { max-width: 34rem; }
.tidy-body { padding: 1rem 1.1rem .9rem; display: flex; flex-direction: column; gap: .6rem; }
.tidy-preview {
  max-height: 40dvh; overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
  font-size: var(--fs-md); line-height: 1.55; color: var(--text); word-break: break-word; transition: opacity .15s;
}
.tidy-preview > :first-child { margin-top: 0; }
.tidy-preview > :last-child { margin-bottom: 0; }
.tidy-preview p { margin: 0 0 .7em; }
.tidy-preview ul, .tidy-preview ol { margin: 0 0 .7em; padding-left: 1.4em; }
.tidy-preview ul { list-style: disc; } .tidy-preview ol { list-style: decimal; }
.tidy-preview a { color: var(--accent); text-decoration: underline; }
.tidy-modal.is-busy .tidy-preview:not(:has(.tidy-skel)) { opacity: .45; }
.tidy-skel { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.tidy-skel i { display: block; height: 11px; border-radius: 6px; background: var(--surface-3); animation: tidy-pulse 1.1s ease-in-out infinite; }
.tidy-skel i:nth-child(1) { width: 38%; } .tidy-skel i:nth-child(2) { width: 94%; animation-delay: .1s; }
.tidy-skel i:nth-child(3) { width: 86%; animation-delay: .2s; } .tidy-skel i:nth-child(4) { width: 58%; animation-delay: .3s; }
@keyframes tidy-pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tidy-skel i { animation: none; } }

.tidy-err {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem .75rem;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft);
  border-radius: var(--r-md); color: var(--text); font-size: var(--fs-sm);
}
.tidy-err[hidden], .tidy-diff[hidden], .tidy-preview[hidden] { display: none; }

.tidy-diff-toggle {
  align-self: flex-start; display: inline-flex; align-items: center; gap: .4rem; padding: .15rem .1rem; border: 0; background: none;
  color: var(--text-2); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.tidy-diff-toggle:hover:not(:disabled) { color: var(--accent); }
.tidy-diff-toggle:disabled { opacity: .5; cursor: default; }
.tidy-diff-toggle i { font-size: 11px; }
.tidy-diff {
  max-height: 28dvh; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); font-size: var(--fs-sm); line-height: 1.6; color: var(--text); word-break: break-word;
}
.tidy-del { text-decoration: line-through; background: var(--danger-soft); color: var(--danger-fg, var(--danger)); border-radius: 3px; padding: 0 2px; }
.tidy-ins { text-decoration: none; background: var(--success-soft); color: var(--success); border-radius: 3px; padding: 0 2px; }
.dark .tidy-del { color: #fca5a5; } .dark .tidy-ins { color: #86efac; }
.tidy-muted { margin: 0; color: var(--text-muted); }

.tidy-label { font-size: var(--fs-2xs); letter-spacing: .04em; text-transform: uppercase; font-weight: 700; color: var(--text-muted); margin-top: .1rem; }
.tidy-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.tidy-chip { cursor: pointer; font-family: inherit; min-height: 32px; border: 1px solid var(--border); background: var(--surface); transition: background .15s, border-color .15s, color .15s; }
.tidy-chip:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.tidy-chip:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 1px; }
.tidy-chip i { display: none; font-size: 11px; }
.tidy-chip.is-on { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.tidy-chip.is-on i { display: inline; }
.tidy-chip:disabled { opacity: .55; cursor: progress; }
.tidy-steer { display: flex; gap: .4rem; align-items: stretch; }
.tidy-steer .input { flex: 1 1 auto; min-width: 0; }

@media (max-width: 767px) {
  .tidy-modal .modal-wrap { padding: 0; justify-content: flex-end; }
  .tidy-modal .modal-wrap::before { flex: 1 1 0; } .tidy-modal .modal-wrap::after { display: none; }
  .tidy-modal .modal-panel { max-width: none; border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0; }
  .tidy-modal .modal-foot { padding-bottom: calc(.8rem + env(safe-area-inset-bottom)) !important; }
  .tidy-modal .modal-foot .btn { flex: 1 1 0; }
  .tidy-modal .modal-foot [data-use] { flex: 2 1 0; }
  .tidy-modal .tidy-steer .input { font-size: 16px !important; }   /* no iOS zoom on focus */
  .modal-root.tidy-modal:not(.hidden) .modal-panel { animation: tidy-sheet-up .22s ease-out; }
  .modal-root.tidy-modal.hidden .modal-panel { transform: translateY(24px); }
}
@keyframes tidy-sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.tidy-spin { margin-left: .35rem; color: var(--accent); font-size: 11px; }
.tidy-spin[hidden] { display: none; }

/* Duo landscape keeps the first recipient controls out of the native clock corner. */
html.is-duo.duo-land.duo-strip-right #composeSheet .rcp-row[data-role="to"] { padding-right: calc(var(--duo-strip-w, 84px) + 12px); }
html.is-duo.duo-land.duo-strip-left #composeSheet .rcp-row[data-role="to"] { padding-left: calc(var(--duo-strip-w, 84px) + 12px); }
