/* Round-8 council design (design/pass-2026-12-01/lib/r.mjs): respond.io's inbox anatomy in 1C yellow.
   Shape, layout, type and density follow respond.io; accent and selection colour follow 1C.
   Small text is 12 px or larger at 4.5:1 or better; control borders are 3:1 against their surface. */
:root {
  color-scheme: light;
  --ink: #1f2329;
  --ink2: #3d434c;
  --muted: #5a616c;
  --line: #e6e4dc;
  --hair: #efede6;
  --control: #8f8a7a;
  --chip: #f3f2ee;
  --cream: #fffbea;
  --sel: #fff8dc;
  --honey-line: #d9ab00;
  --btn: #fce38a;
  --btn-hover: #fbdb66;
  --btn-line: #a8891c;
  --link: #1c55ae;
  --wa: #1f8f4e;
  --due-bg: #fff0cf;
  --due: #7a4300;
  --late-bg: #fde6e2;
  --late: #a11d12;
  --ai: #5b4bd1;
  --ai-bg: #f1efff;
  --note-line: #e3c766;
  --note-ink: #4d3b00;
  --blue: var(--link);
  --amber: #7a4300;
  font: 13.5px/1.45 Inter, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: #fff;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--link); }
.ic { flex: none; vertical-align: -2px; }
kbd { font: inherit; font-size: 12px; padding: 0 4px; border: 1px solid #b9b4a6; border-radius: 3px; color: var(--ink2); background: #fff; }
:focus-visible, a:focus-visible, .thread:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.grow { flex: 1; min-width: 8px; }

/* Controls: flat, 1 px borders at 3:1, small radii (1C Taxi geometry), 32 px tall. */
.button, .saved-list button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px; border: 1px solid var(--control); border-radius: 6px;
  background: #fff; color: var(--ink); font: inherit; font-weight: 550; white-space: nowrap; cursor: pointer;
}
.button:hover, .saved-list button:hover { background: #faf8f1; }
.button:disabled, input:disabled, textarea:disabled, select:disabled { cursor: default; }
.button:disabled:not(.primary), input:disabled, textarea:disabled { opacity: .7; }
.button:focus-visible, .segments button:focus-visible, summary:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.button.primary { background: var(--btn); border-color: var(--btn-line); color: var(--ink); font-weight: 650; }
.button.primary:hover:enabled { background: var(--btn-hover); }
.button.primary:disabled { background: #efede6; border-color: #b9b4a6; color: #5e5b53; }
.button kbd { margin-left: 2px; padding: 0 3px; font-size: 12px; border-color: currentColor; background: transparent; color: inherit; }

/* Avatars with a channel badge, as in respond.io. */
.avatar {
  position: relative; flex: none; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: #ece9df; color: #4a4536; font-size: 12.5px; font-weight: 650;
}
.avatar .ch {
  position: absolute; right: -3px; bottom: -3px; display: grid; place-items: center;
  width: 16px; height: 16px; border: 2px solid #fff; border-radius: 50%; background: #6b6f78;
}
.avatar .ch svg { display: block; }
.avatar[data-channel="WhatsApp"] .ch, .chan-badge[data-channel="WhatsApp"] { background: var(--wa); }
.avatar[data-channel="Instagram"] .ch, .chan-badge[data-channel="Instagram"] { background: #b3307a; }
.avatar[data-channel="Messenger"] .ch, .chan-badge[data-channel="Messenger"] { background: #1765d8; }
.avatar[data-channel="TikTok"] .ch, .chan-badge[data-channel="TikTok"] { background: #111; }
.avatar.sm { width: 20px; height: 20px; font-size: 9.5px; font-weight: 700; }
.avatar.md { width: 28px; height: 28px; font-size: 10.5px; }
.avatar.me { background: #fbe7a1; color: #4d3b00; }
.avatar.ai { background: #eeece6; color: var(--ai); }
.chan-badge { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; border-radius: 50%; background: #6b6f78; }

/* ============ Header ============ */
.header {
  grid-row: 1;
  display: flex; align-items: center; gap: 10px; min-width: 0;
  min-height: 56px; padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--line);
}
.identity { min-width: 0; flex: 0 1 auto; }
.identity h1 { font-size: 15px; font-weight: 650; line-height: 1.25; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.identity p { font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.life {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px;
  background: var(--chip); color: var(--ink2); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.assignment { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.vr { flex: none; width: 1px; height: 22px; background: var(--line); }
.header:not(:has(#assignment:not([hidden]), #assign:not([hidden]), #inbox-head-actions:not([hidden]))) .vr { display: none; }
.open {
  flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 4px;
  color: var(--link); font-size: 12.5px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.open:hover, .option a:hover { text-decoration: underline; text-underline-offset: 2px; }
#assign { flex: none; min-height: 30px; }
.inbox-head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.pick { position: relative; display: inline-flex; align-items: center; }
.pick .ic { position: absolute; left: 9px; pointer-events: none; color: var(--ink2); }
.pick .ic.chev { left: auto; right: 8px; }
.pick select {
  appearance: none; -webkit-appearance: none; max-width: 190px; min-height: 30px;
  padding: 0 28px 0 29px; border-radius: 15px; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis;
}
.pick select:disabled { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; opacity: 1; padding-right: 6px; }
.pick:has(select:disabled) .chev { display: none; }
#inbox-close { min-height: 30px; padding: 0 10px; }
.inbox-head-actions details { position: relative; }
.inbox-head-actions summary { list-style: none; }
.inbox-head-actions summary::-webkit-details-marker { display: none; }
#inbox-more summary { width: 32px; min-height: 32px; padding: 0; border-color: transparent; background: transparent; color: var(--ink2); }
#inbox-more summary:hover, #inbox-more[open] summary { background: var(--chip); }
.inbox-head-actions details button { position: absolute; right: 0; margin-top: 6px; white-space: nowrap; z-index: 2; box-shadow: 0 3px 12px #33415522; }
/* Details toggle: the visible label stays in the DOM as its accessible name; the panel icon is drawn in CSS. */
#inbox-details-toggle { position: relative; width: 32px; min-height: 32px; padding: 0; font-size: 0; color: var(--ink2); border-color: var(--control); }
#inbox-details-toggle::before { content: ""; box-sizing: border-box; width: 16px; height: 13px; border: 1.5px solid currentColor; border-right-width: 5px; border-radius: 2px; }
#inbox-details-toggle[aria-expanded="true"] { background: #fbf3d0; border-color: #a8891c; color: var(--ink); }

/* ============ Thread ============ */
.thread { grid-row: 3; overflow: auto; padding: 16px 22px 10px; }
.thread-inner { width: 100%; max-width: 960px; min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; }
.thread-inner > .day:first-child { margin-top: 0; }
.day {
  align-self: center; margin: 14px 0 10px; padding: 2px 10px; border-radius: 6px;
  background: var(--chip); color: var(--ink2); font-size: 12px; font-weight: 550;
}
.msg {
  display: grid; grid-template-columns: 28px minmax(0, auto); column-gap: 8px;
  grid-template-areas: "av bub" ". meta" ". state";
  justify-items: start; max-width: min(600px, 82%); margin: 3px 0; align-self: flex-start;
}
.msg.out, .msg.ai {
  align-self: flex-end; grid-template-columns: minmax(0, auto) 28px;
  grid-template-areas: "bub av" "meta ." "state ."; justify-items: end;
}
.msg > .avatar { grid-area: av; margin-top: 2px; }
.msg > .bubble { grid-area: bub; }
.msg > .meta { grid-area: meta; }
.msg > .send-state { grid-area: state; }
.bubble { padding: 8px 12px; border-radius: 8px; overflow-wrap: anywhere; white-space: pre-wrap; }
.in .bubble { background: #f1f0ec; }
.out .bubble { background: #faf3da; }
.ai .bubble { background: var(--ai-bg); }
.meta {
  display: flex; align-items: center; gap: 5px; margin: 3px 2px 0;
  color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.meta .who { font-weight: 600; color: var(--ink2); }
.ai .meta .who { color: var(--ai); }
.tick { display: inline-flex; align-items: center; color: var(--muted); }
.tick svg { display: block; }
.tick.read, .tick.read + .tick-label { color: #1d6b45; }
.tick.failed { color: #aa302b; }
.note {
  align-self: stretch; max-width: none; margin: 14px 36px; padding: 8px 12px;
  display: block; border: 1px solid var(--note-line); border-left: 3px solid #d9a900; border-radius: 4px 8px 8px 4px;
  background: #fffdf5; color: var(--note-ink);
}
.note .who { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 2px; font-size: 12px; font-weight: 650; }
.note .who .meta { display: inline; margin: 0; color: #5e4c12; font-weight: 500; }
.note .bubble { padding: 0; border-radius: 0; background: none; color: var(--ink); }
.event { display: block; align-self: center; max-width: 100%; margin: 8px; text-align: center; color: var(--muted); font-size: 12px; }
.event .bubble { padding: 0 8px; }
.event .meta { display: inline; margin-left: 6px; }
.attachment {
  display: grid; grid-template-columns: auto 1fr; gap: 0 9px; align-items: center;
  min-width: min(248px, 100%); padding: 6px 10px 6px 7px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; white-space: normal;
}
.attachment-icon { grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 5px; color: #a3261b; background: #fbe9e6; }
.attachment b { font-weight: 600; font-size: 13px; }
.attachment small { color: var(--muted); font-size: 12px; }
.send-state { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding-top: 4px; color: #6b4a10; font-size: 12px; }
.send-state.failed { color: #a42c27; }
.send-state .button { min-height: 24px; padding: 0 8px; font-size: 12px; }
.msg[data-state="failed"] .bubble { background: #fff1f0; box-shadow: inset 0 0 0 1px #e29b95; }

/* ============ Notices ============ */
.notice {
  grid-row: 2; margin: 8px 18px 0; padding: 7px 10px;
  color: #4a3a12; background: #fff4d9; border: 1px solid #efd79d; border-radius: 7px; font-size: 13px;
}
.shared {
  display: block; padding: 7px 12px; color: #4d3b10; background: #fffaec; font-size: 12.5px;
  border-top: 1px solid #f1e6c4; border-bottom: 1px solid #f1e6c4;
}
.shared strong { font-weight: 650; }

/* ============ Footer: composer card and read-only card ============ */
.footer { grid-row: 4; padding: 8px 22px 12px; }
.footer:has(#channel-line[hidden]) { display: none; }
.footer-inner {
  position: relative; max-width: 960px; margin: 0 auto;
  /* Column 1 takes the channel line's and the tools' own width; column 2 shrinks and its contents wrap,
     so neither pair can crush the other at 1C frame widths. The sign-in notice has its own full-width row. */
  display: grid; grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "chan win" "share share" "ro ro" "ribbon ribbon" "tpl tpl" "share2 share2"
    "draft draft" "staged staged" "signin signin" "tools end" "status status" "mode mode";
}
/* The card is drawn behind its rows so the compose-mode switch can sit below it. */
.footer-inner::before {
  content: ""; grid-row: 1 / 12; grid-column: 1 / -1;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.footer-inner::after { content: ""; grid-row: 1; grid-column: 1 / -1; align-self: end; height: 1px; background: var(--hair); }
.footer-inner:has(#draft:focus-visible)::before { border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
.footer-inner:has(#composer.note-mode)::before { background: var(--cream); border-color: var(--note-line); }
.footer-inner > *, #composer > *, #draft-editor > * { position: relative; }
#composer, #draft-editor { display: contents; }
.channel-line {
  grid-area: chan; display: flex; align-items: center; gap: 7px; min-width: 0; min-height: 40px; padding: 0 12px;
  color: var(--ink2); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden;
}
.chan-badge svg { display: block; }
.window { grid-area: win; justify-self: end; min-width: 0; display: flex; align-items: center; gap: 5px; min-height: 40px; padding: 0 12px; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.window.closed { color: var(--amber); font-weight: 600; }
#send-shared { grid-area: share; }
.footer-inner:has(#template:not([hidden])) #send-shared { grid-area: share2; margin-top: 10px; }

.actions {
  grid-area: ro; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0 12px;
  margin: 12px; padding: 10px 12px; border: 1px solid var(--hair); border-radius: 8px; background: #f7f6f1;
}
.actions:not(:has(#reply:not([hidden]), #read-only:not([hidden]), #shared:not([hidden]))) { display: none; }
.ro-icon { align-self: start; margin-top: 2px; color: var(--ink2); }
.ro-text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; color: var(--ink2); }
.next { color: var(--ink); font-weight: 650; }
.reply {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--btn-line); border-radius: 6px; background: var(--btn); color: var(--ink);
  font-weight: 650; text-decoration: none; white-space: nowrap;
}
.reply:hover { background: var(--btn-hover); }
.actions .shared { grid-column: 1 / -1; margin: 10px -12px -10px; padding: 7px 12px 7px 40px; border-bottom: 0; border-radius: 0 0 8px 8px; }

.closed-ribbon {
  grid-area: ribbon; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  margin: 12px 12px 0; padding: 10px 12px; border-radius: 8px; background: var(--cream); border: 1px solid #ecd98f;
  color: var(--ink2); font-size: 13px;
}
.closed-ribbon strong { color: var(--ink); font-weight: 650; }
.cl-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #fbe7a1; color: #5c4700; }

.template-box {
  grid-area: tpl; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); align-items: start;
  margin: 12px 12px 0; border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 44vh;
}
.template-box > div { padding: 12px 14px 14px; min-width: 0; }
.template-box > div:first-child { border-right: 1px solid var(--line); align-self: stretch; }
.template-box h2 { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 12.5px; font-weight: 650; }
.template-box h2 small, .template-hint, .recipient { color: var(--muted); font-size: 12px; font-weight: 500; }
.template-box label { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12.5px; color: var(--ink2); }
.template-box input, .template-box select {
  font: inherit; font-size: 13px; color: var(--ink); min-width: 0; width: 100%; min-height: 30px; padding: 0 9px;
  border: 1px solid var(--control); border-radius: 5px; background: #fff;
}
.recipient { margin-bottom: 6px; }
/* Neutral preview bubble, so the closed-window card is not one more cream surface. */
.template-preview { padding: 9px 12px; background: #fff; border: 1px solid #d8d5cb; border-radius: 8px; overflow-wrap: anywhere; color: var(--ink); }
.template-preview mark { padding: 0 3px; border-radius: 3px; background: #f6d860; color: #3d2f00; font-weight: 600; }
/* Only the empty placeholder stays on one line; typed values must wrap inside the preview. */
.template-preview mark.blank { white-space: nowrap; background: #fff; color: var(--due); outline: 1px dashed #b06f08; outline-offset: -1px; }
.template-hint { margin-top: 8px; }

#draft {
  grid-area: draft; display: block; width: 100%; min-height: 46px; max-height: 180px; resize: vertical;
  padding: 10px 12px 2px; border: 0; outline: 0; background: transparent; font: inherit; color: var(--ink);
}
#draft::placeholder { color: var(--muted); }
#draft:focus-visible { outline: none; }
.staged { grid-area: staged; display: flex; align-items: center; width: max-content; max-width: calc(100% - 24px); gap: 8px; margin: 4px 12px 0; }
.staged .button { min-height: 24px; padding: 0 8px; font-size: 12px; }
.composer-bar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.controls { grid-area: tools; padding: 2px 8px 8px; }
.button.tool, #saved summary.button {
  min-height: 30px; padding: 0 8px; border-color: transparent; background: transparent;
  color: var(--ink2); font-size: 12.5px; font-weight: 550;
}
.button.tool:hover, #saved summary.button:hover, #saved[open] summary.button { background: var(--chip); }
#saved { position: relative; }
#saved summary { list-style: none; }
#saved summary::-webkit-details-marker { display: none; }
.saved-list {
  position: absolute; bottom: 36px; z-index: 2; display: grid; min-width: 160px; padding: 5px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 3px 12px #33415522;
}
.saved-list button { justify-content: flex-start; border: 0; min-height: 30px; }
.compose-end { grid-area: end; min-width: 0; justify-content: flex-end; gap: 4px 10px; padding: 2px 8px 8px 12px; }
.footer-inner:has(#draft-editor[hidden]) .compose-end { grid-column: 1 / -1; padding-top: 12px; }
.sending-as { min-width: 0; font-size: 12px; color: var(--muted); text-align: right; }
.sending-as.shared-login, .signin { color: #6b4a10; }
.signin { grid-area: signin; padding: 4px 12px 2px; font-size: 12px; }
.signin:empty { padding: 0; }
.footer-inner:has(#draft-editor[hidden]) .signin:not(:empty) { padding-top: 10px; }
.compose-status { grid-area: status; padding: 0 12px 10px; color: #8c4110; font-size: 13px; }

/* Compose mode: the active mode is the card itself; the switch to the other mode sits below it. */
.segments { grid-area: mode; display: flex; align-items: center; gap: 2px; padding-top: 4px; }
.segments button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 6px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.segments button:hover { background: var(--chip); }
.segments button[aria-pressed="true"] { display: none; }
.mode-hint { color: var(--muted); font-size: 12px; }
#composer.note-mode .mode-hint { display: none; }
#composer.note-mode .button.primary:enabled { background: #f6d860; }

/* ============ States the page draws ============ */
.empty { width: min(100%, 500px); margin: auto; padding: 24px 26px 22px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.empty .badge { display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 12px; border-radius: 8px; background: var(--chip); color: var(--ink2); }
.empty .badge.amber { background: var(--due-bg); color: var(--due); }
.empty h2 { font-size: 16.5px; font-weight: 650; }
.empty p { margin-top: 6px; color: var(--ink2); }
.spin { width: 15px; height: 15px; border: 2px solid #e3dfd2; border-top-color: #c79a00; border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.options { list-style: none; margin: 14px 0 0; padding: 0; }
.option { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.option small { color: var(--muted); font-size: 12px; }
.option a { display: inline-flex; align-items: center; min-height: 24px; margin-left: auto; font-weight: 600; text-decoration: none; }

/* ============ Messages: three panes ============ */
body.messages-view {
  grid-template-columns: 320px minmax(0, 1fr) 284px;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}
body.messages-view.details-hidden { grid-template-columns: 320px minmax(0, 1fr) 0; }
.inbox-delay { grid-area: 1 / 1 / 2 / -1; padding: 9px 16px; background: #fff3d8; color: #654410; border-bottom: 1px solid #ecd49c; }
.messages-view .header { grid-area: 2 / 2 / 3 / -1; }
.messages-view .notice { grid-area: 3 / 2 / 4 / 3; }
.messages-view .thread { grid-area: 4 / 2 / 5 / 3; }
.messages-view .footer { grid-area: 5 / 2 / 6 / 3; }
.messages-view .thread-inner, .messages-view .footer-inner { max-width: 860px; }
.messages-view .thread-inner > .day:first-child { margin-top: auto; }
.messages-view .identity h1 { max-width: 300px; }

.inbox-list { grid-area: 2 / 1 / 6 / 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.list-head { display: flex; align-items: center; min-height: 56px; padding: 0 10px 0 12px; border-bottom: 1px solid var(--line); }
.search-label {
  flex: 1; display: flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 10px;
  border: 1px solid var(--control); border-radius: 8px; background: #fff; color: var(--muted);
}
.search-label:focus-within { outline: 2px solid var(--link); outline-offset: 1px; }
.search-label input { flex: 1; align-self: stretch; width: 100%; min-width: 0; min-height: 32px; border: 0; outline: none; background: transparent; font: inherit; font-size: 13px; color: var(--ink); }
.search-label input::placeholder { color: var(--muted); }
.search-label input:focus-visible { outline: none; }
.inbox-tabs { display: flex; gap: 18px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.inbox-tabs button {
  display: flex; align-items: center; gap: 6px; height: 40px; padding: 0; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted);
  font: inherit; font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.inbox-tabs button:hover { color: var(--ink); }
.inbox-tabs button:focus-visible { outline-offset: -2px; }
.inbox-tabs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--honey-line); }
.tab-count {
  min-width: 20px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--chip); color: var(--ink2);
  font-size: 12px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
}
.inbox-tabs button[aria-pressed="true"] .tab-count { background: #fbed9e; color: var(--ink); }
.wait-dot { display: inline-block; width: 6px; height: 6px; margin-left: -2px; border-radius: 50%; background: #c77700; }
.inbox-filters { display: flex; align-items: center; gap: 2px; min-height: 40px; padding: 0 6px; }
.inbox-filters .sep { width: 1px; height: 16px; margin: 0 4px; background: var(--line); }
.drop { position: relative; display: inline-flex; align-items: center; color: var(--ink2); }
.drop select {
  appearance: none; -webkit-appearance: none; field-sizing: content; min-height: 28px; padding: 0 22px 0 8px;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink2);
  font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
}
.drop select:hover { background: var(--chip); }
.drop .ic { position: absolute; right: 6px; pointer-events: none; }
.inbox-rows { flex: 1; min-height: 0; overflow: auto; padding: 2px 6px 6px; }
.inbox-rows:focus-visible { outline-offset: -2px; }
.inbox-rows[aria-busy="true"]:empty {
  /* Loading skeleton: one 64 px row tile, repeated. */
  background:
    linear-gradient(transparent 18px, #efede6 18px 30px, transparent 30px) 57px 0 / 46% 64px repeat-y,
    linear-gradient(transparent 38px, #efede6 38px 48px, transparent 48px) 57px 0 / 70% 64px repeat-y,
    radial-gradient(circle at 28px 30px, #efede6 17px, transparent 18px) 0 0 / 100% 64px repeat-y;
}
.inbox-row {
  position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 0 11px;
  width: 100%; padding: 10px 10px 9px; border: 0; border-radius: 8px; background: transparent;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.inbox-row + .inbox-row::before { content: ""; position: absolute; top: 0; left: 57px; right: 10px; border-top: 1px solid #dedad0; }
.inbox-row[aria-current="true"]::before, .inbox-row[aria-current="true"] + .inbox-row::before { display: none; }
.inbox-row:hover { background: #faf8f1; }
.inbox-row[aria-current="true"] { background: var(--sel); }
.inbox-row:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }
.inbox-row > .avatar { grid-row: span 3; align-self: start; margin-top: 1px; }
.row-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-line + .row-line { margin-top: 2px; }
.row-line.l3 { justify-content: space-between; margin-top: 6px; }
.row-line.l3:empty { display: none; }
.row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.row-time { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--ink2); }
.row-preview .dir { display: inline-block; width: 12px; margin-right: 3px; color: var(--muted); font-weight: 700; }
.inbox-row.unread .row-name { font-weight: 700; }
.inbox-row.unread .row-preview { color: var(--ink); }
/* Answered: regular-weight name, grey preview, no wait chip. */
.inbox-row.answered:not(.unread) .row-name { font-weight: 450; }
.inbox-row.answered:not(.unread) .row-preview { color: var(--muted); }
.inbox-row[aria-current="true"] .row-name { font-weight: 650; }
.inbox-row[aria-current="true"] .row-time { color: var(--ink2); }
.unread-badge {
  flex: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #4f493d; color: #fff; font-size: 12px; font-weight: 700; line-height: 18px; text-align: center;
}
.wait {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px 0 5px; border-radius: 4px;
  color: var(--ink2); font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.wait.calm { padding-left: 0; }
.wait.due { background: var(--due-bg); color: var(--due); }
.wait.late { background: var(--late-bg); color: var(--late); font-weight: 700; }
.wait.done { padding-left: 0; color: var(--muted); font-weight: 500; }
.owner-badge {
  display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 130px; margin-left: auto;
  font-size: 12px; font-weight: 550; color: var(--ink2); white-space: nowrap;
}
.owner-badge span:last-child { overflow: hidden; text-overflow: ellipsis; }
.owner-badge.me { height: 20px; padding: 0 8px; border-radius: 10px; background: #fbe7a1; color: #4d3b00; font-weight: 650; }
.inbox-row[aria-current="true"] .owner-badge.me { background: #f6d860; color: #3d2f00; }
.owner-badge.unassigned { height: 20px; padding: 0 8px; border: 1px dashed #7f7a6c; border-radius: 10px; color: var(--ink2); font-weight: 600; }
.owner-badge .avatar.sm { width: 20px; height: 20px; }
.row-pager { margin: 8px 4px 0; }
.inbox-list-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; padding: 0 12px 0 14px;
  border-top: 1px solid var(--line); color: var(--ink2); font-size: 12px;
}
#inbox-sync.ready::before, #inbox-sync.delayed::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--wa); }
#inbox-sync.delayed { color: #6b4a10; }
#inbox-sync.delayed::before { background: #cf8616; }
.inbox-list-footer kbd { padding: 0 3px; font-size: 12px; }
.inbox-list-empty { padding: 20px 13px; color: var(--muted); }

/* Contact drawer: label over value. */
.inbox-details { grid-area: 3 / 3 / 6 / 4; min-width: 0; overflow: auto; border-left: 1px solid var(--line); }
.details-head { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-bottom: 1px solid var(--hair); font-size: 13.5px; font-weight: 650; }
.details-ident { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--hair); min-width: 0; }
.details-ident:empty { display: none; }
.details-ident > span { min-width: 0; }
.details-ident b { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.details-ident small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#inbox-client, #inbox-contact { padding: 12px 14px 14px; border-bottom: 1px solid var(--hair); }
.inbox-details h2 { margin-bottom: 10px; font-size: 12.5px; font-weight: 650; color: var(--ink2); }
.inbox-details p { font-size: 13px; color: var(--muted); }
.fixture-stamp { margin: -6px 0 10px; font-size: 12px; }
.inbox-details .family { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 8px; padding: 2px 8px; border-radius: 4px; background: #fff3e0; color: #5a3a00; font-size: 12px; font-weight: 600; }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-weight: 550; min-width: 0; }
.inbox-details dl { margin: 10px 0 0; }
.inbox-details dt { font-size: 12px; color: var(--muted); }
.inbox-details dd { margin: 2px 0 10px; font-size: 13.5px; font-weight: 550; }
.inbox-details .details-label { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.inbox-details .details-label select {
  min-height: 28px; padding: 0 6px 0 8px; border-radius: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink);
}
.inbox-details .details-label select:disabled { appearance: none; -webkit-appearance: none; border-color: transparent; background: var(--chip); opacity: 1; min-height: 24px; padding: 0 8px; border-radius: 4px; color: var(--ink2); }
.contact-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 10px; padding: 0; list-style: none; }
.contact-tags li { display: inline-flex; align-items: center; gap: 2px; min-height: 24px; padding: 0 8px; border-radius: 4px; background: var(--chip); color: var(--ink2); font-size: 12.5px; font-weight: 550; }
.contact-tags li:has(button) { padding-right: 0; }
.contact-tags button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 14px; line-height: 1; cursor: pointer; }
.contact-tags button:hover { background: #e6e3da; color: var(--ink); }
.tag-editor { display: flex; gap: 6px; }
.tag-editor input { width: 100%; min-width: 0; }
.tag-editor .button { flex: none; min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.inbox-details input, #inbox-close-note { min-height: 30px; padding: 5px 8px; border: 1px solid var(--control); border-radius: 6px; font: inherit; font-size: 13px; }
.inbox-details details { margin-top: 12px; }
.inbox-details summary { display: list-item; min-height: 26px; line-height: 26px; font-size: 13px; font-weight: 600; color: var(--ink2); cursor: pointer; }
.inbox-details details p { margin-top: 4px; }

#inbox-close-dialog { width: min(420px, 85vw); padding: 18px; border: 1px solid var(--control); border-radius: 12px; color: inherit; }
#inbox-close-dialog::backdrop { background: #1f23295c; }
#inbox-close-dialog h2 { margin-bottom: 10px; font-size: 16px; font-weight: 650; }
#inbox-close-dialog label { font-size: 12.5px; color: var(--ink2); }
#inbox-close-dialog textarea { display: block; width: 100%; margin: 5px 0 12px; }
#inbox-close-dialog form > div { display: flex; justify-content: flex-end; gap: 8px; }

/* ============ Chat tab: a centred 960 px column, header aligned to it ============ */
body:not(.messages-view) .header { padding-inline: max(16px, calc((100% - 960px) / 2)); }
body:not(.messages-view) .thread { padding: 16px 16px 10px; }
body:not(.messages-view) .footer { padding: 8px 16px 12px; }
body:not(.messages-view) .notice { width: min(960px, calc(100% - 32px)); margin: 8px auto 0; }

@media (max-width: 1100px) {
  body.messages-view { grid-template-columns: 320px minmax(0, 1fr) 0; }
  .inbox-details { display: none; }
  #inbox-details-toggle { display: none; }
}
@media (max-width: 600px) {
  .header, .footer, .thread { padding-left: 10px; padding-right: 10px; }
  .header { flex-wrap: wrap; gap: 8px; }
  .msg { max-width: 92%; }
  .template-box { grid-template-columns: 1fr; }
  .template-box > div:first-child { border-right: 0; border-bottom: 1px solid var(--line); }
}
