/* ─── Design Tokens ────────────────────────────────────────────────────── */
:root {
  --teal:           #2A9D8F;
  --teal-dark:      #1E7A6E;
  --teal-light:     #E8F5F3;
  --gold:           #E9A820;
  --gold-dark:      #C8891A;
  --gold-light:     #FEF5E0;
  --lavender:       #8B7FD4;
  --lavender-light: #F0EEFB;
  --lavender-dark:  #6B5EC7;
  --danger:         #E63946;
  --danger-light:   #FEECEE;
  --warning:        #F4A261;
  --warning-light:  #FEF3E8;
  --success:        #2A9D8F;
  --bg:             #F2F5F7;
  --card:           #FFFFFF;
  --text:           #1A2332;
  --text-muted:     #5A6A7E;
  --text-light:     #6B7A8F;
  --border:         #E2E8EF;
  --nav-bg:         #0B1622;
  --nav-text:       #C0D4E8;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:         0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg:      0 12px 40px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-teal:    0 6px 24px rgba(42,157,143,0.22);
  --shadow-gold:    0 6px 24px rgba(233,168,32,0.28);
  --radius-sm:      8px;
  --radius:         14px;
  --radius-lg:      20px;
  --font:           'Inter', system-ui, -apple-system, sans-serif;
  /* Headings use the same warm serif as the TPN Explorer site, so the two
     sit together as one family rather than looking like separate products. */
  --font-display:   'Fraunces', Georgia, 'Times New Roman', serif;
  --font-mono:      'SF Mono', 'Fira Code', 'Courier New', monospace;
}

/* ─── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; display: block; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
main { flex: 1; }

/* ─── Typography ───────────────────────────────────────────────────────── */
/* Metrics copied from the TPN Explorer stylesheet so headings on the two sites
   are genuinely identical, not just the same typeface. Weight stays at 600:
   Fraunces is not loaded heavier, and asking for 700 or 800 makes the browser
   synthesise a fake bold that looks wrong next to the real thing. */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.005em;
}
h1 { font-size: 2.1rem; }
h2 { font-size: 1.55rem; line-height: 1.2; }
h3 { font-size: 1.2rem;  line-height: 1.3; }
h4 { font-size: 1rem;    line-height: 1.35; }
/* Figures on the dashboard cards read as display type too, which is what gives
   the numbers their weight. */
.stat-value { font-family: var(--font-display); }
p  { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

.text-muted  { color: var(--text-muted); }
.text-light  { color: var(--text-light); }
.text-teal   { color: var(--teal); }
.text-gold   { color: var(--gold-dark); }
.text-danger { color: var(--danger); }
.text-sm     { font-size: 0.875rem; }
.text-xs     { font-size: 0.8125rem; }
.text-right  { text-align: right; }
.font-bold   { font-weight: 700; }
.text-center { text-align: center; }

/* ─── Keyframe animations ──────────────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(42,157,143,0); }
  50%       { box-shadow: 0 0 0 6px rgba(42,157,143,0.12); }
}
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes flowDrift {
  0%, 100% { transform: translateY(0) translateX(0); opacity: 0.25; }
  33%       { transform: translateY(-18px) translateX(8px); opacity: 0.45; }
  66%       { transform: translateY(-8px) translateX(-6px); opacity: 0.35; }
}
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@keyframes expandLine {
  from { width: 0; }
  to   { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ─── Navigation ───────────────────────────────────────────────────────── */
.nav {
  background: rgba(11,22,34,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.35);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.nav-logo:hover { text-decoration: none; opacity: 0.9; }
.nav-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(42,157,143,0.4);
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}
.nav-links a {
  color: var(--nav-text);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: all 0.18s;
  display: block;
  text-decoration: none;
}
.nav-links a:hover, .nav-links a.active {
  color: #fff;
  background: rgba(42,157,143,0.2);
}
.nav-cta {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%) !important;
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(42,157,143,0.3);
}
.nav-cta:hover {
  box-shadow: 0 4px 14px rgba(42,157,143,0.45) !important;
  transform: translateY(-1px);
}

/* ─── Dropdown nav ──────────────────────────────────────────────────────────── */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--nav-text);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.18s;
}
.nav-dropdown-toggle:hover,
.nav-dropdown-toggle.active {
  color: #fff;
  background: rgba(42,157,143,0.2);
}
.nav-dropdown-toggle svg { transition: transform 0.2s; }
.nav-dropdown.open .nav-dropdown-toggle svg { transform: rotate(180deg); }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: rgba(11,22,34,0.97);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  list-style: none;
  padding: 0.4rem;
  z-index: 200;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 0.55rem 0.9rem;
  color: var(--nav-text);
  font-size: 0.875rem;
  text-decoration: none;
  border-radius: 7px;
  transition: all 0.15s;
}
.nav-dropdown-menu a:hover,
.nav-dropdown-menu a.active {
  color: #fff;
  background: rgba(42,157,143,0.2);
}

.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 8px;
}
.nav-hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--nav-text);
  border-radius: 2px;
  transition: 0.3s;
}

/* ─── Layout ───────────────────────────────────────────────────────────── */
.container    { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 700px;  margin: 0 auto; padding: 0 1.5rem; }
/* Vertical only — these are routinely combined with .container/.container-sm,
   and the padding shorthand was wiping out the container's side padding, so
   content sat flush against the screen edge on phones. */
.section      { padding-top: 3rem;   padding-bottom: 3rem; }
.section-sm   { padding-top: 1.5rem; padding-bottom: 1.5rem; }

/* ─── Page Header ──────────────────────────────────────────────────────── */
.page-header {
  background: linear-gradient(135deg, var(--nav-bg) 0%, #122030 60%, #1A3040 100%);
  color: #fff;
  padding: 2.75rem 1.5rem 2.25rem;
  position: relative;
  overflow: hidden;
}
.page-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(42,157,143,0.5), transparent);
}
.page-header-inner { max-width: 1100px; margin: 0 auto; }
.page-header h1 {
  font-size: 1.85rem;
  margin-bottom: 0.4rem;
  display: flex; align-items: center; gap: 0.6rem;
}
.page-header p { color: var(--nav-text); margin: 0; font-size: 0.95rem; }

/* ─── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04),
              0 8px 28px rgba(0,0,0,0.09),
              inset 0 1px 0 rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.65);
  overflow: hidden;
  transition: box-shadow 0.22s ease, transform 0.22s ease;
}
.card:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.06),
              0 16px 40px rgba(42,157,143,0.14),
              inset 0 1px 0 rgba(255,255,255,0.95);
  transform: translateY(-3px);
}
.card-body { padding: 1.25rem 1.5rem; }
.card-header {
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid rgba(226,232,239,0.7);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.6) 0%, rgba(250,251,252,0.4) 100%);
}
.card-header h2, .card-header h3 { margin: 0; }
.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ─── Grid ─────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.25rem; }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(42,157,143,0.25);
}
.btn-primary:hover {
  box-shadow: var(--shadow-teal);
  background: linear-gradient(135deg, #2EB0A1 0%, var(--teal) 100%);
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--teal);
  color: var(--teal);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(233,168,32,0.25);
}
.btn-gold:hover { box-shadow: var(--shadow-gold); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c42d39; box-shadow: 0 4px 14px rgba(230,57,70,0.35); }

.btn-outline {
  background: transparent;
  color: var(--teal);
  border: 2px solid var(--teal);
}
.btn-outline:hover { background: var(--teal); color: #fff; }

.btn-sm  { padding: 0.38rem 0.85rem; font-size: 0.8rem; }
.btn-lg  { padding: 0.9rem 1.85rem;  font-size: 1rem; letter-spacing: 0.01em; }
.btn-full { width: 100%; }

/* A thumb needs roughly 44px to hit a control reliably. The small buttons used in table
   rows measured 24 to 30px tall, which is why editing a row on a phone took two or three
   attempts. Phone only, so desktop density is unchanged. */
@media (max-width: 700px) {
  .btn-sm { padding: 0.55rem 0.95rem; font-size: 0.85rem; min-height: 44px; }
  /* 2026-09-14: every button and form box at least 44px on a phone. Sweep found 25 buttons at 37-38px
     and Community's composer selects at 27px. */
  .btn { min-height: 44px; }
  table .btn, table .btn-sm { min-height: 44px; }
  main .form-select, main .form-input { min-height: 44px; }
  #pc-welcome-strip > button[aria-label="Dismiss"] { min-width: 44px; min-height: 44px; top: 0 !important; right: 0 !important; }
  .wall-filter-pill { min-height: 44px; display: inline-flex; align-items: center; }
  .avatar-link { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
  td .btn + .btn, td form + .btn, td .btn + form { margin-left: 0.25rem; }
  .reaction-btn, .community-comment-toggle { min-height: 40px; padding-top: 0.5rem; padding-bottom: 0.5rem; }
  #cookie-banner button { min-height: 40px; }
}

/* ─── Forms ────────────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 1.25rem; }
.form-label  { display: block; font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 0.4rem; }
/* Was display:flex, which turns every run of text and every link inside a hint into a
   separate flex item, so a hint containing a link laid itself out in columns. Hints are
   sentences, so they are a block; the icon some of them carry is aligned inline instead. */
.form-hint   { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-hint > svg { vertical-align: -0.15em; margin-right: 0.3rem; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  transition: border-color 0.18s, box-shadow 0.18s;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(42,157,143,0.12);
}
a:focus-visible, button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 3px; }
.form-textarea { resize: vertical; min-height: 100px; }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235A6A7E' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-divider { border: none; border-top: 1px solid var(--border); margin: 1.75rem 0; }
.form-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--teal);
  margin-bottom: 1rem;
}

/* ─── Alerts / Notices ─────────────────────────────────────────────────── */
.alert {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  /* flow-root (not flex): a flex container splits raw text mixed with
     <strong>/<a> into several separate anonymous flex items, each shrinking
     and wrapping independently instead of reading as one paragraph — this
     was scrambling every alert's text on narrow screens. flow-root keeps
     the floated icon contained without that side effect. */
  display: flow-root;
  border-left: 4px solid transparent;
}
.alert svg { float: left; margin-right: 0.6rem; margin-top: 0.05rem; }
.alert-error   { background: var(--danger-light); color: #8B1A22; border-color: var(--danger); }
.alert-danger  { background: var(--danger-light); color: #8B1A22; border-color: var(--danger); }
.alert-success { background: var(--teal-light);   color: var(--teal-dark); border-color: var(--teal); }
.alert-warning { background: var(--warning-light); color: #8B5A1A; border-color: var(--warning); }
.alert-info    { background: #EBF5FF; color: #1A4A8B; border-color: #4A90D9; }

/* ─── Role badges (admin panel) ────────────────────────────────────────────── */
.role-badge { display:inline-block; padding:0.15rem 0.55rem; border-radius:20px; font-size:0.75rem; font-weight:600; text-transform:capitalize; }
.role-badge.role-admin     { background:rgba(230,57,70,0.12);  color:#c0192a; }
.role-badge.role-moderator { background:rgba(244,162,97,0.18); color:#a0510a; }
.role-badge.role-user      { background:rgba(42,157,143,0.12); color:var(--teal-dark); }

/* ─── Demonstration-site banner ────────────────────────────────────────── */
.demo-banner {
  background: repeating-linear-gradient(
    45deg, #8a5a12, #8a5a12 12px, #7a4f0f 12px, #7a4f0f 24px);
  color: #fff;
  padding: 0.55rem 1.5rem;
  font-size: 0.85rem;
  line-height: 1.45;
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  text-align: center;
}
.demo-banner strong {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  background: rgba(0,0,0,0.28);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}
.demo-banner span { opacity: 0.95; }
/* The nav is sticky in places; keep the banner above it in the flow. */
.demo-mode .admin-tabs { top: auto; }
@media (max-width: 600px) {
  .demo-banner { padding: 0.5rem 1rem; font-size: 0.78rem; }
}

/* ─── Admin sub-navigation ─────────────────────────────────────────────── */
.admin-tabs {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.admin-tabs-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-tabs-inner::-webkit-scrollbar { display: none; }
.admin-tab {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.9rem 0.95rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.admin-tab:hover { color: var(--teal-dark); background: var(--bg); text-decoration: none; }
.admin-tab.active { color: var(--teal-dark); border-bottom-color: var(--teal); }

/* Compact key/value strip for secondary admin figures — nine equal cards of
   mostly zeros read as noise, this keeps the detail without the clutter. */
.admin-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0;
}
.admin-breakdown > div {
  padding: 0.9rem 1.1rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.admin-breakdown > div:last-child { border-right: 0; }
.admin-breakdown dt {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.admin-breakdown dd { font-size: 1.15rem; font-weight: 700; margin: 0; }

/* ─── Quick actions (dashboard) ────────────────────────────────────────── */
/* Was a plain flex-wrap, which left buttons breaking 1 / 2 / 1 / 1 down the
   phone view. A grid keeps them in even rows at every width. */
.quick-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.quick-actions .btn { justify-content: center; }
@media (max-width: 600px) {
  .quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .quick-actions .btn { width: 100%; }
  /* The primary "start/open feed" action reads as the main call to action. */
  .quick-actions .btn-primary { grid-column: 1 / -1; }
  .quick-actions > :last-child:nth-child(even) { grid-column: 1 / -1; }
}

/* ─── Stat Cards (dashboard) ───────────────────────────────────────────── */
.stat-card {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 28px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.65);
  border-top: 3px solid var(--teal);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover {
  box-shadow: var(--shadow-teal);
  transform: translateY(-3px);
}
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  animation: pulse 4s ease-in-out infinite;
}
.stat-icon:nth-child(1) { animation-delay: 0s; }
.stat-icon:nth-child(2) { animation-delay: 1s; }
.stat-icon:nth-child(3) { animation-delay: 2s; }
.stat-icon:nth-child(4) { animation-delay: 3s; }
.stat-icon-teal    { background: var(--teal-light);    color: var(--teal); }
.stat-icon-gold    { background: var(--gold-light);    color: var(--gold-dark); }
.stat-icon-lavender{ background: var(--lavender-light);color: var(--lavender); }
.stat-icon-danger  { background: var(--danger-light);  color: var(--danger); }
.stat-icon-danger  { background: var(--danger-light);  color: var(--danger); }
.stat-value { font-size: 1.25rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ─── Live clock (dashboard greeting) ─────────────────────────────────── */
.dash-clock { text-align: right; }
.dash-clock-time {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--teal);
  line-height: 1;
  letter-spacing: -0.02em;
}
.dash-clock-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ─── Badge ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-teal    { background: var(--teal-light);    color: var(--teal-dark); }
.badge-gold    { background: var(--gold-light);    color: var(--gold-dark); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-lavender{ background: var(--lavender-light);color: var(--lavender-dark); }
.badge-grey    { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* Two fields side by side, one under the other once there is no room. An inline
   grid-template-columns cannot do the second half, which left labels and hints
   wrapping into each other on a phone. */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1.25rem; }
@media (max-width: 700px) { .field-grid { grid-template-columns: 1fr; } }
/* ⛔ 2026-09-14: 45 layouts across the site set their columns inline ("1fr 1fr", a 220px sidebar,
   three across), and an inline grid cannot collapse, so on a phone information boxes were squashed
   past the edge and form boxes spilled off screen (measured at 360 and 390px). One rule folds them to
   a single column under 700px. New work should still use .field-grid, not an inline grid. The
   four-across icon row on Community is deliberately left alone. */
@media (max-width: 700px) {
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:220px 1fr"],
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns:1fr auto auto"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns"] > [style*="grid-column"] { grid-column: auto !important; }
}

/* ─── Table ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 640px; border-collapse: separate; border-spacing: 0; font-size: 0.9rem; }
th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(42,157,143,0.03); }

tbody tr { }

/* On a phone every table is wider than the screen and scrolls sideways, which used to
   take the first column, the one naming the thing, off screen with it. Pinning that
   column keeps the name in view while the numbers scroll under it. Sticky has no effect
   on a cell in a collapsed-border table, hence border-collapse: separate above. */
@media (max-width: 700px) {
  th:first-child, td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--card-bg, #fff);
    /* A box-shadow sits outside the cell and leaves a hairline the underlying column shows
       through. A border is part of the cell, so there is no seam to peek through. */
    border-right: 1px solid var(--border);
  }
  th:first-child { background: var(--bg); z-index: 3; }
  /* A tap leaves the row in :hover on a touch screen, and that rule repaints the pinned
     cell with a 3% translucent tint, which lets the columns scrolling underneath show
     through it as text over text. A hover tint is no affordance on a phone anyway. */
  tr:hover td { background: none; }
  tr:hover td:first-child { background: var(--card-bg, #fff); }

  /* A table of five columns cannot be read on a 390px screen however it scrolls, so the
     ones the user works through item by item become a card each: the name as a heading,
     every other cell labelled, and the input on its own line. */
  table.stack-on-phone { min-width: 0; width: 100%; display: block; }
  table.stack-on-phone thead { display: none; }
  table.stack-on-phone tbody { display: block; }
  table.stack-on-phone tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    margin: 0 0 0.6rem;
    background: var(--card-bg, #fff);
  }
  table.stack-on-phone td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    position: static;
    border: none;
    border-right: none;
    padding: 0.2rem 0;
    background: none;
  }
  table.stack-on-phone td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex: 0 0 auto;
  }
  table.stack-on-phone td.stack-title {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.4rem;
  }
  table.stack-on-phone td.stack-title::before { content: none; }
  table.stack-on-phone td.stack-action {
    display: block;
    margin-top: 0.5rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
  }
  table.stack-on-phone td.stack-action::before {
    display: block;
    margin-bottom: 0.3rem;
  }
  table.stack-on-phone td.stack-action .form-input { width: 100% !important; max-width: 100%; }
  table.stack-on-phone tr:last-child td { border-bottom: none; }
  /* A row of actions needs to sit as buttons side by side, not as a labelled value. */
  table.stack-on-phone td.stack-action[data-label=""],
  table.stack-on-phone td.stack-action:not([data-label]) { white-space: normal !important; }
  table.stack-on-phone td.stack-action:not([data-label])::before { content: none; }
  table.stack-on-phone td.stack-action .btn { min-height: 40px; }
  /* An item's Adjust or Edit form, a row directly under its own card. */
  table.stack-on-phone tr.stack-panel-row { border: none; padding: 0; background: none; margin: -0.35rem 0 0.9rem; }
  table.stack-on-phone td.stack-panel { display: block; padding: 0; }
  table.stack-on-phone td.stack-panel::before { content: none; }
  /* An edit form laid out two-up inline cannot fit a card on a phone: one column. */
  table.stack-on-phone td.stack-panel [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  table.stack-on-phone td.stack-panel [style*="grid-column"] { grid-column: auto !important; }
  table.stack-on-phone td.stack-panel form { padding: 0.75rem !important; }
  /* A cell whose heading is empty (the buttons column) and anything with an empty label shows no label. */
  table.stack-on-phone td[data-label=""]::before { content: none; }

  /* Stock sections: each wired item as a card with labelled amount boxes (the grid hid them off screen). */
  .sec-scroll { overflow-x: visible !important; }
  .sec-grid { display: block !important; min-width: 0 !important; }
  .sec-grid .sec-head { display: none; }
  .sec-grid .sec-row { display: block !important; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin: 0 0 0.6rem; background: var(--card-bg, #fff); }
  .sec-grid .sec-cell { display: flex !important; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.3rem 0 !important; border: none !important; }
  .sec-grid .sec-cell::before { content: attr(data-label); color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
  .sec-grid .sec-name { display: block !important; font-weight: 700; font-size: 1rem; }
  .sec-grid .sec-name::before, .sec-grid .sec-empty, .sec-grid .sec-actions::before { content: none; }
  .sec-grid .sec-empty { display: none !important; }
  .sec-grid .sec-add .sec-cell[data-label="Add an item"] { display: block !important; }
  .sec-grid .sec-add .sec-cell[data-label="Add an item"]::before { display: block; margin-bottom: 0.3rem; }
  .sec-grid .sec-actions { justify-content: flex-start; margin-top: 0.4rem; }
  .sec-grid .sec-actions .btn { min-height: 40px; }
}

/* ─── Emergency section ────────────────────────────────────────────────── */
.emergency-block {
  background: var(--danger-light);
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.emergency-block h3 { color: var(--danger); display: flex; align-items: center; gap: 0.5rem; }
.call-999 {
  background: linear-gradient(135deg, #c42d39 0%, var(--danger) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(230,57,70,0.3);
}

/* ─── Wellbeing / Mental Health ────────────────────────────────────────── */
.wellbeing-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--lavender);
  border-top: 4px solid var(--lavender);
  padding: 1.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
}
.wellbeing-card:hover {
  box-shadow: 0 6px 20px rgba(139,127,212,0.18);
  transform: translateY(-2px);
}
.mood-selector { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.mood-btn {
  padding: 0.45rem 0.9rem;
  border-radius: 2rem;
  border: 2px solid var(--border);
  background: var(--card);
  cursor: pointer;
  transition: all 0.18s;
  display: flex; align-items: center; gap: 0.4rem;
  color: var(--text-muted);
  font-family: var(--font);
}
.mood-btn .mood-label { font-size: 0.8rem; font-weight: 500; }
.mood-btn:hover, .mood-btn.selected {
  border-color: var(--lavender);
  background: var(--lavender-light);
  color: var(--lavender-dark);
  transform: scale(1.04);
  box-shadow: 0 2px 8px rgba(139,127,212,0.2);
}

/* ─── Community banner (matches hero palette) ──────────────────────────── */
.comm-banner {
  background: linear-gradient(-45deg, #0B1622 0%, #0F2535 30%, #1A3A4A 65%, #0D2030 100%);
  background-size: 400% 400%;
  animation: gradientShift 16s ease infinite;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.comm-banner .page-header-inner { position: relative; z-index: 1; }
.comm-banner p { color: rgba(255,255,255,0.72); margin: 0.25rem 0 0; }
.comm-banner-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%; height: 100%;
}

/* ─── Hero (landing) ───────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(-45deg, #0B1622 0%, #0F2535 30%, #1A3A4A 65%, #0D2030 100%);
  background-size: 400% 400%;
  animation: gradientShift 16s ease infinite;
  color: #fff;
  padding: 5.5rem 1.5rem 4.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%; height: 100%;
}
.hero > .container { position: relative; z-index: 1; }
.hero h1 {
  font-size: 2.9rem;
  font-weight: 600;
  margin-bottom: 1.35rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.hero h1 span { color: var(--gold); }
.hero p {
  font-size: 1.15rem;
  color: #A8C4D8;
  max-width: 560px;
  margin: 0 auto 2.5rem;
}
.hero-btns { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ─── Feature strip ────────────────────────────────────────────────────── */
.feature-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--teal-light);
  color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
  transition: transform 0.2s;
}
.feature-icon:hover { transform: scale(1.08); }

/* ─── Password show/hide ───────────────────────────────────────────────── */
.pw-wrap { position: relative; }
.pw-wrap .form-input { padding-right: 2.75rem; }
.pw-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  display: flex; align-items: center;
  transition: color 0.15s;
}
.pw-toggle:hover { color: var(--teal); }

/* ─── Auth pages ───────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, var(--bg) 0%, #EBF3F5 100%);
  position: relative;
  overflow: hidden;
}
.auth-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%; height: 100%;
  opacity: 0.5;
}
.auth-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(42,157,143,0.08);
  padding: 2.75rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: fadeSlideIn 0.4s ease both;
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo .logo-mark {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 0.85rem;
  color: #fff;
  box-shadow: var(--shadow-teal);
}
.auth-logo h1 { font-size: 1.45rem; margin-bottom: 0.25rem; }
.auth-logo p { color: var(--text-muted); font-size: 0.9rem; }
.auth-divider { text-align: center; color: var(--text-light); font-size: 0.85rem; margin: 1rem 0; }
.auth-footer { text-align: center; font-size: 0.875rem; color: var(--text-muted); margin-top: 1.5rem; }

/* ─── Dashboard layout ─────────────────────────────────────────────────── */
.dash-wrap {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: calc(100vh - 64px);
}
.sidebar {
  background: linear-gradient(180deg, #FFFFFF 0%, #F6F9FA 100%);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}
.sidebar-nav { list-style: none; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem 0.65rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.18s;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar-nav li a:hover {
  color: var(--text);
  background: rgba(42,157,143,0.06);
  border-left-color: rgba(42,157,143,0.3);
}
.sidebar-nav li a.active {
  color: var(--teal);
  background: var(--teal-light);
  border-left-color: var(--teal);
  font-weight: 600;
  margin-right: 0.5rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.sidebar-nav li a .nav-icon {
  width: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: 0.8;
}
.sidebar-nav li a.active .nav-icon { opacity: 1; }
.sidebar-section {
  padding: 1.1rem 1.5rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
}
.dash-content {
  padding: 2rem;
  overflow-y: auto;
  animation: fadeSlideIn 0.3s ease both;
  background-image: radial-gradient(circle, rgba(42,157,143,0.07) 1px, transparent 1px);
  background-size: 22px 22px;
  background-attachment: local;
}

/* Staggered card entrance */
.dash-content .card:nth-child(1) { animation: fadeSlideIn 0.35s 0.05s ease both; }
.dash-content .card:nth-child(2) { animation: fadeSlideIn 0.35s 0.12s ease both; }
.dash-content .card:nth-child(3) { animation: fadeSlideIn 0.35s 0.19s ease both; }
.dash-content .card:nth-child(4) { animation: fadeSlideIn 0.35s 0.26s ease both; }
.dash-content .card:nth-child(5) { animation: fadeSlideIn 0.35s 0.33s ease both; }
.dash-content .card:nth-child(6) { animation: fadeSlideIn 0.35s 0.40s ease both; }

/* Animated underline on form section titles */
.form-section-title {
  position: relative;
  padding-bottom: 0.35rem;
}
.form-section-title::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--teal), var(--teal-dark));
  border-radius: 2px;
  animation: expandLine 0.55s 0.1s ease forwards;
}

/* ─── Progress/status indicator ───────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
}
.status-green  { background: #2ECC71; }
.status-amber  { background: #F4A261; }
.status-red    { background: var(--danger); }

/* ─── Utility ──────────────────────────────────────────────────────────── */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-sm      { gap: 0.5rem; }
.gap         { gap: 1rem; }
.gap-lg      { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.hidden { display: none !important; }

/* ─── Footer ───────────────────────────────────────────────────────────── */
footer {
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: 3rem 1.5rem 1.5rem;
  font-size: 0.875rem;
  border-top: 1px solid rgba(255,255,255,0.04);
}
footer .footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  /* Resources holds 9 fairly long labels, so it needs more room than the
     external-links column or the labels break mid-phrase. */
  grid-template-columns: 1.6fr 2fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}
footer ul li { break-inside: avoid; }
footer a { color: var(--nav-text); transition: color 0.15s; }
footer a:hover { color: #fff; text-decoration: none; }
footer ul { list-style: none; }
footer ul li { margin-bottom: 0.5rem; }
.footer-bottom {
  max-width: 1100px;
  margin: 0 auto;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-light);
}
.footer-disclaimer {
  background: rgba(233,168,32,0.08);
  border-left: 3px solid rgba(233,168,32,0.5);
  padding: 0.75rem 1.1rem;
  font-size: 0.8rem;
  color: #A09080;
  max-width: 1100px;
  margin: 1rem auto 0;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ─── SVG icon helpers ─────────────────────────────────────────────────── */
.logo-svg { display: block; }
.role-icon-wrap {
  width: 36px; height: 36px;
  background: var(--teal-light); color: var(--teal);
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.footer-disclaimer-icon { flex-shrink: 0; margin-top: 0.1rem; opacity: 0.7; }
.feature-icon svg { display: block; }
.pw-toggle svg { display: block; }

/* ─── Print styles ─────────────────────────────────────────────────────── */
@media print {
  .nav, .sidebar, footer, .btn, .no-print, .dash-clock { display: none !important; }
  .dash-wrap { display: block; }
  .dash-content { padding: 0; animation: none; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; border-top: none; }
  .card:hover { transform: none; box-shadow: none; }
}

/* ─── Print passport ────────────────────────────────────────────────────── */

/* Screen: hide print-only elements */
.print-passport-header,
.print-passport-footer,
.print-value { display: none; }

@media print {
  /* Hide screen chrome */
  .no-print,
  nav, .sidebar, footer,
  .btn, button,
  .alert,
  .dash-clock { display: none !important; }

  /* Reset layout */
  body { background: #fff !important; color: #1A2332 !important; font-size: 10pt; margin: 0; }
  .dash-wrap { display: block !important; }
  .dash-content { padding: 0 !important; }
  main { padding: 0 !important; }

  /* Print header */
  .print-passport-header {
    display: block !important;
    padding: 0 0 1rem;
    border-bottom: 2px solid #2A9D8F;
    margin-bottom: 1rem;
  }
  .print-passport-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }
  .print-passport-logo {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #2A9D8F;
    margin-bottom: 0.5rem;
  }
  .print-passport-banner {
    background: #2A9D8F;
    color: #fff;
    font-weight: 700;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 0.4rem;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-passport-patient {
    font-size: 1.4rem;
    font-weight: 800;
    color: #1A2332;
    line-height: 1.1;
  }
  .print-passport-date {
    font-size: 0.75rem;
    color: #777;
    margin-top: 0.15rem;
  }
  .print-passport-qr img { display: block; border: 1px solid #ddd; }
  .print-passport-qr-label {
    font-size: 0.55rem;
    color: #999;
    text-align: center;
    margin-top: 0.2rem;
  }

  /* Cards */
  .card {
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    margin-bottom: 0.75rem !important;
    page-break-inside: avoid;
  }
  .card-header {
    border-bottom: 1px solid #2A9D8F !important;
    padding: 0.4rem 0.75rem !important;
  }
  .card-header h3 {
    font-size: 0.8rem !important;
    color: #2A9D8F !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .card-body { padding: 0.6rem 0.75rem !important; }

  /* Hide inputs, show print values */
  .form-input,
  .form-select,
  .form-textarea,
  .form-hint,
  .form-divider { display: none !important; }

  .print-value {
    display: block !important;
    font-size: 0.88rem;
    color: #1A2332;
    padding: 0.2rem 0;
    min-height: 1.2rem;
    font-weight: 500;
  }
  .print-value-allergies {
    color: #c0392b;
    font-weight: 700;
  }

  /* Labels */
  .form-label {
    font-size: 0.65rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.1rem !important;
  }
  .form-section-title {
    font-size: 0.6rem;
    color: #2A9D8F;
    border-bottom: 1px solid #2A9D8F;
    padding-bottom: 0.1rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  /* Emergency contact gets red accent */
  .print-section-emergency {
    border: 2px solid #c0392b !important;
  }
  .print-section-emergency .card-header {
    border-bottom: 1px solid #c0392b !important;
    background: #fdf0ef !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-section-emergency .card-header h3 { color: #c0392b !important; }

  /* Grid stays 2-col on print */
  .form-row { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 0.5rem !important; }

  /* Print footer */
  .print-passport-footer {
    display: block !important;
    text-align: center;
    font-size: 0.65rem;
    color: #aaa;
    border-top: 1px solid #ddd;
    margin-top: 1rem;
    padding-top: 0.5rem;
  }
}

/* ─── Documents ─────────────────────────────────────────────────────────── */
.doc-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg-alt);
}
.doc-dropzone:hover, .doc-dropzone.drag-over {
  border-color: var(--teal);
  background: var(--teal-light);
}
.doc-dropzone.has-file { border-color: var(--teal); background: var(--teal-light); }
.doc-dropzone-icon { color: var(--text-muted); margin-bottom: 0.75rem; }
.doc-dropzone.drag-over .doc-dropzone-icon,
.doc-dropzone.has-file .doc-dropzone-icon { color: var(--teal); }
.doc-dropzone-text { font-size: 0.9rem; color: var(--text); }
.doc-dropzone-link { color: var(--teal); font-weight: 600; }
.doc-dropzone-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.35rem; }
.doc-dropzone.has-file .doc-dropzone-hint { color: var(--teal-dark); font-weight: 600; }

.doc-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: var(--bg-alt); }
.doc-row-icon {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  color: var(--text-muted);
}
.doc-icon-pdf { background: #fdf0ef; color: var(--danger); }
.doc-icon-jpg, .doc-icon-png { background: var(--teal-light); color: var(--teal); }
.doc-type-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 0.45rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: currentColor;
  color: #fff;
  padding: 1px 3px;
  border-radius: 3px;
  line-height: 1.4;
}
.doc-icon-pdf .doc-type-badge { background: var(--danger); }
.doc-icon-jpg .doc-type-badge, .doc-icon-png .doc-type-badge { background: var(--teal); }
.doc-row-info { flex: 1; min-width: 0; }
.doc-row-name { font-size: 0.88rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-row-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }
.doc-row-actions { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; }
.doc-row-info .badge { white-space: nowrap; }
/* Phones: the buttons squeezed the letter details into a one word column. Buttons go on
   their own line under the details, lined up with the text, and the full name shows. */
@media (max-width: 700px) {
  .doc-row { flex-wrap: wrap; align-items: flex-start; }
  .doc-row-name { white-space: normal; overflow-wrap: anywhere; }
  .doc-row-actions { width: 100%; padding-left: calc(40px + 0.85rem); }
}
.btn-danger-outline {
  background: none;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  transition: background 0.15s, color 0.15s;
}
.btn-danger-outline:hover { background: var(--danger); color: #fff; }

/* ─── Insight chips ─────────────────────────────────────────────────────── */
.insight-chips {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.insight-chip {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  line-height: 1.45;
  animation: fadeSlideIn 0.35s ease both;
}
.insight-chip-icon {
  flex-shrink: 0;
  margin-top: 0.05rem;
}
.insight-chip-teal {
  background: var(--teal-light);
  color: var(--teal-dark);
  border-left: 3px solid var(--teal);
}
.insight-chip-gold {
  background: var(--gold-light);
  color: #7a5100;
  border-left: 3px solid var(--gold);
}
.insight-chip-danger {
  background: var(--danger-light);
  color: #8b1520;
  border-left: 3px solid var(--danger);
}
.insight-chip-lavender {
  background: var(--lavender-light);
  color: #4a3f8c;
  border-left: 3px solid var(--lavender);
}

/* ─── Feed Companion ────────────────────────────────────────────────────── */
.companion-wrap {
  min-height: 100vh;
  background: var(--nav-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 6rem 1.5rem 3rem;
  transition: background 0.4s ease;
}
.companion-wrap.night {
  background: #050a10;
}
.companion-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(16px);
  z-index: 100;
}
.companion-bar-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem 0.4rem;
  gap: 0.5rem;
}
.companion-bar-row2 {
  display: flex;
  align-items: center;
  padding: 0 1rem 0.5rem;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.companion-bar-row2::-webkit-scrollbar { display: none; }
.companion-tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.companion-tabs::-webkit-scrollbar { display: none; }
.companion-tab {
  padding: 0.28rem 0.85rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.12);
  transition: background 0.18s, color 0.18s;
}
.companion-tab:hover { color: #fff; background: rgba(255,255,255,0.18); text-decoration: none; }
.companion-tab.active { background: var(--teal); color: #fff; border-color: transparent; }

/* Multi-bag dashboard row */
.multi-bag-row {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.65);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(42,157,143,0.12);
  padding: 0.85rem 1.25rem;
}
.multi-bag-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.multi-bag-cards { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.multi-bag-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.85rem 0.5rem 0.5rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.18s, box-shadow 0.18s;
  font-size: 0.82rem;
}
.multi-bag-card:hover { border-color: var(--teal); box-shadow: 0 2px 8px rgba(42,157,143,0.15); text-decoration: none; color: var(--teal); }
.companion-back {
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: color 0.2s;
}
.companion-back:hover { color: #fff; }
.companion-feed-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.01em;
}
.companion-night-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0.4rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.companion-night-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

.companion-ring-wrap {
  position: relative;
  width: 240px;
  height: 240px;
  margin-top: 2rem;
}
.companion-ring { width: 240px; height: 240px; }
.companion-arc {
  transition: stroke-dashoffset 1s linear;
}
.companion-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.03em;
}
.night .companion-pct { color: var(--teal); }

.companion-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  width: 100%;
  max-width: 520px;
}
.companion-stat {
  text-align: center;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.5rem;
}
.night .companion-stat { background: rgba(255,255,255,0.04); }
.companion-stat-val {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--teal);
  line-height: 1.2;
}
.companion-stat-lbl {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.45);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.companion-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.companion-done {
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}
.companion-done-icon { color: var(--teal); }
.companion-done-msg {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

/* Mobile companion */
@media (max-width: 600px) {
  .companion-stats { grid-template-columns: repeat(2, 1fr); }
  .companion-ring-wrap { width: 200px; height: 200px; }
  .companion-ring { width: 200px; height: 200px; }
  .companion-pct { font-size: 2rem; }
}

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dash-wrap { grid-template-columns: 220px 1fr; }
}
@media (max-width: 900px) {
  .dash-wrap { grid-template-columns: 1fr; }
  .sidebar {
    display: none;
    position: fixed;
    top: 64px; left: 0;
    width: 260px;
    height: calc(100vh - 64px);
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { display: block; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  footer .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 0.85rem; }
  .companion-stats { grid-template-columns: repeat(2, 1fr); }
}
/* The full horizontal nav needs about 846px. Below that it used to run off
   the side of the screen, because the hamburger only appeared under 600px -
   so every tablet (iPad portrait is 810px) overflowed on every page. */
@media (max-width: 900px) {
  .nav-links {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 64px; left: 0; right: 0;
    max-height: calc(100dvh - 64px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--nav-bg);
    padding: 1rem;
    gap: 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .nav-links.open { display: flex; }
  .nav-hamburger { display: flex; }
  .nav-dropdown-toggle { width: 100%; justify-content: space-between; padding: 0.65rem 0.5rem; }
  .nav-dropdown-menu { position: static; box-shadow: none; border: none; background: rgba(255,255,255,0.05); border-radius: 8px; margin: 0.25rem 0 0.25rem 0.5rem; padding: 0.25rem; }
  .nav-dropdown-menu a { padding: 0.5rem 0.75rem; }
}

@media (max-width: 600px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  .section { padding-top: 1.5rem; padding-bottom: 1.5rem; }
  .hero { padding: 2.5rem 1rem 2rem; }
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: 0.9rem; }
  .grid-3 .card-body, .grid-2 .card-body { padding: 0.9rem 1rem; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  /* At-a-glance stat cards stay two-up on a phone — stacking five of them
     one-per-row turned the dashboard into a very long scroll. */
  .grid-stats { grid-template-columns: 1fr 1fr; }
  /* An odd number of cards leaves a stranded half-width card on the last
     row — let it span instead. */
  .grid-stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .form-row { grid-template-columns: 1fr; }
  .auth-card { padding: 2rem 1.25rem; }
  footer .footer-inner { grid-template-columns: 1fr; }
  footer .footer-inner > div:nth-child(n+2) { display: none; }
  .footer-bottom { flex-direction: column; gap: 0.5rem; text-align: center; }
  .dash-content { padding: 1.25rem 1rem; }
  .dash-clock-time { font-size: 1.3rem; }
  .stat-card { padding: 0.75rem 0.85rem; gap: 0.65rem; }
  .grid-4, .grid-5 { gap: 0.65rem; }
  .flex-between { flex-wrap: wrap; gap: 0.75rem; }
}
@media (max-width: 400px) {
  .companion-ring-wrap { width: 180px; height: 180px; }
  .companion-ring { width: 180px; height: 180px; }
}

/* ─── Dropdown slide-in animation ──────────────────────────────────────── */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.nav-dropdown.open .nav-dropdown-menu {
  animation: slideDown 0.18s ease both;
}

/* ─── Dropdown divider ──────────────────────────────────────────────────── */
.nav-dropdown-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 0.3rem 0.5rem;
  pointer-events: none;
}

/* ─── Nav badge (community notification count) ─────────────────────────── */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 999px;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1;
}

/* ─── Nav icon-only link (search) ────────────────────────────────────────── */
.nav-icon-link {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0.5rem !important;
  width: 36px;
  height: 36px;
}

/* ─── Hamburger → X transform ────────────────────────────────────────────── */
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ─── Scroll-reveal utility ─────────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Community wall page ────────────────────────────────────────────────── */
.community-layout-3col-wrap { max-width: 1240px; }
.community-layout-3col {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 300px;
  gap: 1.5rem;
  align-items: start;
}
.community-feed { min-width: 0; }
.community-identity,
.community-discovery { position: sticky; top: 80px; align-self: start; }

.community-identity-quicklinks {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.85rem;
}
.community-quicklink {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.community-quicklink:hover { background: var(--bg-alt); color: var(--teal); text-decoration: none; }

.community-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  justify-items: center;
}
.community-suggest-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
}

/* Author hover card */
.author-pop-anchor { position: relative; }
.author-pop-card {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 100;
  width: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  padding: 1rem;
  text-align: center;
}
.author-pop-anchor:hover .author-pop-card,
.author-pop-anchor:focus-within .author-pop-card { display: block; }

/* Author badge chip beside name */
.author-badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.68rem;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  background: var(--lavender-light);
  color: var(--lavender-dark);
  vertical-align: middle;
  margin-left: 0.2rem;
}

/* FAQ accordion (parents.php, carers.php) */
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; }
.faq-toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.9rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
}
.faq-toggle:hover { color: var(--teal); }
.faq-toggle svg { margin-left: auto; flex-shrink: 0; }
.faq-body { padding: 0 1.25rem 1rem; font-size: 0.9rem; color: var(--text-muted); line-height: 1.65; }
.faq-body p { margin: 0; }

/* Account type identity chip */
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 20px;
  vertical-align: middle;
}
.account-chip-teal    { background: var(--teal-light);    color: var(--teal-dark); }
.account-chip-gold    { background: var(--gold-light);    color: #92580a; }
.account-chip-lavender{ background: var(--lavender-light);color: var(--lavender-dark); }

.community-post {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  border-left: 3px solid transparent;
  transition: box-shadow 0.2s ease, transform 0.18s ease;
}
.community-post:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.community-post.is-pinned { border-left-color: var(--gold); }
.community-post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.community-post-author {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.community-post-author .avatar,
.community-post-author .avatar-letter { box-shadow: 0 0 0 2px var(--lavender-light); }
.community-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--lavender) 0%, var(--lavender-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.community-post-meta { font-size: 0.78rem; color: var(--text-muted); }
.community-post-body { font-size: 0.93rem; line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.community-post-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
}
.reaction-btn:hover { border-color: var(--lavender); color: var(--lavender-dark); background: var(--lavender-light); }
.reaction-btn.reacted { border-color: var(--lavender); color: var(--lavender-dark); background: var(--lavender-light); font-weight: 600; }
.reaction-btn.react-heart.reacted     { background: rgba(220,53,69,0.1);  color: #c0392b; border-color: rgba(220,53,69,0.3); }
.reaction-btn.react-helpful.reacted   { background: var(--teal-light);    color: var(--teal); border-color: rgba(42,157,143,0.35); }
.reaction-btn.react-inspiring.reacted { background: rgba(245,158,11,0.1); color: #b45309; border-color: rgba(245,158,11,0.3); }

.community-comment-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.community-comment-toggle:hover { color: var(--teal); background: var(--teal-light); }

.community-comments {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.community-comment {
  display: flex;
  gap: 0.65rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.community-comment:last-of-type { border-bottom: none; }
.community-comment-body { flex: 1; min-width: 0; }
.community-comment-text { font-size: 0.87rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.community-comment-meta { font-size: 0.74rem; color: var(--text-muted); margin-top: 0.2rem; }
.community-comment-form { margin-top: 0.75rem; display: flex; gap: 0.5rem; align-items: flex-start; }
.community-comment-form textarea { flex: 1; min-height: 56px; resize: vertical; font-size: 0.875rem; }

.community-new-post {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  border-top: 3px solid var(--lavender);
}
.community-new-post textarea { width: 100%; min-height: 90px; resize: vertical; margin-bottom: 0.75rem; }

.pin-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  background: var(--gold-light);
  color: var(--gold-dark);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Tablet: 2-col, identity as full-width top strip */
@media (max-width: 1099px) {
  .community-layout-3col { grid-template-columns: minmax(0, 1fr) 280px; }
  .community-identity { grid-column: 1 / -1; order: -1; position: static; }
  .community-identity-card .card-body {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    text-align: left;
    flex-wrap: wrap;
  }
  .community-identity-quicklinks { flex-direction: row; flex-wrap: wrap; margin-top: 0; }
}
/* Mobile: single column */
@media (max-width: 767px) {
  .community-layout-3col { grid-template-columns: 1fr; }
  .community-identity { order: 1; }
  .community-feed { order: 2; }
  .community-discovery { order: 3; position: static; }
  .author-pop-card { display: none !important; }
}

/* ─── Profile page ────────────────────────────────────────────────────────── */
.profile-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--lavender) 0%, var(--lavender-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.75rem;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

/* ─── Search page ─────────────────────────────────────────────────────────── */
.search-result {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
  border-radius: var(--radius-sm);
}
.search-result:hover { background: var(--teal-light); text-decoration: none; }
.search-result:last-child { border-bottom: none; }
.search-result-type {
  flex-shrink: 0;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.search-type-note       { background: var(--teal-light);     color: var(--teal-dark); }
.search-type-community  { background: var(--lavender-light); color: var(--lavender-dark); }
.search-type-medication { background: var(--gold-light);     color: var(--gold-dark); }
.search-type-team       { background: #e8eef5;               color: #34495e; }
.search-type-page       { background: #fdf3e3;               color: #92580a; }
.search-result-body { flex: 1; min-width: 0; }
.search-result-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.15rem; }
.search-result-snippet { font-size: 0.82rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.search-result-date { font-size: 0.75rem; color: var(--text-light); white-space: nowrap; }

/* ─── Avatar (shared letter-circle + photo) ──────────────────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}
.avatar-letter {
  background: linear-gradient(135deg, var(--lavender) 0%, var(--lavender-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
  user-select: none;
}
.avatar-link { display: inline-flex; text-decoration: none; flex-shrink: 0; }
.avatar-link:hover { opacity: 0.88; }

/* ─── Nav account avatar menu ────────────────────────────────────────────── */
.nav-account { position: relative; }
.nav-account-toggle {
  padding: 0.25rem !important;
  display: flex;
  align-items: center;
  gap: 0;
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
}
.nav-account-toggle .avatar,
.nav-account-toggle .avatar-letter {
  outline: 2px solid transparent;
  transition: outline-color 0.18s;
}
.nav-account-toggle:hover .avatar,
.nav-account-toggle:hover .avatar-letter,
.nav-account-toggle.active .avatar,
.nav-account-toggle.active .avatar-letter {
  outline-color: var(--teal);
}
.nav-account-badge {
  position: absolute;
  top: 0; right: 0;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  background: var(--danger);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--nav-bg);
  pointer-events: none;
}
.nav-account-menu {
  left: auto !important;
  right: 0 !important;
  min-width: 200px !important;
}
.nav-account-head {
  padding: 0.6rem 0.9rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0.25rem;
  pointer-events: none;
  color: var(--nav-text);
}
@media (max-width: 600px) {
  .nav-account-menu { left: 0 !important; right: 0 !important; }
}

/* ─── Community post photo grid ──────────────────────────────────────────── */
.cpm-grid {
  display: grid;
  gap: 3px;
  margin-top: 0.75rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cpm-grid-1 { grid-template-columns: 1fr; }
.cpm-grid-2 { grid-template-columns: 1fr 1fr; }
.cpm-grid-3 { grid-template-columns: 1fr 1fr; }
.cpm-grid-3 .cpm-img-wrap:first-child { grid-column: 1 / -1; }
.cpm-grid-4 { grid-template-columns: 1fr 1fr; }
.cpm-img-wrap { display: block; overflow: hidden; }
.cpm-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  transition: transform 0.22s ease;
}
.cpm-grid-1 .cpm-img { max-height: 420px; height: auto; object-fit: contain; }
.cpm-img-wrap:hover .cpm-img { transform: scale(1.03); }

/* ─── Wall filter pills ──────────────────────────────────────────────────── */
.wall-filter {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.wall-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--card);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all 0.18s;
}
.wall-filter-pill:hover { border-color: var(--lavender); color: var(--lavender-dark); text-decoration: none; }
.wall-filter-pill.active { background: var(--lavender-light); color: var(--lavender-dark); border-color: var(--lavender); font-weight: 600; }

/* ─── Friend grid & cards ────────────────────────────────────────────────── */
.friend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}
.friend-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  border: 1px solid var(--border);
}
.friend-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.friend-card-compact {
  flex-direction: column;
  justify-content: center;
  padding: 0.75rem 0.5rem;
  gap: 0.4rem;
  color: var(--text);
}
.friend-card-info { flex: 1; min-width: 0; }
.friend-card-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-card-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; flex-shrink: 0; }

/* ─── Profile header (redesigned) ───────────────────────────────────────── */
.profile-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem;
  align-items: start;
}
.profile-avatar-wrap { flex-shrink: 0; }
.profile-header-info { min-width: 0; }
.profile-header-actions {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.profile-social-bar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}
.profile-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--lavender-light);
  color: var(--lavender-dark);
  text-decoration: none;
  transition: background 0.18s, color 0.18s;
}
.profile-social-link:hover { background: var(--lavender-dark); color: #fff; text-decoration: none; }

@media (max-width: 540px) {
  .profile-header { grid-template-columns: 1fr; }
  .profile-avatar-wrap { margin: 0 auto; }
  .profile-header-actions { grid-column: 1; }
}

/* ── Post tags ─────────────────────────────────────────────────────────────── */
.post-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.post-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  background: var(--lavender-light);
  color: var(--lavender-dark);
  text-decoration: none;
  transition: background 0.15s;
}
.post-tag:hover { background: var(--lavender); color: #fff; text-decoration: none; }

/* ── @mention highlight ────────────────────────────────────────────────────── */
.mention { color: var(--lavender-dark); font-weight: 600; }

/* ── Messages layout ───────────────────────────────────────────────────────── */
.messages-inbox { border: 1px solid var(--border); border-radius: 0.75rem; overflow: hidden; }
.messages-inbox-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
  transition: background 0.15s;
}
.messages-inbox-item:hover { background: var(--surface-elevated); text-decoration: none; }
.messages-inbox-item.active { background: var(--lavender-light); }
.messages-thread { display: flex; flex-direction: column; gap: 0.5rem; }
.message-bubble {
  max-width: 75%;
  padding: 0.5rem 0.85rem;
  border-radius: 1rem;
  font-size: 0.88rem;
  line-height: 1.45;
}
.message-bubble.sent {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}
.message-bubble.received {
  align-self: flex-start;
  background: var(--surface-elevated);
  border-bottom-left-radius: 0.25rem;
}

/* ── Notifications ─────────────────────────────────────────────────────────── */
.notif-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  transition: background 0.15s;
}
.notif-row.unread {
  background: var(--surface-elevated);
  border-left: 3px solid var(--primary);
}
.notif-row:last-child { border-bottom: none; }

/* ── Badge display ─────────────────────────────────────────────────────────── */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.badge-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #78350f;
}

@media (max-width: 700px) {
  .messages-inbox { max-height: 200px; overflow-y: auto; }
}
/* touched 2026-07-07 - harmless comment, demo push for Daz to watch the dashboard live */

/* ─── Read-aloud walkthrough (demonstration mode) ──────────────────────── */
.ra-bar {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 10000; /* above the cookie banner, which is also bottom-fixed */
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(11,22,34,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 0.4rem 0.5rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.28);
  max-width: calc(100vw - 2rem);
}
.ra-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, opacity 0.15s;
}
.ra-btn:hover:not(:disabled) { background: rgba(255,255,255,0.2); }
.ra-btn:disabled { opacity: 0.35; cursor: default; }
.ra-btn-primary { background: var(--teal); padding: 0.45rem 0.9rem; }
.ra-btn-primary:hover:not(:disabled) { background: var(--teal-dark); }
.ra-label {
  color: rgba(255,255,255,0.75);
  font-size: 0.78rem;
  padding: 0 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ra-speed {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.ra-speed option { color: #1a2733; }

/* Whatever is being read gets marked, so it can be followed on screen. */
.ra-reading {
  background: var(--gold-light) !important;
  box-shadow: 0 0 0 4px var(--gold-light);
  border-radius: 4px;
  transition: background 0.2s;
}

@media (max-width: 600px) {
  .ra-bar { gap: 0.25rem; padding: 0.35rem 0.4rem; bottom: 0.6rem; }
  .ra-label { display: none; }
  .ra-btn { padding: 0.4rem 0.55rem; font-size: 0.8rem; }
  .ra-btn-primary span { display: none; }
}
@media print { .ra-bar { display: none; } }

/* Close control on the read-aloud bar, plus the quiet pill that brings it back.
   Hiding is remembered, so the bar must never be the only way to get it again. */
.ra-btn-close { font-size: 1.1rem; line-height: 1; opacity: 0.7; }
.ra-btn-close:hover { opacity: 1; }
.ra-reopen {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10000;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-family: inherit;
  color: #fff;
  background: rgba(11,22,34,0.9);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  cursor: pointer;
}
.ra-reopen:hover { background: rgba(11,22,34,1); }
@media print { .ra-reopen { display: none; } }

/* Voice picker sits with the speed control in the read-aloud bar. */
.ra-select-wrap { display: inline-flex; }
@media (max-width: 600px) {
  /* Two dropdowns plus four buttons will not fit a phone, so the voice
     picker gives way and the speed control stays. */
  .ra-select-wrap { display: none; }
}

/* Stock section rows: invisible wrappers on desktop so every cell stays in the one shared grid.
   On a phone they become cards (see the 700px block). */
.sec-grid .sec-row { display: contents; }

/* 2026-10-30: the Feed section (it has a "Used with" column) is too wide for a table even on a
   desktop, where the page column is about 600px, so it uses the phone cards at every width. */
.sec-scroll.sec-cards { overflow-x: visible !important; }
.sec-grid.sec-cards { display: block !important; min-width: 0 !important; }
.sec-grid.sec-cards .sec-head { display: none; }
.sec-grid.sec-cards .sec-row { display: block !important; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin: 0 0 0.6rem; background: var(--card-bg, #fff); }
.sec-grid.sec-cards .sec-cell { display: flex !important; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.3rem 0 !important; border: none !important; }
.sec-grid.sec-cards .sec-cell::before { content: attr(data-label); color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.sec-grid.sec-cards .sec-name { display: block !important; font-weight: 700; font-size: 1rem; }
.sec-grid.sec-cards .sec-name::before, .sec-grid.sec-cards .sec-empty, .sec-grid.sec-cards .sec-actions::before { content: none; }
.sec-grid.sec-cards .sec-empty { display: none !important; }
.sec-grid.sec-cards .sec-add .sec-cell[data-label="Add an item"] { display: block !important; }
.sec-grid.sec-cards .sec-add .sec-cell[data-label="Add an item"]::before { display: block; margin-bottom: 0.3rem; }
.sec-grid.sec-cards .sec-actions { justify-content: flex-start; margin-top: 0.4rem; }
.sec-grid.sec-cards .sec-actions .btn { min-height: 40px; }

/* 2026-11-23: messages page had an inline 220px + 1fr grid with no phone rule, so on a phone it ran 120px off
   the right edge. Same two columns on a wide screen, one column (card on top) under 768px. */
.messages-page-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 767px) { .messages-page-layout { grid-template-columns: minmax(0, 1fr); } }
