/* Venus Collective patient portal.
 *
 * One stylesheet for every portal page. It replaced four private <style>
 * blocks that had drifted: the signed-in shell, the chat page, the password
 * page and the sign-in page each carried their own copy of the same header
 * and their own hand-typed #6B4C8A, so a colour change touched four files and
 * missed one.
 *
 * THE PALETTE IS HER BRAND, and it is the one SHE chose. #101 derived a
 * burgundy palette from static/logo.png; she saw it and said no: "Red is
 * known to be an aggressive color, and I would prefer to be more calming and
 * inviting." These three values are sampled from the alternate logo she sent
 * on 2026-11-22 (#111). The neutrals are derived from her pink's and purple's
 * own hues rather than picked.
 *
 * Note for anyone tempted to re-derive this a third time: logo.png is one of
 * several logo variants she has, and the purple it replaced (#6B4C8A) was
 * within 1.30:1 of the purple she actually wanted. Ask her, do not sample.
 *
 * CONTRAST IS A RULE HERE, NOT A PREFERENCE, AND IT IS MEASURED AGAINST THE
 * SURFACE THE TEXT SITS ON, NOT AGAINST WHITE. --brand is 9.01:1 and carries
 * every piece of coloured text. --brand-accent looks like it could too, at
 * 4.67:1 on white, and cannot: these pages sit on --surface, where it is
 * 4.47:1, and on --brand-tint-soft, where it is 4.24:1. --brand-soft is
 * 1.87:1 and is never in the conversation.
 *
 * So the accent is a marker and a fill, which is the same category the old
 * coral was in at 3.4:1. It changed colour, not category. This paragraph
 * said the opposite until portal_palette_test.go was written and disagreed.
 * If you add a pair, measure it, and measure it on --surface.
 */

/* Playfair Display, self-hosted. #102.
 *
 * NOT loaded from Google Fonts. A fonts.googleapis.com link would send each
 * patient's IP and the referring URL to a third party, from a page whose body
 * is PHI and which already sets noindex and a no-referrer policy for exactly
 * that reason. One stylesheet link would undo all of it.
 *
 * Two files, and they are two SUBSETS rather than two weights: Google serves
 * one variable file covering the whole 400-700 range, so the URLs its API
 * gives for 400 and for 700 are byte-identical. latin-ext is here so a name
 * like Łukasz renders in Playfair rather than falling back to Georgia for
 * that one glyph and printing a patient's name in two fonts.
 *
 * font-display: swap, so the text is readable in Georgia while 38KB loads
 * rather than invisible. Georgia stays in the stack below: remove these two
 * files and the portal still reads correctly, which is the fallback #101
 * shipped and this does not replace.
 *
 * Playfair Display is SIL OFL 1.1; the licence is beside the files.
 */
@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/playfair-display-latin.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: "Playfair Display";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/playfair-display-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Brand, from the logo she chose. Named by ROLE, not by colour: the first
   * palette was named --burgundy and had to be renamed when she changed her
   * mind. The next change should be a value edit and nothing else.
   *
   * The three below are now her EXACT values, read from the text layer of
   * RBTL-LogoGuide.ai, which she attached on 2026-11-22 and nobody opened
   * until 2026-11-24. They were previously eyedropped from the JPEG in the
   * same mail and every one was a step or two out: #67337B for #67337A,
   * #CC3395 for #CB3694, #F5A7BC for #F6A8BC. Her names for them are jenny,
   * roseine and tela. Her other two, flo #B43938 and lily #DF6D26, are the
   * red and orange she rejected and are deliberately unused.                */
  --brand-deep:      #4F265E; /* the rail and the mobile header. Not one of  */
                              /* her five; jenny darkened for white text.    */
  --brand:           #67337A; /* jenny. buttons, links, all coloured text     */
  --brand-accent:    #CB3694; /* roseine. markers and fills. NEVER text:     */
                              /* 4.47:1 on --surface. See the note above.     */
  --brand-soft:      #F6A8BC; /* tela, the logo petal. Decoration, not text.  */
  --brand-tint:      #F8DDE4; /* small accents, selected states               */
  --brand-tint-soft: #FDF1F4; /* a tint behind a paragraph of text            */

  /* Surfaces: a near-white at her pink's hue, not the blue-grey of a
   * dashboard and no longer the warm cream that was tuned to burgundy.      */
  --surface:       #FDF9FA;
  --card:          #FFFFFF;
  --line:          #F2E9EB;
  --line-strong:   #E5D7DA;

  /* Ink, shifted to her purple's hue rather than red's */
  --ink:           #261F29;
  --ink-muted:     #706076;
  --ink-on-dark:   #FFFFFF;
  --ink-on-dark-muted: rgba(255,255,255,0.78);

  /* Status, warm-shifted so they sit in the same world */
  --ok-bg:         #E8F3EA;  --ok-ink:   #1F5130;  --ok-line: #C9E3D0;
  --warn-bg:       #FDF1E3;  --warn-ink: #7A4710;  --warn-line: #F2DBBD;
  --bad-bg:        #FBE9E9;  --bad-ink:  #8B1A1A;  --bad-line: #F0C9C9;

  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --space-1: 0.25rem; --space-2: 0.5rem;  --space-3: 0.75rem;
  --space-4: 1rem;    --space-5: 1.5rem;  --space-6: 2rem;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --rail-w: 15rem;
  --bar-h: 3.75rem; /* the phone tab bar, excluding the home-indicator inset */

  --shadow-card: 0 1px 2px rgba(42,32,34,0.05);
  --shadow-lift: 0 6px 20px rgba(42,32,34,0.12);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

/* ---- the top bar -------------------------------------------------------
 * On a phone this is the only chrome at the top: the wordmark, and the two
 * account controls. On desktop it stays, because the rail holds navigation
 * and this holds identity, and splitting them is what her Healthie screen
 * does too.
 */
.portal-top {
  background: var(--brand-deep);
  color: var(--ink-on-dark);
  padding: calc(env(safe-area-inset-top, 0px) + var(--space-3)) var(--space-4) var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 20;
}
/* nowrap on both ends: at 390px the wordmark broke across two lines and
   took "Sign out" with it, which made the bar twice as tall as it needed to
   be on the one width that can least afford it. */
.portal-top h1 { font-size: 1rem; margin: 0; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
.portal-top h1 a.home-link,
.portal-top h1 a.home-link:visited {
  color: var(--ink-on-dark);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  letter-spacing: 0.02em;
}
.portal-top a { color: var(--ink-on-dark-muted); text-decoration: none; font-size: 0.8125rem; }
.portal-top form { margin: 0; }
.portal-top a:hover, .portal-top a:focus-visible { color: var(--ink-on-dark); }
.header-links { display: flex; align-items: center; gap: var(--space-4); white-space: nowrap; }
@media (max-width: 24rem) {
  .portal-top { gap: var(--space-2); padding-left: var(--space-3); padding-right: var(--space-3); }
  .header-links { gap: var(--space-3); }
  .portal-top a { font-size: 0.75rem; }
}

/* ---- the rail / tab bar ------------------------------------------------
 * One element in the markup, two placements. A phone gets a fixed bottom tab
 * bar, which is the idiom for an installed PWA and where a thumb already is.
 * At 900px it becomes the full-height rail from her Healthie screenshot.
 *
 * The class name portal-nav is load-bearing: tests parse the document and
 * look for a <nav> carrying it on every surface, because a page that drops
 * the nav is a one-way door.
 */
.portal-rail {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: var(--card);
  border-top: 1px solid var(--line-strong);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.rail-brand { display: none; }

.portal-nav { display: flex; align-items: stretch; }
.portal-nav a {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-2) 2px calc(var(--space-2) + 2px);
  min-height: var(--bar-h);
  font-size: 0.6875rem;
  line-height: 1.1;
  text-align: center;
  color: var(--ink-muted);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Scoped to .portal-nav rather than to its anchors: the More control is a
   label, not a link, and an unsized SVG in a flex column grew to 74px and
   took the whole tab bar to 123px tall with it. */
.portal-nav .ico { width: 22px; height: 22px; flex: 0 0 auto; }
.portal-nav a.active { color: var(--brand); font-weight: 600; }
.portal-nav a.active::before {
  content: "";
  position: absolute;
  top: 0; left: 18%; right: 18%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--brand-accent);
}
.portal-nav a:hover { color: var(--brand); }

/* The count beside Forms. A patient who never opens Forms has to learn from
 * here that one is waiting, so it sits on the icon rather than after a label
 * that a narrow phone truncates. */
.nav-count {
  position: absolute;
  top: 4px;
  left: 50%;
  margin-left: 2px;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: var(--ink-on-dark);
  border-radius: var(--radius-pill);
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
}

/* "More" holds the surfaces a patient reaches less often. A checkbox drives
 * it rather than a script or a disclosure element: a closed <details> does
 * not render its contents, so the rail below could not reuse the same markup
 * and three surfaces vanished from the desktop sidebar. This one list serves
 * both shapes.
 */
.nav-more { flex: 1 1 0; min-width: 0; display: flex; }
.nav-more > summary {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-2) 2px calc(var(--space-2) + 2px);
  min-height: var(--bar-h);
  font-size: 0.6875rem;
  color: var(--ink-muted);
  cursor: pointer;
  list-style: none;
}
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more[open] > summary,
.nav-more.here > summary { color: var(--brand); font-weight: 600; }
.nav-more.here > summary::before {
  content: "";
  position: absolute;
  top: 0; left: 18%; right: 18%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--brand-accent);
}
.more-sheet {
  display: flex;
  flex-direction: column;
  position: absolute;
  bottom: 100%;
  right: var(--space-2);
  min-width: 13rem;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: var(--space-2);
  margin-bottom: var(--space-2);
}
.more-sheet a {
  flex: none;
  flex-direction: row;
  justify-content: flex-start;
  gap: var(--space-3);
  min-height: 2.75rem;
  padding: var(--space-3);
  font-size: 0.9375rem;
  border-radius: var(--radius-sm);
  text-align: left;
}
.more-sheet a.active { background: var(--brand-tint); }
.more-sheet a.active::before { display: none; }

/* ---- content ----------------------------------------------------------- */

main {
  flex: 1;
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4)
           calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + var(--space-5));
}

h2.page {
  font-family: var(--font-display);
  font-size: 1.625rem;
  line-height: 1.2;
  font-weight: 700;
  margin: var(--space-2) 0 var(--space-4);
  color: var(--ink);
}

/* A section label above a group. Small, spaced, quiet: it names the thing
 * below without competing with it. */
.portal-eyebrow {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: var(--space-5) 0 var(--space-2);
}
h2.page + .portal-eyebrow, .portal-eyebrow:first-child { margin-top: 0; }

.portal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-card);
}
.portal-card h2 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 var(--space-1);
}
.portal-card p { margin: 0; font-size: 0.9375rem; color: var(--ink-muted); line-height: 1.5; }

/* The one card that is the point of the page it sits on. */
.portal-card.feature {
  border-color: var(--line-strong);
  border-left: 4px solid var(--brand-accent);
}
.portal-card.quiet { background: var(--brand-tint-soft); border-color: transparent; box-shadow: none; }
.portal-card.quiet p { color: var(--ink); }

.portal-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: center;
  box-shadow: var(--shadow-card);
}
.portal-row .when { display: block; font-size: 0.8125rem; color: var(--ink-muted); margin-top: 0.15rem; }
.portal-row .meta { display: block; font-size: 0.8125rem; color: var(--ink-muted); margin-top: 0.35rem; }
/* A row whose action sits under its content rather than beside it, because
   the content is two or three lines and a pill on the right of that reads as
   belonging to the last line only. */
.portal-row.stacked { display: block; }
.portal-row.stacked a.row-link { display: inline-flex; margin: var(--space-3) var(--space-2) 0 0; }

/* ---- actions -----------------------------------------------------------
 * Three names for one button because three call sites could not share a
 * parent: card-link sits in a card, row-link in a row, portal-btn stands on
 * its own. They are deliberately identical.
 */
.portal-btn, .portal-card a.card-link, .portal-row a.row-link, button.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--brand);
  color: var(--ink-on-dark);
  border: 1px solid var(--brand);
  text-decoration: none;
  padding: 0.6rem 1.05rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  min-height: 2.75rem; /* a thumb target, not a mouse target */
}
.portal-card a.card-link { margin-top: var(--space-3); }
.portal-row a.row-link { flex: 0 0 auto; }
.portal-btn:hover, .portal-card a.card-link:hover, .portal-row a.row-link:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
}
/* The second action beside a first. Outlined: --brand text, never the accent. */
.portal-btn.quiet, .portal-row a.row-link.quiet, .portal-card a.card-link.quiet {
  background: var(--card);
  color: var(--brand);
  border-color: var(--brand);
}
.portal-btn.quiet:hover, .portal-row a.row-link.quiet:hover {
  background: var(--brand-tint);
  color: var(--brand-deep);
}
.portal-btn:disabled, button.portal-btn:disabled {
  background: var(--line-strong);
  border-color: var(--line-strong);
  color: var(--ink-muted);
  cursor: default;
}

a.text-link, a.text-link:visited { color: var(--brand); font-weight: 600; }
p.portal-action { margin: var(--space-3) 0; }
details.portal-disclosure { margin-top: var(--space-3); }
details.portal-disclosure form { margin-top: var(--space-3); }
form.portal-form { margin-top: var(--space-3); }
/* One booking slot. Each is its own POST, so they are forms rather than
   links, and they wrap like the buttons they look like. */
form.slot { display: inline-block; margin: 0 0.4rem 0.4rem 0; }
.service-name { font-weight: 600; font-size: 1rem; }
.service-length { font-size: 0.875rem; color: var(--ink-muted); margin-bottom: var(--space-2); }
.answer { margin-top: var(--space-3); }
.answer-label { display: block; color: var(--ink-muted); font-size: 0.8125rem; }
p.portal-back { margin: var(--space-5) 0 0; font-size: 0.875rem; }

/* A disclosure that reads as a link, for the secondary ask that would crowd
   the row it belongs to if it were always open. */
summary.link-summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brand);
  list-style: none;
}
summary.link-summary::-webkit-details-marker { display: none; }
summary.link-summary::after { content: " \25BE"; }
details[open] > summary.link-summary::after { content: " \25B4"; }

.portal-empty { color: var(--ink-muted); font-size: 0.9375rem; }

/* The quiet list at the foot of the home page. Deliberately not cards: these
   are already in the nav, and giving them the same weight as the two above
   is how that page became a menu of six identical tiles. */
ul.portal-links { list-style: none; margin: 0; padding: 0; }
ul.portal-links li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9375rem;
  line-height: 1.45;
}
ul.portal-links li:last-child { border-bottom: 0; }
ul.portal-links a, ul.portal-links a:visited {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}
ul.portal-links a:hover { text-decoration: underline; }
ul.portal-links span { color: var(--ink-muted); }
.portal-note {
  background: var(--brand-tint-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: 0.9375rem;
  color: var(--ink);
  margin-bottom: var(--space-4);
  line-height: 1.5;
}
.portal-note strong { color: var(--brand-deep); }
/* A note that closes a page rather than opening one. */
.portal-note.footnote { margin: var(--space-5) 0 0; }
.portal-note.bad { background: var(--bad-bg); color: var(--bad-ink); }
.portal-note.bad strong { color: var(--bad-ink); }
/* Kelly's note is the content of the page it sits on, not an aside about
   it, so it is a plain card. It read as a second caveat while it shared the
   tint of the caveat printed underneath it. Pre-wrap because she typed those
   line breaks and they are part of what she wrote. */
.portal-card.note { white-space: pre-wrap; line-height: 1.6; margin-top: var(--space-4); font-size: 0.9375rem; }
.portal-card.warn { background: var(--warn-bg); border-color: var(--warn-line); margin-top: var(--space-4); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-ok   { background: var(--ok-bg);   color: var(--ok-ink); }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge-bad  { background: var(--bad-bg);  color: var(--bad-ink); }
.badge-pink { background: var(--brand-tint);   color: var(--brand-deep); }

/* ---- forms ------------------------------------------------------------- */

label { display: block; font-size: 0.875rem; font-weight: 600; margin-top: var(--space-4); }
/* A field's own quiet label, where the question is the prompt and not a
   heading for a section. */
label.field-label { font-size: 0.8125rem; color: var(--ink-muted); margin: 0 0 var(--space-1); }
label.radio-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9375rem;
  font-weight: 500;
  margin: 0 var(--space-4) 0 0;
}
label.radio-inline input { width: auto; margin: 0; }
input[type="file"] { display: block; margin: var(--space-1) 0 var(--space-3); font-size: 0.875rem; max-width: 100%; }
input[type="text"], input[type="email"], input[type="tel"],
input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 1rem; /* never smaller: iOS zooms the page on a smaller field */
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  margin: var(--space-1) 0 var(--space-3);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 2px;
}
.err, .ok {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  font-size: 0.875rem;
  border: 1px solid;
}
.err { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad-line); }
.ok  { background: var(--ok-bg);  color: var(--ok-ink);  border-color: var(--ok-line); }
.small { font-size: 0.8125rem; color: var(--ink-muted); }
hr { border: none; border-top: 1px solid var(--line); margin: var(--space-6) 0 var(--space-4); }

/* ---- sign in -----------------------------------------------------------
 * The first screen a patient ever sees, and the only one with no nav. It
 * gets the wordmark large, because this is where a patient decides she is in
 * the right place.
 */
body.portal-auth { background: var(--surface); display: block; }
.auth-wrap { max-width: 26rem; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-6); }
.auth-mark { text-align: center; margin-bottom: var(--space-5); }
.auth-mark img { width: 7.5rem; height: auto; }
.auth-wrap h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 var(--space-1);
  text-align: center;
}
.auth-wrap p.sub {
  color: var(--ink-muted);
  margin: 0 0 var(--space-5);
  font-size: 0.9375rem;
  line-height: 1.5;
  text-align: center;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-4) var(--space-5);
  box-shadow: var(--shadow-card);
}
.auth-wrap button {
  width: 100%;
  margin-top: var(--space-4);
  background: var(--brand);
  color: var(--ink-on-dark);
  border: 1px solid var(--brand);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 2.75rem;
}
.auth-wrap button.secondary { background: var(--card); color: var(--brand); }
.auth-wrap button:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.auth-wrap button.secondary:hover { background: var(--brand-tint); color: var(--brand-deep); }
.channel { display: flex; gap: var(--space-2); margin-top: var(--space-1); }
.channel label {
  flex: 1;
  padding: 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  text-align: center;
  font-weight: 500;
  margin-top: 0;
  cursor: pointer;
}
.channel input { display: none; }
.channel input:checked + span { color: var(--brand); font-weight: 600; }
.channel label:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }

/* ---- chat --------------------------------------------------------------
 * The one page with its own shape: the thread scrolls and the composer is
 * pinned. On a phone the composer sits directly above the tab bar, so the
 * two stack and neither covers the other.
 */
body.portal-chat main {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
  max-width: 46rem;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + 4.75rem);
}
.push-banner {
  background: var(--brand-tint-soft);
  border-bottom: 1px solid var(--line-strong);
  padding: var(--space-3) var(--space-4);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.875rem;
}
.push-banner .btn-primary {
  background: var(--brand);
  color: var(--ink-on-dark);
  border: 1px solid var(--brand);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.push-banner .btn-ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid transparent;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  cursor: pointer;
}
.msg {
  max-width: 80%;
  padding: 0.6rem 0.85rem;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg .meta { display: block; font-size: 0.6875rem; opacity: 0.75; margin-top: var(--space-1); }
.msg-in { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg-out { align-self: flex-end; background: var(--brand); color: var(--ink-on-dark); border-bottom-right-radius: 5px; }
.msg-out .meta { color: rgba(255,255,255,0.78); }
.msg .attach-link { display: block; margin-top: var(--space-1); font-size: 0.8125rem; font-weight: 600; color: inherit; text-decoration: underline; }
.portal-composer {
  background: var(--card);
  border-top: 1px solid var(--line-strong);
  padding: var(--space-3) var(--space-4);
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
  z-index: 25;
}
.composer { display: flex; gap: var(--space-2); align-items: flex-end; max-width: 46rem; margin: 0 auto; }
.composer textarea {
  flex: 1;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  resize: none;
  font-family: inherit;
  min-height: 2.75rem;
  max-height: 8rem;
  margin-top: 0;
}
.composer button {
  background: var(--brand);
  color: var(--ink-on-dark);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  padding: 0.6rem 1.1rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 2.75rem;
}
.composer button:disabled { background: var(--line-strong); border-color: var(--line-strong); color: var(--ink-muted); cursor: default; }
#composer-ok { display: none; }

/* ---- 900px and up: the rail -------------------------------------------- */

@media (min-width: 900px) {
  .portal-rail {
    top: 0;
    right: auto;
    bottom: 0;
    width: var(--rail-w);
    background: var(--brand-deep);
    border-top: 0;
    border-right: 0;
    padding: var(--space-5) var(--space-3);
    padding-bottom: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    overflow-y: auto;
  }
  .rail-brand { display: block; text-align: center; }
  .rail-brand img {
    width: 5.5rem;
    height: auto;
    background: var(--brand-tint);
    border-radius: var(--radius);
    padding: var(--space-3);
  }

  .portal-nav { flex-direction: column; align-items: stretch; gap: 2px; }
  .portal-nav a {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-3);
    padding: 0.7rem var(--space-3);
    min-height: 2.75rem;
    font-size: 0.9375rem;
    text-align: left;
    color: var(--ink-on-dark-muted);
    border-radius: var(--radius-sm);
  }
  .portal-nav a:hover { color: var(--ink-on-dark); background: rgba(255,255,255,0.08); }
  .portal-nav a.active { color: var(--ink-on-dark); background: rgba(255,255,255,0.12); }
  .portal-nav a.active::before {
    top: 0.4rem; bottom: 0.4rem; left: 0; right: auto;
    width: 3px; height: auto;
    border-radius: 0 3px 3px 0;
  }
  /* White on the accent is 4.47:1 on our surfaces, which this rule exists to
     forbid. On the rail the pill inverts instead: --brand on white is 9.01:1. */
  .nav-count { position: static; margin-left: auto; background: var(--card); color: var(--brand); }

  /* Everything the phone hid behind More is just another rail item.
     Guarded on ::details-content: a closed <details> does not render its
     contents, so without that selector hiding the summary here would strand
     Documents, Medications and Billing with no way to reach them. An older
     browser keeps the summary and the popover instead. */
  @supports selector(::details-content) {
    .nav-more { display: contents; }
    .nav-more > summary { display: none; }
    .nav-more::details-content { content-visibility: visible; display: contents; }
  }
  .more-sheet {
    display: flex;
    flex-direction: column;
    position: static;
    min-width: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
    gap: 2px;
  }
  .more-sheet a { font-size: 0.9375rem; padding: 0.7rem var(--space-3); color: var(--ink-on-dark-muted); }
  .more-sheet a:hover { color: var(--ink-on-dark); background: rgba(255,255,255,0.08); }
  .more-sheet a.active { background: rgba(255,255,255,0.12); color: var(--ink-on-dark); }
  .more-sheet a.active::before { display: block; }

  .portal-top { padding-left: calc(var(--rail-w) + var(--space-5)); padding-right: var(--space-5); }
  main { padding-left: calc(var(--rail-w) + var(--space-5)); padding-right: var(--space-5); padding-bottom: var(--space-6); max-width: calc(46rem + var(--rail-w)); margin: 0; }
  .portal-composer { left: var(--rail-w); bottom: 0; padding-left: calc(var(--rail-w) + var(--space-5)); padding-right: var(--space-5); left: 0; }
  body.portal-chat main { padding-bottom: 5.5rem; }
  .composer { margin: 0; }
  h2.page { font-size: 1.875rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
