/* PrestoHelp - the desk. Staff pages, behind a session.
 *
 * Dark bar, light page: the desk must never be mistaken for a customer's own
 * help centre, which staff will also have open. No inline styles anywhere -
 * style-src is 'self' with no 'unsafe-inline', so a style="..." attribute
 * would be silently ignored by the browser (tests/markup.sh fails on one).
 */

:root {
  --ink:      #1b1c21;
  --ink-soft: #5d6066;
  --line:     #e2e4e9;
  --page:     #f6f7f9;
  --card:     #ffffff;
  --accent:   #3f3d9e;
  --bad:      #a4262c;
  --good:     #1f6f54;
  --bar:      #1b1c21;
  --radius:   10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

.bar { background: var(--bar); color: #fff; }
.bar .wrap { display: flex; align-items: center; gap: 24px; min-height: 56px; }
.bar a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; letter-spacing: -0.01em; }
.brand span { font-weight: 400; opacity: 0.65; }
.nav { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.nav a:hover { text-decoration: underline; }
.nav form { margin: 0; }
.nav button {
  background: none; border: 1px solid rgba(255,255,255,0.35); color: #fff;
  border-radius: 6px; padding: 5px 10px; font: inherit; cursor: pointer;
}

main { padding: 28px 0 64px; }

.head { margin-bottom: 20px; }
.h-page { font-size: 1.6rem; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.015em; }
.h-sec  { font-size: 1.1rem; margin: 28px 0 10px; }
.h-sec.m-0 { margin: 0; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }
.m-0 { margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }

.narrow { max-width: 420px; margin: 24px auto; }
.row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}
.stack > * + * { margin-top: 14px; }
.shown-once { border-color: var(--accent); border-width: 2px; }

.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #c3c7cf; border-radius: 7px;
}
.field textarea { resize: vertical; }
.field input[type="checkbox"], .field input[type="radio"] { width: auto; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-block; padding: 9px 14px; font: inherit; font-weight: 600;
  color: var(--ink); background: #fff; border: 1px solid #c3c7cf;
  border-radius: 7px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--ink-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-block { display: block; width: 100%; }
.btn-small { padding: 5px 9px; font-size: 0.85rem; font-weight: 500; }

.note { border-radius: 7px; padding: 10px 12px; margin: 0 0 16px; border: 1px solid; }
.note-ok    { background: #eef7f3; border-color: #bfdfd2; color: var(--good); }
.note-error { background: #fdf0f0; border-color: #efc9ca; color: var(--bad); }

.grid { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.grid th, .grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid thead th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid .num { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
.grid .subject { font-weight: 600; }
.grid form { margin: 0; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #eceef3; font-size: 0.8rem; white-space: nowrap;
}
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 0.75rem; white-space: nowrap; }
.badge-yes { background: #eef7f3; color: var(--good); }
.badge-no  { background: #fdf0f0; color: var(--bad); }

.pairs { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.pairs dt { font-weight: 600; }
.pairs dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .bar .wrap { flex-wrap: wrap; gap: 12px; padding: 10px 20px; }
  .nav { margin-left: 0; gap: 12px; flex-wrap: wrap; }
  .grid, .grid thead, .grid tbody, .grid tr, .grid th, .grid td { display: block; }
  .grid thead { display: none; }
  .grid tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  .grid td { border: 0; padding: 4px 12px; }
}

/* ---------------------------------------------------------- phase 2 ------
 * A thread: the conversation, the customer down the side, and TWO COMPOSERS
 * THAT DO NOT LOOK ALIKE.
 *
 * The reply box and the note box are deliberately different colours and sit
 * under different headings, because an internal note reaching a customer is
 * the failure that must be impossible (PLAN.md section 10). The structure is
 * what makes it impossible - two routes, two columns, and a Mailer that
 * refuses anything internal - and this is the part a person sees.
 */

.thread { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.talkcol { min-width: 0; }
.side { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }

.talk { list-style: none; margin: 0 0 24px; padding: 0; }
.msg { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--card); }
.msg + .msg { margin-top: 10px; }
.msg-them { border-left: 3px solid #c3c7cf; }
.msg-us   { border-left: 3px solid var(--accent); }
/* A note is unmistakable at a glance, and it is in no customer copy at all. */
.msg-note { border-left: 3px solid var(--bad); background: #fffaf0; }
.msg-who { margin-bottom: 6px; }
.msg-body { white-space: normal; overflow-wrap: anywhere; }

.quoted { margin-top: 8px; }
.quoted summary { cursor: pointer; }
.quote {
  margin: 8px 0 0; padding: 10px 12px; background: var(--page);
  border: 1px solid var(--line); border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 24em; overflow: auto;
}

.composer { margin-top: 18px; }
.composer textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #c3c7cf; border-radius: 7px; resize: vertical;
}
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.composer-reply { border-top: 3px solid var(--accent); }
.composer-note  { border-top: 3px solid var(--bad); }

.plain { list-style: none; margin: 0; padding: 0; }
.plain li + li { margin-top: 10px; }

@media (max-width: 900px) {
  .thread { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================== phase 3 ==
 *
 * The desk home's four numbers, the view and service chips, the first-reply
 * clock's three colours, and the collision line above the composer.
 *
 * STILL NO INLINE STYLES ANYWHERE. style-src is 'self' with no
 * 'unsafe-inline', so a style="..." attribute is silently ignored by the
 * browser while looking fine in the source - tests/markup.sh fails on one.
 */

/* THE FOUR NUMBERS (PLAN.md section 10). Big, because the point of them is to
 * be read from across a room rather than consulted. */
.nums {
  display: grid; gap: 12px; margin: 0 0 20px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.nums li + li { margin-top: 0; }
.num-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: grid; gap: 2px;
}
.num-card a { text-decoration: none; color: inherit; display: block; }
.num-card a:hover .num-n { text-decoration: underline; }
.num-n { display: block; font-size: 1.9rem; font-weight: 700; line-height: 1.15; }
.num-l { display: block; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.num-why { display: block; font-size: 0.75rem; }
.num-warn { border-left: 3px solid #b26b00; }
.num-bad  { border-left: 3px solid var(--bad); }

/* The chips: saved views, then services. Links, not a form. */
.chipbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip-link { text-decoration: none; }
.chip-link:hover { border-color: var(--accent); }
.chip-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-tag { background: #eef3ff; border-color: #cdd9f5; }

.searchbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }
.searchbar input[type="search"] {
  flex: 1 1 320px; padding: 9px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #c3c7cf; border-radius: 7px;
}

/* A screen-reader-only label: a search box and a date box need a name, and
 * the box beside them says what they are to anyone who can see. */
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* THE FIRST-REPLY CLOCK. Three colours and two of them are warnings: amber at
 * four business hours, red past one business day (decision 8). Never colour
 * alone - the cell says what it means in words as well, because a column that
 * only a colour distinguishes is a column somebody cannot read. */
.clockcell { white-space: nowrap; }
.clock { font-size: 0.85rem; }
.clock-green { color: var(--good); }
.clock-amber { color: #8a5200; font-weight: 600; }
.clock-red   { color: var(--bad); font-weight: 700; }
.clock-late  { color: var(--bad); }
.clock-met   { color: var(--ink-soft); }
.clock-none  { color: var(--ink-soft); }

.tagcell { max-width: 180px; }
.tagcell .chip { margin: 1px 2px 1px 0; }

.badge-pri    { background: var(--bad); color: #fff; border-color: var(--bad); }
.badge-sales  { background: #eef3ff; border-color: #cdd9f5; }
.badge-snooze { background: #fff6e5; border-color: #f0d9a8; }
.badge-auto   { background: var(--page); border-color: var(--line); color: var(--ink-soft); }

/* THE COLLISION WARNING, above the composer: two agents answering the same
 * question is the failure customers complain about most. Kept in the layout
 * even when it is empty, so the composer does not jump down the page when the
 * script fills it in twenty seconds later. */
.note-collide { background: #fff6e5; border-color: #f0d9a8; min-height: 1.5em; }
.note-collide.is-quiet { visibility: hidden; }

.buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.inlineform { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.inlineform input[type="date"], .inlineform input[type="number"], .inlineform select,
.field select, .field input[type="text"] {
  padding: 8px 10px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #c3c7cf; border-radius: 7px;
}
.field select, .field input[type="text"] { width: 100%; }

.checks { columns: 2; column-gap: 14px; font-size: 0.9rem; }
.checks li + li { margin-top: 4px; }
.inline { display: flex; flex-wrap: wrap; gap: 6px; }
.inline li + li { margin-top: 0; }

/* ---------------------------------------------------------- phase 4 ------
 * The topics area: the list, the editor and the preview.
 *
 * The editor reuses .thread (two columns) because it is the same problem as
 * the thread - a wide thing to write in, with its settings beside it - and one
 * grid is easier to keep working at phone width than two.
 */

.badge-draft     { background: var(--page); border-color: var(--line); color: var(--ink-soft); }
.badge-published { background: #eef7f3; border-color: #bfdfd2; color: var(--good); }
.badge-internal  { background: #fff6e5; border-color: #f0d9a8; }

.searchbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 16px; }
.searchbar input[type="search"] { min-width: 18rem; }

.checks label { display: block; }

/* The preview, and the editors

/* ---------------------------------------------------------- phase 4 ------
 * The topics area: the list, the editor and the preview.
 *
 * The editor reuses .thread (two columns) because it is the same problem as
 * the thread - a wide thing to write in, with its settings beside it - and one
 * grid is easier to keep working at phone width than two.
 *
 * The .prose rules are the customer stylesheet's, repeated here rather than
 * shared: what the preview shows has to be the page and not an approximation
 * of it, and the two stylesheets have different palettes.
 */

.badge-draft     { background: var(--page); border-color: var(--line); color: var(--ink-soft); }
.badge-published { background: #eef7f3; border-color: #bfdfd2; color: var(--good); }
.badge-internal  { background: #fff6e5; border-color: #f0d9a8; }

.searchbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 16px; }
.searchbar input[type="search"] { min-width: 18rem; }

.checks label { display: block; }

.prose-card { max-width: 48em; }
.prose { max-width: 42em; }
.prose h2 { font-size: 1.3rem; margin: 28px 0 10px; }
.prose h3 { font-size: 1.1rem; margin: 22px 0 8px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 24px; }
.prose li + li { margin-top: 6px; }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em; background: var(--card); border-radius: 4px; padding: 1px 5px;
}
.prose pre {
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  padding: 14px 16px; overflow-x: auto; margin: 0 0 16px;
}
.prose pre code { background: none; padding: 0; }
.prose blockquote {
  margin: 0 0 16px; padding: 2px 0 2px 16px;
  border-left: 3px solid var(--line); color: var(--ink-soft);
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

.onpage { margin: 0 0 20px; padding: 12px 14px; background: var(--card); border-radius: 7px; }
.onpage .plain li + li { margin-top: 4px; }

@media (max-width: 900px) {
  .searchbar input[type="search"] { min-width: 0; width: 100%; }
}

/* ================================ phase 5: the words customers use */
/* Two fields that are halves of one fact (what they type, what we call it),
   side by side so the pair reads as a pair - and stacked at phone width,
   where side by side would make both of them too narrow to read. */
.row2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) {
  .row2 { grid-template-columns: 1fr; }
}

/* ====================================== phase 6: a secret, shown once */
/* Monospaced and selectable in one go, because what happens next is a
   copy and a paste into a .env on another machine. Scrolls rather than
   wraps: a wrapped 64-character secret is one somebody pastes with a
   newline in the middle of it. */
.secret {
  margin: 0; padding: 12px 14px; overflow-x: auto;
  background: var(--page); border: 1px solid var(--line); border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem; line-height: 1.5; white-space: pre; user-select: all;
}

/* ============================================= phase 7: the reports */
/* A REPORT IS A TABLE OF NUMBERS, AND THE DESK'S PHONE RULE UNDOES IT. Higher
   up, a .grid at phone width becomes stacked blocks with its headings hidden -
   right for the queue, where every row says what it is (a subject, a service,
   a wait), and wrong here, where a stacked row is six numbers in a column with
   nothing to say which is which. Looked at on a 375px screen, and it was
   unreadable.

   Inside a .scroller the table stays a table, keeps its headings and scrolls
   sideways, which is what a phone can actually do with eight columns of
   numbers. The min-width is what makes it scroll rather than squeeze every
   column down to two characters. */
.scroller { overflow-x: auto; margin-bottom: 16px; }
@media (max-width: 720px) {
  .scroller .grid       { display: table; min-width: 560px; }
  .scroller .grid thead  { display: table-header-group; }
  .scroller .grid tbody  { display: table-row-group; }
  .scroller .grid tfoot  { display: table-footer-group; }
  .scroller .grid tr     { display: table-row; padding: 0; }
  .scroller .grid th,
  .scroller .grid td     { display: table-cell; padding: 10px 12px; border-bottom: 1px solid var(--line); }
}

/* ============================================ rolled-up messages (1 Dec 2026)
   A <details> per message. The summary says who and when, and closed it also
   shows the first sentence: 100 characters, which is two or three lines on a
   phone. Open, the sentence would be the message twice, so it goes. */
.roll > summary { cursor: pointer; list-style: none; position: relative; padding-right: 24px; }
.roll > summary::-webkit-details-marker { display: none; }
.roll > summary::after {
  content: ""; position: absolute; right: 4px; top: 6px; width: 7px; height: 7px;
  border: solid var(--ink-soft); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.roll[open] > summary::after { top: 9px; transform: rotate(-135deg); }
.roll > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.roll .msg-who { display: block; overflow-wrap: anywhere; }
.roll .msg-preview { display: block; overflow-wrap: anywhere; }
.roll[open] .msg-preview { display: none; }
.roll[open] > summary { margin-bottom: 6px; }
.roll .msg-who { margin-bottom: 0; }
.roll:not([open]) .msg-who { margin-bottom: 2px; }

.h-sub { font-size: 1rem; }
.narrow-left { max-width: 480px; }

/* ================================ the topic editor's toolbar and page
   The page is drawn with the preview's own .prose rules, so what is written is
   what a reader sees. The bar stays put while the page scrolls under it. */
.ed { border: 1px solid #c3c7cf; border-radius: 7px; background: #fff; }
.ed:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.ed-bar {
  position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 4px; padding: 6px;
  background: var(--page); border-bottom: 1px solid var(--line); border-radius: 7px 7px 0 0;
}
.ed-btn {
  min-height: 34px; min-width: 34px; padding: 4px 9px; font: inherit; font-size: 0.85rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 5px; cursor: pointer;
}
.ed-btn:hover { border-color: var(--ink-soft); }
.ed-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.ed-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ed-bold { font-weight: 700; }
.ed-italic { font-style: italic; }
.ed-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ed-swap { margin-left: auto; color: var(--accent); }
.ed-link { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.ed-link[hidden] { display: none; }
.field .ed-link input { flex: 1 1 220px; width: auto; }
.ed-msg { flex-basis: 100%; color: var(--bad); font-size: 0.85rem; }
.ed-msg:empty { display: none; }
.ed-page { max-width: none; min-height: 26em; padding: 16px 18px; overflow-wrap: anywhere; }
.ed-page:focus { outline: none; }
.ed-page > :first-child { margin-top: 0; }
.ed-page a { color: var(--accent); }
.ed-page code, .ed-page pre { background: var(--page); }
.ed-page pre { white-space: pre-wrap; }
.field .ed textarea { display: block; border: 0; border-radius: 0 0 7px 7px; outline: none; min-height: 26em; }
.field .ed textarea:focus { outline: none; }
.ed [hidden] { display: none !important; }
@media (max-width: 720px) {
  .ed-btn { min-height: 40px; min-width: 40px; }
  .ed-page { padding: 14px 12px; }
}
