@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-display: swap;
  font-weight: 300 700;
  src: url("vendor/space-grotesk/space-grotesk-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-display: swap;
  font-weight: 300 700;
  src: url("vendor/space-grotesk/space-grotesk-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --page: #eef1f2;
  --panel: #fbfcfd;
  --input: #ffffff;
  --ink: #1a2126;
  --muted: #5b6770;
  --placeholder: #93a0a6;
  --border: #d5dbde;
  --border-strong: #c3ccd0;
  --teal: #0f766e;
  --teal-hover: #115e59;
  --secondary: #e4e9eb;
  --secondary-hover: #d7dee1;
  --danger: #b42318;
  --danger-hover: #912018;
  --error-tint: #fbeeec;
  --error-border: #efc7c2;
  --gold: #c9950c;
  --gold-light: #e8b83a;
  --gold-text: #8a6407;
  --gold-tint: #f6f1e3;
  --gold-border: #e5dcc3;
  --select-tint: #f2f8f7;
  --select-ring: #cfe4e1;
  --dim: #9aa4a9;
  --absent: #8a969c;
  --absent-border: #aeb9be;
  --disabled-fill: #cdd6d9;
  --image-well: #dfe4e6;
  --attention: #6d28d9;
  --attention-hover: #5b21b6;
  --display: "Space Grotesk", system-ui, sans-serif;
  --radius: 10px;
  --float-shadow: 0 2px 8px rgba(26, 33, 38, 0.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--page); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--page); color: var(--ink); font: 15px/1.5 system-ui, sans-serif;
}
a { color: var(--teal); }
a:hover { color: var(--teal-hover); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.muted { color: var(--muted); }
.display { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; }
.label {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted);
}
.tabular { font-variant-numeric: tabular-nums; }

/* Frame */
.bar {
  flex: none; display: flex; align-items: center; gap: 26px; height: 60px; padding: 0 24px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.bar .spacer { flex-grow: 1; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.who form { margin: 0; }
.bar-actions { display: flex; gap: 10px; }
.clock-group { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.clock-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted);
}
.clock { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
.clock.lead { font-size: 26px; }
.clock.minor { font-size: 16px; font-weight: 600; color: var(--muted); }
main { flex: 1 0 auto; display: flex; flex-direction: column; }
main.centered { align-items: center; justify-content: center; gap: 16px; padding: 28px 24px; }
main.document { align-items: center; gap: 16px; padding: 28px 24px 36px; }
.flash {
  width: min(100%, 560px); list-style: none; margin: 0; padding: 10px 14px;
  background: var(--error-tint); border: 1px solid var(--error-border); border-radius: var(--radius);
}
.flash li + li { margin-top: 4px; }

/* A failure the participant sees: a titled box (Study.failure) or a line of text */
.failed {
  background: var(--error-tint); border: 1px solid var(--error-border); border-radius: var(--radius);
  color: var(--danger);
}
.failed.box { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; font-size: 14px; line-height: 1.4; }
.failed.box span { color: var(--ink); }
.failed:not(.box) { width: fit-content; max-width: 100%; padding: 0 7px; border-radius: 6px; font-weight: 600; }
/* Under the header, stays in view on a scrolled page, above the full-screen image, Help,
   and the paused overlay */
.failed.connection-lost {
  position: sticky; top: 0; z-index: 51; flex: none; padding: 8px 24px;
  border-width: 0 0 1px; border-radius: 0; text-align: center;
}

/* Buttons: one system (settled item 12). 48 px in forms, 40 px in bars and tables, and
   .big for the single action read and pressed at arm's length. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 48px; padding: 0 26px; border: 0; border-radius: var(--radius);
  background: var(--teal); color: #ffffff; font: inherit; font-size: 16px; font-weight: 700;
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.btn:hover { background: var(--teal-hover); color: #ffffff; }
.btn.secondary { padding: 0 22px; background: var(--secondary); color: var(--ink); font-size: 15px; font-weight: 600; }
.btn.secondary:hover { background: var(--secondary-hover); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-hover); }
.btn.small { height: 40px; padding: 0 14px; font-size: 15px; font-weight: 600; }
.btn:disabled, .btn:disabled:hover { background: var(--disabled-fill); color: var(--absent); cursor: not-allowed; }
.btn[aria-disabled="true"] { pointer-events: none; background: var(--disabled-fill); color: var(--absent); }
.btn.wide { width: 100%; }
.big { height: 52px; font-size: 17px; }
.btn svg { flex-shrink: 0; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; }
.stack { display: flex; flex-direction: column; }
.divider { border-top: 1px solid var(--border); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field input, .field textarea {
  font: inherit; font-size: 15px; font-weight: 400; color: var(--ink);
  background: var(--input); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.field input { height: 46px; padding: 0 13px; }
.field textarea { padding: 12px 13px; resize: vertical; }
.field .hint { font-weight: 400; color: var(--muted); }
input::placeholder, textarea::placeholder { color: var(--placeholder); }

/* A step that cannot be taken back asks first (P5, P7b) */
dialog.confirm {
  width: min(calc(100vw - 32px), 440px); padding: 0; color: var(--ink); background: var(--panel);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 18px 50px rgba(26, 33, 38, 0.25);
}
dialog.confirm::backdrop { background: rgba(16, 20, 22, 0.45); }
.confirm form { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 24px 24px 20px; }
.confirm h2 { margin: 0; font-size: 21px; }
.confirm p { margin: 0; }
.confirm-warning {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--error-tint); border: 1px solid var(--error-border); border-radius: var(--radius);
  color: var(--danger); font-weight: 700;
}
.confirm-warning svg { flex-shrink: 0; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.confirm-value { font-weight: 700; overflow-wrap: anywhere; }

/* P1 */
.login { width: min(100%, 420px); gap: 18px; padding: 36px; }
.login header { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login h1 { margin: 0; font-size: 23px; }
.login-page .flash { width: min(100%, 420px); }
.login form { display: flex; flex-direction: column; gap: 18px; margin: 0; }

/* P7b */
.compensation { width: min(100%, 560px); gap: 16px; padding: 34px 38px; }
.compensation h1 { margin: 0; font-size: 24px; }
.compensation p { margin: 0; }
.compensation form { display: flex; flex-direction: column; gap: 18px; margin: 0; }

/* P2, P8: a given Markdown file, rendered as is */
.document-card { width: min(100%, 780px); padding: 36px 44px; line-height: 1.55; }
.prose h1 { margin: 0 0 6px; font-family: var(--display); font-size: 26px; letter-spacing: -0.01em; line-height: 1.25; }
.prose h2 { margin: 22px 0 8px; font-family: var(--display); font-size: 17px; line-height: 1.3; }
.prose h3 { margin: 18px 0 6px; font-size: 15px; }
.prose p { margin: 0 0 10px; }
.prose ol, .prose ul { margin: 0 0 10px; padding-left: 22px; }
.prose li { margin-bottom: 5px; }
.prose blockquote { margin: 0 0 12px; padding: 8px 14px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.prose table { width: 100%; margin: 0 0 10px; border-collapse: collapse; }
.prose th, .prose td { padding: 6px 10px; border: 1px solid var(--border-strong); text-align: left; }
.document-card .closing { display: flex; justify-content: flex-end; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.document-card .closing.note { flex-direction: column; justify-content: flex-start; gap: 8px; margin-top: 16px; }
.document-card .closing.back { justify-content: space-between; align-items: center; }

/* P3 */
.waiting { width: min(100%, 560px); gap: 16px; padding: 34px 38px; }
.waiting h1 { margin: 0; font-size: 24px; }
.bullets { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.bullets li { display: flex; align-items: center; gap: 11px; }
.bullets li::before { content: ""; width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--teal); }
.notice {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px;
  background: #e8f2f0; border: 1px solid #c4dcd8; border-radius: var(--radius);
}
.notice .dot { width: 10px; height: 10px; margin-top: 6px; flex-shrink: 0; border-radius: 50%; background: var(--teal); }
.notice strong { display: block; font-weight: 600; }
/* One box in three colours: as it should be, not there yet, wrong. */
.notice.pending { background: var(--gold-tint); border-color: var(--gold-border); }
.notice.pending .dot { background: var(--gold); }
.notice.bad { background: var(--error-tint); border-color: var(--error-border); }
.notice.bad .dot { background: var(--danger); }
.notice small { font-size: 13px; color: var(--muted); }
.confirmed { display: flex; align-items: center; gap: 11px; font-size: 17px; font-weight: 700; }
.quiet-link { font-size: 14px; font-weight: 600; text-decoration: none; align-self: flex-start; }
.waiting .group { gap: 10px; }
.waiting .step { gap: 14px; }
.waiting form { margin: 0; }
.waiting p { margin: 0; }

/* P4 */
.between { width: min(100%, 540px); align-items: center; gap: 16px; padding: 38px 42px; text-align: center; }
.between form { width: 100%; margin: 0; }
.between p { margin: 0; }
.between .aside { font-size: 13px; }

/* P7 */
.summary { width: min(100%, 1120px); align-items: center; gap: 16px; padding: 28px 34px; }
.summary h1 { margin: 0; font-size: 25px; }
.summary form { width: 100%; margin: 0; }

/* Maps (P5–P7): one pane, an OSM and a Google layer stacked with only the active one
   visible, and controls floating over it */
.map-pane { position: relative; overflow: hidden; background: #e5e3df; }
.map-layer { position: absolute; inset: 0; z-index: 0; visibility: hidden; }
.map-layer.active { z-index: 1; visibility: visible; }
.map-layer.leaflet-container { font: inherit; background: #e5e3df; }
.failed.centered, .failed.tiles-failed {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(calc(100% - 32px), 360px); text-align: center;
}
/* Below the search and the layer switch, above Leaflet's panes and controls */
.failed.tiles-failed { top: 60px; transform: translateX(-50%); z-index: 1001; }
.map-layer .leaflet-control-attribution {
  padding: 0 6px; background: rgba(251, 252, 253, 0.75); color: var(--muted); font-size: 10px;
}
.map-layer .leaflet-control-attribution a { color: var(--muted); }
.ovl {
  position: absolute; z-index: 5; background: var(--panel);
  border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--float-shadow);
}
.ovl.zoom { right: 12px; bottom: 12px; display: flex; flex-direction: column; overflow: hidden; }
.zbtn {
  display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0;
  border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 18px; font-weight: 600;
  line-height: 1; cursor: pointer;
}
.zbtn + .zbtn { border-top: 1px solid var(--border); }
.zbtn:hover { background: var(--secondary); }
.mapseg { top: 12px; right: 12px; display: flex; overflow: hidden; }
.mapseg button {
  padding: 7px 14px; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1.5; cursor: pointer;
}
.mapseg button:hover { background: var(--secondary); }
.mapseg button[aria-pressed="true"] { background: var(--teal); color: #ffffff; }

/* P9: the supervisor's pause covers everything but the clocks' truth. */
.paused {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center;
  background: rgba(16, 20, 22, 0.88);
}
.paused strong { font-family: var(--display); font-size: 26px; font-weight: 700; color: #ffffff; }
.paused span { font-size: 16px; color: #b8c2c7; }

/* Help drawer (P4, P5): the study information without leaving the task */
.drawer {
  position: fixed; top: calc(60px + var(--notice-height, 0px)); right: 0; bottom: 0; z-index: 40; width: min(100vw, 440px);
  overflow-y: auto; padding: 22px 26px; background: var(--panel);
  border-left: 1px solid var(--border); box-shadow: -12px 0 30px rgba(26, 33, 38, 0.12);
}
.drawer .close {
  position: sticky; top: 0; float: right; display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin: 0 0 8px 12px; padding: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.drawer .close:hover { background: var(--secondary); }

@media (max-width: 640px) {
  .failed.connection-lost { padding: 8px 14px; }
  .clock.lead { font-size: 22px; }
  .document-card { padding: 26px 22px; }
  .waiting, .between, .summary, .login { padding: 26px 22px; }
}

/* P2b: the recording add-on */
.addon { display: flex; flex-direction: column; gap: 16px; }
.addon .install { gap: 18px; }
.addon .install .heading { gap: 4px; }
.addon .install p { margin: 0; }
.addon h2 { margin: 0; font-family: var(--display); font-size: 17px; line-height: 1.3; }
.addon ol { flex-direction: column; gap: 14px; margin: 0; padding-left: 22px; }
.addon li > .btn, .addon li > img { display: flex; width: fit-content; margin-top: 8px; }
.addon li > img { width: auto; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; }
.addon #addon-done { align-self: flex-start; }
.addon code { padding: 1px 5px; background: var(--secondary); border-radius: 5px; font-size: 14px; }
.addon [data-browser] { display: none; }
html[data-browser="firefox"] .addon [data-browser~="firefox"],
html[data-browser="chrome"] .addon [data-browser~="chrome"],
html[data-browser="other"] .addon [data-browser~="other"] { display: flex; }
.addon .closing { margin-top: 8px; }

/* P2c: the video guide */
.video { width: min(100%, 1000px); display: flex; flex-direction: column; gap: 16px; }
.video .prose p { margin: 0; }
.video video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; background: #000000; border-radius: 8px; }
.video .closing { margin-top: 8px; }

/* P2d: the quiz, a grid of cards that are selected by a click */
.quiz { width: min(100%, 1000px); display: flex; flex-direction: column; gap: 16px; }
.quiz .prose p { margin: 0; }
.quiz ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; margin: 0; padding: 0; list-style: none; }
.quiz li { position: relative; display: flex; }
.quiz input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.quiz .scenario {
  position: relative; flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: var(--input); border: 2px solid var(--border); border-radius: var(--radius);
}
.quiz label.scenario { cursor: pointer; transition: border-color 0.12s, box-shadow 0.12s; }
.quiz label.scenario:hover { border-color: var(--border-strong); box-shadow: var(--float-shadow); }
.quiz input:checked + .scenario { background: var(--select-tint); border-color: var(--teal); }
.quiz input:focus-visible + .scenario { outline: 3px solid var(--select-ring); outline-offset: 2px; }
.quiz .scenario img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain; background: var(--image-well); }
.quiz .scenario p { margin: 0; padding: 14px 16px 16px; }
.quiz .pick {
  position: absolute; top: 10px; right: 10px; display: none; align-items: center; gap: 6px; padding: 4px 12px 4px 10px;
  background: var(--teal); border-radius: 999px; color: #ffffff; font-size: 13px; font-weight: 600;
}
.quiz .pick::before { content: "\2713"; }
.quiz input:checked + .scenario .pick { display: inline-flex; }
/* The result: the cards in two piles, by what the rule says */
.quiz .pile { display: flex; flex-direction: column; gap: 12px; }
.quiz .pile + .pile { margin-top: 12px; }
.quiz .pile h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--display); font-size: 19px; line-height: 1.3; }
.quiz .pile.allowed h2 { color: var(--teal); }
.quiz .pile.allowed h2::before { content: "\2713"; }
.quiz .pile.forbidden h2 { color: var(--danger); }
.quiz .pile.forbidden h2::before { content: "\2715"; }
.quiz .explanation {
  display: flex; flex-direction: column; gap: 6px; margin: auto 14px 14px; padding: 12px 14px;
  background: var(--page); border: 1px solid var(--border); border-radius: 8px;
}
.quiz .explanation p { padding: 0; }
.quiz .scenario.mistake { border-color: var(--gold); }
.quiz .mistake .explanation { background: var(--gold-tint); border: 2px solid var(--gold); }
.quiz .flag { display: flex; align-items: center; gap: 9px; font-size: 16px; }
.quiz .flag .dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; background: var(--gold); }
.quiz .closing { margin-top: 8px; }
@media (max-width: 640px) {
  .quiz ul { grid-template-columns: minmax(0, 1fr); }
}

/* The recording: its mark in the header while it runs, and the bar under the header
   while it does not */
/* The recording's mark in a session page's header, and the bar under the header while
   something is wrong with it */
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px 3px 9px; border: 1px solid; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.good { color: var(--teal); background: #e8f2f0; border-color: #c4dcd8; }
.chip.bad { color: var(--danger); background: var(--error-tint); border-color: var(--error-border); }
.recording-bar {
  position: sticky; top: 0; z-index: 51; flex: none; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: center; gap: 6px 16px; min-height: 46px; padding: 6px 24px;
  background: var(--error-tint); border-bottom: 1px solid var(--error-border); font-size: 14px;
}
.recording-bar strong { font-weight: 600; }
/* The page that winds up the recording: how much of what is left has been sent */
.progress { height: 10px; background: var(--secondary); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--teal); border-radius: 999px; transition: width 0.4s; }
.stopping .sending { gap: 8px; }
.stopping .closing { margin-top: 8px; }
.recording-bar a.btn { text-decoration: none; }
.row { display: flex; align-items: center; gap: 14px; }
.failed.box:not(:has(> :not([hidden]))) { display: none; }

/* The chat: a button in the header; its note and its panel drop down from it, above
   everything, the paused overlay included */
.chat { position: relative; display: flex; color: var(--ink); }
.chat-toggle { position: relative; z-index: 61; }
.chat.unread .chat-toggle {
  background: var(--attention); color: #ffffff; font-weight: 700;
  animation: chat-pulse 1.3s ease-out infinite;
}
.chat.unread .chat-toggle:hover { background: var(--attention-hover); }
.chat-new, .chat.unread .chat-toggle .chat-idle { display: none; }
.chat.unread .chat-toggle .chat-new { display: inline; }
@keyframes chat-pulse {
  0% { box-shadow: 0 0 0 0 rgba(109, 40, 217, 0.7); }
  70%, 100% { box-shadow: 0 0 0 16px rgba(109, 40, 217, 0); }
}
.chat-preview, .chat-panel { position: absolute; top: calc(100% + 11px); right: 0; z-index: 61; }
.chat-preview::before, .chat-panel::before {
  content: ""; position: absolute; top: -6px; right: 14px; width: 12px; height: 12px;
  background: inherit; transform: rotate(45deg);
}
.chat-preview {
  width: max-content; max-width: min(320px, calc(100vw - 28px)); display: flex; flex-direction: column; gap: 2px;
  padding: 9px 13px; background: var(--attention); border: 0; border-radius: var(--radius);
  box-shadow: var(--float-shadow); color: #ffffff; font: inherit; font-size: 14px; line-height: 1.4; text-align: left; cursor: pointer;
}
.chat-preview:hover { background: var(--attention-hover); }
.chat-preview-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.chat-panel {
  width: min(360px, calc(100vw - 28px)); max-height: min(520px, calc(100vh - 84px));
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: 0 12px 30px rgba(26, 33, 38, 0.18); font-size: 15px; font-weight: 400; white-space: normal;
}
.chat-panel::before { top: -7px; border: solid var(--border-strong); border-width: 1px 0 0 1px; }
.chat-panel > header { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); }
.chat-panel .close {
  display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0;
  background: transparent; border: 0; border-radius: 8px; cursor: pointer;
}
.chat-panel .close:hover { background: var(--secondary); }
.chat-panel > p { margin: 0; padding: 12px 14px; font-size: 14px; }
.chat-lost, .chat-failed { color: var(--danger); background: var(--error-tint); font-weight: 600; }
.chat-failed { border-radius: 0 0 12px 12px; }
.chat-messages { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 14px; list-style: none; overflow-y: auto; }
.chat-messages:empty { display: none; }
.chat-messages li { max-width: 86%; display: flex; flex-direction: column; padding: 7px 11px; border-radius: var(--radius); line-height: 1.4; }
.chat-messages .theirs { align-self: flex-start; background: var(--secondary); }
.chat-messages .mine { align-self: flex-end; background: #dcedea; }
.chat-messages p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-messages time { align-self: flex-end; font-size: 11px; color: var(--muted); }
.chat-form { flex: none; display: flex; align-items: flex-end; gap: 8px; margin: 0; padding: 10px; border-top: 1px solid var(--border); }
.chat-form textarea {
  flex: 1 1 auto; min-width: 0; height: 40px; max-height: 120px; padding: 9px 12px; resize: none;
  font: inherit; line-height: 20px; color: var(--ink);
  background: var(--input); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.chat-form .btn { flex: none; }
/* A window too narrow for the loud label: the note carries it */
@media (max-width: 900px) {
  .bar { gap: 14px; padding: 0 14px; }
  .chat.unread .chat-toggle .chat-new { display: none; }
  .chat.unread .chat-toggle .chat-idle { display: inline; }
  .chat-preview .chat-new { display: block; font-weight: 700; }
}
@media (max-width: 760px) {
  .bar-actions > .btn, .chat .chat-toggle { gap: 0; padding: 0 11px; font-size: 0; }
}
/* Too narrow to hang from the button: from the header's right end instead */
@media (max-width: 640px) {
  .bar { position: relative; }
  .chat { position: static; }
  .chat-preview, .chat-panel { top: calc(100% + 6px); right: 14px; }
  .chat-preview::before, .chat-panel::before { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chat.unread .chat-toggle { animation: none; box-shadow: 0 0 0 5px rgba(109, 40, 217, 0.35); }
}
