/* DoctorWithData v2 — design system 2.0
 * --------------------------------------------------------------------------
 * A contemporary clinical-research aesthetic. Indigo-violet primary, soft
 * layered shadows, Inter type, frosted-glass header, smooth micro-interactions,
 * automatic dark mode (prefers-color-scheme), full RTL support, and reduced-
 * motion guard. Every existing class name is preserved so React components
 * don't need any changes.
 * -------------------------------------------------------------------------- */

/* -- Type — Inter via system font stack with Google Fonts as progressive enhancement -- */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap");

/* ============================================================================
 *  Tokens
 * ============================================================================ */
:root {
  /* Colour scale — light mode */
  --bg:            #fafbfc;
  --bg-grad:       radial-gradient(ellipse at top, #f3f1ff 0%, #fafbfc 60%);
  --surface:       #ffffff;
  --surface-2:     #f6f7fa;
  --surface-3:     #ebeef3;
  --text:          #1a1d28;
  --text-2:        #2c3346;
  --text-muted:    #5a6478;
  --text-faint:    #8b94a7;
  --border:        #e6e9ef;
  --border-strong: #cdd2dc;

  /* Brand — indigo / violet */
  --primary:       #4f46e5;
  --primary-h:     #4338ca;
  --primary-soft:  #eef2ff;
  --primary-ring:  rgba(79, 70, 229, 0.12);
  --accent:        #14b8a6;
  --accent-soft:   #ecfdf5;

  /* Semantic */
  --success:       #10b981;
  --success-soft:  #ecfdf5;
  --warning:       #f59e0b;
  --warning-soft:  #fffbeb;
  --danger:        #ef4444;
  --danger-soft:   #fef2f2;

  /* Elevation — softer, layered */
  --sh-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --sh-lg: 0 12px 32px -8px rgba(15, 23, 42, 0.18), 0 4px 12px -3px rgba(15, 23, 42, 0.08);
  --sh-glow: 0 0 0 4px var(--primary-ring);

  /* Shape */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 120ms;
  --t-mid:  220ms;

  /* Layout */
  --container: 1140px;
  --content-padding: 24px;

  /* Type */
  --font-sans: "Inter", "Inter Variable", system-ui, -apple-system, "Segoe UI",
               "Roboto", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code",
               "Source Code Pro", Menlo, Consolas, monospace;
}

/* Auto dark mode — preserves the same shape language with a deep navy palette. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0b0e16;
    --bg-grad:       radial-gradient(ellipse at top, #1a1530 0%, #0b0e16 60%);
    --surface:       #141823;
    --surface-2:     #1b1f2e;
    --surface-3:     #232838;
    --text:          #e8eaee;
    --text-2:        #c5cad6;
    --text-muted:    #8b94a7;
    --text-faint:    #5a6478;
    --border:        #232838;
    --border-strong: #313748;
    --primary:       #818cf8;
    --primary-h:     #a5b4fc;
    --primary-soft:  rgba(129, 140, 248, 0.12);
    --primary-ring:  rgba(129, 140, 248, 0.18);
    --accent:        #2dd4bf;
    --accent-soft:   rgba(45, 212, 191, 0.12);
    --success-soft:  rgba(16, 185, 129, 0.12);
    --warning-soft:  rgba(245, 158, 11, 0.12);
    --danger-soft:   rgba(239, 68, 68, 0.14);
    --sh-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --sh-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --sh-md: 0 4px 12px -2px rgba(0, 0, 0, 0.45), 0 2px 6px -1px rgba(0, 0, 0, 0.3);
    --sh-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.55), 0 4px 12px -3px rgba(0, 0, 0, 0.35);
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11", "calt";
  text-rendering: optimizeLegibility;
}

::selection { background: var(--primary-ring); color: var(--text); }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--primary-h); text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 3px;
}

h1, h2, h3, h4, h5 {
  letter-spacing: -0.015em;
  font-weight: 700;
  color: var(--text);
}
h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.025em; }
h2 { font-size: 22px; line-height: 1.3; }
h3 { font-size: 17px; line-height: 1.35; }
h4 { font-size: 14px; line-height: 1.4; }

p { margin: 0 0 0.85em; }
p:last-child { margin-bottom: 0; }

code {
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: var(--font-mono);
  color: var(--text-2);
  border: 1px solid var(--border);
}
pre code { background: transparent; border: 0; padding: 0; }
kbd {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 1px 0 var(--border-strong);
  font-family: var(--font-mono);
  color: var(--text-2);
}

/* Custom scrollbar — subtle, contemporary */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; }

/* ============================================================================
 *  Header — frosted glass, sticky, polished
 * ============================================================================ */
header.app {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background var(--t-mid) var(--ease);
}
@media (prefers-color-scheme: dark) {
  header.app { background: rgba(11, 14, 22, 0.72); }
}
header.app .row {
  max-width: var(--container);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}
header.app .brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
header.app nav {
  margin-inline-start: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
header.app nav a {
  position: relative;
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--t-fast) var(--ease);
}
header.app nav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}
header.app .toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all var(--t-fast) var(--ease);
}
header.app .toggle:hover { border-color: var(--border-strong); }
header.app .toggle input { margin: 0; accent-color: var(--primary); cursor: pointer; }

/* ============================================================================
 *  Layout — main container
 * ============================================================================ */
main {
  max-width: var(--container);
  margin: 0 auto;
  padding: 28px var(--content-padding) 96px;
  animation: fadeIn 280ms var(--ease-out) both;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================================
 *  Cards
 * ============================================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--sh-xs);
  transition: box-shadow var(--t-mid) var(--ease), border-color var(--t-mid) var(--ease);
}
.card:hover { box-shadow: var(--sh-sm); }

/* ============================================================================
 *  Hub cards (.goal-grid / .goal-card) — flagship visual
 * ============================================================================ */
.goal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.goal-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  cursor: pointer;
  transition: transform var(--t-mid) var(--ease),
              box-shadow var(--t-mid) var(--ease),
              border-color var(--t-mid) var(--ease);
  isolation: isolate;
}
.goal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--t-mid) var(--ease);
  pointer-events: none;
  z-index: 1;
}
.goal-card::after {
  content: "→";
  position: absolute;
  top: 22px;
  inset-inline-end: 22px;
  font-size: 18px;
  color: var(--text-faint);
  transition: transform var(--t-mid) var(--ease), color var(--t-mid) var(--ease);
}
[dir="rtl"] .goal-card::after { content: "←"; }
.goal-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-md);
}
.goal-card:hover::before { opacity: 1; }
.goal-card:hover::after  { color: var(--primary); transform: translateX(4px); }
[dir="rtl"] .goal-card:hover::after { transform: translateX(-4px); }
.goal-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.goal-card h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.goal-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
}

/* ============================================================================
 *  Trust strip & transparency band — surfaces the platform's commitments
 * ============================================================================ */

/* Compact pill row at the top of Home — quick at-a-glance trust signals. */
.trust-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 24px;
}
.trust-strip .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: -0.005em;
  box-shadow: var(--sh-xs);
  transition: all var(--t-fast) var(--ease);
  cursor: default;
}
.trust-strip .pill:hover {
  border-color: var(--primary);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}
.trust-strip .pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}
.trust-strip .pill .icon { font-size: 14px; line-height: 1; }

/* Hero "Transparency commitments" band — gradient-framed list with check icons. */
.transparency-band {
  position: relative;
  background:
    radial-gradient(ellipse at top right, var(--primary-soft), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  margin-top: 24px;
  box-shadow: var(--sh-sm);
  isolation: isolate;
  overflow: hidden;
}
/* Animated gradient ring around the band */
.transparency-band::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(135deg, var(--primary), var(--accent), var(--primary));
  background-size: 200% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  animation: shimmerBorder 9s linear infinite;
  z-index: 1;
}
@keyframes shimmerBorder {
  0%   { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}
.transparency-band > * { position: relative; z-index: 2; }
.transparency-band .label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.transparency-band h2 {
  margin: 12px 0 6px;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.transparency-band > p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 18px;
  max-width: 60ch;
}
.transparency-band ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.transparency-band li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.5;
  transition: all var(--t-fast) var(--ease);
}
.transparency-band li:hover {
  border-color: var(--primary);
  box-shadow: var(--sh-xs);
  transform: translateY(-1px);
}
/* The icon column — a tinted square with the SVG check / icon glyph */
.transparency-band li .check {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--sh-xs);
}
.transparency-band li.is-link {
  border-style: dashed;
  background: transparent;
}
.transparency-band li.is-link a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.transparency-band li.is-link a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .transparency-band { padding: 22px 18px 18px; }
  .transparency-band h2 { font-size: 20px; }
}

/* ============================================================================
 *  Trust receipt — small badge row used inside .cite footers on result pages
 * ============================================================================ */
.trust-receipt {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.trust-receipt .receipt-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.trust-receipt .receipt-pill::before {
  content: "✓";
  color: var(--success);
  font-weight: 700;
}

/* ============================================================================
 *  Filter chips
 * ============================================================================ */
.filters { display: flex; gap: 8px; margin: 18px 0; flex-wrap: wrap; }
.chip {
  padding: 6px 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: all var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.chip.active {
  background: var(--primary);
  color: var(--primary-soft);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

/* ============================================================================
 *  Scale tiles
 * ============================================================================ */
.scale-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.scale-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.scale-tile:hover {
  border-color: var(--primary);
  box-shadow: var(--sh-sm);
  transform: translateY(-1px);
}
.scale-tile h4 { margin: 0 0 6px; color: var(--text); font-size: 15px; font-weight: 600; }
.scale-tile p  { margin: 0 0 10px; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.scale-tile .badge {
  display: inline-flex;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  margin-inline-end: 4px;
  margin-top: 0;
  letter-spacing: 0.01em;
}
.b1 { background: var(--success-soft); color: #047857; }
.b2 { background: var(--warning-soft); color: #b45309; }
.b3 { background: var(--danger-soft);  color: #b91c1c; }
@media (prefers-color-scheme: dark) {
  .b1 { color: #34d399; }
  .b2 { color: #fbbf24; }
  .b3 { color: #f87171; }
}

/* ============================================================================
 *  Search
 * ============================================================================ */
.search {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  transition: all var(--t-fast) var(--ease);
}
.search:hover { border-color: var(--border-strong); }
.search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

/* ============================================================================
 *  Form elements
 * ============================================================================ */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  color: var(--text-2);
  font-size: 13px;
  margin-bottom: 6px;
}
.field .plain { font-size: 12px; color: var(--text-muted); margin-inline-start: 6px; font-weight: 400; }

input[type="number"],
input[type="text"],
input[type="search"],
input[type="email"],
input[type="date"],
input[type="url"],
input[type="tel"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  transition: all var(--t-fast) var(--ease);
  -webkit-appearance: none;
  -moz-appearance: none;
       appearance: none;
}
input[type="number"]:hover, input[type="text"]:hover, input[type="search"]:hover,
select:hover, textarea:hover { border-color: var(--border-strong); }
input[type="number"]:focus, input[type="text"]:focus, input[type="search"]:focus,
input[type="email"]:focus, input[type="date"]:focus, input[type="url"]:focus,
select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='none' stroke='%235a6478' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5L6 8l3.5-3.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-inline-end: 32px;
}
[dir="rtl"] select { background-position: left 10px center; padding-inline-end: 12px; padding-inline-start: 32px; }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); cursor: pointer; }

.field .check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  font-size: 14px;
}
.field .check:hover { background: var(--surface-2); border-color: var(--border-strong); }
.field .check:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); }

/* ============================================================================
 *  Result card — hero output
 * ============================================================================ */
.result {
  position: relative;
  margin-top: 22px;
  padding: 22px 24px;
  background:
    radial-gradient(ellipse at top right, var(--primary-soft), transparent 70%),
    var(--surface);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: var(--sh-md), 0 0 0 4px var(--primary-ring);
  overflow: hidden;
}
.result::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  opacity: 0.06;
  pointer-events: none;
}
.result .total {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.result .band {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-top: 6px;
  letter-spacing: -0.01em;
}
.result .guidance { margin-top: 10px; color: var(--text-2); font-size: 14px; }

/* ============================================================================
 *  Disclosure / details
 * ============================================================================ */
.disclosure { margin-top: 18px; }
.disclosure summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  transition: color var(--t-fast) var(--ease);
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::before {
  content: "›";
  display: inline-block;
  transform: rotate(0deg);
  transition: transform var(--t-fast) var(--ease);
  font-size: 18px;
  line-height: 1;
}
.disclosure[open] summary::before { transform: rotate(90deg); }
[dir="rtl"] .disclosure summary::before { content: "‹"; }
[dir="rtl"] .disclosure[open] summary::before { transform: rotate(-90deg); }
.disclosure-body {
  padding: 14px 16px;
  margin-top: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

/* ============================================================================
 *  Reroute card
 * ============================================================================ */
.reroute {
  background:
    linear-gradient(135deg, var(--warning-soft), transparent 70%),
    var(--surface);
  border: 1px solid var(--warning);
  padding: 22px;
  border-radius: var(--radius-md);
  box-shadow: var(--sh-sm);
}
.reroute h3 { margin-top: 0; color: var(--text); }
.reroute .reason {
  background: var(--surface);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 14px 0;
  font-size: 14px;
}

/* ============================================================================
 *  Buttons
 * ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: -0.005em;
  text-decoration: none;
  transition: all var(--t-fast) var(--ease);
  box-shadow: var(--sh-xs);
}
.btn:hover {
  background: var(--primary-h);
  border-color: var(--primary-h);
  box-shadow: var(--sh-sm);
  transform: translateY(-1px);
  text-decoration: none;
  color: #ffffff;
}
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-ring); }
.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn.secondary {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  box-shadow: var(--sh-xs);
}
.btn.secondary:hover {
  background: var(--surface-2);
  border-color: var(--text-faint);
  color: var(--text);
}

/* ============================================================================
 *  Glossary terms
 * ============================================================================ */
.glossary-term {
  border-bottom: 1px dashed var(--text-faint);
  cursor: help;
  text-decoration: none;
  transition: border-color var(--t-fast) var(--ease);
}
.glossary-term:hover { border-bottom-color: var(--primary); border-bottom-style: solid; }

/* ============================================================================
 *  Consent banner
 * ============================================================================ */
.consent {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  max-width: 640px;
  margin: 0 auto;
  background: var(--text);
  color: #ffffff;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--sh-lg);
  z-index: 100;
  animation: slideUp 320ms var(--ease-out) both;
  border: 1px solid rgba(255,255,255,0.06);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: none; }
}
.consent p { margin: 0 0 12px; font-size: 13px; opacity: 0.9; }
.consent .row { display: flex; gap: 8px; flex-wrap: wrap; padding: 0; }

/* ============================================================================
 *  Help bubble — floating action
 * ============================================================================ */
.help-bubble {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  background: var(--surface);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: var(--sh-md), 0 0 0 1px var(--border);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: 0;
  z-index: 90;
  transition: all var(--t-mid) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.help-bubble:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: var(--sh-lg), 0 0 0 1px var(--primary);
  color: var(--primary);
}
.help-bubble:focus-visible { outline: none; box-shadow: var(--sh-lg), 0 0 0 4px var(--primary-ring); }

/* ============================================================================
 *  Crumbs / muted / cite
 * ============================================================================ */
.crumbs {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.crumbs a { color: var(--text-muted); transition: color var(--t-fast) var(--ease); }
.crumbs a:hover { color: var(--primary); text-decoration: none; }

.muted { color: var(--text-muted); font-size: 13px; line-height: 1.55; }

.cite {
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 14px;
  line-height: 1.6;
}

/* ============================================================================
 *  Audit log — terminal-ish
 * ============================================================================ */
.audit {
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  background: #0b0e16;
  color: #93f7a8;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  line-height: 1.6;
  border: 1px solid #1f2533;
}
.audit div { margin-bottom: 2px; }

/* ============================================================================
 *  Tour modal
 * ============================================================================ */
.tour {
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 22, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 200ms var(--ease-out) both;
}
.tour-card {
  background: var(--surface);
  max-width: 480px;
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  box-shadow: var(--sh-lg);
  border: 1px solid var(--border);
  animation: popIn 280ms var(--ease-out) both;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.tour-card h2 { margin: 0 0 10px; color: var(--text); }
.tour-card p  { color: var(--text-2); }
.tour-dots { display: flex; gap: 6px; justify-content: center; margin: 16px 0; }
.tour-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); transition: all var(--t-mid) var(--ease); }
.tour-dot.active { background: var(--primary); transform: scale(1.3); box-shadow: 0 0 0 4px var(--primary-ring); }

/* ============================================================================
 *  Tables — used by Table 1, Reproducibility, etc.
 * ============================================================================ */
table {
  font-feature-settings: "tnum" 1;
}
table th { font-weight: 600; color: var(--text-2); }
table tbody tr { transition: background var(--t-fast) var(--ease); }
table tbody tr:hover { background: var(--surface-2); }

/* ============================================================================
 *  Utilities
 * ============================================================================ */
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

::placeholder { color: var(--text-faint); opacity: 1; }

img, svg { max-width: 100%; }

/* Skeleton shimmer for future use */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ============================================================================
 *  Reduced motion — respect the OS setting
 * ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================================
 *  Print — clean, ink-friendly clinical output
 * ============================================================================ */
@media print {
  :root { --bg: white; --surface: white; --text: #000; --text-2: #222; --text-muted: #444; --border: #ccc; }
  body { background: white; }
  header.app, .help-bubble, .consent, .tour, nav, .toggle, .filters, .crumbs { display: none !important; }
  main { padding: 0; max-width: none; }
  .card, .goal-card, .scale-tile, .result, .reroute {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
  a { color: #000; text-decoration: underline; }
  .audit { background: white; color: #000; border: 1px solid #ccc; }
}

/* ============================================================================
 *  Mobile refinement
 * ============================================================================ */
@media (max-width: 640px) {
  body { font-size: 14px; }
  h1 { font-size: 26px; }
  h2 { font-size: 20px; }
  header.app .row { padding: 10px 16px; gap: 8px; }
  header.app nav { gap: 2px; }
  header.app nav a { padding: 6px 8px; font-size: 13px; }
  main { padding: 18px 16px 80px; }
  .card { padding: 18px; border-radius: var(--radius); }
  .goal-card { padding: 20px; }
  .result { padding: 18px; }
  .result .total { font-size: 34px; }
  .help-bubble { bottom: 14px; padding: 10px 14px; font-size: 13px; }
  .consent { left: 12px; right: 12px; bottom: 12px; padding: 14px; }
}

/* ============================================================================
 *  RTL — fine adjustments beyond Logical Properties auto-flips
 * ============================================================================ */
[dir="rtl"] body { font-family: var(--font-sans); }
[dir="rtl"] header.app .brand { background: linear-gradient(225deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
[dir="rtl"] .audit { font-family: var(--font-mono); direction: ltr; text-align: left; }

/* ============================================================================
 *  Hero — landing page hero used on Home and on hub pages
 * ============================================================================ */
.hero {
  position: relative;
  padding: 56px 0 32px;
  margin-bottom: 8px;
  isolation: isolate;
}
.hero::before {
  /* Subtle radial mesh anchored top-right */
  content: "";
  position: absolute;
  inset: -40px -40px auto auto;
  width: 540px; height: 540px;
  background:
    radial-gradient(circle at 30% 30%, var(--primary-soft) 0%, transparent 55%),
    radial-gradient(circle at 75% 60%, var(--accent-soft) 0%, transparent 55%);
  filter: blur(60px);
  opacity: 0.85;
  z-index: -1;
  pointer-events: none;
}
.hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-2);
  text-transform: uppercase;
  box-shadow: var(--sh-xs);
}
.hero .eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 0 3px var(--success-soft);
}
.hero h1 {
  font-size: 52px;
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-weight: 800;
  margin: 16px 0 16px;
  max-width: 22ch;
}
.hero h1 .accent {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .lede {
  font-size: 18px;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0 0 24px;
}
.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}
.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.005em;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none !important;
  transition: all var(--t-fast) var(--ease);
  font-family: inherit;
}
.btn-primary {
  background: var(--primary);
  color: #fff !important;
  box-shadow: 0 4px 14px -4px var(--primary-ring), 0 1px 2px rgba(15,23,42,0.05);
}
.btn-primary:hover { background: var(--primary-h); transform: translateY(-1px); box-shadow: 0 8px 20px -6px var(--primary-ring); }
.btn-ghost {
  background: transparent;
  color: var(--text-2) !important;
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text) !important; border-color: var(--text-faint); }

@media (max-width: 720px) {
  .hero { padding: 36px 0 24px; }
  .hero h1 { font-size: 36px; }
  .hero .lede { font-size: 16px; }
  .hero::before { width: 360px; height: 360px; opacity: 0.6; }
}

/* ============================================================================
 *  Page title — inner pages (replaces hardcoded #103565 H1 inline styles)
 * ============================================================================ */
.page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 6px;
  line-height: 1.2;
}
.page-title-icon { margin-right: 6px; }
.page-tagline {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0 0 18px;
  max-width: 70ch;
}

/* ============================================================================
 *  Metric tiles — used in result panels, dashboards, hubs
 * ============================================================================ */
.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: all var(--t-fast) var(--ease);
}
.metric:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--sh-xs); }
.metric .metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.metric .metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 2px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.metric .metric-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.metric.is-primary { background: linear-gradient(135deg, var(--primary-soft), transparent 70%), var(--surface); border-color: var(--primary); }
.metric.is-primary .metric-value { color: var(--primary); }
.metric.is-success .metric-value { color: var(--success); }
.metric.is-warning .metric-value { color: var(--warning); }
.metric.is-danger  .metric-value { color: var(--danger); }

/* ============================================================================
 *  Status pills — color-coded interpretation bands (e.g., risk-low / risk-high)
 * ============================================================================ */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.status-pill.success { color: var(--success); background: var(--success-soft); border-color: transparent; }
.status-pill.warning { color: var(--warning); background: var(--warning-soft); border-color: transparent; }
.status-pill.danger  { color: var(--danger);  background: var(--danger-soft);  border-color: transparent; }
.status-pill.info    { color: var(--primary); background: var(--primary-soft); border-color: transparent; }

/* ============================================================================
 *  Section header — standardised heading + meta row
 * ============================================================================ */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0 12px;
}
.section-header h2 { margin: 0; }
.section-header .meta {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================================================
 *  Footer — site-wide footer used on hubs and detail pages
 * ============================================================================ */
.site-footer {
  margin-top: 96px;
  padding: 32px 0 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}
.site-footer .row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--text); }

/* ============================================================================
 *  Subtle scroll-reveal — opt-in via .reveal class (set initial state, clear via observer)
 * ============================================================================ */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 320ms var(--ease-out), transform 320ms var(--ease-out);
  }
  .reveal.in { opacity: 1; transform: none; }
}
