/* ===========================================================================
   The Study: shared styles.

   PROVISIONAL design. No logo, palette or mockup has been approved yet, so
   this is a plain, readable starting point: warm paper background, white
   cards, a text wordmark, one deep blue accent, a serif for headings and
   (later) passages, system fonts only. Every colour and size lives in :root
   below so the look can be replaced in one place once a design is chosen.

   Layout lessons carried over from Da Hangout and Blend (read-only
   references): overflow-x: clip rather than hidden (iOS scrolling), 16px
   form text (no iOS zoom on focus), safe-area insets, flex children that
   never shrink to zero, readable form text, and keyboard focus kept clear
   of the pinned phone tab bar.
   =========================================================================== */

:root {
  /* ---- surfaces ---- */
  --paper: #f6f3ec;            /* page ground (keep equal to theme-color in base.html) */
  --card: #ffffff;
  --sample-surface: #fbf8f1;   /* the "Preview" box on Home */
  --note-bg: #f3f0e8;
  --track: #e7e1d4;            /* empty part of a progress bar */
  --sample-fill: #9a927f;      /* filled part of a SAMPLE progress bar: muted, not the accent */
  --pill-bg: #ebe6db;          /* static role labels (filled, so they don't look like links) */
  --hover: #ece7dc;

  /* ---- lines ---- */
  --line: #ddd6c8;             /* card edges, dividers (decorative) */
  --line-strong: #8d8676;      /* form fields, quiet buttons: 3.6:1 on white */

  /* ---- text ---- */
  --ink: #1e2228;
  --ink-2: #4c525c;            /* secondary text: 7:1 on paper */
  --ink-3: #5f6570;            /* small notes: 5.3:1 on paper */

  /* ---- accent ---- */
  --accent: #24546b;           /* primary buttons, current tab: 8:1 with white */
  --accent-hover: #1b4357;
  --accent-soft: #e3edf1;      /* current tab / chip on desktop */
  --on-accent: #ffffff;

  /* ---- "sample", "not built yet" and status labels ---- */
  --sample-bg: #fbf0d6;
  --sample-line: #c9a85a;
  --sample-ink: #6a4d10;       /* 7:1 on --sample-bg */
  --status-bg: #edf0f3;
  --status-line: #b8c2cc;
  --status-ink: #36414c;

  /* ---- messages ---- */
  --ok-bg: #e8f3ea;  --ok-line: #9cc5a4;  --ok-ink: #1d4a27;
  --err-bg: #fbeae8; --err-line: #e2a49c; --err-ink: #7a1f16;
  --err-field: #b3261e;        /* edge of a field with a problem */
  --danger: #a3261e;           /* "Yes, remove" style buttons: 6.9:1 with white */
  --danger-hover: #861d17;
  --qr-bg: #ffffff;            /* QR codes need a plain white surround */
  --qr-ink: #000000;
  --print-bg: #ffffff; --print-ink: #000000;

  /* ---- keyboard focus ---- */
  --focus: #b45309;            /* amber ring, distinct from the blue accent */

  /* ---- type ---- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  /* ---- shape + spacing ---- */
  --radius: 16px;
  --radius-sm: 12px;
  --gutter: 20px;
  --column: 560px;             /* phone/tablet column width */
  --tabbar-h: 60px;
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  /* clip, not hidden: hidden would turn <body> into its own scroll box,
     which strands the end of long pages in iOS Safari. */
  overflow-x: clip;
}
h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; }
a { color: inherit; }

/* Keyboard focus: always visible. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
main:focus { outline: none; }            /* the skip-link target itself */

.skip-link {
  position: absolute; left: 12px; top: -200px; z-index: 100;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------------------
   App shell (signed in)
   --------------------------------------------------------------------------- */
/* A flex column whose children never shrink (flex-basis auto), so long pages
   always grow the document and stay reachable. */
.shell {
  max-width: var(--column);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page {
  flex: 1 0 auto;
  padding: 0 var(--gutter) calc(36px + env(safe-area-inset-bottom, 0px));
}
.has-tabbar .page {
  padding-bottom: calc(var(--tabbar-h) + 36px + env(safe-area-inset-bottom, 0px));
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--gutter) 10px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font-family: var(--font-serif); font-size: 1.375rem; font-weight: 700;
  letter-spacing: -.01em; line-height: 1.1; color: var(--ink); text-decoration: none;
}
.topbar .wordmark { min-height: 44px; display: inline-flex; align-items: center; flex: none; }
.topbar-end { display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); border: 1px solid var(--line);
  color: var(--accent); font-size: .8125rem; font-weight: 700; letter-spacing: .03em;
  text-decoration: none;
}
.avatar:hover { border-color: var(--line-strong); }
.avatar.is-active { border: 2px solid var(--accent); }

.chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  color: var(--ink); font-size: .875rem; font-weight: 700; text-decoration: none;
}
.chip:hover { background: var(--hover); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---- Tab bar: pinned to the bottom on phones ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: var(--column); margin: 0 auto;
  display: flex;
  padding: 0 8px env(safe-area-inset-bottom, 0px);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; min-height: var(--tabbar-h);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-size: .9375rem; font-weight: 600;
  text-decoration: none; border-radius: 10px;
}
.tab:hover { color: var(--ink); }
/* Current tab: accent colour, bolder AND underlined, so it never relies on colour alone. */
.tab.is-active {
  color: var(--accent); font-weight: 700;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 7px;
}
.tabbar .tab:focus-visible { outline-offset: -4px; }

/* While the tab bar is pinned (phones, and any window under 900px wide,
   including desktop browsers zoomed to 200%+), keep that strip out of the
   area the browser scrolls a focused control into. static/js/app.js covers
   WebKit, which doesn't scroll a control that is already on screen. */
@media (max-width: 899.98px) {
  html { scroll-padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px); }
}

/* ---------------------------------------------------------------------------
   Page content
   --------------------------------------------------------------------------- */
.page-head { padding-top: 28px; }
.page-head h1 {
  font-family: var(--font-serif); font-size: 1.875rem; line-height: 1.15;
  font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; text-wrap: balance;
}
.page-sub { margin-top: 8px; color: var(--ink-2); max-width: 720px; }
.eyebrow {
  margin-bottom: 6px; font-size: .8125rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3); overflow-wrap: anywhere;
}

.stack { margin-top: 24px; display: grid; gap: 16px; }
.card {
  min-width: 0; padding: 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.card p + p { margin-top: 10px; }
.card-title { font-size: 1.125rem; line-height: 1.3; font-weight: 700; }
.status-pill + .card-title { margin-top: 12px; }
.card-title + p, .card-title + .empty { margin-top: 10px; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.empty-lead { font-family: var(--font-serif); font-size: 1.25rem; line-height: 1.35; }
.empty p:not(.empty-lead) { color: var(--ink-2); }
.note {
  margin-top: 14px; padding: 10px 12px; border-radius: 10px;
  background: var(--note-bg); color: var(--ink-2); font-size: .9375rem;
}
.card p.note { margin-top: 14px; }

.status-pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  background: var(--status-bg); border: 1px solid var(--status-line); color: var(--status-ink);
}

/* ---- the clearly labelled sample box on Home ---- */
.card-sample { background: var(--sample-surface); border: 1px dashed var(--sample-line); }
.sample-tag {
  flex: none; padding: 1px 10px; border-radius: 999px; white-space: nowrap;
  font-size: .75rem; font-weight: 700; letter-spacing: .02em;
  background: var(--sample-bg); border: 1px solid var(--sample-line); color: var(--sample-ink);
}
.sample-note { margin-top: 8px; font-size: .9375rem; color: var(--ink-2); }
.sample-session {
  margin-top: 16px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.sample-session .block-label { margin-bottom: 4px; }
.session-title { font-family: var(--font-serif); font-size: 1.25rem; line-height: 1.3; font-weight: 700; overflow-wrap: anywhere; }
.reading { margin-top: 6px; }
.reading-label {
  margin-right: 6px; font-size: .75rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-3);
}
.meta { margin-top: 4px; font-size: .9375rem; color: var(--ink-2); }
.card .sample-session p + p { margin-top: 4px; }
.sample-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.card .sample-block p + p { margin-top: 2px; }
.block-label { font-size: .8125rem; font-weight: 700; color: var(--ink-2); }
progress.progress {
  -webkit-appearance: none; appearance: none; display: block;
  width: 100%; height: 8px; margin-top: 8px; border: 0; border-radius: 999px;
  background: var(--track); color: var(--accent); overflow: hidden;
}
.progress::-webkit-progress-bar { background: var(--track); border-radius: 999px; }
.progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* ---- "planned" lists on the placeholder pages ---- */
.planned-title {
  margin-top: 18px; font-size: .75rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-2);
}
.planned { list-style: none; margin-top: 8px; }
.planned li { position: relative; padding: 10px 0 10px 24px; border-top: 1px solid var(--line); }
/* An open circle: planned, not done. */
.planned li::before {
  content: ""; position: absolute; left: 3px; top: calc(10px + .45em);
  width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--line-strong);
}
.card-title + .planned { margin-top: 12px; }

.privacy { margin-top: 12px; }
.privacy > div { padding: 12px 0; border-top: 1px solid var(--line); }
.privacy dt { font-weight: 700; }
.privacy dd { margin-top: 2px; color: var(--ink-2); }

/* ---- account ---- */
.facts { margin-top: 10px; }
.facts > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.facts dt { color: var(--ink-2); }
.facts dd { font-weight: 700; text-align: right; overflow-wrap: anywhere; min-width: 0; }

/* ---- people and groups ---- */
.people, .groups { list-style: none; margin-top: 10px; }
.person, .group-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.person-name, .group-name { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.you { font-weight: 400; color: var(--ink-3); }
.role-pill {
  flex: none; padding: 2px 10px; border-radius: 6px; font-size: .75rem; font-weight: 700;
  background: var(--pill-bg); color: var(--ink-2);
}
.role-leader { background: var(--accent); color: var(--on-accent); }
.count-pill {
  min-width: 28px; padding: 1px 9px; border-radius: 999px; text-align: center;
  font-size: .8125rem; font-weight: 700; background: var(--accent-soft); color: var(--accent);
}

.row-link {
  margin-top: 12px; min-height: 52px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  color: var(--ink); font-weight: 700; text-decoration: none;
}
.row-link:hover { background: var(--hover); }
.row-link svg {
  flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------------------------------------------------------------------------
   Buttons and messages
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-size: 1rem; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-quiet:hover { background: var(--hover); }

.flash-stack { padding-top: 16px; display: grid; gap: 8px; }
.flash { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9375rem; font-weight: 600; border: 1px solid; }
.flash-success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.flash-error { background: var(--err-bg); border-color: var(--err-line); color: var(--err-ink); }
.flash-warning { background: var(--sample-bg); border-color: var(--sample-line); color: var(--sample-ink); }
.offline-banner { margin-top: 12px; }
.flash-inline { padding: 0 0 10px; }
.offline-banner[hidden] { display: none; }
.announcement-card { border-left: 4px solid var(--accent); }
.announcement-text p + p { margin-top: 8px; }
.announcement-card .card-title + .announcement-text { margin-top: 8px; }
.announcement-meta { margin-top: 8px; font-size: .875rem; }

/* ---------------------------------------------------------------------------
   Signed-out pages: sign in, errors
   --------------------------------------------------------------------------- */
.public {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(32px + env(safe-area-inset-top, 0px)) var(--gutter) calc(32px + env(safe-area-inset-bottom, 0px));
}
.wordmark-large { margin-bottom: 20px; font-size: 2.25rem; text-align: center; }
.auth-card {
  width: 100%; max-width: 400px; padding: 24px 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
}
.auth-card h1 { font-family: var(--font-serif); font-size: 1.625rem; line-height: 1.2; font-weight: 700; }
.auth-sub { margin-top: 4px; color: var(--ink-2); }
.auth-card .flash { margin-top: 16px; }
.auth-card form { margin-top: 18px; }
.auth-card .btn { margin-top: 20px; }
.auth-foot { width: 100%; max-width: 400px; margin-top: 18px; text-align: center; font-size: .9375rem; color: var(--ink-2); }

/* ---------------------------------------------------------------------------
   Form fields. 16px text so iPhones don't zoom in on focus.
   --------------------------------------------------------------------------- */
.field { margin: 0; padding: 0; border: 0; min-width: 0; }
.field + .field { margin-top: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: .9375rem; font-weight: 700; }
.field input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.field input:focus-visible { border-color: var(--accent); outline-offset: 2px; }
.field input[aria-invalid="true"] { border-color: var(--err-field); border-width: 2px; }

.signout-form { margin: 0; }

/* ---------------------------------------------------------------------------
   Forms on cards, problems, confirmations (Stage 2 onwards)
   --------------------------------------------------------------------------- */
.field-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.field + .field-pair, .field-pair + .field { margin-top: 14px; }
.field-pair > .field + .field { margin-top: 0; }
.field textarea, .field select {
  width: 100%; padding: 10px 14px;
  font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field select { min-height: 48px; }
.field textarea:focus-visible, .field select:focus-visible { border-color: var(--accent); outline-offset: 2px; }
.field textarea[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--err-field); border-width: 2px; }
.field-hint { margin-top: 6px; font-size: .875rem; color: var(--ink-3); }
.field-error { margin-top: 6px; font-size: .9375rem; font-weight: 700; color: var(--err-field); }
.form-card .card-title + * { margin-top: 12px; }
.form-card > .card-title, .card > .card-title + form, .notes-card > .card-title { margin-bottom: 12px; }
.form-card .btn { margin-top: 18px; }
.form-card > .field-hint { margin-top: 8px; }
.form-errors { margin: 0 0 14px; }
.form-errors p { font-weight: 700; }
.form-errors ul { margin-top: 6px; padding-left: 20px; font-weight: 600; }
.form-errors a { color: inherit; }

.btn-danger { background: var(--danger); color: var(--on-accent); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-small { min-height: 44px; padding: 0 14px; font-size: .9375rem; }
.btn[hidden] { display: none; }
.inline-form { margin: 0; flex: none; }

.action-card > * + * { margin-top: 12px; }
details.confirm > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm[open] > summary { background: var(--hover); }
details.confirm > p { margin-top: 12px; color: var(--ink-2); }
details.confirm > form { margin-top: 12px; }
details.confirm + details.confirm { margin-top: 12px; }

.back-link {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 0 6px -6px;
  padding: 10px 6px; min-height: 44px;
  color: var(--ink-2); font-size: .9375rem; font-weight: 700; text-decoration: none;
}
.back-link:hover { color: var(--ink); text-decoration: underline; }
.back-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.tool-list { list-style: none; display: grid; gap: 12px; }
.tool-list .row-link { margin-top: 0; }
.row-link-tall { min-height: 72px; padding: 12px 16px; }
.row-link-tall span { display: flex; flex-direction: column; gap: 2px; }
.row-link-tall small { font-weight: 400; font-size: .9375rem; color: var(--ink-2); }

.card-flush { padding-top: 4px; padding-bottom: 4px; }
.card-flush .people { margin-top: 0; }
.people > li:first-child > .person, .people > li.person:first-child { border-top: 0; }
.person-link { color: inherit; text-decoration: none; min-height: 60px; }
.person-link:hover .person-name { text-decoration: underline; }
.person-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-meta { font-size: .875rem; color: var(--ink-3); overflow-wrap: anywhere; }

/* ---- invitation ---- */
.invite-card { text-align: center; }
.invite-card > * + * { margin-top: 12px; }
.qr-box { background: var(--qr-bg); border-radius: var(--radius-sm); padding: 14px; max-width: 280px; margin: 0 auto; border: 1px solid var(--line); }
.qr-box svg, .poster-qr svg { display: block; width: 100%; height: auto; }
.qr-box svg path, .poster-qr svg path { fill: var(--qr-ink); }
.invite-hint { color: var(--ink-2); }
.field-label { display: block; text-align: left; font-size: .9375rem; font-weight: 700; }
.invite-link {
  width: 100%; min-height: 48px; padding: 10px 14px;
  font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.invite-card .field-label + .invite-link { margin-top: 6px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button-row .btn { flex: 1 1 auto; white-space: nowrap; }
.copy-status { min-height: 1.4em; font-size: .9375rem; color: var(--ink-2); }
.invite-card .note { text-align: left; }

/* ---------------------------------------------------------------------------
   Study: sessions, passages, questions (Stage 3 onwards)
   --------------------------------------------------------------------------- */
.muted { color: var(--ink-3); }
.count { font-weight: 400; color: var(--ink-3); }
.btn-primary .count { color: inherit; }
.text-link { color: var(--accent); font-weight: 700; font-size: .9375rem; }
.section-heading { font-size: 1.25rem; font-weight: 700; margin: 8px 0 12px; }

.current-card > * + * { margin-top: 8px; }
.current-card .btn { margin-top: 16px; }
.current-card .eyebrow { margin-top: 12px; margin-bottom: 0; }
.current-card .note { margin-top: 16px; }
.current-card .note a { color: var(--accent); font-weight: 700; }
.session-title a { color: inherit; }

.readings { list-style: none; margin-top: 6px; }
.reading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 6px 0; }
.reading-ref { font-family: var(--font-serif); font-size: 1.1875rem; font-weight: 700; }
.reading-link { color: var(--accent); font-weight: 700; font-size: .9375rem; min-height: 44px; display: inline-flex; align-items: center; }
.reading-url { flex-basis: 100%; font-size: .875rem; color: var(--ink-3); overflow-wrap: anywhere; }
.edit-list .reading { border-top: 1px solid var(--line); padding: 10px 0; }
.edit-list .reading form { margin-left: auto; }

.gathering { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; color: var(--ink-2); }
.gathering svg { flex: none; width: 20px; height: 20px; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.intro { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.intro p + p, .question-prompt p + p { margin-top: 10px; }

.session-list { list-style: none; margin-top: 8px; }
.session-list > li + li { border-top: 1px solid var(--line); }
.session-link, .person-link {
  position: relative; padding-right: 28px;
}
.session-link::after, .person-link::after {
  content: ""; position: absolute; right: 6px; top: 50%; width: 8px; height: 8px;
  border-top: 2px solid var(--ink-3); border-right: 2px solid var(--ink-3);
  transform: translateY(-50%) rotate(45deg);
}
.session-link {
  display: flex; flex-direction: column; gap: 2px; padding-top: 12px; padding-bottom: 12px;
  padding-left: 0; min-height: 56px;
  color: inherit; text-decoration: none;
}
.session-link-title { font-weight: 700; }
.session-link:hover .session-link-title { text-decoration: underline; }
.session-link-meta { font-size: .9375rem; color: var(--ink-2); overflow-wrap: anywhere; }
.card-flush .session-list { margin-top: 0; }
.current-tag {
  display: inline-block; padding: 0 8px; border-radius: 6px; font-size: .75rem; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); vertical-align: 2px;
}
.eyebrow .status-tag, .eyebrow .current-tag { text-transform: none; letter-spacing: 0; }
.status-tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .75rem; font-weight: 700; letter-spacing: .02em; text-transform: none; }
.status-draft { background: var(--sample-bg); color: var(--sample-ink); }
.status-published { background: var(--ok-bg); color: var(--ok-ink); }
.status-archived { background: var(--pill-bg); color: var(--ink-2); }
.archived-note { margin: 0; }

.question-list { list-style: none; display: grid; gap: 16px; padding: 0; margin: 0; }
.question-number { font-size: .8125rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.question-prompt { margin-top: 6px; font-family: var(--font-serif); font-size: 1.1875rem; line-height: 1.45; }

/* ---- the leader's editor ---- */
.sub-form { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.sub-form > * + * { margin-top: 14px; }
.sub-title { font-size: 1rem; font-weight: 700; }
.ref-fieldset legend { font-size: .9375rem; font-weight: 700; padding: 0; margin-bottom: 4px; }
.ref-grid { margin-top: 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.ref-grid .field + .field { margin-top: 0; }
.ref-grid .field label { font-weight: 600; font-size: .875rem; }
.inline-add { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.inline-add .btn { margin-top: 12px; }
.edit-questions { list-style: none; padding: 0; margin: 8px 0 0; }
.edit-question { padding: 14px 0; border-top: 1px solid var(--line); }
.edit-question form .field { margin-top: 6px; }
.edit-question form > .btn { margin-top: 8px; }
.button-row-tight { margin-top: 8px; gap: 8px; }
.button-row-tight .btn { flex: 0 0 auto; }
.action-card form, .action-card details { display: block; }

/* ---------------------------------------------------------------------------
   Answers, notes and the private review (Stage 4 onwards)
   --------------------------------------------------------------------------- */
.privacy-strip {
  margin-bottom: 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--ink); font-size: .9375rem;
}
.privacy-strip p + p { margin-top: 4px; }
.private-tag {
  display: inline-block; margin-left: 4px; padding: 0 8px; border-radius: 6px;
  font-size: .75rem; font-weight: 700; vertical-align: 1px;
  background: var(--pill-bg); color: var(--ink-2);
}
.answer { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.answer > * + * { margin-top: 12px; }
.answer-state { font-size: .9375rem; color: var(--ink-2); }
.state-tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .75rem; font-weight: 700; margin-right: 4px; }
.state-none { background: var(--pill-bg); color: var(--ink-2); }
.state-draft { background: var(--sample-bg); color: var(--sample-ink); }
.state-submitted { background: var(--ok-bg); color: var(--ok-ink); }
.state-shared { background: var(--accent); color: var(--on-accent); }
.submitted-box, .readonly-draft {
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--paper); border: 1px solid var(--line);
}
.submitted-text p + p, .readonly-draft p + p, .review-text p + p { margin-top: 8px; }
.submitted-box .block-label + div, .readonly-draft .block-label + div { margin-top: 4px; }
.answer-form .field textarea { min-height: 120px; }
.answer-form .button-row { margin-top: 10px; }
.answer-form .field-hint { margin-top: 8px; }
.save-status { min-height: 1.4em; margin-top: 8px; font-size: .9375rem; color: var(--ink-2); }
.save-status.is-ok { color: var(--ok-ink); font-weight: 600; }
.save-status.is-error { color: var(--err-ink); font-weight: 600; }
.save-status .retry { margin-left: 4px; }
.other-version { margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.other-version summary { cursor: pointer; font-weight: 700; }
.other-version-text { margin-top: 6px; white-space: pre-wrap; color: var(--ink-2); }
.notes-card > * + * { margin-top: 10px; }
.notes-card textarea { min-height: 140px; }
.progress-block { margin-top: 14px; }

.review-note { margin: 0; }
.review-card > * + * { margin-top: 10px; }
.review-list { list-style: none; margin-top: 12px; }
.review-item { padding: 12px 0; border-top: 1px solid var(--line); }
.review-meta { font-size: .9375rem; }
.review-text { margin-top: 6px; }

/* ---------------------------------------------------------------------------
   Sharing and the group discussion screen (Stage 5)
   --------------------------------------------------------------------------- */
.share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.shared-answers { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.shared-answers .sub-title { font-size: .9375rem; }
.shared-answer { margin: 10px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.shared-answer figcaption { font-size: .875rem; font-weight: 700; color: var(--accent); }
.shared-text { margin-top: 4px; }
.shared-text p + p { margin-top: 8px; }
.shared-empty { margin-top: 8px; }
/* A sharing check failed: hide answer text until the server confirms again. */
.shares-unverified .shared-text { visibility: hidden; }
.shares-unverified .shared-answer::after {
  content: "Checking that this is still shared\2026"; display: block; margin-top: -1.2em;
  font-size: .875rem; color: var(--ink-2);
}
.share-preview { border: 2px solid var(--accent); }
.share-author { font-weight: 700; color: var(--accent); }
.plain-list { margin-top: 10px; padding-left: 20px; }
.plain-list li + li { margin-top: 6px; }

.discussion { max-width: min(92vw, 1400px); }
.discussion-body .shell { max-width: none; }
/* Shown to the whole group: no app header, tabs, unread badge or account
   button on the projected screen ("Leave discussion" is on the page). */
.discussion-body .topbar { display: none; }
.discussion-body .page { padding-bottom: 40px; }
.discussion-count { font-size: .9375rem; font-weight: 700; color: var(--ink-2); }
.discussion-question {
  font-family: var(--font-serif); font-size: 1.75rem; line-height: 1.25; margin-top: 6px;
  overflow-wrap: anywhere;
}
.discussion-answers { border-top: 0; padding-top: 0; margin-top: 20px; }
.discussion-answer { padding: 16px 18px; font-size: 1.1875rem; }
.discussion-empty {
  padding: 22px; border-radius: var(--radius); border: 1px dashed var(--line-strong);
  font-size: 1.125rem; color: var(--ink-2); background: var(--card);
}
.discussion-controls { margin-top: 20px; display: grid; gap: 10px; justify-items: start; }
.discussion-foot { margin-top: 18px; font-size: .9375rem; }
@media (min-width: 900px) {
  .discussion-question { font-size: clamp(2.25rem, 3.5vw, 4rem); }
  .discussion-answer { font-size: clamp(1.375rem, 2.2vw, 2.5rem); }
  .discussion-answer figcaption { font-size: clamp(.875rem, 1.2vw, 1.25rem); }
  .discussion-count, .discussion .eyebrow { font-size: clamp(.875rem, 1.1vw, 1.25rem); }
}

/* ---------------------------------------------------------------------------
   Chat (Stage 6)
   --------------------------------------------------------------------------- */
.unread-badge {
  display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; line-height: 20px; text-align: center; text-decoration: none;
  background: var(--danger); color: var(--on-accent);
}
.chat-note { margin: 0; }
.skip-to-composer { justify-self: start; min-height: 44px; display: inline-flex; align-items: center; }
.message-actions details.confirm { flex-basis: 100%; }
.message-actions details.confirm > p { font-size: .9375rem; }
.messages { list-style: none; display: grid; gap: 10px; padding: 0; margin: 0; }
.message {
  padding: 12px 14px; border-radius: var(--radius); background: var(--card);
  border: 1px solid var(--line); min-width: 0;
}
.message.mine { background: var(--accent-soft); border-color: var(--accent-soft); }
.message.removed { background: transparent; border-style: dashed; }
.message-meta { font-size: .875rem; }
.message-meta .muted { margin-left: 4px; }
.message-body { margin-top: 4px; overflow-wrap: anywhere; }
.message-body p + p { margin-top: 6px; }
.removed-text { margin-top: 4px; font-style: italic; color: var(--ink-3); }
.quote {
  margin-top: 6px; padding: 4px 10px; border-left: 3px solid var(--accent);
  font-size: .875rem; color: var(--ink-2); overflow-wrap: anywhere;
}
.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.react-chip {
  min-height: 44px; min-width: 52px; padding: 2px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--card); font: inherit; font-size: .9375rem;
  cursor: pointer; position: relative;
}
.react-chip.is-mine { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.message-actions { margin-top: 6px; }
.message-actions > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  cursor: pointer; list-style: none; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 700; color: var(--ink-2); background: var(--card);
}
.message-actions > summary::-webkit-details-marker { display: none; }
.message-actions > summary::after {
  content: ""; width: 7px; height: 7px; margin-left: 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}
.message-actions[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.message.mine .message-actions > summary { background: transparent; }
.action-panel-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0 2px; }
.react-pick { display: flex; flex-wrap: wrap; gap: 2px; }
.react-btn {
  min-width: 44px; min-height: 44px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; font-size: 1.25rem; cursor: pointer;
}
.react-btn:hover { background: var(--hover); }
.unread-divider { list-style: none; text-align: center; font-size: .8125rem; font-weight: 700; color: var(--danger); }
.unread-divider span { padding: 0 10px; background: var(--paper); }
.unread-divider { border-top: 2px solid var(--danger); margin-top: 8px; line-height: 0; padding-top: 0; }
.chat-update { min-height: 0; font-size: .875rem; color: var(--ink-3); }
.composer > * + * { margin-top: 10px; }
.composer textarea { min-height: 80px; }
.reply-bar { font-size: .9375rem; color: var(--ink-2); overflow-wrap: anywhere; }
.reply-bar .text-link { margin-left: 6px; }

/* Very short windows (a phone on its side, or 300-400% zoom): text boxes
   shrink so a focused one still fits above the pinned tab bar. They scroll
   inside, and can still be dragged taller. */
@media (max-height: 500px) {
  .field textarea, .answer-form .field textarea, .notes-card textarea {
    min-height: 0; height: 30vh; max-height: 30vh;
  }
}

.auth-wide { max-width: 480px; }
.auth-foot a { color: var(--accent); font-weight: 700; }

/* ---------------------------------------------------------------------------
   Desktop: wider page, tabs move into the header
   --------------------------------------------------------------------------- */
@media (min-width: 900px) {
  :root { --gutter: 32px; }
  .shell { max-width: 1080px; }
  .topbar { gap: 28px; padding-top: 16px; padding-bottom: 16px; }

  .tabbar {
    position: static; z-index: auto; flex: 1; max-width: none; margin: 0;
    gap: 6px; padding: 0; background: transparent; border: 0;
  }
  .tab { flex: 0 0 auto; min-height: 44px; padding: 0 18px; border-radius: 999px; }
  .tab:hover { background: var(--hover); }
  .tab.is-active { background: var(--accent-soft); text-decoration: none; }
  .tabbar .tab:focus-visible { outline-offset: 2px; }

  .has-tabbar .page { padding-bottom: 56px; }
  .page-head { padding-top: 40px; }
  .page-head h1 { font-size: 2.375rem; }
  .page-sub { font-size: 1.0625rem; }

  .stack.narrow { max-width: 720px; }
  /* Phone-width buttons would be heavy 720px slabs here. */
  .stack > .btn-block, .stack > form:not(.card) > .btn-block { width: auto; min-width: 14rem; justify-self: start; }
  .stack > form:not(.card) { justify-self: start; }
  .card { padding: 24px; }
}

/* ---------------------------------------------------------------------------
   Printing the invitation: only the poster goes on paper.
   --------------------------------------------------------------------------- */
.print-poster { display: none; }
@media print {
  body.has-print-poster { background: var(--print-bg); color: var(--print-ink); }
  body.has-print-poster .skip-link,
  body.has-print-poster .topbar,
  body.has-print-poster .page > :not(.print-poster) { display: none !important; }
  body.has-print-poster .shell, body.has-print-poster .page { display: block; min-height: 0; padding: 0; }
  body.has-print-poster .print-poster { display: block; text-align: center; padding-top: 24px; }
  .poster-title { font-family: var(--font-serif); font-size: 28pt; font-weight: 700; }
  .poster-sub { font-size: 14pt; }
  .poster-qr { width: 9cm; margin: 18px auto 8px; }
  .poster-hint { font-size: 14pt; font-weight: 700; }
  .poster-url { margin-top: 10px; font-size: 10pt; overflow-wrap: anywhere; }
}

/* Windows high-contrast and other forced-colour modes keep shapes visible. */
@media (forced-colors: active) {
  .btn, .tab.is-active, .chip, .sample-tag, .status-pill, .role-pill { border: 1px solid CanvasText; }
  .tab.is-active { text-decoration: underline; }
}
