/* DDW dashboard. One sheet for every page; app/site/snapshot.py also inlines it to draw a chat as a picture, so the
   bubble rules (.thread, .msg, .meta, .text, .thumb) must stand on their own, with no script and no web font.
   Identity: the black of the logo, the navy and brass of DDW's own invoices, hairlines like a shop drawing.
   Type: Alexandria speaks for the system, Noto Naskh for what people wrote. No inline style anywhere (CSP). */
:root {
  --ink: #000;
  --navy: #17365d;
  --brass: #c49a5a;
  --brass-ink: #7a5b26;
  --paper: #f1f3f5;
  --sheet: #fff;
  --line: #d3dae2;
  --hair: #e6eaef;
  --text: #14202c;
  --muted: #5b6573;
  --ok: #17794a;
  --ok-soft: #e2f2e9;
  --late: #b3361b;
  --late-soft: #fbe9e4;
  --wait-soft: #f6eddb;
  --live: #25d07a;
  --rail: 224px;
  --ui: "Alexandria", "Noto Kufi Arabic", system-ui, "Segoe UI", sans-serif;
  --said: "Noto Naskh Arabic", "Alexandria", "Noto Kufi Arabic", system-ui, sans-serif;
  /* names the Plan 2 to 5 sheets were written against */
  --bg: var(--paper);
  --surface: var(--sheet);
  --accent: var(--navy);
  --accent-soft: #e6ecf3;
  --radius: 4px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--text); font: 400 15px/1.6 var(--ui); }
a { color: var(--navy); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }
.muted { color: var(--muted); }
.num, .time, .clock, .figure, .at { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 2px; }
.rail :focus-visible, .today :focus-visible, .guest :focus-visible { outline-color: var(--brass); }

/* ---- the shell: a black rail on a wide screen */
.rail {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 20; width: var(--rail);
  display: flex; flex-direction: column; gap: 6px; padding: 26px 16px 18px; overflow-y: auto;
  background: var(--ink); color: #fff; view-transition-name: rail;
}
.brand { display: block; padding-inline: 8px; color: #fff; text-decoration: none; }
.brand img { display: block; width: 112px; height: auto; }
.brand span { display: block; margin-top: 9px; font-size: 7.5px; font-weight: 300; letter-spacing: 0.3em; white-space: nowrap; opacity: 0.82; }
.agent-state { display: flex; align-items: center; gap: 8px; margin: 14px 8px 0; font-size: 12px; color: rgba(255, 255, 255, 0.62); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); flex: none; }
.agent-state.on { color: rgba(255, 255, 255, 0.86); }
.agent-state.on .dot { background: var(--live); animation: beat 2.4s ease-out infinite; }
.menu, .menu[popover] {
  position: static; inset: auto; display: flex; flex-direction: column; flex: 1; width: auto; height: auto; margin: 0;
  padding: 0; border: 0; overflow: visible; background: none; color: inherit;
}
.menu-close { display: none; }
.rail nav { display: block; }
.nav-group { display: flex; flex-direction: column; gap: 1px; margin-top: 20px; }
.nav-label { padding: 0 10px 5px; font-size: 11px; color: rgba(255, 255, 255, 0.42); }
.rail nav a {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-inline-start: 2px solid transparent;
  border-start-end-radius: 3px; border-end-end-radius: 3px; color: rgba(255, 255, 255, 0.74); text-decoration: none;
  font-size: 14px; transition: color 120ms, background-color 120ms;
}
.rail nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.rail nav a[aria-current="page"] {
  color: #fff; font-weight: 500; background: rgba(255, 255, 255, 0.11); border-inline-start-color: var(--brass);
  view-transition-name: nav-current;
}
.badge {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; margin-inline-start: auto;
  border-radius: 10px; background: var(--brass); color: var(--ink); font: 600 11px/1 var(--ui);
  font-variant-numeric: tabular-nums;
}
.menu .who {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: auto; padding: 16px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14); font-size: 12.5px;
}
.who-name { flex-basis: 100%; font-size: 14px; font-weight: 500; }
.menu .who a, .menu .who button.link { color: rgba(255, 255, 255, 0.66); }
.menu .who a:hover, .menu .who button.link:hover { color: #fff; }
.menu .who form { margin: 0; }
.tabs { display: none; }

body { padding-inline-start: var(--rail); }
body.guest { padding: 0; }
main { max-width: 1320px; margin: 0 auto; padding: 30px 36px 72px; view-transition-name: sheet; }
main:has(.inbox) { padding-bottom: 30px; }
.banner {
  padding: 7px 36px; background: var(--wait-soft); color: var(--brass-ink); border-bottom: 1px solid #ead9b6;
  font-size: 13px; font-weight: 500; text-align: center;
}

/* ---- words and sheets */
h1, h2, h3 { font-family: var(--ui); }
h1.page, main > h1 {
  margin: 0 0 18px; padding-bottom: 12px; border-bottom: 2px solid var(--brass);
  font-size: 26px; font-weight: 300; line-height: 1.3;
}
h1.page .tag { vertical-align: middle; }
/* the four request areas share one menu link: the one you are in reads as the page title, the others sit beside it */
.areas { align-items: baseline; gap: 4px 22px; margin: 0 0 18px; padding-bottom: 12px; border-bottom: 2px solid var(--brass); }
.areas strong { order: -1; margin-inline-end: auto; font-size: 26px; font-weight: 300; line-height: 1.3; }
.areas a:not(.button) { color: var(--muted); font-size: 14px; text-decoration: none; }
.areas a:not(.button):hover { color: var(--navy); }
.areas a.button { align-self: center; padding: 6px 14px; font-size: 13px; }
h2.section { display: flex; align-items: center; gap: 14px; margin: 34px 0 12px; font-size: 13px; font-weight: 500; color: var(--muted); }
h2.section::after { content: ""; flex: 1; height: 6px; border-top: 1px solid var(--line); border-inline-end: 1px solid var(--line); }
main > p.muted { margin: -8px 0 16px; font-size: 13.5px; }

.card, .panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); }
.panel { padding: 20px 22px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.panel h2 a { color: inherit; }
.panel h3 { font-weight: 600; }
.panel :is(table, ul, form) + h3 { margin-top: 22px; }  /* a second list in the same panel starts after a breath */
.panel .question, .panel > p.muted { margin: -8px 0 14px; color: var(--muted); font-size: 13px; }
.empty { margin: 0; color: var(--muted); font-size: 13.5px; }
.error { padding: 11px 14px; margin: 0 0 16px; background: var(--late-soft); color: var(--late); border-inline-start: 3px solid var(--late); border-radius: var(--radius); }
.notice { display: block; margin-bottom: 16px; padding: 11px 14px; background: var(--wait-soft); color: var(--brass-ink); border-radius: var(--radius); text-decoration: none; }
.late { color: var(--late); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* the cards: one sheet ruled into cells, a schedule on a drawing, not a row of tiles. The rules are outlines in a
   1px gap: an outline is painted over the neighbour, a border under a negative margin was hidden by it */
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1px; margin-bottom: 24px; overflow: hidden;
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius);
}
.card { padding: 18px 20px 16px; border: 0; border-radius: 0; outline: 1px solid var(--hair); }
/* Hamad's questions are always seven: the last takes what is left of its row, so the sheet ends without a blank cell */
.questions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.questions > :last-child { grid-column: span 2; }
.card h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card h2 a { color: inherit; text-decoration-color: var(--brass); }
.card .question { margin: 2px 0 12px; color: var(--muted); font-size: 12.5px; }
.card .value { margin: 0 0 6px; color: var(--navy); font-size: 30px; font-weight: 300; line-height: 1.2; font-variant-numeric: tabular-nums; }
.card .value.late { color: var(--late); }
.card ul { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.card li { padding: 2px 0; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--hair); }
.rows li:first-child { border-top: 0; }
.rows .time { min-width: 76px; color: var(--muted); font-size: 12.5px; }
.rows .time.late { color: var(--late); }
.rows.board .num { margin-inline-start: auto; font-size: 17px; font-weight: 300; color: var(--navy); }

.tag {
  display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper);
  color: var(--muted); font: 500 11.5px/1.7 var(--ui); white-space: nowrap; text-decoration: none;
}
a.tag:hover { border-color: var(--navy); color: var(--navy); }
strong.tag { background: var(--navy); border-color: var(--navy); color: #fff; }
.tag.late { background: var(--late-soft); color: var(--late); border-color: transparent; }
.tag.wait { background: var(--wait-soft); color: var(--brass-ink); border-color: transparent; }
.tag.live { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.live::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-inline-end: 6px; border-radius: 50%; background: var(--live); animation: beat 2.4s ease-out infinite; }
.tag .time { font-size: inherit; color: inherit; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: start; font-size: 12px; font-weight: 500; color: var(--muted); }
td { padding: 10px; border-bottom: 1px solid var(--hair); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, td.time { white-space: nowrap; }  /* a number or an hour is never broken over two lines */
tbody tr:hover td { background: #fafbfc; }
tr.cheapest td { background: var(--ok-soft); }
.form-table input, .form-table select { width: 100%; }

input, select, textarea {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--sheet); color: var(--text);
  font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy); outline-offset: -1px; border-color: var(--navy); }
button, a.button {
  display: inline-block; padding: 7px 16px; border: 1px solid var(--navy); border-radius: 6px; background: var(--navy);
  color: #fff; font: 500 14px/1.5 var(--ui); text-decoration: none; cursor: pointer;
  transition: background-color 120ms, transform 80ms;
}
button:hover, a.button:hover { background: #0f2745; color: #fff; }
button:active, a.button:active { transform: translateY(1px); }
button.quiet { background: var(--sheet); color: var(--text); border-color: var(--line); }
button.quiet:hover { background: var(--paper); border-color: var(--muted); }
button.small { padding: 3px 11px; font-size: 12.5px; }
form.inline { display: inline-block; margin: 0; margin-inline-start: 8px; }
button.link { padding: 0; border: 0; background: none; color: var(--navy); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { background: none; }
label { font-family: var(--ui); }
.actions { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: 0 0 14px; }
.actions form { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.actions details summary { padding: 7px 0; cursor: pointer; color: var(--navy); font-size: 14px; }
.edit { flex-direction: column; min-width: min(420px, 80vw); }
.edit textarea { width: 100%; font-family: var(--said); font-size: 15px; }
.file {
  display: inline-block; margin-inline-end: 6px; padding: 1px 8px; border: 1px solid var(--line); border-radius: 3px;
  font: 500 11.5px/1.8 var(--ui); letter-spacing: 0.02em; text-decoration: none;
}
.file:hover { border-color: var(--navy); }
.demo-controls { display: flex; gap: 8px; margin-top: 28px; }
.demo-controls form { margin: 0; }

/* ---- home: today on a tape */
.today { padding: 24px 28px 18px; border-radius: 6px 6px 0 0; background: var(--ink); color: #fff; }
.today-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.today h1 { margin: 0; font-size: 30px; font-weight: 300; line-height: 1.25; }
.clock { margin: 0; font-size: 30px; font-weight: 200; line-height: 1.25; }
.tape { margin-top: 12px; padding-inline: 12px; }
.tape svg { display: block; width: 100%; height: 84px; overflow: visible; }
.tape .base { stroke: rgba(255, 255, 255, 0.24); stroke-width: 1; }
.tape .base.done { stroke: var(--brass); stroke-width: 2; }
.tape .tick { stroke: rgba(255, 255, 255, 0.34); stroke-width: 1; }
.tape .tick.major { stroke: rgba(255, 255, 255, 0.75); }
.tape .hour { fill: rgba(255, 255, 255, 0.5); font: 400 10.5px var(--ui); text-anchor: middle; font-variant-numeric: tabular-nums; }
.tape .hour.major { fill: rgba(255, 255, 255, 0.8); }
.tape .mark { stroke-width: 1.5; stroke-linecap: round; }
.tape .mark.in { stroke: rgba(255, 255, 255, 0.9); }
.tape .mark.out { stroke: var(--brass); }
.tape .mark.doc { stroke: var(--brass); stroke-width: 3; }
.tape .stop { fill: var(--ink); stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.5; }
.tape .stop.idle { stroke: rgba(255, 255, 255, 0.28); }
.tape .stop.done { fill: var(--brass); stroke: var(--brass); }
.tape .stop.missed { fill: #e2573a; stroke: #e2573a; }
.tape .stop.live { fill: var(--live); stroke: var(--live); transform-box: fill-box; transform-origin: center; animation: swell 1.8s ease-in-out infinite; }
.tape .now { stroke: var(--live); stroke-width: 1.5; filter: drop-shadow(0 0 5px var(--live)); animation: laser 2.6s ease-in-out infinite; }
.stops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 20px; margin: 10px 0 0; padding: 12px 0 0; list-style: none; border-top: 1px solid rgba(255, 255, 255, 0.14); }
.stops li { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; align-items: baseline; font-size: 13.5px; color: rgba(255, 255, 255, 0.5); }
.stops .time { font-size: 12.5px; }
.stops .note { grid-column: 2; font-size: 12px; }
.stops .done, .stops .live, .stops .missed { color: #fff; }
.stops .done .note { color: var(--brass); }
.stops .live .note { color: var(--live); }
.stops .missed .note { color: #f08a72; }

.pulse {
  display: grid; grid-template-columns: repeat(5, 1fr); margin: 0; padding: 0; list-style: none; overflow: hidden;
  background: var(--sheet); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 6px 6px;
}
.pulse li { margin-inline-end: -1px; border-inline-end: 1px solid var(--hair); }
.pulse a { display: flex; flex-direction: column; height: 100%; padding: 14px 20px 15px; color: inherit; text-decoration: none; transition: background-color 120ms; }
.pulse a:hover { background: #fafbfc; }
.pulse .label { font-size: 12.5px; color: var(--muted); }
.figure { display: flex; align-items: baseline; gap: 6px; }
.figure b { color: var(--navy); font-size: 36px; font-weight: 300; line-height: 1.25; }
.figure i { color: var(--muted); font-size: 16px; font-style: normal; }
.pulse .note { font-size: 12px; color: var(--muted); }
.pulse .wait .figure b { color: var(--brass-ink); }
.pulse .wait .label::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-inline-end: 7px; border-radius: 50%; background: var(--brass); animation: beat-brass 2.2s ease-out infinite; }
.pulse .late .figure b { color: var(--late); }

.now-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(290px, 1fr); gap: 16px; align-items: start; margin-top: 16px; }
.now-grid .panel { margin-bottom: 0; }
.side { display: grid; gap: 16px; }
.more { margin: 12px 0 0; font-size: 13px; }

.feed, .asks { margin: 0; padding: 0; list-style: none; }
.feed li { border-top: 1px solid var(--hair); }
.feed li:first-child { border-top: 0; }
.feed a { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 0 12px; padding: 9px 10px; margin-inline: -10px; border-inline-start: 2px solid transparent; color: inherit; text-decoration: none; }
.feed a:hover { background: #fafbfc; }
.feed .agent a { border-inline-start-color: var(--brass); }
.feed .time { grid-row: span 2; padding-top: 2px; font-size: 12px; color: var(--muted); }
.feed .by { font-size: 13px; font-weight: 500; }
.feed .by .muted { font-weight: 400; }
.feed .said, .asks .said { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: #33414f; }
.asks li { border-top: 1px solid var(--hair); }
.asks li:first-child { border-top: 0; }
.asks a { display: grid; gap: 3px; padding: 10px 12px; margin-inline: -12px; border-inline-start: 2px solid var(--brass); color: inherit; text-decoration: none; }
.asks a:hover { background: var(--wait-soft); }
.asks .meta { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 500; color: var(--text); }
.asks .meta .time { font-weight: 400; font-size: 12px; color: var(--muted); }
.asks .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.needs h2 { display: flex; align-items: center; gap: 8px; }
.needs h2 .badge { margin: 0; }

/* ---- what people wrote: Naskh, as on their phones */
.msg .text, .draft .text, .said, .quote, .bubbles p, .question-text { font: 15px/1.6 "Noto Naskh Arabic", "Alexandria", "Noto Kufi Arabic", system-ui, sans-serif; }

/* ---- chats */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100dvh - 60px); overflow: hidden; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); }
body:has(.banner) .inbox { height: calc(100dvh - 97px); }
.inbox-list.panel { margin: 0; padding: 16px 0 8px; overflow-y: auto; border: 0; border-inline-end: 1px solid var(--line); border-radius: 0; }
.inbox-list h2 { padding-inline: 18px; }
.inbox-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper); }
.inbox-thread.pick { align-items: center; justify-content: center; gap: 18px; }
.pick img { width: 150px; height: auto; filter: invert(1); opacity: 0.1; }
.chatlist { list-style: none; margin: 0; padding: 0; }
.chatlist a {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "av name time" "av last tag";
  gap: 1px 12px; align-items: center; padding: 10px 16px; border-inline-start: 2px solid transparent;
  border-top: 1px solid var(--hair); color: var(--text); text-decoration: none;
}
.chatlist li:first-child a { border-top: 0; }
.chatlist a:hover { background: #fafbfc; }
.chatlist a[aria-current] { background: var(--paper); border-inline-start-color: var(--brass); }
.avatar { grid-area: av; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 15px; font-weight: 500; }
.avatar.group { border-radius: 11px; }
.avatar.tone-1 { background: var(--ink); }
.avatar.tone-2 { background: var(--brass-ink); }
.avatar.tone-3 { background: var(--muted); }
.chatlist .name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.chatlist .name .muted { font-size: 12px; font-weight: 400; }
.chatlist .last { grid-area: last; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 14px/1.5 var(--said); }
.chatlist .time { grid-area: time; font-size: 11.5px; color: var(--muted); }
.chatlist .tag { grid-area: tag; justify-self: end; }
.thread-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 12px 20px; background: var(--sheet); border-bottom: 1px solid var(--line); }
.thread-head h1.page { margin: 0; padding: 0; border: 0; font-size: 17px; font-weight: 600; }
.thread-head h1.page + .facts { margin: 0; }
.thread-head .back { display: none; }
.thread-head .replay { margin-inline-start: auto; padding: 4px 12px; font-size: 13px; }
.thread-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column-reverse; padding: 16px 22px 20px; }

.thread { display: flex; flex-direction: column; gap: 2px; max-width: 760px; }
.thread-scroll .thread { max-width: none; }
.msg, .draft { position: relative; max-width: min(78%, 560px); margin-top: 8px; padding: 7px 12px 6px; border: 1px solid var(--hair); border-radius: 14px; background: var(--sheet); }
.msg[data-cont] { margin-top: 0; }
.msg.in { align-self: flex-start; border-start-start-radius: 4px; }
.msg.out { align-self: flex-end; border-color: transparent; border-start-end-radius: 4px; background: var(--navy); color: #fff; }
.msg.out[data-by="owner"] { background: var(--ink); }
.msg.out a { color: #fff; }
.meta { margin-bottom: 1px; font-size: 12px; font-weight: 500; color: var(--muted); }
.msg.in .meta bdi { color: var(--brass-ink); }
.msg.out .meta { color: rgba(255, 255, 255, 0.72); }
.kind { font-size: 13px; color: var(--muted); }
.msg.out .kind, .msg.out .text.muted { color: rgba(255, 255, 255, 0.72); }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg[data-id] { display: flex; flex-wrap: wrap; align-items: flex-end; column-gap: 12px; }
.msg[data-id] > * { flex: 0 0 100%; min-width: 0; }
.msg[data-id] > .text { flex: 1 1 auto; }
.msg[data-id] > .text.muted { flex-basis: 100%; }
.msg[data-id] > .at { flex: 0 0 auto; margin-inline-start: auto; font-size: 10.5px; line-height: 1.9; opacity: 0.6; }
/* a wrapping row is as wide as all its parts side by side: a picture with a caption is held to the picture's width.
   The picture itself is never cropped: a photographed page shows whole */
.msg:has(.thumb) { max-width: min(78%, 326px); }
/* a reaction hangs on the bubble it answers: ours on their side, theirs on ours */
.msg[data-react] { align-self: flex-start; z-index: 1; margin: -7px 12px 0; padding: 0 7px; border: 1px solid var(--line); border-radius: 12px; background: var(--sheet); color: var(--text); }
.msg.in[data-react] { align-self: flex-end; }
.msg[data-react] .text { font-size: 14px; line-height: 1.55; }
.msg .thumb { display: block; width: auto; max-width: 100%; height: auto; max-height: 230px; margin: 3px 0 4px; border-radius: 9px; }
.msg .file { display: inline-flex; align-items: center; gap: 9px; margin: 3px 0; padding: 8px 12px; border-radius: 8px; background: var(--paper); font-size: 13px; letter-spacing: 0; }
.msg .file[data-fmt]::before { content: attr(data-fmt); padding: 1px 5px; border: 1px solid currentColor; border-radius: 2px; font-size: 9.5px; font-weight: 600; opacity: 0.8; }
.msg.out .file { border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.12); }
.msg audio { max-width: 100%; height: 34px; }
.quote { margin: 2px 0 4px; padding: 2px 9px; border-inline-start: 2px solid var(--brass); border-radius: 3px; background: rgba(20, 32, 44, 0.05); font-size: 13px; opacity: 0.9; }
.quote bdi { font: 500 12px var(--ui); color: var(--brass-ink); }
.msg.out .quote { background: rgba(255, 255, 255, 0.12); }
.msg.out .quote bdi { color: var(--brass); }
.draft { align-self: flex-end; border: 1px dashed var(--brass); background: var(--wait-soft); }
.draft.status-dropped { border-color: var(--line); background: transparent; opacity: 0.75; }
.draft.status-review_failed, .draft.status-lint_failed, .draft.status-failed { border-color: var(--late); background: var(--late-soft); }
.notes { margin-top: 6px; font-size: 13px; color: var(--late); }
.day-line { display: flex; align-items: center; gap: 14px; margin: 16px 0 4px; font-size: 12px; color: var(--muted); }
.day-line::before, .day-line::after { content: ""; flex: 1; height: 7px; border-bottom: 1px solid var(--line); }
.day-line::before { border-inline-start: 1px solid var(--line); }
.day-line::after { border-inline-end: 1px solid var(--line); }
.day-line span { transform: translateY(3px); }
.typing { padding-bottom: 9px; }
.dots { display: inline-flex; gap: 4px; padding-top: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.4; animation: dots 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }

/* ---- the test chat: write as this chat's person (sim adapter only) */
.say { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; padding: 10px 16px 8px; background: var(--sheet); border-top: 1px solid var(--line); }
.say .say-text { flex: 1 1 160px; min-width: 0; padding: 9px 14px; border-radius: 20px; font-family: var(--said); font-size: 15px; }
.say select { max-width: 40%; border-radius: 20px; }
.say button { border-radius: 20px; padding-inline: 20px; }
.attach { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--muted); cursor: pointer; }
.attach:hover, .attach.has-file { background: var(--paper); color: var(--navy); }
.attach.has-file { box-shadow: inset 0 0 0 2px var(--brass); }
.attach input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.attach:focus-within { outline: 2px solid var(--navy); outline-offset: 2px; }
.attach svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.say-note { flex-basis: 100%; margin: 0; font-size: 11.5px; color: var(--muted); }
.say-note.late { color: var(--late); }
.thread .error { align-self: stretch; margin: 10px 0 0; }
.try { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.try .panel { margin: 0; }
.voices a { grid-template-areas: "av name" "av last"; grid-template-columns: 40px minmax(0, 1fr); padding-inline: 4px; }
.try-cta { display: grid; gap: 2px; padding: 16px 20px; border: 1px solid var(--brass); border-inline-start-width: 3px; border-radius: var(--radius); background: var(--sheet); color: var(--text); text-decoration: none; transition: background-color 120ms; }
.try-cta:hover { background: var(--wait-soft); color: var(--text); }
.try-cta strong { font-size: 16px; font-weight: 600; }
.try-cta span { font-size: 13px; color: var(--muted); }

/* ---- approvals: what will be sent, shown as it will arrive */
.approval { border-inline-start: 3px solid var(--brass); }
.approval > .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 10px; font-size: 14px; color: var(--text); }
.approval > .meta a { font-weight: 600; text-decoration: none; }
.approval > .meta .time { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.approval .bubbles { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.approval .bubbles p { margin: 0; padding: 7px 13px; border-radius: 14px; border-start-start-radius: 4px; background: var(--navy); color: #fff; white-space: pre-wrap; }
.question-text { margin: 4px 0 0; padding: 10px 14px; border-radius: var(--radius); background: var(--paper); white-space: pre-wrap; }
.approval .actions { margin: 14px 0 0; align-items: flex-start; }
.approval .actions button { padding: 9px 22px; }

/* ---- login: the plate */
.login { display: flex; flex-direction: column; gap: 14px; max-width: 320px; margin: 14vh auto 0; }
.guest { background: var(--ink); color: #fff; }
.guest main { padding-top: 24px; }
.login img { display: block; width: 240px; height: auto; margin: 0 auto 22px; }
.login h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.login input { padding: 10px 12px; border-color: rgba(255, 255, 255, 0.28); background: #fff; }
.login button { padding: 10px 16px; border-color: var(--brass); background: var(--brass); color: var(--ink); font-weight: 600; }
.login button:hover { background: #d6ae70; color: var(--ink); }
.login a { align-self: center; color: rgba(255, 255, 255, 0.6); font-size: 13px; }
.login .error { margin: 0; }

/* ---- motion: one moment when the day opens, then only what is live */
@view-transition { navigation: auto; }
::view-transition-old(sheet) { animation: 110ms ease-in both leave; }
::view-transition-new(sheet) { animation: 240ms 60ms cubic-bezier(0.2, 0.7, 0.2, 1) both arrive; }
::view-transition-group(nav-current) { animation-duration: 260ms; animation-timing-function: cubic-bezier(0.3, 0.7, 0.2, 1); }
@keyframes leave { to { opacity: 0; } }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(37, 208, 122, 0.6); } 70%, 100% { box-shadow: 0 0 0 7px rgba(37, 208, 122, 0); } }
@keyframes beat-brass { 0% { box-shadow: 0 0 0 0 rgba(196, 154, 90, 0.6); } 70%, 100% { box-shadow: 0 0 0 7px rgba(196, 154, 90, 0); } }
@keyframes swell { 50% { transform: scale(1.45); opacity: 0.7; } }
@keyframes laser { 50% { opacity: 0.55; } }
@keyframes dots { 0%, 60%, 100% { transform: none; opacity: 0.35; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes draw { from { transform: scaleY(0); opacity: 0; } }
@keyframes show { from { opacity: 0; } }
@keyframes land { from { opacity: 0; transform: translateY(-8px); background: var(--wait-soft); } 60% { background: var(--wait-soft); } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
/* the page opens: the tape draws itself up to now, the figures hold a beat for the count (app.js) */
#live:not(.settled) .tape .tick, #live:not(.settled) .tape .mark { transform-box: fill-box; transform-origin: bottom; animation: draw 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
#live:not(.settled) .tape .mark { animation-delay: 380ms; }
#live:not(.settled) .tape .hour, #live:not(.settled) .tape .stop:not(.live) { animation: show 500ms 300ms both; }
#live:not(.settled):not(.counting) .figure b { animation: show 10ms 600ms both; }
.feed li.is-new { animation: land 1100ms ease-out both; }
.msg.is-new { animation: pop 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both; transform-origin: bottom; }
.msg:target { outline: 2px solid var(--brass); outline-offset: 2px; scroll-margin-block: 14px; }
.replaying .msg.held, .replaying .draft.held, .replaying .day-line.held { display: none; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- a phone: the band on top, four places under the thumb */
@media (max-width: 1279px) {
  .questions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .questions > :last-child { grid-column: span 3; }
}
@media (max-width: 1023px) {
  body { padding-inline-start: 0; padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  body.guest { padding-bottom: 0; }
  body:has(.inbox.open) .rail, body:has(.inbox.open) .tabs, body:has(.inbox.open) .banner { display: none; }
  .rail { position: sticky; top: 0; inset-inline-start: auto; width: auto; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; overflow: visible; }
  .brand { padding: 0; }
  .brand img { width: 74px; }
  .brand span { display: none; }
  .agent-state { margin: 0; }
  .menu, .menu[popover] { display: none; }
  .menu:popover-open {
    position: fixed; inset: 0; display: flex; width: 100%; height: 100%; max-width: none; max-height: none;
    padding: 18px 20px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; background: var(--ink); color: #fff;
  }
  .menu::backdrop { background: rgba(0, 0, 0, 0.6); }
  .menu-close { display: block; align-self: flex-end; padding: 6px 14px; border-color: rgba(255, 255, 255, 0.3); background: none; color: #fff; }
  .menu-close:hover { background: rgba(255, 255, 255, 0.1); }
  .nav-group { margin-top: 18px; }
  .rail nav a { padding: 10px 12px; font-size: 16px; }
  .menu .who { margin-top: 28px; padding-top: 18px; font-size: 14px; }
  .tabs {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
    padding-bottom: env(safe-area-inset-bottom); background: var(--sheet); border-top: 1px solid var(--line);
    view-transition-name: tabs;
  }
  .tabs a, .tabs button {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 2px 7px;
    border: 0; border-top: 2px solid transparent; border-radius: 0; background: none; color: var(--muted);
    font: 400 10.5px/1.4 var(--ui); text-decoration: none; margin-top: -1px;
  }
  .tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
  .tabs a[aria-current="page"] { color: var(--navy); font-weight: 600; border-top-color: var(--brass); }
  .tabs .badge { position: absolute; top: 4px; inset-inline-start: calc(50% + 6px); margin: 0; }
  main { padding: 18px 16px 40px; }
  .banner { padding: 6px 16px; font-size: 12px; }
  h1.page, main > h1 { font-size: 22px; margin-bottom: 14px; padding-bottom: 10px; }
  .areas strong { flex-basis: 100%; font-size: 22px; }
  .areas { margin-bottom: 14px; padding-bottom: 10px; }
  .panel { padding: 16px; }
  .two, .now-grid { grid-template-columns: minmax(0, 1fr); }
  .now-grid .side { display: contents; }
  .try-cta, .needs { order: -1; }
  .today { padding: 18px 16px 14px; }
  .today h1, .clock { font-size: 22px; }
  .tape { padding-inline: 8px; }
  .tape .hour:not(.major) { display: none; }
  .stops { grid-template-columns: 1fr 1fr; gap: 10px 14px; }
  .pulse { grid-template-columns: 1fr 1fr; }
  .pulse li { border-block-end: 1px solid var(--hair); margin-block-end: -1px; }
  .pulse li:last-child:nth-child(odd) { grid-column: span 2; }
  .pulse a { padding: 12px 16px; }
  .figure b { font-size: 30px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .questions > :last-child { grid-column: span 2; }
  .card { padding: 14px 14px 12px; }
  .card .value { font-size: 24px; }
  .inbox, body:has(.banner) .inbox { display: block; height: auto; overflow: visible; border: 0; background: none; }
  .inbox-list.panel { border: 1px solid var(--line); border-radius: var(--radius); }
  .inbox .pick, .inbox.open .inbox-list { display: none; }
  .inbox.open, body:has(.banner) .inbox.open { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--paper); }
  .inbox.open .inbox-thread { flex: 1; }
  .thread-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "back name play" "back facts play"; gap: 0 12px; padding: calc(9px + env(safe-area-inset-top)) 14px 9px; background: var(--ink); color: #fff; border: 0; }
  .thread-head .back { grid-area: back; display: inline-block; padding: 8px 0; color: var(--brass); font-size: 13px; text-decoration: none; }
  .thread-head .back::before { content: "\2039\00a0"; }
  .thread-head h1.page { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .thread-head h1.page + .facts { grid-area: facts; min-height: 0; color: rgba(255, 255, 255, 0.6); font-size: 12px; }
  .thread-head .replay { grid-area: play; border-color: rgba(255, 255, 255, 0.3); background: none; color: #fff; }
  .thread-scroll { padding: 10px 12px 14px; }
  .inbox-thread:not(:has(.say)) .thread-scroll { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .say { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .say .say-text { font-size: 16px; }
  .say select { flex: 1 1 100%; max-width: none; }  /* who speaks, on its own row: the box and the button stay together */
  .say button { padding-inline: 14px; }
  .try { grid-template-columns: minmax(0, 1fr); }
  .msg, .draft { max-width: 88%; }
  .msg .thumb { max-height: 180px; }
  .msg:has(.thumb) { max-width: min(88%, 256px); }
  /* a wide table scrolls sideways under its own first column: the row keeps its name while the numbers move */
  table { display: block; overflow-x: auto; }
  th, td { padding-inline: 8px; }
  th { white-space: nowrap; }
  td:not(.num, .time, :first-child):not(:has(input, select, button)) { min-width: 116px; }
  table:not(.form-table) td:first-child:not(.num) { min-width: 104px; }
  table:not(.form-table) :is(th, td):first-child { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--sheet); }
  .login { margin-top: 12vh; padding-inline: 8px; }
}
@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
  .questions > :last-child { grid-column: auto; }
  .agent-state { font-size: 11.5px; }
}
