/* =========================================================
   LGCYBOX UI refresh — imported from the claude.ai/design
   "LGCYBOX UI Refresh" project (tokens.css + desktop.jsx).
   Selected pieces: global pill nav (B), authed dashboard
   hero+ring (C/H), memo grid + freshness chips (D/I),
   activity feed (E), trustees panel (F), support PageCode (J).

   All styling lives here as classes — the strict CSP forbids
   inline style="" attributes, so the design's inline styles
   were lifted into the rules below.
   ========================================================= */

:root {
  --paper: #f6f1ea;
  --paper-2: #efe7d8;
  --surface: #fffefb;
  --surface-2: #fbf6ec;
  --ink: #1a2540;
  --ink-2: #4b5469;
  --ink-3: #8a8e9d;
  --line: #e5ddd0;
  --line-2: #d8cdb8;
  --terra: #b8624a;
  --terra-2: #934a36;
  --sage: #5e7a5c;
  --sage-2: #466a44;
  --amber: #c99b3d;
  --rose: #a8453c;
  --gold: #b48a4a;
  --serif: "Newsreader", "Source Serif Pro", Georgia, serif;
  --sans: "Geist", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", monospace;
  --r-2: 12px;
  --r-3: 20px;
  --r-4: 28px;
  --sh-1: 0 1px 2px rgba(26, 37, 64, .04), 0 2px 8px rgba(26, 37, 64, .03);
  --sh-2: 0 2px 6px rgba(26, 37, 64, .05), 0 16px 40px rgba(26, 37, 64, .08);
}

/* =========================================================
   B — Global navigation restyle.
   Overrides static/css/styles_topnav5.css (loaded earlier,
   so equal-specificity rules here win on source order).
   ========================================================= */

/* The base .app-header is dark navy with `!important` (sticky-bleed fix in
   styles.css). The refresh nav is a light paper bar, so override the bg
   with matching weight and re-tone the brand text that was light-on-dark. */
.app-header {
  /* Dark navy bar for maximum contrast against the paper page. */
  background: var(--ink) !important;
  border-bottom: 1px solid rgba(246, 241, 234, .12);
  box-shadow: var(--sh-2);
}

.brand-link .brand-label,
.brand-label {
  font-family: var(--serif);
  letter-spacing: .04em;
  font-weight: 600;
  color: var(--paper);
}
.brand-link small { color: rgba(246, 241, 234, .6); }

/* Logo sits to the LEFT of the menu bar on one row (the design layout),
   instead of stacked above it. The brand keeps its intrinsic width; the
   menu takes the rest of the row. */
.app-header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand-link { flex: 0 0 auto; }

.menu {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  margin: 0;
  max-width: none;
  flex: 1 1 auto;
  min-width: 0;
}

/* Right-align the account / login menu so primary links group by the logo
   and the user controls sit at the far end of the bar. */
.menu > ol > li.menu-item-user,
.menu > ol > li.menu-item-push { margin-left: auto; }

@media (max-width: 899px) {
  /* Narrow screens: fall back to brand on top, menu below. */
  .app-header-inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .menu { flex: none; }
  .menu > ol > li.menu-item-user,
  .menu > ol > li.menu-item-push { margin-left: 0; }
}

.menu > ol > li > a {
  color: rgba(246, 241, 234, .82);
  border-radius: 999px;
  font-family: var(--sans);
  font-weight: 500;
}
.menu > ol > li > a i {
  color: rgba(246, 241, 234, .55);
}
.menu > ol > li > a:hover,
.menu > ol > li > a:focus {
  color: var(--paper);
  background: rgba(246, 241, 234, .12);
}
.menu > ol > li > a:hover i,
.menu > ol > li > a:focus i {
  color: var(--paper);
}

/* Active page pill — terracotta pops against the dark bar. */
.menu > ol > li > a.is-active {
  color: #fff;
  background: var(--terra);
}
.menu > ol > li > a.is-active i { color: #fff; }

.menu-cta {
  background: var(--terra) !important;
  color: var(--surface) !important;
  box-shadow: none;
}
.menu-cta:hover,
.menu-cta:focus {
  background: var(--terra-2) !important;
  color: var(--surface) !important;
}

.menu-item-user > a {
  background: rgba(246, 241, 234, .08);
  border: 1px solid rgba(246, 241, 234, .15);
}
.menu-item-user .user-avatar {
  background: var(--terra);
  color: #fff;
}
.menu-item-user .user-name { color: var(--paper); }

/* Sub-menu surfaces stay light; just re-tone to the warm palette. */
.menu .sub-menu {
  background: var(--surface);
  border-color: var(--line);
}
.menu .sub-menu .menu-item a { color: var(--ink-2); }
.menu .sub-menu .menu-item a i { color: var(--ink-3); }
.menu .sub-menu .menu-item a:hover,
.menu .sub-menu .menu-item a:focus {
  background: color-mix(in oklab, var(--terra) 14%, var(--surface));
  color: var(--terra-2);
}
.menu .sub-menu .menu-item a:hover i,
.menu .sub-menu .menu-item a:focus i { color: var(--terra-2); }

@media (max-width: 899px) {
  .menu .sub-menu,
  .menu .sub-menu-right { background: var(--surface-2); }
  .menu .sub-menu .menu-item a { color: var(--ink-2); }
}

/* =========================================================
   .lg — shared design-system primitives (scoped so they
   don't leak onto Bootstrap pages).
   ========================================================= */

.lg, .lg * { box-sizing: border-box; }
.lg {
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
.lg .serif { font-family: var(--serif); }
.lg .mono { font-family: var(--mono); }

.lg .eyebrow {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  margin: 0;
}

.lg .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
}

.lg .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.lg .btn:hover { text-decoration: none; }
.lg .btn--terra { background: var(--terra); border-color: var(--terra); color: var(--surface); }
.lg .btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }

.lg .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.lg .chip--sage  { background: #e9efe6; border-color: #cdd9c8; color: var(--sage-2); }
.lg .chip--terra { background: #f5e3dc; border-color: #e7c6b8; color: var(--terra-2); }
.lg .chip--amber { background: #f4e6c4; border-color: #e3cf8f; color: #826322; }

.lg .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.lg svg { display: block; }

/* =========================================================
   .lg-dash — authed dashboard layout (home.html when signed in).
   ========================================================= */

/* The dashboard page paints its whole background paper so the content
   blends edge-to-edge with the (paper) header instead of sitting as a
   rectangle on the default app-body gradient. */
body.lg-page { background: var(--paper); }

.lg-dash {
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 8px 0 16px;
}

/* C/H — hero banner + freshness ring */
.lg-dash .hero {
  padding: 40px;
  border-radius: var(--r-4);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: center;
  background: linear-gradient(120deg, var(--surface) 0%, var(--surface-2) 100%);
}
.lg-dash .hero h1 {
  margin: 0;
  font-size: 42px;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.lg-dash .hero h1 .muted { color: var(--ink-2); }
.lg-dash .hero .hero-eyebrow { margin: 0 0 14px; }
.lg-dash .hero .hero-lede {
  margin: 16px 0 24px;
  font-size: 17px;
  color: var(--ink-2);
  max-width: 560px;
}
.lg-dash .hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.lg-dash .ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.lg-dash .ring-wrap .ring-caption {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 500;
  text-align: center;
}
.lg-dash .ring-track { stroke: rgba(26, 37, 64, .08); }
.lg-dash .ring-value { stroke: var(--terra); }
.lg-dash .ring-num { font-family: var(--serif); fill: var(--ink); font-weight: 500; }
.lg-dash .ring-pct { fill: var(--ink-3); }

/* Section headers shared by memo/activity/trustees */
.lg-dash .sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}
.lg-dash .sec-head h2 { margin: 0; font-size: 28px; font-weight: 500; }
.lg-dash .sec-head h3 { margin: 0; font-size: 22px; font-weight: 500; }
.lg-dash .sec-link { font-size: 14px; color: var(--ink-2); text-decoration: none; }
.lg-dash .sec-link:hover { color: var(--terra-2); }

/* D/I — memo grid */
.lg-dash .memo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.lg-dash .tile {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 168px;
  text-decoration: none;
  color: inherit;
}
.lg-dash .tile {
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.lg-dash .tile:hover,
.lg-dash .tile:focus-visible {
  box-shadow: var(--sh-2);
  transform: translateY(-3px);
  border-color: var(--terra);
  outline: none;
}
.lg-dash .tile:hover .tile-icon,
.lg-dash .tile:focus-visible .tile-icon { border-color: var(--terra); }
.lg-dash .tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lg-dash .tile-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: color-mix(in oklab, var(--paper) 60%, white);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.lg-dash .tile-icon i { font-size: 20px; line-height: 1; }
.lg-dash .tile-icon.ic-fin { color: var(--memo-fin); }
.lg-dash .tile-icon.ic-personal { color: var(--memo-personal); }
.lg-dash .tile-icon.ic-terra { color: var(--terra); }
.lg-dash .tile-icon.ic-sage  { color: var(--sage); }
.lg-dash .tile-icon.ic-gold  { color: var(--gold); }
.lg-dash .tile-icon.ic-ink   { color: var(--ink); }
.lg-dash .tile-icon.ic-ink-2 { color: var(--ink-2); }
.lg-dash .tile-icon.ic-terra-2 { color: var(--terra-2); }
.lg-dash .tile-icon.ic-sage-2 { color: var(--sage-2); }
.lg-dash .tile-icon.ic-rose  { color: var(--rose); }
.lg-dash .tile-name { font-family: var(--serif); font-size: 20px; font-weight: 500; }
.lg-dash .tile-count { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

/* Two-column lower section */
.lg-dash .dash-cols {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 24px;
}
.lg-dash .panel { padding: 28px; }

/* E — activity feed */
.lg-dash .act-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.lg-dash .act-row:first-of-type { border-top: 0; }
.lg-dash .act-when { font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
.lg-dash .act-what { font-size: 14px; color: var(--ink); }
.lg-dash .act-empty { font-size: 14px; color: var(--ink-3); padding: 8px 0; }

/* F — trustees panel */
.lg-dash .trustee-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.lg-dash .trustee-row:first-of-type { border-top: 0; }
.lg-dash .trustee-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
}
.lg-dash .trustee-avatar.a-terra { background: var(--terra); }
.lg-dash .trustee-avatar.a-sage  { background: var(--sage); }
.lg-dash .trustee-avatar.a-gold  { background: var(--gold); }
.lg-dash .trustee-name { font-size: 15px; font-weight: 500; }
.lg-dash .trustee-sub { font-size: 12px; color: var(--ink-3); }
.lg-dash .panel-add {
  width: 100%;
  margin-top: 14px;
}

/* Dashboard footer */
.lg-dash .dash-foot {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  font-size: 13px;
  color: var(--ink-3);
}

@media (max-width: 991px) {
  .lg-dash .memo-grid { grid-template-columns: repeat(2, 1fr); }
  .lg-dash .dash-cols { grid-template-columns: 1fr; }
  .lg-dash .hero { grid-template-columns: 1fr; }
  .lg-dash .hero h1 { font-size: 32px; }
}
@media (max-width: 575px) {
  .lg-dash .memo-grid { grid-template-columns: 1fr; }
  .lg-dash .hero { padding: 28px; }
  .lg-dash .panel { padding: 20px; }
}

/* =========================================================
   GLOBAL APP SKIN — carry the warm-paper refresh across every
   page, not just the dashboard. The app's components read from
   the --color-* custom properties defined in styles.css, so the
   bulk of the reskin is just remapping those tokens onto the
   refresh palette below. This block loads last, so it wins.
   ========================================================= */

:root {
  /* Surfaces + lines */
  --color-bg-deep: var(--paper);
  --color-bg-gradient-start: var(--paper);
  --color-bg-gradient-end: var(--paper-2);
  --color-surface: var(--surface);
  --color-surface-muted: var(--surface-2);
  --color-surface-alt: var(--paper-2);
  --color-border: var(--line);
  --color-border-strong: var(--line-2);
  /* Ink */
  --color-ink: var(--ink);
  --color-ink-soft: var(--ink-2);
  --color-ink-muted: var(--ink-3);
  --color-ink-faint: var(--ink-3);
  /* Accent → terracotta */
  --color-primary: var(--terra);
  --color-primary-hover: var(--terra-2);
  --color-primary-soft: #f5e3dc;
  --color-accent: var(--terra);
  /* Status */
  --color-success: var(--sage-2);
  --color-warning: var(--amber);
  --color-danger: var(--rose);
  --color-danger-hover: #8a3a32;
}

/* Whole app sits on flat paper (not the old cool gradient), matching the
   dashboard + the paper header. */
.app-body {
  background: var(--paper);
  font-family: var(--sans);
}

/* Serif headings everywhere, like the dashboard. h6 stays the small-caps
   eyebrow it already is. */
.app-body h1, .app-body h2, .app-body h3, .app-body h4, .app-body h5 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -.01em;
}

/* Form controls + buttons don't inherit font-family from the body — pin
   them to Geist so typography is identical on every page. */
.app-body input,
.app-body select,
.app-body textarea,
.app-body button,
.app-body .btn,
.app-body .form-control { font-family: var(--sans); }
.app-body .btn { font-weight: 500; }

/* --- Memo-type icon colours -------------------------------------------
   Kept consistent across the dashboard, tile pages and list pages:
   BLUE for financial memos, PINK/PURPLE for personal (written/will/
   funeral/video). Dashboard tile glyphs use --memo-fin / --memo-personal
   (see .tile-icon rules); list + tile cards use the gradients below. */
:root {
  --memo-fin: #2563eb;
  --memo-fin-2: #0ea5e9;
  --memo-personal: #7c3aed;
  --memo-personal-2: #ec4899;
}

/* Tile pages (.memo-tile-icon): financial blue is the default in
   memo_tiles.css; the personal grid carries .memo-tiles--personal. Make
   both explicit against the shared tokens. */
.memo-tile-icon { background: linear-gradient(135deg, var(--memo-fin), var(--memo-fin-2)); }
.memo-tiles--personal .memo-tile-icon { background: linear-gradient(135deg, var(--memo-personal), var(--memo-personal-2)); }

/* List-page cards (.memo-card), by section. Selectors mirror
   listanddetailspages.css so they win on source order. */
/* Financial → blue */
.memo-card[data-memo-type="bankaccount"]::before,
.memo-card[data-memo-type="cryptoaccount"]::before,
.memo-card[data-memo-type="cryptowallet"]::before,
.memo-card[data-memo-type="investment"]::before,
.memo-card[data-memo-type="loancreditcard"]::before,
.memo-card[data-memo-type="mortgage"]::before,
.memo-card[data-memo-type="pension"]::before,
.memo-card[data-memo-type="realestate"]::before,
.memo-card[data-memo-type="otherfinancial"]::before { background: linear-gradient(90deg, var(--memo-fin), var(--memo-fin-2)); }
.memo-card[data-memo-type="bankaccount"] .memo-card-icon,
.memo-card[data-memo-type="cryptoaccount"] .memo-card-icon,
.memo-card[data-memo-type="cryptowallet"] .memo-card-icon,
.memo-card[data-memo-type="investment"] .memo-card-icon,
.memo-card[data-memo-type="loancreditcard"] .memo-card-icon,
.memo-card[data-memo-type="mortgage"] .memo-card-icon,
.memo-card[data-memo-type="pension"] .memo-card-icon,
.memo-card[data-memo-type="realestate"] .memo-card-icon,
.memo-card[data-memo-type="otherfinancial"] .memo-card-icon { background: linear-gradient(135deg, var(--memo-fin), var(--memo-fin-2)); box-shadow: 0 12px 22px rgba(37, 99, 235, .22); }
/* Personal → pink/purple */
.memo-card[data-memo-type="funeral"]::before,
.memo-card[data-memo-type="videoimage"]::before,
.memo-card[data-memo-type="will"]::before,
.memo-card[data-memo-type="written"]::before { background: linear-gradient(90deg, var(--memo-personal), var(--memo-personal-2)); }
.memo-card[data-memo-type="funeral"] .memo-card-icon,
.memo-card[data-memo-type="videoimage"] .memo-card-icon,
.memo-card[data-memo-type="will"] .memo-card-icon,
.memo-card[data-memo-type="written"] .memo-card-icon { background: linear-gradient(135deg, var(--memo-personal), var(--memo-personal-2)); box-shadow: 0 12px 22px rgba(124, 58, 237, .22); }

/* Auth + feature icons (login/signup, marketing cards) → terracotta. */
.auth-card .auth-icon,
.feature-icon { background: var(--terra); }

/* Freshness badge on list-view memo cards (mirrors the dashboard chips). */
.memo-freshness {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.memo-freshness--fresh { background: #e9efe6; border: 1px solid #cdd9c8; color: var(--sage-2); }
.memo-freshness--stale { background: #f4e6c4; border: 1px solid #e3cf8f; color: #826322; }
.memo-freshness--muted { background: #ecebe7; border: 1px solid #d8d6cf; color: #76726a; }

/* Medical edit: rotate + disable URL buttons sit side by side, wrapping on
   narrow screens. Each is its own POST form, so flex the wrapper. */
.medical-url-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 28px;
}
.medical-url-actions .inline-form { margin: 0; }

/* --- Risk callouts ----------------------------------------------------
   Loud red banner for "your memos can never be released" + a softer amber
   note next to the "notify after death" toggle. Icon + body in a flex row. */
.danger-callout,
.warn-callout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 0 22px;
}
.danger-callout {
  background: #fbe9e7;
  border: 1px solid #e7a79c;
  color: #7d2418;
}
.warn-callout {
  background: #f8efd6;
  border: 1px solid #e3cf8f;
  color: #6f5618;
  margin: 18px 0 4px;
}
.danger-callout-icon,
.warn-callout-icon {
  flex: 0 0 auto;
  font-size: 20px;
  line-height: 1.4;
}
.danger-callout p,
.warn-callout p { margin: 6px 0 0; font-size: 14px; line-height: 1.5; }
.danger-callout strong { font-size: 15px; }
.danger-callout-fix { font-weight: 600; }
.danger-callout-fix a { color: inherit; text-decoration: underline; }
/* On list cards, pin the badge to the top-right corner like the dashboard
   tiles (the card is position:relative). */
.memo-card > .memo-freshness {
  position: absolute;
  top: 1.6rem;
  right: 1.5rem;
}

/* --- Text-size control (3 levels) -------------------------------------
   The class lands on <html> (set by js/text-size.js) and scales the whole
   page via zoom, so px- and rem-based type both grow/shrink together. */
html.ts-sm { zoom: 0.9; }
html.ts-md { zoom: 1; }
html.ts-lg { zoom: 1.15; }

.text-size-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}
.text-size-label { color: var(--ink-3); margin-right: 2px; }
.text-size-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--sans);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.text-size-btn-lg { font-size: 1.05em; }
.text-size-btn:hover { border-color: var(--terra); color: var(--terra-2); }
.text-size-btn[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

/* --- Separate section boxes site-wide ---------------------------------
   Drop the single big .page-surface card on every page; inner cards and
   sections then read as separate boxes on the paper background, matching
   the dashboard. Pages whose content isn't already a card get one below. */
.page-surface {
  /* display:contents removes the wrapper's box entirely, so it can never
     render as an outer card around the page's own cards — bulletproof
     against any cached/legacy .page-surface background rule. */
  display: contents;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.page-surface-inner { padding: 8px 0 16px; }

/* Guarantee a card for content blocks that aren't otherwise boxed:
   every styled-form variant (incl. styled-form-personal, which has no
   rule of its own in forms.css), legal text, and the .surface-box helper
   used by the delete-confirmation pages. */
[class^="styled-form-"],
[class*=" styled-form-"],
.legal-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 28px;
}
.legal-body { max-width: 820px; margin: 0 auto; }

/* auth-card pages (login, signup, change password, password reset, …) wrap
   a form in a card, but forms.css also auto-cards form[action][method] —
   two boxes. Strip the inner form's card so .auth-card is the single box.
   !important to beat the higher-specificity forms.css selector. */
.auth-card form {
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
}

/* No divider line / big gap between the last field and the submit button. */
.submit-buttons,
.one-submit-button {
  border-top: 0;
  padding-top: 0;
  margin-top: 0.75rem;
}

/* --- Rich-text editor (big memo notes) + rendered output -------------- */
.rt-hidden { display: none !important; }
.rt-editor {
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  overflow: hidden;
  background: var(--surface);
}
.rt-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.rt-btn {
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.rt-btn:hover { background: var(--surface); color: var(--ink); }
.rt-btn.is-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.rt-btn-clear { margin-left: auto; color: var(--ink-3); }
.rt-btn-clear:hover { background: #f5e3dc; color: var(--terra-2); }

/* Instant styled tooltip above each toolbar button (reads its aria-label). */
.rt-btn { position: relative; }
.rt-btn:hover::after,
.rt-btn:focus-visible::after {
  content: attr(aria-label);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 20;
  pointer-events: none;
}
.rt-btn:hover::before,
.rt-btn:focus-visible::before {
  content: "";
  position: absolute;
  top: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--ink);
  z-index: 20;
  pointer-events: none;
}

/* The Clear button sits at the right edge; right-align its tooltip so it
   doesn't spill past (and get clipped by) the editor box. */
.rt-btn-clear:hover::after,
.rt-btn-clear:focus-visible::after {
  left: auto;
  right: 0;
  transform: none;
}
.rt-btn-clear:hover::before,
.rt-btn-clear:focus-visible::before {
  left: auto;
  right: 8px;
  transform: none;
}
.rt-surface {
  min-height: 140px;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-wrap;
  outline: none;
}
.rt-surface:focus { box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--terra) 30%, transparent); }
.rt-surface p, .rich-content p { margin: 0 0 .5em; }
.rt-surface ul, .rt-surface ol,
.rich-content ul, .rich-content ol { margin: 0 0 .5em 1.25em; }

/* Rendered rich text (detail pages). pre-wrap keeps legacy plain-text
   line breaks; the tag rules handle editor output. */
.rich-content { white-space: pre-wrap; }
.rich-content strong, .rich-content b { font-weight: 700; }
.rich-content em, .rich-content i { font-style: italic; }
.rich-content u { text-decoration: underline; }

/* Delete confirmation reuses the detail-page .card layout. Cancel is a
   neutral pill; the confirm is a danger pill (the [href*=delete] rule in
   styles.css only colours <a> buttons, and our confirm is a <button>). */
.card-button-secondary,
.card-button-secondary:hover,
.card-button-secondary:focus {
  background: var(--surface);
  color: var(--ink) !important;
  border-color: var(--line-2);
  box-shadow: none;
}
.card-button-secondary:hover,
.card-button-secondary:focus { background: var(--surface-2); }
.card-button-danger {
  background: var(--rose);
  border-color: var(--rose);
  color: #fff !important;
}
.card-button-danger:hover,
.card-button-danger:focus {
  background: #8a3a32;
  border-color: #8a3a32;
  color: #fff !important;
  box-shadow: 0 6px 14px rgba(168, 69, 60, .35);
}

/* Simple table styling (cookie policy, etc.). */
.cookie-table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
}
.cookie-table th,
.cookie-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.cookie-table th { color: var(--ink-2); font-weight: 600; }
.cookie-table code { font-family: var(--mono); font-size: 13px; color: var(--terra-2); }

/* Pricing FAQ → carded list with divided question items. */
.pricing-faq {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 28px;
  margin-top: 24px;
  max-width: 820px;
}
.pricing-faq h2 { font-size: 1.4rem; margin: 0 0 4px; }
.pricing-faq h3 {
  font-size: 1.05rem;
  margin: 0;
  padding: 20px 0 6px;
  border-top: 1px solid var(--line);
}
.pricing-faq h3:first-of-type { border-top: 0; padding-top: 14px; }
.pricing-faq p { margin: 0; color: var(--ink-2); line-height: 1.55; }

/* Bulk-trustee controls: group label+field so the grid lays out cleanly
   (trustee | action | apply) instead of wrapping. */
.bulk-trustee-controls { background: var(--surface); border-color: var(--line); align-items: end; }
.bulk-trustee-field { display: flex; flex-direction: column; gap: 6px; }
.bulk-trustee-field > label,
.bulk-trustee-field-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-3);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.bulk-trustee-action { flex-direction: column; gap: 6px; }
.bulk-trustee-action label { font-weight: 500; color: var(--ink); }
.bulk-trustee-controls .button-48 { align-self: end; }

/* Tiles pages additionally lay their blocks out with an even gap. */
body.sectioned .page-surface-inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 8px 0 16px;
}
body.sectioned .page-surface-inner > * { margin: 0; }
body.sectioned .page-header { border-bottom: 0; padding-bottom: 0; }
body.sectioned .dashboard-intro { margin: 0; }
body.sectioned .how-it-works {
  margin: 0;
  padding: 28px;
  border-top: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
}

/* =========================================================
   MOBILE NAV — hamburger collapse + tap-to-open submenus.
   Desktop keeps the hover bar (styles_topnav5.css). Below
   899px the menu hides behind .nav-toggle and JS (nav.js)
   toggles .is-open / .submenu-open. This block loads last so
   it overrides the older hover-based mobile rules.
   ========================================================= */

/* Hamburger button — hidden on desktop, shown on narrow screens. */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper, #f6f1ea);
  font-size: 20px;
  cursor: pointer;
  transition: background 0.18s ease;
}
.nav-toggle:hover,
.nav-toggle:focus { background: rgba(255, 255, 255, 0.16); outline: 0; }

@media (max-width: 899px) {
  /* Brand + hamburger share the top row; the menu drops to a full-width
     row below and is hidden until toggled. Overrides the column layout
     set earlier in this file. */
  .app-header-inner {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }
  .brand-link { flex: 1 1 auto; }
  .nav-toggle { display: inline-flex; }

  .menu { flex: 1 1 100%; order: 3; }
  /* Collapsed by default; the hamburger adds .is-open to reveal it. */
  .menu > ol { display: none; }
  .menu.is-open > ol { display: flex; }

  /* Submenus open on tap (.submenu-open) instead of hover. Re-stating the
     hover selectors as display:none here (later source order, so they win)
     neutralises the touch-hostile hover rule from styles_topnav5.css. */
  .menu .sub-menu,
  .menu .sub-menu-right { display: none; }
  .menu > ol > li:hover > .sub-menu,
  .menu > ol > li:focus-within > .sub-menu { display: none; }
  .menu .menu-item.submenu-open > .sub-menu { display: block; }

  /* Rotate the caret on the open parent for an affordance. */
  .menu .menu-item.submenu-open > a .fa-caret-down { transform: rotate(180deg); }
  .menu .menu-item > a .fa-caret-down { transition: transform 0.18s ease; }

  /* Comfortable touch targets for every menu link. */
  .menu > ol > li > a,
  .menu .sub-menu .menu-item a,
  .menu .sub-menu .menu-item .logout-form button { min-height: 44px; }
}

/* =========================================================
   RESPONSIVE TABLES — the few raw data tables (activity log,
   medical access log, cookie list) would otherwise force a
   horizontal page stretch on phones. Let them scroll inside
   their own box instead of widening the viewport.
   ========================================================= */
@media (max-width: 575.98px) {
  .activity-table,
  .listing-table,
  .cookie-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
}

/* Build identifier in the footer — muted, monospace, unobtrusive.
   Lets you eyeball which commit an environment is serving. */
.app-footer .app-version {
  font-family: var(--mono, monospace);
  font-size: 12px;
  color: var(--ink-3, #8a93a6);
  opacity: 0.75;
}
