/* ==========================================================================
   Civitas Audit Books — Pure Native Apple System Design (SF Pro + SF Mono),
   True Neutral Surfaces (Zero Clay/Beige), WCAG 2.1 AA+, Spring Motion
   ========================================================================== */

/* 1. Root Large-Text Scale (rem-based: scales cleanly XS 14px -> XL 24px) */
html {
  font-size: 17px; /* Default M — iOS/macOS Body standard */
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h, 76px) + 18px);
  scroll-padding-bottom: calc(var(--composer-dock-h, 0px) + 28px);
  color-scheme: light;
}
html[data-text-size="xs"] { font-size: 14px; }
html[data-text-size="s"]  { font-size: 15.5px; }
html[data-text-size="m"]  { font-size: 17px; }
html[data-text-size="l"]  { font-size: 20px; }
html[data-text-size="xl"] { font-size: 24px; }

html[data-theme="dark"] { color-scheme: dark; }

/* Operator Workbench keeps crisp desktop density while honoring L/XL zoom */
html[data-surface="workbench"] { font-size: 14.5px; }
html[data-surface="workbench"][data-text-size="l"] { font-size: 16.5px; }
html[data-surface="workbench"][data-text-size="xl"] { font-size: 18.5px; }

/* 2. Pure Apple Neutral Tokens — WCAG 2.2 AA+AAA Verified Contrast */
:root {
  --bg: #ffffff;
  --bg-grouped: #f5f5f7;
  --bg-glass: rgba(255, 255, 255, 0.9);
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-muted: #f5f5f7;
  --surface-hover: #ebebf0;

  --ink: #1d1d1f;              /* 16.83:1 on #ffffff (AAA) */
  --ink-secondary: #3a3a3d;    /* 11.4:1 on #ffffff, 10.41:1 on #f5f5f7 (AAA) */
  --ink-muted: #4d4d52;        /* 8.40:1 on #ffffff, 7.72:1 on #f5f5f7, 7.07:1 on #ebebf0 (AAA) */

  --hairline: rgba(0, 0, 0, 0.14);
  --border: rgba(0, 0, 0, 0.24);
  --border-strong: rgba(0, 0, 0, 0.42);
  --control-border: #68686e;   /* 5.5:1 on #ffffff, 5.08:1 on #f5f5f7 (WCAG 1.4.11 >=3:1) */

  /* Single iconic deep Apple Blue accent (AAA >=7.5:1) */
  --accent: #0052a3;           /* 7.68:1 with white text (AAA) */
  --accent-text: #004b96;      /* 8.58:1 on white, 7.41:1 on soft tint (AAA) */
  --accent-hover: #003f82;     /* 10.33:1 with white text (AAA) */
  --accent-soft: rgba(0, 82, 163, 0.085);
  --accent-border: rgba(0, 82, 163, 0.48);
  --accent-ink: #ffffff;

  --user-bubble-bg: #0052a3;
  --user-bubble-ink: #ffffff;

  /* Apple HIG accessible system status colors (AAA >=7:1 on light surfaces) */
  --ok: #125c28;               /* 8.12:1 on #ffffff, 7.02:1 on soft */
  --ok-soft: rgba(18, 92, 40, 0.08);
  --ok-border: rgba(18, 92, 40, 0.44);
  --watch: #7a3600;            /* 8.92:1 on #ffffff, 7.80:1 on soft */
  --watch-soft: rgba(180, 83, 9, 0.09);
  --watch-border: rgba(122, 54, 0, 0.46);
  --high: #9e111b;             /* 8.24:1 on #ffffff, 7.07:1 on soft */
  --bad: #9e111b;
  --high-soft: rgba(158, 17, 27, 0.08);
  --high-border: rgba(158, 17, 27, 0.46);
  --critical: #820c16;         /* 8.53:1 on #fde2e4 */
  --critical-soft: #fde2e4;
  --critical-border: #a61e2a;
  --reason: #3a3a3d;
  --reason-soft: #f5f5f7;
  --reason-border: rgba(0, 0, 0, 0.28);

  --code-bg: #161618;
  --code-ink: #f0f0f3;
  --backdrop: rgba(0, 0, 0, 0.42);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.08);
  --shadow-sheet: 0 24px 64px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.06);

  /* Pure native Apple San Francisco + SF Mono (Zero Georgia/Iowan serif!) */
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 14px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --focus-outline: #0052a3;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 5px var(--focus-outline);
  --tap-min: 44px;
  --topbar-h: 76px;
}

/* Workbench sits on Apple grouped light gray (#f5f5f7) with pure #ffffff cards */
html[data-surface="workbench"] body {
  background: var(--bg-grouped);
}

/* Dark Mode — True iOS / iMessage Dark Elevation Ladder (#000000 -> #1c1c1e -> #262629 -> #323236)
   with WCAG 2.2 AAA ink & luminous sky-blue accent */
html[data-theme="dark"] {
  --bg: #000000;
  --bg-grouped: #000000;
  --bg-glass: rgba(0, 0, 0, 0.86);
  --surface: #1c1c1e;
  --surface-elevated: #262629;
  --surface-muted: #262629;
  --surface-hover: #323236;

  --ink: #ececf1;              /* 17.83:1 on #000, 12.82:1 on #262629 (AAA) */
  --ink-secondary: #d8d8e0;    /* 9.01:1 on #323236 (AAA) */
  --ink-muted: #c4c4ce;        /* 12.13:1 on #000, 9.83:1 on #1c1c1e, 7.38:1 on #323236 (AAA) */

  --hairline: rgba(255, 255, 255, 0.16);
  --border: rgba(255, 255, 255, 0.26);
  --border-strong: rgba(255, 255, 255, 0.44);
  --control-border: #94949e;   /* 5.02:1 on #262629 (WCAG 1.4.11 >=3:1) */

  --accent: #5ca9ff;           /* 8.57:1 with #000000 ink (AAA) */
  --accent-text: #8ec5ff;      /* 9.38:1 on #1c1c1e, 7.33:1 on soft (AAA) */
  --accent-hover: #82bfff;     /* 10.85:1 with #000000 ink (AAA) */
  --accent-soft: rgba(10, 132, 255, 0.18);
  --accent-border: rgba(142, 197, 255, 0.56);
  --accent-ink: #000000;

  --user-bubble-bg: #0052b3;   /* 7.35:1 with #ffffff ink (AAA) */
  --user-bubble-ink: #ffffff;

  --ok: #5be376;               /* 10.29:1 on #1c1c1e, 7.69:1 on soft */
  --ok-soft: rgba(50, 215, 75, 0.14);
  --ok-border: rgba(91, 227, 118, 0.52);
  --watch: #ffc461;            /* 10.79:1 on #1c1c1e, 7.82:1 on soft */
  --watch-soft: rgba(255, 179, 64, 0.14);
  --watch-border: rgba(255, 196, 97, 0.54);
  --high: #ff9e96;             /* 9.08:1 on #1c1c1e, 7.21:1 on soft */
  --bad: #ff9e96;
  --high-soft: rgba(255, 105, 97, 0.14);
  --high-border: rgba(255, 158, 150, 0.56);
  --critical: #ffa8a0;         /* 7.55:1 on critical-soft */
  --critical-soft: rgba(255, 69, 58, 0.16);
  --critical-border: rgba(255, 168, 160, 0.62);
  --reason: #ececf1;
  --reason-soft: #1c1c1e;
  --reason-border: rgba(255, 255, 255, 0.28);

  --backdrop: rgba(0, 0, 0, 0.72);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-md: 0 14px 40px rgba(0, 0, 0, 0.72);
  --shadow-sheet: 0 24px 72px rgba(0, 0, 0, 0.84);
  --focus-outline: #8ec5ff;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 5px var(--focus-outline);
}

/* High-Contrast Accessibility Mode (WCAG AAA, pure black/white, 2px borders, 48px targets) */
html[data-contrast="high"] {
  --bg: #ffffff;
  --bg-grouped: #ffffff;
  --bg-glass: #ffffff;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-muted: #f2f2f2;
  --surface-hover: #e5e5e5;
  --ink: #000000;
  --ink-secondary: #000000;
  --ink-muted: #1a1a1a;
  --hairline: #000000;
  --border: #000000;
  --border-strong: #000000;
  --control-border: #000000;
  --accent: #0037b8;           /* 9.38:1 with #ffffff (AAA) */
  --accent-text: #002f9e;      /* 9.49:1 on #e6eeff (AAA) */
  --accent-hover: #002680;
  --accent-soft: #e6eeff;
  --accent-border: #0037b8;
  --accent-ink: #ffffff;
  --user-bubble-bg: #000000;
  --user-bubble-ink: #ffffff;
  --ok: #064f1d;               /* 8.87:1 on #e3f9eb (AAA) */
  --ok-soft: #e3f9eb;
  --ok-border: #064f1d;
  --watch: #693100;            /* 9.28:1 on #fff2d6 (AAA) */
  --watch-soft: #fff2d6;
  --watch-border: #693100;
  --high: #8f0811;             /* 7.80:1 on #ffe2e4 (AAA) */
  --bad: #8f0811;
  --high-soft: #ffe2e4;
  --high-border: #8f0811;
  --critical: #7a000b;
  --critical-soft: #ffe2e4;
  --critical-border: #7a000b;
  --reason: #000000;
  --reason-soft: #f2f2f2;
  --reason-border: #000000;
  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-md: none;
  --focus-outline: #0037b8;
  --focus-ring: 0 0 0 2px #ffffff, 0 0 0 6px #0037b8;
  --tap-min: 48px;
}

html[data-theme="dark"][data-contrast="high"] {
  --bg: #000000;
  --bg-grouped: #000000;
  --bg-glass: #000000;
  --surface: #0a0a0a;
  --surface-elevated: #1c1c1e;
  --surface-muted: #1c1c1e;
  --surface-hover: #2c2c2e;
  --ink: #ffffff;
  --ink-secondary: #ffffff;
  --ink-muted: #f0f0f0;
  --hairline: #ffffff;
  --border: #ffffff;
  --border-strong: #ffffff;
  --control-border: #ffffff;
  --accent: #7ab8ff;           /* 10.13:1 with #000000 (AAA) */
  --accent-text: #a8d2ff;      /* 9.82:1 on #0b2447 (AAA) */
  --accent-hover: #a8d2ff;
  --accent-soft: #0b2447;
  --accent-border: #7ab8ff;
  --accent-ink: #000000;
  --user-bubble-bg: #1c1c1e;
  --user-bubble-ink: #ffffff;
  --ok: #7bf09c;               /* 11.42:1 on #072611 (AAA) */
  --ok-soft: #072611;
  --ok-border: #7bf09c;
  --watch: #ffd97d;            /* 11.98:1 on #2e1d00 (AAA) */
  --watch-soft: #2e1d00;
  --watch-border: #ffd97d;
  --high: #ff9c96;             /* 8.82:1 on #33090b (AAA) */
  --bad: #ff9c96;
  --high-soft: #33090b;
  --high-border: #ff9c96;
  --critical: #ff9c96;
  --critical-soft: #33090b;
  --critical-border: #ff9c96;
  --reason: #ffffff;
  --reason-soft: #1c1c1e;
  --reason-border: #ffffff;
  --focus-outline: #ffd166;
  --focus-ring: 0 0 0 2px #000000, 0 0 0 6px #ffd166;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-feature-settings: "kern" 1, "liga" 1;
  letter-spacing: -0.009em;
  line-height: 1.56;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100dvh;
}
/* Open up tracking slightly in dark mode so light strokes never bloom or crowd */
html[data-theme="dark"],
html[data-theme="dark"] body {
  letter-spacing: 0.002em;
}
html[data-theme="dark"] ::selection {
  background: rgba(92, 169, 255, 0.36);
  color: #ffffff;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; color: inherit; }
code, pre { font-family: var(--mono); }

input::placeholder,
textarea::placeholder {
  color: var(--ink-muted);
  opacity: 1;
}

/* WCAG 2.4.11 / 2.4.12 Focus Not Obscured */
a, button, input, select, textarea, summary, [tabindex], .msg-assistant {
  scroll-margin-top: calc(var(--topbar-h, 76px) + 18px);
  scroll-margin-bottom: calc(var(--composer-dock-h, 0px) + 28px);
}

/* WCAG 2.4.7 / 2.4.13 High-Contrast Focus Appearance */
:focus-visible {
  outline: 3px solid var(--focus-outline);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

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

/* Skip Navigation Links (WCAG 2.4.1) */
.skip-links {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  display: flex;
  gap: 0.5rem;
  padding: 0.4rem;
  pointer-events: none;
}
.skip-link {
  position: absolute;
  transform: translateY(-140%);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  transition: transform 0.2s var(--ease-spring);
}
.skip-link:focus {
  position: relative;
  transform: translateY(0);
  text-decoration: none;
}

.ico {
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -0.15em;
}

/* ==========================================================================
   3. Confidentiality Legend & Pure Apple Translucent Navigation Bar
   ========================================================================== */

.confidentiality-banner {
  position: sticky;
  top: 0;
  z-index: 95;
  background: #1d1d1f;
  color: #f5f5f7;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 5px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  line-height: 1.35;
}
.confidentiality-banner.hidden { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
  padding: 0.52rem 1.2rem;
}
html[data-contrast="high"] .topbar {
  backdrop-filter: none;
  border-bottom-width: 2px;
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.hamburger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0.35rem 0.72rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 500;
  transition: background 0.16s ease, transform 0.14s var(--ease-spring);
}
.hamburger-btn:hover { background: var(--surface-muted); }
.hamburger-btn:active { transform: scale(0.96); }
html[data-contrast="high"] .hamburger-btn { border: 2px solid var(--border); }

.burger-lines {
  width: 1.05rem;
  height: 0.78rem;
  position: relative;
  display: inline-block;
}
.burger-lines span {
  position: absolute;
  left: 0;
  right: 0;
  height: 1.7px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.28s var(--ease-spring), opacity 0.2s ease;
}
.burger-lines span:nth-child(1) { top: 0; }
.burger-lines span:nth-child(2) { top: calc(50% - 0.85px); }
.burger-lines span:nth-child(3) { bottom: 0; }
.hamburger-btn[aria-expanded="true"] .burger-lines span:nth-child(1) { transform: translateY(0.34rem) rotate(45deg); }
.hamburger-btn[aria-expanded="true"] .burger-lines span:nth-child(2) { opacity: 0; }
.hamburger-btn[aria-expanded="true"] .burger-lines span:nth-child(3) { transform: translateY(-0.34rem) rotate(-45deg); }

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.02rem;
}
.brand-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: var(--tap-min);
  gap: 0.02rem;
}
.brand-link:hover { text-decoration: none; }
.brand-kicker {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  line-height: 1.2;
}
.brand-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.06rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.022em;
  line-height: 1.2;
}

/* Native macOS/iOS Segmented Control */
.segmented-pill {
  display: inline-flex;
  align-items: center;
  padding: 2.5px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--control-border);
  max-width: 100%;
}
html[data-contrast="high"] .segmented-pill { border-width: 2px; }
.segmented-pill .mode-tab {
  min-height: var(--tap-min);
  min-width: 0;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background 0.2s var(--ease-spring), color 0.15s ease, box-shadow 0.2s var(--ease-spring);
}
.segmented-pill .mode-tab:hover { color: var(--ink); }
.segmented-pill .mode-tab.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0.5px 1px rgba(0, 0, 0, 0.04);
}
/* Correct Apple Dark Mode elevation polarity: recessed track (#1c1c1e), elevated active thumb (#323236) */
html[data-theme="dark"] .segmented-pill {
  background: var(--surface);
  border-color: var(--control-border);
}
html[data-theme="dark"] .segmented-pill .mode-tab {
  color: var(--ink-muted);
}
html[data-theme="dark"] .segmented-pill .mode-tab:hover {
  color: var(--ink);
}
html[data-theme="dark"] .segmented-pill .mode-tab.active {
  background: var(--surface-hover);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
html[data-contrast="high"] .segmented-pill .mode-tab.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

/* One-tap Light/Dark Quick Toggle (Moon in Light Mode, Sun in Dark Mode) */
.theme-toggle-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0.35rem 0.58rem;
}
.theme-toggle-btn .theme-ico-sun { display: none; }
.theme-toggle-btn .theme-ico-moon { display: inline-block; }
html[data-theme="dark"] .theme-toggle-btn .theme-ico-sun { display: inline-block; }
html[data-theme="dark"] .theme-toggle-btn .theme-ico-moon { display: none; }

.text-stepper {
  display: inline-flex;
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  overflow: hidden;
}
html[data-contrast="high"] .text-stepper { border: 2px solid var(--border); background: var(--surface); }
.text-stepper button {
  min-width: 38px;
  min-height: 36px;
  border: none;
  background: transparent;
  padding: 0.2rem 0.52rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  transition: background 0.14s ease;
}
.text-stepper button:hover:not(:disabled) { background: var(--surface-hover); }
.text-stepper button:disabled { opacity: 0.3; cursor: not-allowed; }
.text-stepper .size-readout {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0 0.38rem;
  color: var(--ink-secondary);
  border-left: 1px solid var(--hairline);
  border-right: 1px solid var(--hairline);
  min-width: 1.85rem;
  text-align: center;
  text-transform: uppercase;
}

/* ==========================================================================
   4. Clean Apple Buttons & Restrained Badges
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  min-height: var(--tap-min);
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-decoration: none;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s var(--ease-spring);
}
html[data-contrast="high"] .btn { border-width: 2px; min-height: var(--tap-min); font-weight: 600; }
.btn:hover:not(:disabled) { background: var(--surface-muted); border-color: var(--border-strong); text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(0.975); }
.btn:disabled { opacity: 0.46; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
}

.btn-danger {
  background: var(--high);
  border-color: var(--high);
  color: #ffffff;
  font-weight: 600;
}
.btn-danger:hover:not(:disabled) { background: #7f0c15; border-color: #7f0c15; }
html[data-theme="dark"] .btn-danger {
  color: #000000;
}
html[data-theme="dark"] .btn-danger:hover:not(:disabled) {
  background: #ffb8b2;
  border-color: #ffb8b2;
  color: #000000;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-muted); color: var(--ink); }

.btn-sm {
  min-height: var(--tap-min);
  padding: 0.36rem 0.78rem;
  font-size: 0.8rem;
}
html[data-contrast="high"] .btn-sm { min-height: var(--tap-min); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.2rem 0.56rem;
  border-radius: 999px;
  border: 1px solid transparent;
  line-height: 1.2;
  white-space: nowrap;
}
html[data-contrast="high"] .badge { border-width: 2px; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-border); }
.badge-watch { background: var(--watch-soft); color: var(--watch); border-color: var(--watch-border); }
.badge-high { background: var(--high-soft); color: var(--high); border-color: var(--high-border); }
.badge-critical { background: var(--critical-soft); color: var(--critical); border-color: var(--critical-border); }
.badge-neutral { background: var(--surface-muted); color: var(--ink-secondary); border-color: var(--hairline); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-border); }

/* ==========================================================================
   5. Crisp Apple Welcome Screen (Pure Neutral Canvas, Clean 2x2 Starters)
   ========================================================================== */

.resident-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 2.2rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
}
/* Keep primary content panels at least one full viewport tall so the single page footer
   stays strictly below the fold until the user intentionally scrolls down. */
.resident-wrap > section[role="tabpanel"] {
  min-height: calc(100dvh - 88px);
  width: 100%;
  min-width: 0;
}

.welcome-hero {
  padding: 0.2rem 0 0.45rem;
  animation: fadeSlideUp 0.44s var(--ease-out) both;
}
/* Keep <h1> in the accessibility tree when welcome hero collapses into chat thread */
.welcome-hero.compact {
  padding: 0;
  margin: 0;
  height: 0;
  overflow: visible;
  animation: none;
}
.welcome-hero.compact > :not(h1) {
  display: none;
}
.welcome-hero.compact > h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Quiet left-aligned metadata trigger (never competes as another pill row) */
.eyebrow-pill {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.38rem;
  padding: 0.25rem 0;
  border-radius: 6px;
  background: transparent;
  border: none;
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.005em;
  text-align: left;
  color: var(--ink-muted);
  margin: 0 0 0.5rem;
  min-height: var(--tap-min);
  max-width: 100%;
  transition: color 0.15s ease;
}
.eyebrow-pill .ico {
  width: 0.78rem;
  height: 0.78rem;
  opacity: 0.65;
  flex-shrink: 0;
  transition: transform 0.15s var(--ease-spring), opacity 0.15s ease;
}
button.eyebrow-pill:hover {
  color: var(--accent-text);
}
button.eyebrow-pill:hover .ico {
  opacity: 1;
  transform: translateX(2px);
}
html[data-contrast="high"] .eyebrow-pill {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.live-dot {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 50%;
  background: #30d158;
  flex-shrink: 0;
}

.welcome-hero h1.hero-title {
  max-width: 24ch;
  margin-bottom: 1.35rem;
}

/* Subtle studio top-light wash on pure white Resident canvas (zero clay/beige, pure porcelain depth) */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 420px;
  background: radial-gradient(ellipse 72% 300px at 50% -70px, rgba(0, 113, 227, 0.06), transparent 72%);
  pointer-events: none;
  z-index: 0;
}
html[data-theme="dark"] body::before {
  background: radial-gradient(ellipse 68% 260px at 50% -90px, rgba(10, 132, 255, 0.08), transparent 72%);
}
html[data-contrast="high"] body::before,
html[data-surface="workbench"] body::before {
  display: none;
}

.topbar, main, .composer-dock { position: relative; z-index: 1; }
.topbar { position: sticky; z-index: 60; }
.composer-dock { position: fixed; z-index: 50; }

/* Signature Apple-minimal rounded squircle brand emblem */
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(180deg, #2c2c2e 0%, #141416 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
html[data-theme="dark"] .brand-mark {
  background: linear-gradient(180deg, #3a3a3c 0%, #242426 100%);
}
html[data-contrast="high"] .brand-mark {
  background: var(--ink);
  color: var(--bg);
  box-shadow: none;
}

.welcome-hero h1 {
  font-family: var(--display);
  font-size: clamp(2.05rem, 4.3vw, 2.85rem);
  font-weight: 600;
  margin: 0 0 0.78rem;
  line-height: 1.08;
  letter-spacing: -0.038em;
  color: var(--ink);
  max-width: 19ch;
  text-wrap: balance;
}
.welcome-hero h1 .headline-muted {
  color: var(--ink-muted);
}
html[data-contrast="high"] .welcome-hero h1 .headline-muted { color: var(--ink); }

/* Sculpted Apple Bento Starter Cards with tactile shadow + micro-squircle icon */
.starter-btn {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.9rem;
  text-align: left;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  color: var(--ink);
  font-size: 0.93rem;
  font-weight: 500;
  line-height: 1.44;
  letter-spacing: -0.012em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.035), 0 8px 22px -12px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: background 0.2s var(--ease-spring), border-color 0.2s ease, box-shadow 0.24s var(--ease-spring), transform 0.2s var(--ease-spring);
}
html[data-theme="dark"] .starter-btn {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .starter-btn:hover {
  background: #222226;
  border-color: var(--accent-border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(10, 132, 255, 0.18);
}
html[data-contrast="high"] .starter-btn { border: 2px solid var(--border-strong); background: var(--surface); box-shadow: none; }
.starter-btn:hover {
  border-color: var(--accent-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05), 0 16px 32px -14px rgba(0, 113, 227, 0.16);
  transform: translateY(-2px);
}
.starter-btn:active { transform: scale(0.988); }

.starter-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.starter-top-left {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

/* Tactile iMessage Blue User Bubble (WCAG AAA contrast across all modes) */
.msg-user {
  align-self: flex-end;
  max-width: 78%;
  background: var(--user-bubble-bg);
  color: var(--user-bubble-ink);
  padding: 0.76rem 1.12rem;
  border-radius: 22px 22px 6px 22px;
  font-size: 0.96rem;
  line-height: 1.46;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 16px -4px rgba(0, 82, 163, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  word-break: break-word;
  animation: fadeSlideUp 0.28s var(--ease-out) both;
}
html[data-contrast="high"] .msg-user { background: var(--user-bubble-bg); color: var(--user-bubble-ink); box-shadow: none; border: 2px solid var(--border-strong); }

/* Floating Studio Pill Composer */
.composer-pill {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  background: var(--surface);
  border: 1.5px solid var(--control-border);
  border-radius: 28px;
  padding: 0.44rem 0.48rem 0.44rem 1.15rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04), 0 16px 40px -12px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: border-color 0.18s ease, box-shadow 0.22s var(--ease-spring);
}
html[data-theme="dark"] .composer-pill {
  background: #222226;
  border-color: var(--control-border);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.78), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
html[data-theme="dark"] .composer-pill:focus-within {
  border-color: var(--focus-outline);
  outline: 3px solid var(--focus-outline);
  outline-offset: 2px;
  box-shadow: var(--focus-ring), 0 14px 40px rgba(0, 0, 0, 0.82);
}
.composer-pill:focus-within {
  border-color: var(--focus-outline);
  outline: 3px solid var(--focus-outline);
  outline-offset: 2px;
  box-shadow: var(--focus-ring), 0 18px 42px -12px rgba(0, 82, 163, 0.18);
}
.composer-send-btn {
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 82, 163, 0.26);
  transition: transform 0.16s var(--ease-spring), background 0.15s ease, opacity 0.16s ease;
}
.composer-send-btn:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); transform: scale(1.04); }
.composer-send-btn:active:not(:disabled) { transform: scale(0.94); }
.composer-send-btn:disabled { opacity: 0.42; cursor: not-allowed; box-shadow: none; }
html[data-contrast="high"] .composer-send-btn {
  border: 2px solid var(--border-strong);
  box-shadow: none;
}

/* Sculpted Financial Table Elevation */
.answer-table-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03), 0 12px 30px -16px rgba(0, 0, 0, 0.08);
}

/* Workbench Apple Card Elevation */
.wb-kpi-card, .wb-control-bar, .wb-rail, .wb-detail {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 8px 24px -16px rgba(0, 0, 0, 0.07);
}
.welcome-hero p.lead {
  margin: 0 0 1.85rem;
  color: var(--ink-muted);
  max-width: 56ch;
  font-size: 1rem;
  line-height: 1.56;
  letter-spacing: -0.01em;
}
.welcome-hero p.lead strong {
  color: var(--ink);
  font-weight: 600;
}

/* Crisp Single-Layer Apple Starter Grid (No heavy outer bezels) */
.starter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.35rem;
}

.starter-bezel {
  display: contents; /* Clean single-layer surface without clunky nested frame */
}

.starter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.starter-kicker {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}
.starter-arrow {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  transition: background 0.18s var(--ease-spring), color 0.18s ease, transform 0.2s var(--ease-spring);
}
html[data-theme="dark"] .starter-arrow {
  background: var(--surface-elevated);
  color: var(--ink-secondary);
}
.starter-btn:hover .starter-arrow {
  background: var(--accent);
  color: var(--accent-ink);
  transform: translateX(2px);
}

.welcome-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--ink-muted);
  padding-top: 0.25rem;
}

/* ==========================================================================
   6. Pure Apple Chat Rhythm, Monochrome Thinking Orb & Inline Source Chips
   ========================================================================== */

.thread {
  display: flex;
  flex-direction: column;
  gap: 1.85rem;
  width: 100%;
  min-width: 0;
}

/* Open, razor-clean verified assistant response on pure neutral canvas */
.msg-assistant {
  background: transparent;
  padding: 0.15rem 0 0.4rem;
  width: 100%;
  min-width: 0;
  animation: fadeSlideUp 0.34s var(--ease-out) both;
}
html[data-contrast="high"] .msg-assistant {
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.2rem;
}

/* Quiet Apple Metadata Header (Replaces noisy badge stacks!) */
.assistant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.assistant-meta-line {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-muted);
}
.assistant-meta-line .meta-ok {
  color: var(--ok);
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-weight: 600;
}
.assistant-meta-line .meta-watch {
  color: var(--watch);
  font-weight: 600;
}
.assistant-meta-line .meta-high {
  color: var(--high);
  font-weight: 600;
}
.meta-sep { opacity: 0.4; }

.sources-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  min-height: var(--tap-min);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.sources-chip-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
}
html[data-contrast="high"] .sources-chip-btn { border: 2px solid var(--border); min-height: 44px; }

.answer-prose {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  width: 100%;
  max-width: 66ch;
  min-width: 0;
  letter-spacing: -0.008em;
  word-break: break-word;
}
.answer-prose p { margin: 0 0 0.9rem; }
.answer-prose p:last-child { margin-bottom: 0; }
.answer-prose ul,
.answer-prose ol {
  margin: 0.38rem 0 0.9rem 1.28rem;
  padding: 0;
}
.answer-prose li { margin-bottom: 0.44rem; }
.answer-prose strong { font-weight: 600; color: var(--ink); }
html[data-theme="dark"] .answer-prose {
  letter-spacing: 0.003em;
  line-height: 1.68;
}
html[data-theme="dark"] .answer-prose strong {
  color: #ffffff;
}

.answer-subhead {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  margin: 1.25rem 0 0.45rem;
  letter-spacing: -0.02em;
}
.answer-subhead:first-child { margin-top: 0; }

.reveal-fade {
  animation: softAppear 0.32s var(--ease-out) both;
}

/* Verified Key Numbers Strip — Clean Apple Metric Tiles */
.key-metrics-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 0.6rem;
  margin: 0 0 1rem;
  max-width: 66ch;
}
.metric-tile {
  text-align: left;
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface-muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.14s var(--ease-spring);
}
.metric-tile:hover {
  background: var(--surface);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.metric-tile:active { transform: scale(0.985); }
html[data-contrast="high"] .metric-tile { border: 2px solid var(--border-strong); background: var(--surface); }
.metric-tile-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-muted);
  line-height: 1.3;
}
.metric-tile-val {
  font-family: var(--mono);
  font-size: 1.18rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.metric-tile-foot {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  gap: 0.24rem;
}

/* Crisp Single-Layer Apple Financial Tables + Subtle Blue Proportion Bars */
.answer-table-wrap {
  margin: 0.9rem 0 1.15rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.answer-table-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
html[data-theme="dark"] .answer-table-card {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.52);
}
html[data-contrast="high"] .answer-table-card { border: 2px solid var(--border-strong); }
.answer-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.72rem 0.95rem;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-muted);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.answer-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.answer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  line-height: 1.45;
}
.answer-table th,
.answer-table td {
  padding: 0.78rem 0.95rem;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}
.answer-table tbody tr:last-child td,
.answer-table tbody tr:last-child th { border-bottom: none; }
.answer-table tfoot tr.row-summary td,
.answer-table tfoot tr.row-summary th {
  border-top: 1px solid var(--border);
  border-bottom: none;
  background: var(--surface-muted);
  font-weight: 600;
  color: var(--ink);
}
.answer-table tbody tr:hover td,
.answer-table tbody tr:hover th { background: rgba(0, 113, 227, 0.025); }
html[data-theme="dark"] .answer-table tbody tr:hover td,
html[data-theme="dark"] .answer-table tbody tr:hover th { background: rgba(255, 255, 255, 0.045); }
.answer-table tbody tr.row-highlight td,
.answer-table tbody tr.row-highlight th {
  background: var(--accent-soft);
}
.answer-table tbody tr.row-highlight td:first-child,
.answer-table tbody tr.row-highlight th:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}
.answer-table thead th {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  color: var(--ink-secondary);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  white-space: normal;
  line-height: 1.3;
  padding-top: 0.62rem;
  padding-bottom: 0.62rem;
  vertical-align: middle;
}
.answer-table tbody th,
.answer-table tfoot th {
  font-weight: 600;
  color: var(--ink);
}
.answer-table th.num {
  font-family: var(--sans);
  white-space: normal;
}
.answer-table th.is-sortable {
  padding: 0;
}
.table-sort-btn {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0.56rem 0.95rem;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.36rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.table-sort-btn:hover {
  background: var(--surface-hover);
  color: var(--ink);
}
.table-sort-btn:focus-visible {
  outline-offset: -2px;
}
.answer-table th.num .table-sort-btn {
  flex-direction: row-reverse;
  justify-content: flex-start;
  text-align: right;
}
.answer-table th.rank-cell .table-sort-btn {
  justify-content: center;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
}
.table-sort-label {
  min-width: 0;
}
.table-sort-indicator {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5px;
  width: 9px;
  flex-shrink: 0;
  color: var(--ink-muted);
}
.table-sort-indicator svg {
  width: 8px;
  height: 5px;
  opacity: 0.28;
  transition: opacity 0.14s ease, color 0.14s ease;
}
html[data-theme="dark"] .table-sort-indicator svg {
  opacity: 0.56;
}
.table-sort-btn:hover .table-sort-indicator svg {
  opacity: 0.62;
}
html[data-theme="dark"] .table-sort-btn:hover .table-sort-indicator svg {
  opacity: 0.9;
}
.answer-table th[aria-sort="ascending"],
.answer-table th[aria-sort="descending"] {
  color: var(--ink);
}
.answer-table th[aria-sort="ascending"] .sort-chev-up {
  opacity: 1;
  color: var(--accent-text);
}
.answer-table th[aria-sort="ascending"] .sort-chev-down {
  opacity: 0.14;
}
.answer-table th[aria-sort="descending"] .sort-chev-down {
  opacity: 1;
  color: var(--accent-text);
}
.answer-table th[aria-sort="descending"] .sort-chev-up {
  opacity: 0.14;
}
html[data-contrast="high"] .table-sort-btn {
  min-height: 44px;
}

.answer-table td.col-subject,
.answer-table tbody th.col-subject,
.answer-table tfoot th.col-subject {
  font-weight: 600;
  color: var(--ink);
  min-width: 132px;
  letter-spacing: -0.01em;
}
.answer-table td.col-callout {
  min-width: 150px;
}
.answer-table td.col-context {
  color: var(--ink-secondary);
  font-size: 0.83rem;
  line-height: 1.48;
}
/* Proportional comparison widths apply ONLY to 3+ column narrative comparison tables */
.answer-table-card.is-comparison-table td.col-subject,
.answer-table-card.is-comparison-table tbody th.col-subject,
.answer-table-card.is-comparison-table tfoot th.col-subject { width: 26%; }
.answer-table-card.is-comparison-table td.col-callout { width: 31%; }
.answer-table-card.is-comparison-table td.col-context { width: 43%; }

/* Clean numeric & bar columns share unified tabular sans typography and flush-right alignment */
.answer-table td.num {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 1%;
  padding-left: 1.35rem;
}
.answer-table th.num {
  width: 1%;
  min-width: 7.25rem;
}
.answer-table th.num .table-sort-btn {
  padding-left: 1.35rem;
}
.answer-table td.col-bar {
  min-width: 9.5rem;
}

/* Scannable Metric & Rank Callout Stack inside Tables */
.table-callout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.28rem;
  max-width: 100%;
}
.table-callout-main {
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.22;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: normal;
  word-break: break-word;
}
.table-callout-main.is-rank-callout {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.62rem;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent-text);
  font-size: 0.94rem;
}
html[data-theme="dark"] .table-callout-main.is-rank-callout {
  background: var(--surface-elevated);
  border-color: rgba(122, 184, 255, 0.34);
  color: #8ec5ff;
}
.table-callout-sub {
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.38;
  color: var(--ink-secondary);
  white-space: normal;
  word-break: break-word;
}
.table-callout-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.52rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.table-callout-pill.tone-positive {
  background: rgba(15, 84, 36, 0.08);
  color: #0f5424;
  border: 1px solid rgba(15, 84, 36, 0.42);
}
.table-callout-pill.tone-warm {
  background: rgba(180, 83, 9, 0.09);
  color: #7a3600;
  border: 1px solid rgba(122, 54, 0, 0.44);
}
.table-callout-pill.tone-neutral {
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--accent-border);
}
html[data-theme="dark"] .table-callout-pill.tone-positive {
  background: rgba(48, 209, 88, 0.16);
  color: #7bf09c;
  border-color: rgba(123, 240, 156, 0.45);
}
html[data-theme="dark"] .table-callout-pill.tone-warm {
  background: rgba(245, 158, 11, 0.16);
  color: #ffd166;
  border-color: rgba(255, 209, 102, 0.45);
}
html[data-contrast="high"] .table-callout-pill {
  border-width: 1.5px;
  color: var(--ink);
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

/* Responsive Mobile Callout Cards for 3+ column explanatory comparison tables */
@media (max-width: 680px) {
  .answer-table-card.is-comparison-table .answer-table-scroll {
    overflow-x: visible;
  }
  .answer-table-card.is-comparison-table .answer-table,
  .answer-table-card.is-comparison-table tbody,
  .answer-table-card.is-comparison-table tfoot,
  .answer-table-card.is-comparison-table tr,
  .answer-table-card.is-comparison-table td,
  .answer-table-card.is-comparison-table tbody th,
  .answer-table-card.is-comparison-table tfoot th,
  .answer-table-card.is-comparison-table td.col-subject,
  .answer-table-card.is-comparison-table th.col-subject,
  .answer-table-card.is-comparison-table td.col-callout,
  .answer-table-card.is-comparison-table td.col-context,
  .answer-table-card.is-comparison-table td.num,
  .answer-table-card.is-comparison-table td.col-bar,
  .answer-table-card.is-comparison-table td.rank-cell {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 0;
    border: none;
    white-space: normal;
    text-align: left !important;
  }
  .answer-table-card.is-comparison-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .answer-table-card.is-comparison-table tbody tr,
  .answer-table-card.is-comparison-table tfoot tr {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    gap: 0.44rem;
  }
  .answer-table-card.is-comparison-table tbody tr:last-child {
    border-bottom: none;
  }
  .answer-table-card.is-comparison-table tfoot tr.row-summary {
    border-top: 1px solid var(--border);
    border-bottom: none;
    background: var(--surface-muted);
  }
  .answer-table-card.is-comparison-table tfoot tr.row-summary td {
    border-top: none;
    background: transparent;
  }
  .answer-table-card.is-comparison-table td.col-subject,
  .answer-table-card.is-comparison-table tbody th.col-subject,
  .answer-table-card.is-comparison-table tfoot th.col-subject {
    font-size: 0.92rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: -0.01em;
    line-height: 1.35;
    color: var(--ink);
    word-break: normal;
    overflow-wrap: break-word;
  }
  .answer-table-card.is-comparison-table td.col-callout .table-callout {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  .answer-table-card.is-comparison-table td.col-callout .table-callout-main {
    font-size: 1.1rem;
  }
  .answer-table-card.is-comparison-table td.num .val-with-bar {
    display: flex;
    align-items: flex-start;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 0.3rem;
  }
  .answer-table-card.is-comparison-table td.num .val-text {
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: -0.02em;
  }
  .answer-table-card.is-comparison-table td.num .val-bar-track {
    max-width: 100%;
    height: 4px;
  }
  .answer-table-card.is-comparison-table td.col-context {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--ink-secondary);
    word-break: normal;
    overflow-wrap: break-word;
  }
  .answer-table-card.is-comparison-table tbody td[data-label]:not(.col-subject)::before,
  .answer-table-card.is-comparison-table tfoot td[data-label]:not(.col-subject)::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-muted);
    margin-bottom: 0.14rem;
  }
  .answer-table-card.is-comparison-table td.col-context .inline-cite-btn {
    margin-top: 0.2rem;
  }
}
.answer-table .rank-cell {
  width: 1%;
  min-width: 3.75rem;
  white-space: nowrap;
  text-align: center;
  padding-left: 0.75rem;
  padding-right: 0.55rem;
}
.answer-table th.rank-cell .table-sort-btn {
  white-space: nowrap;
  padding-left: 0.75rem;
  padding-right: 0.55rem;
}
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-secondary);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
}
.answer-table tbody tr:first-child .rank-badge {
  background: var(--ink);
  color: var(--bg);
}
.val-with-bar {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.28rem;
  min-width: 7.25rem;
  width: 100%;
  max-width: 9.5rem;
}
.val-text {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
}
.val-bar-track {
  width: 100%;
  max-width: 8.5rem;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}
html[data-theme="dark"] .val-bar-track {
  background: #303036;
}
.val-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.78;
}
html[data-contrast="high"] .val-bar-fill { opacity: 1; }

/* Inline Clickable Citation Chips INSIDE Answer Prose (Crisp Apple Blue Tint) */
.inline-cite-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.24rem;
  vertical-align: baseline;
  max-width: 100%;
  margin: 0.08rem 0.16rem;
  padding: 0.12rem 0.52rem;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: var(--sans);
  font-size: 0.76em;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.38;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.12s var(--ease-spring);
}
.inline-cite-btn > span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.inline-cite-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
/* Dark mode: neutral elevated capsule + luminous sky-blue link (zero blue-on-dark-navy blur) */
html[data-theme="dark"] .inline-cite-btn {
  background: #222226;
  border-color: rgba(255, 255, 255, 0.14);
  color: #82bfff;
}
html[data-theme="dark"] .inline-cite-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.inline-cite-btn:active { transform: scale(0.96); }
.inline-cite-btn.cite-calc {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--ink-secondary);
}
.inline-cite-btn.cite-calc:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.inline-cite-btn.cite-sql {
  background: var(--ok-soft);
  border-color: var(--ok-border);
  color: var(--ok);
}
.inline-cite-btn.cite-sql:hover {
  background: var(--ok);
  border-color: var(--ok);
  color: #ffffff;
}
html[data-theme="dark"] .inline-cite-btn.cite-sql {
  background: #18261d;
  border-color: rgba(50, 215, 75, 0.34);
  color: #6ee792;
}
html[data-theme="dark"] .inline-cite-btn.cite-sql:hover {
  background: var(--ok);
  border-color: var(--ok);
  color: #06180a;
}
html[data-contrast="high"] .inline-cite-btn,
html[data-contrast="high"] .inline-cite-btn.cite-calc,
html[data-contrast="high"] .inline-cite-btn.cite-sql,
html[data-contrast="high"] .inline-cite-btn.cite-web {
  border-width: 2px;
  border-color: var(--accent-border);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.22rem 0.62rem;
}
html[data-contrast="high"] .inline-cite-btn:hover,
html[data-contrast="high"] .inline-cite-btn.cite-calc:hover,
html[data-contrast="high"] .inline-cite-btn.cite-sql:hover,
html[data-contrast="high"] .inline-cite-btn.cite-web:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

/* Monochrome Apple Thinking Indicator (Exact wtpchat Orb + Neutral Shimmer) */
.thinking-shell {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.5rem 0.1rem;
  animation: fadeSlideUp 0.24s var(--ease-out) both;
}
.thinking-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.thinking-orb {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--ink-secondary);
  animation: spinRing 0.85s linear infinite;
  flex-shrink: 0;
}
.thinking-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-muted);
  background: linear-gradient(90deg, var(--ink-muted) 0%, var(--ink) 48%, var(--ink-muted) 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: textShimmer 1.9s linear infinite;
}
html[data-contrast="high"] .thinking-label {
  background: none;
  -webkit-text-fill-color: var(--ink);
  color: var(--ink);
}

.thinking-skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-width: 32rem;
  padding-left: 1.55rem;
}
.skel-bar {
  height: 0.62rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--surface-hover) 50%, var(--surface-muted) 75%);
  background-size: 200% 100%;
  animation: skelSweep 1.4s ease-in-out infinite;
}
.skel-bar.w1 { width: 90%; }
.skel-bar.w2 { width: 72%; }
.skel-bar.w3 { width: 48%; }

.thinking-steps-disclosure {
  padding-left: 1.55rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.thinking-steps-disclosure summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--ink-muted);
}
.progress-steps {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.78rem;
  color: var(--ink-secondary);
}
.progress-steps li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 36rem;
}
.progress-steps .ms {
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  flex-shrink: 0;
}

.progress-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  box-shadow: var(--shadow-xs);
}
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.45rem;
}

/* ==========================================================================
   7. Truth-Class Callouts & Quiet Progressive Disclosure
   ========================================================================== */

.truth-section { margin-top: 1.1rem; }
.truth-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
  font-size: 0.69rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.reasoning-box {
  background: var(--reason-soft);
  border-left: 2.5px solid var(--ink-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.82rem 1rem;
  font-size: 0.9rem;
  color: var(--ink-secondary);
  max-width: 66ch;
}
html[data-contrast="high"] .reasoning-box { border: 2px solid var(--border); border-radius: var(--radius-sm); color: var(--ink); }
.reasoning-box ul { margin: 0.25rem 0 0 1.15rem; padding: 0; }
.reasoning-box li { margin-bottom: 0.36rem; }

.missing-box {
  background: var(--watch-soft);
  border-left: 2.5px solid var(--watch);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.82rem 1rem;
  font-size: 0.9rem;
  color: var(--ink);
  max-width: 66ch;
}
html[data-contrast="high"] .missing-box { border: 2px solid var(--watch-border); border-radius: var(--radius-sm); }
.missing-box ul { margin: 0.25rem 0 0 1.15rem; padding: 0; }

.truth-details {
  margin-top: 0.7rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 66ch;
}
html[data-contrast="high"] .truth-details { border: 2px solid var(--border-strong); }
.truth-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.64rem 0.95rem;
  min-height: var(--tap-min);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  user-select: none;
}
.truth-details > summary::-webkit-details-marker { display: none; }
.truth-details > summary .chev {
  color: var(--ink-muted);
  transition: transform 0.2s var(--ease-spring);
}
.truth-details[open] > summary .chev { transform: rotate(180deg); }
.truth-details-body { padding: 0 0.95rem 0.95rem; }

.fact-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.fact-row {
  padding: 0.8rem 0.95rem;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}
html[data-contrast="high"] .fact-row { border: 2px solid var(--border); background: var(--surface); }
.fact-claim { font-weight: 600; margin-bottom: 0.3rem; color: var(--ink); }
.fact-quote {
  color: var(--ink-secondary);
  font-size: 0.88rem;
  line-height: 1.54;
  border-left: 2.5px solid var(--accent);
  padding-left: 0.75rem;
  margin: 0.4rem 0 0.55rem;
}
.fact-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.calc-row {
  padding: 0.8rem 0.95rem;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  margin-bottom: 0.55rem;
}
.calc-result {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-text);
}
.calc-formula {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-secondary);
  margin: 0.25rem 0;
}

/* Primary Follow-Up Suggestions (Elevated directly beneath the answer) */
.next-questions-block {
  margin-top: 1.35rem;
  max-width: 66ch;
}
.next-questions-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
  margin-bottom: 0.5rem;
}
.door-list {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}
.door-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: var(--tap-min);
  padding: 0.62rem 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 0.89rem;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.14s var(--ease-spring), box-shadow 0.16s ease;
}
.door-btn:hover {
  border-color: var(--accent-border);
  color: var(--accent-text);
  background: var(--accent-soft);
  box-shadow: 0 3px 10px -4px rgba(0, 113, 227, 0.16);
  transform: translateY(-1px);
}
.door-btn:active { transform: scale(0.99); }
.door-arrow {
  color: var(--ink-muted);
  flex-shrink: 0;
  transition: transform 0.18s var(--ease-spring), color 0.15s ease;
}
.door-btn:hover .door-arrow {
  color: var(--accent-text);
  transform: translateX(3px);
}
html[data-contrast="high"] .door-btn { border: 2px solid var(--border-strong); min-height: 48px; }

/* Secondary Unified Full-Context Accordion (Whisper-quiet beneath follow-ups) */
.secondary-audit-strip {
  margin-top: 1.15rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--hairline);
  max-width: 66ch;
}
.full-context-accordion {
  margin-bottom: 0.55rem;
}
.full-context-accordion > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.48rem 0.7rem;
  margin: 0 -0.7rem;
  border-radius: 10px;
  min-height: 40px;
  color: var(--ink-muted);
  font-size: 0.8rem;
  transition: background 0.14s ease, color 0.14s ease;
  user-select: none;
}
.full-context-accordion > summary::-webkit-details-marker { display: none; }
.full-context-accordion > summary:hover {
  background: var(--surface-muted);
  color: var(--ink);
}
.full-context-accordion[open] > summary {
  color: var(--ink);
  background: var(--surface-muted);
}
.full-context-accordion[open] > summary .chev {
  transform: rotate(180deg);
}
.fc-summary-left {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.fc-title {
  font-weight: 600;
  color: var(--ink-secondary);
}
.fc-meta {
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.full-context-body {
  margin-top: 0.75rem;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
html[data-contrast="high"] .full-context-body {
  background: var(--surface);
  border: 2px solid var(--border-strong);
}
.fc-group .fact-row,
.fc-group .calc-row {
  background: var(--surface);
}
.fc-group .reasoning-box {
  background: var(--surface);
  border-left-color: var(--ink-muted);
}

.answer-footer {
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
  font-size: 0.74rem;
  color: var(--ink-muted);
}

/* Inline Report-a-Mistake Tray */
.report-tray {
  margin-top: 0.65rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
}
html[data-contrast="high"] .report-tray { border: 2px solid var(--border-strong); background: var(--surface); }
.report-tray-head {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.report-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-bottom: 0.6rem;
}
.report-chip {
  min-height: var(--tap-min);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: var(--surface);
  color: var(--ink-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.report-chip:hover { border-color: var(--accent-border); color: var(--accent-text); }
.report-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.report-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.report-input {
  min-height: 40px;
  font-size: 0.84rem;
  padding: 0.45rem 0.75rem;
}
.feedback-group {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   8. Sculpted Apple Pill Composer (No Heavy Bezel Frame) & Quiet Utility Strip
   ========================================================================== */

.composer-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--bg) 82%, rgba(255, 255, 255, 0) 100%);
  padding: 0.72rem 1rem calc(0.68rem + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  pointer-events: none;
}
.composer-dock.is-turnstile-takeover {
  z-index: 140;
}
html[data-theme="dark"] .composer-dock {
  background: linear-gradient(to top, #000000 68%, rgba(0, 0, 0, 0.88) 84%, rgba(0, 0, 0, 0) 100%);
}
html[data-contrast="high"] .composer-dock {
  background: var(--bg);
  border-top: 2px solid var(--border-strong);
  padding-top: 0.65rem;
}

/* Turnstile Composer Takeover: stays 0px while silent/satisfied; cleanly replaces chat input when verification is required */
.turnstile-takeover {
  margin: 0;
  padding: 0;
}
.turnstile-takeover-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
}
.turnstile-takeover-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.turnstile-takeover-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.012em;
}
.turnstile-takeover-sub {
  font-size: 0.76rem;
  color: var(--ink-muted);
  line-height: 1.38;
}
.turnstile-pending-preview {
  margin-top: 0.42rem;
  font-size: 0.8rem;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.turnstile-cancel-btn {
  flex-shrink: 0;
  min-height: var(--tap-min);
  padding: 0.35rem 0.72rem;
}
.turnstile-mount {
  margin: 0;
  padding: 0;
  line-height: 0;
}
.turnstile-mount.is-satisfied {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Active Turnstile Takeover — replaces #chatForm in-place using the exact Apple composer surface */
.composer-dock.is-turnstile-takeover .composer-suggestions {
  display: none !important;
}
.composer-bezel.is-turnstile-takeover #chatForm,
.composer-bezel.is-turnstile-takeover .composer-share-row,
.composer-bezel.is-turnstile-takeover .composer-share-details {
  display: none !important;
}
.composer-bezel.is-turnstile-takeover .turnstile-takeover {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 0.82rem 1rem 0.9rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04), 0 16px 40px -12px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  animation: softAppear 0.2s var(--ease-out) both;
}
html[data-theme="dark"] .composer-bezel.is-turnstile-takeover .turnstile-takeover {
  background: #222226;
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.78), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
html[data-contrast="high"] .composer-bezel.is-turnstile-takeover .turnstile-takeover {
  border: 2px solid var(--border-strong);
  box-shadow: none;
}
.composer-bezel.is-turnstile-takeover .turnstile-takeover-head {
  display: flex;
}
.composer-bezel.is-turnstile-takeover .turnstile-mount {
  margin-top: 0.6rem;
  line-height: normal;
  max-height: none;
  overflow: visible;
  opacity: 1;
  pointer-events: auto;
}

/* Genuine single top-level contentinfo footer strictly below the fold; always keyboard-reachable */
.site-footer {
  max-width: 780px;
  margin: 1.5rem auto 0;
  padding: 0.85rem 1.25rem calc(max(9.5rem, var(--composer-dock-h, 0px) + 2.25rem) + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  line-height: 1.48;
  color: var(--ink-muted);
}
.site-footer-note {
  margin: 0;
}
.site-footer-links {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.footer-sep {
  color: var(--ink-muted);
}
.footer-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.65rem;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font: inherit;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}
.footer-link-btn:hover {
  color: var(--ink);
  background: var(--surface-muted);
  text-decoration: underline;
}
html[data-contrast="high"] .footer-link-btn {
  color: var(--ink);
  text-decoration: underline;
}

.composer-inner {
  max-width: 780px;
  margin: 0 auto;
  pointer-events: auto;
}

/* Composer Alt Toolbar: Contextual Suggested Next Questions attached to the text field */
.composer-suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  margin-bottom: 0.45rem;
}
.composer-suggestions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.35rem;
  font-size: 0.69rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}
.composer-suggestions-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
}
.composer-suggestions-dismiss:hover {
  background: var(--surface-muted);
  color: var(--ink);
}
.composer-suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 0.42rem;
}
.composer-sug-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  width: 100%;
  min-height: var(--tap-min);
  padding: 0.48rem 0.78rem;
  border-radius: 13px;
  border: 1px solid var(--control-border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.34;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.14s var(--ease-spring), box-shadow 0.15s ease;
}
html[data-theme="dark"] .composer-sug-chip {
  background: rgba(34, 34, 37, 0.88);
  border-color: var(--border);
}
.composer-sug-chip:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: 0 3px 10px -4px rgba(0, 113, 227, 0.18);
  transform: translateY(-1px);
}
.composer-sug-chip:active { transform: scale(0.99); }
.composer-sug-chip .sug-arrow {
  color: var(--ink-muted);
  flex-shrink: 0;
  transition: transform 0.16s var(--ease-spring), color 0.14s ease;
}
.composer-sug-chip:hover .sug-arrow {
  color: var(--accent-text);
  transform: translateX(2px);
}
html[data-contrast="high"] .composer-sug-chip {
  background: var(--surface);
  backdrop-filter: none;
  border: 2px solid var(--border-strong);
  min-height: 44px;
}

.composer-bezel {
  display: block; /* Single clean Apple surface, zero chunky outer frame */
}
html[data-contrast="high"] .composer-pill { border: 2px solid var(--border-strong); background: var(--surface); box-shadow: none; }

.composer-right-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  align-self: flex-end;
  padding-bottom: 0.1rem;
}

.composer-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  min-height: var(--tap-min);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: var(--surface-muted);
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.composer-more-btn:hover {
  background: var(--surface-hover);
  color: var(--ink);
  border-color: var(--border-strong);
}
html[data-theme="dark"] .composer-more-btn {
  background: #2e2e33;
  border-color: var(--control-border);
  color: var(--ink-secondary);
}
html[data-theme="dark"] .composer-more-btn:hover {
  background: #3a3a40;
  color: #ffffff;
}
.composer-more-btn .chev {
  width: 13px;
  height: 13px;
  transition: transform 0.18s var(--ease-spring);
}
.composer-more-btn[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
}
.composer-more-btn[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

.composer-accept-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  min-height: var(--tap-min);
  padding: 0.35rem 0.92rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px -2px rgba(0, 82, 163, 0.32);
  transition: background 0.15s ease, transform 0.14s var(--ease-spring), box-shadow 0.15s ease;
}
.composer-accept-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px -2px rgba(0, 82, 163, 0.38);
}
.composer-accept-btn:active { transform: scale(0.98); }
.composer-accept-btn .ico {
  width: 14px;
  height: 14px;
}
html[data-contrast="high"] .composer-more-btn,
html[data-contrast="high"] .composer-accept-btn {
  min-height: var(--tap-min);
  border-width: 2px;
}

.composer-input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.composer-textarea {
  width: 100%;
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.96rem;
  line-height: 1.44;
  min-height: var(--tap-min);
  max-height: 13.5rem;
  padding: 0.56rem 0;
  resize: none;
  overflow-y: hidden;
  outline: 2px solid transparent;
}

/* Full multi-line suggested follow-up card integrated directly into the composer pill
   so suggested questions are NEVER clipped to 1 line and are unmistakably ready to ask. */
.composer-pill.has-suggestion {
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  border-radius: 22px;
  padding: 0.72rem 0.72rem 0.58rem 1rem;
}
.composer-pill.has-suggestion .composer-right-controls {
  width: 100%;
  justify-content: flex-end;
  align-self: stretch;
  padding-bottom: 0;
  border-top: 1px solid var(--hairline);
  padding-top: 0.48rem;
}
.composer-pill.has-suggestion #utilNewChatBtn {
  margin-right: auto;
}
.composer-pill.has-suggestion .composer-textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  color: transparent;
  caret-color: var(--ink);
  cursor: text;
}
.composer-pill.has-suggestion .composer-textarea::placeholder {
  color: transparent;
}
.composer-suggestion-preview {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  width: 100%;
  pointer-events: none;
}
.composer-suggestion-kicker {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  color: var(--accent-text);
  opacity: 0.9;
}
html[data-theme="dark"] .composer-suggestion-kicker {
  color: #8ec5ff;
  opacity: 1;
}
.composer-suggestion-text {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.42;
  color: var(--ink);
  white-space: normal;
  word-break: break-word;
}
.composer-pill.has-suggestion:focus-within .composer-suggestion-preview {
  opacity: 0.8;
}
.composer-textarea:focus,
.composer-textarea:focus-visible {
  outline: 2px solid transparent;
  box-shadow: none;
}
.composer-textarea::placeholder { color: var(--ink-muted); opacity: 1; }

/* High-Privacy-First Opt-In Parish Sharing Bar below Composer (OFF by default, >=44px targets) */
.composer-share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
  padding: 0 0.45rem;
}
.composer-share-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: var(--tap-min);
  padding: 0.25rem 0.35rem 0.25rem 0.15rem;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  flex: 1 1 min(220px, 100%);
  min-width: 0;
}
.composer-share-label:hover {
  color: var(--ink);
}
.composer-share-checkbox,
.followup-share-checkbox {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 6px;
}
.composer-share-text {
  min-width: 0;
}
.composer-share-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--accent-text);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.composer-share-info-btn:hover,
.composer-share-info-btn[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
html[data-contrast="high"] .composer-share-info-btn {
  border: 2px solid var(--border);
}
.composer-share-details {
  margin-top: 0.35rem;
  padding: 0.72rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1.5px solid var(--control-border);
  box-shadow: var(--shadow-sm);
  font-size: 0.8rem;
  line-height: 1.48;
  color: var(--ink-secondary);
}
.composer-share-details[hidden] {
  display: none !important;
}
.composer-share-details-copy {
  margin: 0 0 0.45rem;
}
.composer-share-details-copy strong {
  color: var(--ink);
}
.composer-share-details-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.composer-share-policy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: var(--surface-muted);
  color: var(--accent-text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.composer-share-policy-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
html[data-contrast="high"] .composer-share-details {
  border-width: 2px;
  box-shadow: none;
}

.utility-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.42rem;
  padding: 0 0.4rem;
  font-size: 0.74rem;
  color: var(--ink-muted);
}
.utility-actions {
  display: flex;
  align-items: center;
  gap: 0.18rem;
  flex-wrap: wrap;
}
.utility-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.26rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.74rem;
  font-weight: 500;
  min-height: var(--tap-min);
  transition: background 0.14s ease, color 0.14s ease;
}
.utility-btn:hover { background: var(--surface-muted); color: var(--ink); }
.utility-btn.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-border);
}
html[data-contrast="high"] .utility-btn { min-height: var(--tap-min); border-color: var(--border); color: var(--ink); }

.composer-input {
  flex: 1;
  min-height: var(--tap-min);
  padding: 0.55rem 0.9rem;
  border: 1.5px solid var(--control-border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
  color: var(--ink);
}
.composer-input:focus,
.composer-input:focus-visible {
  outline: 3px solid var(--focus-outline);
  outline-offset: 2px;
  border-color: var(--focus-outline);
  box-shadow: var(--focus-ring);
}
.composer-input[aria-invalid="true"] {
  border-color: var(--high);
}

/* ==========================================================================
   9. Floating Apple Sheets (Left Hamburger Menu & Right Live PDF Sheet)
   ========================================================================== */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 160;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s var(--ease-spring), visibility 0s linear 0.24s;
  display: flex;
  padding: 0.65rem;
}
.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.24s var(--ease-spring), visibility 0s linear 0s;
}
.drawer-overlay.align-left { justify-content: flex-start; }
.drawer-overlay.align-right { justify-content: flex-end; }
html[data-contrast="high"] .drawer-overlay { backdrop-filter: none; }

.drawer-sheet {
  height: 100%;
  background: var(--surface);
  color: var(--ink);
  border-radius: 18px;
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-sheet);
  display: flex;
  flex-direction: column;
  max-width: 100%;
  transition: transform 0.34s var(--ease-spring);
  overflow: hidden;
  outline: none;
}
.drawer-overlay.align-left .drawer-sheet {
  width: min(388px, calc(100vw - 56px));
  transform: translateX(-106%);
}
.drawer-overlay.align-right .drawer-sheet {
  width: min(720px, calc(100vw - 64px));
  transform: translateX(106%);
}
.drawer-overlay.open .drawer-sheet { transform: translateX(0); }
html[data-theme="dark"] .drawer-sheet { border-color: rgba(255, 255, 255, 0.15); }
html[data-contrast="high"] .drawer-sheet { border-width: 2px; border-color: var(--border-strong); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1.2rem;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  flex-shrink: 0;
}
.drawer-title-group { min-width: 0; }
.drawer-kicker {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}
.drawer-title {
  margin: 0.1rem 0 0;
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.24;
  color: var(--ink);
  word-break: break-word;
}
.drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.05rem 1.2rem 1.6rem;
  -webkit-overflow-scrolling: touch;
}

.drawer-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--hairline);
}
.drawer-section:last-child { border-bottom: none; margin-bottom: 0; }
.drawer-section-label {
  font-size: 0.69rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin: 0 0 0.6rem;
}

.menu-nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.menu-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  min-height: var(--tap-min);
  padding: 0.52rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  transition: background 0.14s ease;
}
.menu-nav-item:hover { background: var(--surface-muted); text-decoration: none; }
.menu-nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.menu-nav-sub {
  font-size: 0.74rem;
  font-weight: 400;
  color: var(--ink-muted);
}

.seg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--tap-min), 1fr));
  gap: 0.35rem;
}
.seg-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dp-helper {
  margin-top: 0.42rem;
  font-size: 0.72rem;
  line-height: 1.42;
  color: var(--ink-muted);
}

.seg-btn {
  min-height: var(--tap-min);
  padding: 0.42rem 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--control-border);
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.seg-btn:hover { background: var(--surface-hover); }
html[data-theme="dark"] .seg-btn {
  background: #2a2a2f;
  border-color: var(--control-border);
}
html[data-theme="dark"] .seg-btn:hover {
  background: #35353c;
}
.seg-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
html[data-theme="dark"] .seg-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.text-preview-box {
  margin-top: 0.55rem;
  padding: 0.68rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  font-size: 1rem;
  line-height: 1.48;
  color: var(--ink);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--control-border);
  background: var(--surface-muted);
  min-height: var(--tap-min);
  cursor: pointer;
  margin-top: 0.55rem;
}
html[data-contrast="high"] .toggle-row { border: 2px solid var(--border); background: var(--surface); }
.toggle-row input {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

/* ==========================================================================
   10. Embedded Live PDF.js Viewer inside the Slide-Over Sheet
   ========================================================================== */

.source-switcher {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.65rem 1.2rem;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-muted);
  flex-shrink: 0;
}
.switcher-pill {
  flex-shrink: 0;
  min-height: var(--tap-min);
  padding: 0.36rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.switcher-pill:hover { border-color: var(--accent-border); color: var(--accent-text); }
.switcher-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.drawer-pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.drawer-pdf-toolbar .btn,
.viewer-toolbar .btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
}

.drawer-pdf-stage {
  background: #2c2c2e;
  border: 1px solid var(--hairline);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 0.85rem;
  overflow: auto;
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
html[data-theme="dark"] .drawer-pdf-stage {
  background: #0d0d0f;
}

.drawer-html-stage {
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  font-size: 0.92rem;
  line-height: 1.62;
  white-space: pre-wrap;
  max-height: 55vh;
  overflow-y: auto;
}
.drawer-html-stage mark,
.viewer-text-mark {
  background: #fde047;
  color: #111111;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
}

.pdf-canvas-wrap {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  margin: 0 auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.36);
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
}
.pdf-canvas-wrap canvas {
  display: block;
}
/* Gently soften harsh white-paper glare on dark screens without inverting authentic scans */
html[data-theme="dark"] .pdf-canvas-wrap canvas {
  filter: brightness(0.93) contrast(1.02);
}
#evHighlightLayer,
#highlightLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pdf-highlight-box {
  position: absolute;
  background: rgba(255, 214, 10, 0.38);
  border: 2px solid rgba(212, 160, 0, 0.92);
  border-radius: 3px;
  pointer-events: none;
}

/* ==========================================================================
   11. Tables, Code Blocks, Full-Screen Viewer & Apple-Grouped Workbench
   ========================================================================== */

.table-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}
html[data-contrast="high"] .table-scroll { border: 2px solid var(--border); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 0.58rem 0.72rem;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
.data-table thead th {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  background: var(--surface-muted);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
html[data-theme="dark"] .data-table thead th {
  color: var(--ink-secondary);
}
.data-table tbody th {
  font-weight: 500;
  color: var(--ink);
  background: transparent;
}
.data-table .btn {
  white-space: nowrap;
}
.num {
  text-align: right !important;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.code-box {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Workbench */
.wb-shell {
  max-width: 1520px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem 2.5rem;
}
.wb-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
  padding: 0.85rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.wb-metrics {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.wb-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.wb-kpi-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0.9rem 1.05rem;
}
.wb-kpi-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.wb-kpi-val {
  font-family: var(--mono);
  font-size: 1.24rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 0.18rem;
  letter-spacing: -0.02em;
}
.wb-kpi-sub {
  font-size: 0.74rem;
  color: var(--ink-muted);
  margin-top: 0.16rem;
}

.mode-tabs {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.mode-tab {
  min-height: 38px;
  padding: 0.38rem 0.9rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-weight: 500;
  font-size: 0.84rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-tab:hover { background: var(--surface); color: var(--ink); }
.mode-tab.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  border-color: var(--hairline);
  box-shadow: var(--shadow-xs);
}

.wb-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1rem;
  align-items: start;
}
.wb-rail {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}
.wb-rail-head {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-muted);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.wb-trace-list {
  max-height: calc(100vh - 280px);
  overflow-y: auto;
}
.wb-trace-item {
  width: 100%;
  text-align: left;
  padding: 0.78rem 0.9rem;
  border: none;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.wb-trace-item:hover { background: var(--surface-muted); }
.wb-trace-item.active { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.wb-trace-q {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.wb-detail {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.2rem 1.35rem;
  min-height: 520px;
}
.wb-section {
  margin-top: 1.2rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--hairline);
}
.wb-section h3 {
  margin: 0 0 0.65rem;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}
.diff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

/* Full-screen PDF Viewer */
.viewer-body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.viewer-topbar-inner {
  max-width: 100%;
}
.viewer-brand-title {
  margin: 0;
  font-size: 1.02rem;
}
.viewer-page-indicator {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-secondary);
  padding: 0 0.25rem;
}
.viewer-side-heading {
  margin: 0 0 0.35rem;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.viewer-meta-block {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  line-height: 1.55;
  margin-bottom: 1rem;
}
.viewer-details-summary {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-secondary);
  padding: 0.35rem 0.25rem;
  margin-bottom: 0.35rem;
  border-radius: 8px;
}
.viewer-raw-text {
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-muted);
  color: var(--ink);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  max-height: 52vh;
  overflow-y: auto;
  border: 1px solid var(--control-border);
  margin: 0;
}
.viewer-grid {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: 370px 1fr;
  min-height: calc(100dvh - 140px);
}
.viewer-side {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  padding: 1rem 1.15rem;
  overflow-y: auto;
}
.viewer-stage {
  background: #2c2c2e;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 1.1rem;
}
html[data-theme="dark"] .viewer-stage {
  background: #0d0d0f;
}
.viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 1.2rem;
  border-top: 1px solid var(--hairline);
  background: var(--surface);
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.viewer-footer-links {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   12. Motion Keyframes, Responsive Breakpoints, Reduced Motion & Print
   ========================================================================== */

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes softAppear {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes spinRing {
  to { transform: rotate(360deg); }
}

@keyframes textShimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -120% 0; }
}

@keyframes skelSweep {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (max-width: 900px) {
  .wb-grid, .viewer-grid, .diff-grid { grid-template-columns: 1fr; }
  .viewer-grid { height: auto; }
  .msg-user { max-width: 90%; }
  .brand-kicker { display: none; }
}

/* Apple Books / Safari Reader Style Aa Display Popover */
.display-popover-anchor {
  position: relative;
}
.aa-glyph {
  font-weight: 600;
  letter-spacing: -0.04em;
  font-size: 0.92em;
}
.display-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(356px, calc(100vw - 24px));
  background: var(--surface);
  border: 1.5px solid var(--control-border);
  border-radius: 18px;
  padding: 0.85rem 1rem 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 20px 48px -12px rgba(0, 0, 0, 0.18);
  z-index: 120;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 0.18s var(--ease-spring), transform 0.22s var(--ease-spring), visibility 0s linear 0.22s;
}
.display-popover.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity 0.18s var(--ease-spring), transform 0.22s var(--ease-spring), visibility 0s linear 0s;
}
html[data-theme="dark"] .display-popover {
  background: #1e1e22;
  border-color: var(--control-border);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.85), 0 0 0 0.5px rgba(255, 255, 255, 0.06);
}
html[data-contrast="high"] .display-popover {
  border: 2px solid var(--border-strong);
  box-shadow: none;
}

.dp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--hairline);
}
.dp-head-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.dp-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: var(--surface-muted);
  color: var(--ink);
  flex-shrink: 0;
  transition: background 0.14s ease;
}
.dp-close-btn:hover {
  background: var(--surface-hover);
}
html[data-contrast="high"] .dp-close-btn {
  border: 2px solid var(--border);
}

.dp-group {
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--hairline);
}
.dp-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}
.dp-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}
.dp-value {
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent-text);
}
.dp-size-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.dp-size-grid {
  flex: 1 1 min(230px, 100%);
  min-width: 0;
}
.dp-size-grid .seg-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0.28rem 0.2rem;
  font-size: 0.78rem;
}
.dp-step-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: var(--radius-sm);
  border: 1px solid var(--control-border);
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  flex-shrink: 0;
  transition: background 0.14s ease;
}
.dp-step-btn:hover:not(:disabled) { background: var(--surface-hover); }
.dp-step-btn:disabled { opacity: 0.42; cursor: not-allowed; }
.display-popover .seg-btn { min-height: var(--tap-min); }
html[data-contrast="high"] .display-popover .seg-btn,
html[data-contrast="high"] .dp-step-btn { min-height: var(--tap-min); border: 2px solid var(--border); }

.dp-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--control-border);
  cursor: pointer;
  min-height: var(--tap-min);
}
html[data-contrast="high"] .dp-toggle { border: 2px solid var(--border); background: var(--surface); }
.dp-toggle-title {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}
.dp-toggle-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 0.08rem;
}
.dp-toggle input {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.btn-active-tint {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
  font-weight: 600;
}
.policy-prose {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-secondary);
}
.policy-prose h3 {
  margin: 0.2rem 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.012em;
}
.policy-prose p { margin: 0; }
.policy-prose ul { margin: 0.25rem 0 0 1.2rem; padding: 0; }
.policy-prose li { margin-bottom: 0.35rem; }

/* ==========================================================================
   14. Follow-Up Contact Capture & Official Source Tier Pills
   ========================================================================== */

.inline-cite-btn.cite-web {
  background: rgba(10, 127, 90, 0.08);
  border-color: rgba(9, 87, 62, 0.42);
  color: #09573e;
}
.inline-cite-btn.cite-web:hover {
  background: #09573e;
  border-color: #09573e;
  color: #ffffff;
}
html[data-theme="dark"] .inline-cite-btn.cite-web {
  background: #18261d;
  border-color: rgba(123, 240, 156, 0.46);
  color: #7bf09c;
}
html[data-theme="dark"] .inline-cite-btn.cite-web:hover {
  background: var(--ok);
  border-color: var(--ok);
  color: #06180a;
}
html[data-contrast="high"] .inline-cite-btn.cite-web {
  background: var(--accent);
  border-color: var(--accent-border);
  color: var(--accent-ink);
}

/* Follow-Up Contact Capture Card (Pure Apple Neutral + Blue Accent) */
.followup-card {
  margin-top: 0.85rem;
  padding: 0.95rem 1.05rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: var(--surface-muted);
}
.followup-card.followup-prominent {
  background: var(--accent-soft);
  border-color: rgba(0, 113, 227, 0.24);
}
html[data-theme="dark"] .followup-card.followup-prominent {
  border-color: rgba(10, 132, 255, 0.34);
}
html[data-contrast="high"] .followup-card {
  border-width: 2px;
  border-color: var(--border-strong);
}

.followup-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.followup-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.followup-card-sub {
  font-size: 0.81rem;
  line-height: 1.48;
  color: var(--ink-secondary);
  margin-top: 0.2rem;
}

.followup-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.72rem;
}
.followup-form .composer-input {
  width: 100%;
  box-sizing: border-box;
}

.followup-channel-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.followup-channel-seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--control-border);
}
.followup-ch-btn {
  min-height: var(--tap-min);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.followup-ch-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.followup-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.followup-field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.followup-input-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.followup-input-row .composer-input {
  min-width: min(220px, 100%);
}

.followup-privacy-promise {
  padding: 0.72rem 0.88rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  border-left: 3.5px solid var(--accent);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-secondary);
}
.followup-privacy-promise strong {
  color: var(--ink);
}
html[data-contrast="high"] .followup-privacy-promise {
  border: 2px solid var(--border-strong);
  background: var(--surface);
}

.followup-share-opt {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  min-height: var(--tap-min);
  padding: 0.58rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--control-border);
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.44;
  cursor: pointer;
}
.followup-share-opt:hover {
  background: var(--surface-hover);
}
html[data-contrast="high"] .followup-share-opt {
  border-width: 2px;
  background: var(--surface);
}

.followup-privacy-note {
  font-size: 0.76rem;
  color: var(--ink-muted);
  line-height: 1.48;
}

.followup-error {
  font-size: 0.8rem;
  color: var(--bad);
  font-weight: 500;
}

.followup-success {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.84rem;
  color: var(--ok);
  font-weight: 600;
}
.followup-success-sub {
  font-size: 0.78rem;
  color: var(--ink-secondary);
  font-weight: 400;
}

/* Contextual Gap Prompt Bar (quiet neutral surface below answer actions — zero color clash!) */
.gap-prompt-bar {
  margin-top: 0.85rem;
  max-width: 66ch;
  padding: 0.75rem 0.95rem;
  border-radius: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 0.85rem;
  flex-wrap: wrap;
}
html[data-theme="dark"] .gap-prompt-bar {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.12);
}
html[data-contrast="high"] .gap-prompt-bar {
  border-width: 2px;
  border-color: var(--border-strong);
}
.gap-prompt-bar.gap-prompt-done {
  background: var(--ok-soft);
  border-color: var(--ok-border);
}
.gap-prompt-copy {
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
  min-width: 0;
  flex: 1 1 260px;
}
.gap-prompt-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.gap-prompt-sub {
  font-size: 0.8rem;
  line-height: 1.44;
  color: var(--ink-secondary);
}
.gap-prompt-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.gap-prompt-cta {
  background: var(--surface);
  color: var(--accent-text);
  border: 1px solid var(--border-strong);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.gap-prompt-cta:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
}
html[data-theme="dark"] .gap-prompt-cta {
  background: var(--surface-elevated);
  border-color: var(--border);
  color: var(--accent-text);
}
html[data-theme="dark"] .gap-prompt-cta:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
html[data-contrast="high"] .gap-prompt-cta {
  border-width: 2px;
  border-color: var(--accent);
}

/* Single Unified Quiet Post-Answer Utility Bar (Full Context + Quiet Actions on ONE row) */
.answer-utility-bar {
  margin-top: 0.7rem;
  padding-top: 0;
  max-width: 66ch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.75rem;
  flex-wrap: wrap;
}

.fc-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-height: var(--tap-min);
  padding: 0.35rem 0.6rem;
  margin-left: -0.6rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.fc-toggle-copy {
  display: inline-flex;
  align-items: baseline;
  gap: 0.14rem 0.42rem;
  flex-wrap: wrap;
  text-align: left;
  line-height: 1.35;
  min-width: 0;
}
.fc-toggle-btn:hover,
.fc-toggle-btn[aria-expanded="true"] {
  color: var(--ink);
}
.fc-toggle-btn:hover {
  background: var(--surface-muted);
}
.fc-toggle-btn .fc-meta {
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--ink-muted);
}
.fc-toggle-btn .chev {
  width: 14px;
  height: 14px;
  color: var(--ink-muted);
  transition: transform 0.18s var(--ease-spring);
}
.fc-toggle-btn[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

.answer-quiet-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
}
.util-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 0.35rem 0.68rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.util-action-btn:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--ink);
}
html[data-theme="dark"] .util-action-btn {
  color: #b4b4be;
}
html[data-theme="dark"] .util-action-btn:hover:not(:disabled) {
  color: #ffffff;
}
.util-action-btn:disabled {
  color: var(--ok);
  cursor: default;
  opacity: 0.92;
}
html[data-contrast="high"] .fc-toggle-btn,
html[data-contrast="high"] .util-action-btn {
  min-height: 44px;
  border: 1px solid var(--border-strong);
}

/* Single-Layer Editorial Full Context Disclosure (Zero Nested Cards or Callout Boxes) */
.full-context-panel {
  max-width: 66ch;
  margin-top: 0.55rem;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius);
  background: var(--surface-muted);
  border: none;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  animation: softAppear 0.2s var(--ease-out) both;
}
html[data-theme="dark"] .full-context-panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
}
html[data-contrast="high"] .full-context-panel {
  background: var(--surface);
  border: 2px solid var(--border-strong);
}

.fc-section + .fc-section {
  padding-top: 1.1rem;
  border-top: 1px solid var(--hairline);
}

.fc-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}
.fc-section-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.012em;
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}
.fc-section-sub {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--ink-muted);
}
.fc-section-count {
  font-size: 0.75rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}
.fc-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fc-status-dot.is-watch {
  background: var(--watch);
}

/* Analytical Reasoning — Flat Editorial Prose Directly on the Panel */
.fc-reasoning-list,
.fc-missing-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}
.fc-reasoning-item,
.fc-missing-item {
  position: relative;
  padding-left: 0.95rem;
}
.fc-reasoning-item::before,
.fc-missing-item::before {
  content: "";
  position: absolute;
  left: 0.1rem;
  top: 0.62em;
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background: var(--ink-muted);
  opacity: 0.75;
}
.fc-missing-item::before {
  background: var(--watch);
  opacity: 0.95;
}
.fc-reasoning-text {
  margin: 0;
  font-size: 0.91rem;
  line-height: 1.62;
  color: var(--ink);
}
.fc-missing-item {
  font-size: 0.89rem;
  line-height: 1.56;
  color: var(--ink);
}
.fc-reasoning-refs {
  margin-top: 0.28rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem 0.3rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.fc-refs-label {
  margin-right: 0.12rem;
}
.fc-ref-sep {
  opacity: 0.55;
}
.fc-ref-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  background: transparent;
  border: none;
  padding: 0.25rem 0.45rem;
  margin: -0.25rem -0.15rem;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}
.fc-ref-link:hover {
  color: var(--accent-text);
  background: var(--accent-soft);
}
html[data-theme="dark"] .fc-ref-link {
  color: #82bfff;
  text-decoration: underline;
  text-decoration-color: rgba(130, 191, 255, 0.35);
  text-underline-offset: 2px;
}
.full-context-panel .inline-cite-btn {
  font-size: 0.74em;
  padding: 0.08rem 0.44rem;
}

/* Verified Source Quotes — Hairline-Separated Typographic Rows (No Nested Cards/Bars) */
.fc-quote-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.fc-quote-item {
  display: grid;
  grid-template-columns: 1.3rem minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--hairline);
  border-radius: 8px;
  transition: background 0.35s ease;
}
.fc-quote-item:first-child {
  padding-top: 0.1rem;
}
.fc-quote-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}
.fc-quote-item.is-highlighted {
  background: var(--accent-soft);
  padding-left: 0.55rem;
  padding-right: 0.55rem;
  margin-left: -0.55rem;
  margin-right: -0.55rem;
}
.fc-quote-num {
  font-size: 0.76rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  padding-top: 0.16rem;
}
.fc-quote-body {
  min-width: 0;
}
.fc-quote-claim {
  font-size: 0.89rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.46;
}
.fc-quote-text {
  margin: 0.3rem 0 0.46rem;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.54;
  color: var(--ink-secondary);
}
.fc-quote-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem 0.75rem;
  flex-wrap: wrap;
}
.fc-quote-source {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--ink-muted);
  min-width: 0;
  flex: 1 1 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fc-inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.fc-action-link {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-height: var(--tap-min);
  padding: 0.25rem 0.5rem;
  margin: -0.25rem -0.5rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease;
}
.fc-action-link.is-primary {
  color: var(--accent-text);
}
.fc-action-link.is-primary:hover {
  background: var(--accent-soft);
  text-decoration: none;
}
.fc-action-link.is-muted {
  color: var(--ink-muted);
}
.fc-action-link.is-muted:hover {
  color: var(--ink);
  background: var(--surface-hover);
  text-decoration: none;
}

/* Verified Math & Checkbook SQL — Flat Hairline Rows Inside Full Context */
.fc-calc-list {
  display: flex;
  flex-direction: column;
}
.fc-calc-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--hairline);
}
.fc-calc-item:first-child {
  padding-top: 0.05rem;
}
.fc-calc-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}
.fc-calc-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.fc-calc-label {
  font-size: 0.89rem;
  font-weight: 600;
  color: var(--ink);
}
.fc-calc-foot {
  margin-top: 0.3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem 0.75rem;
  flex-wrap: wrap;
}
.fc-calc-inputs {
  font-size: 0.76rem;
  color: var(--ink-muted);
  line-height: 1.45;
}
.fc-sql-row {
  padding-top: 0.65rem;
}
.fc-calc-item + .fc-sql-row {
  margin-top: 0.25rem;
  border-top: 1px solid var(--hairline);
}

html[data-contrast="high"] .fc-action-link,
html[data-contrast="high"] .fc-ref-link {
  min-height: 44px;
  text-decoration: underline;
}

.sheet-question-preview {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink);
}
.sheet-question-preview-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: 0.25rem;
}

/* Official Public Source & Sheet Layout inside right drawer */
.brief-sheet-block {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.brief-sheet-answer {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  font-size: 0.92rem;
  line-height: 1.58;
  color: var(--ink);
}
.brief-source-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.brief-source-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  background: var(--surface);
}
html[data-theme="dark"] .brief-source-item {
  background: var(--surface-elevated);
  border-color: rgba(255, 255, 255, 0.11);
}
.brief-source-title {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.38;
}
.brief-source-sub {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: 0.15rem;
}

@media (max-width: 760px) {
  .topbar {
    padding: 0.42rem 0.65rem 0.5rem;
  }
  .topbar-inner {
    gap: 0.42rem 0.35rem;
  }
  .topbar-left {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
    gap: 0.25rem;
  }
  .topbar-left .brand-link {
    min-width: 0;
    min-height: var(--tap-min);
    justify-content: center;
  }
  .topbar-left .brand-title {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hamburger-btn {
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    padding: 0.25rem 0.35rem;
  }
  .topbar-actions {
    order: 2;
    flex-shrink: 0;
    flex-wrap: nowrap;
    gap: 0.12rem;
  }
  /* Viewer topbar toolbar wraps cleanly on narrow screens (0px overflow at 320px) */
  .viewer-topbar .topbar-left {
    flex: 1 1 100%;
  }
  .viewer-topbar .topbar-actions {
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  /* Quiet ghost header actions on mobile while preserving full >=44px WCAG 2.5.5 touch targets */
  .topbar-actions .btn {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    padding: 0.25rem 0.42rem;
    gap: 0.24rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }
  .viewer-topbar .topbar-actions .btn {
    border-color: var(--control-border);
    background: var(--surface);
  }
  .viewer-topbar .topbar-actions .btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
  }
  .topbar-actions .theme-toggle-btn {
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    padding: 0.25rem 0.35rem;
  }
  .topbar-actions .btn:hover {
    background: var(--surface-muted);
  }
  .segmented-pill {
    order: 3;
    flex: 1 0 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .segmented-pill.has-taxbill-tab {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .segmented-pill .mode-tab {
    width: 100%;
    min-width: 0;
    min-height: var(--tap-min);
    padding: 0.32rem 0.35rem;
    font-size: 0.78rem;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
    overflow-wrap: break-word;
  }
  .hamburger-btn .menu-label, .display-btn-label { display: none; }
}

/* Guarantee zero horizontal overflow at 320px even at Large / Extra Large text sizes */
@media (max-width: 440px) {
  .topbar-inner {
    flex-wrap: wrap;
  }
  .topbar-actions {
    flex-wrap: wrap;
  }
  html[data-text-size="l"] .segmented-pill .mode-tab,
  html[data-text-size="xl"] .segmented-pill .mode-tab {
    font-size: 0.7rem;
    padding: 0.28rem 0.22rem;
  }
  html[data-text-size="l"] .topbar-left .brand-title,
  html[data-text-size="xl"] .topbar-left .brand-title {
    font-size: 0.86rem;
  }
}

@media (max-width: 680px) {
  .display-popover-anchor { position: static; }
  .display-popover {
    top: calc(100% + 8px);
    left: 12px;
    right: 12px;
    width: auto;
    max-width: 400px;
    margin-left: auto;
    max-height: calc(100dvh - 84px);
    overflow-y: auto;
    transform-origin: top center;
  }
  .starter-grid { grid-template-columns: 1fr; }
  .drawer-overlay { padding: 0; }
  .drawer-sheet { border-radius: 0; }
  .resident-wrap {
    padding: 1.05rem 0.95rem 1.25rem;
  }
  .answer-utility-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    margin-top: 0.65rem;
  }
  .fc-toggle-btn {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
    padding: 0.35rem 0;
  }
  .answer-quiet-actions {
    margin-left: -0.55rem;
    gap: 0.05rem 0.15rem;
  }
  .gap-prompt-bar {
    margin-top: 0.9rem;
    padding: 0.72rem 0.88rem;
  }
  .full-context-panel {
    padding: 0.95rem 1rem;
    gap: 1rem;
  }
  .fc-section + .fc-section {
    padding-top: 0.95rem;
  }
  .fc-quote-source {
    flex-basis: 100%;
    white-space: normal;
  }
  .resident-wrap > section[role="tabpanel"] {
    min-height: calc(100dvh - 112px);
  }
  .eyebrow-pill {
    font-size: 0.72rem;
    gap: 0.32rem;
    margin-bottom: 0.45rem;
  }
  .welcome-hero h1.hero-title {
    font-size: 1.92rem;
    margin-bottom: 1.05rem;
  }
  .composer-dock {
    padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
  }
  .composer-pill {
    padding: 0.38rem 0.42rem 0.38rem 0.95rem;
    border-radius: 24px;
    align-items: flex-end;
  }
  .composer-pill.has-suggestion {
    border-radius: 20px;
    padding: 0.65rem 0.65rem 0.5rem 0.9rem;
    align-items: stretch;
  }
  .composer-textarea {
    font-size: 16px; /* Prevents iOS Safari auto-zoom on focus */
    min-height: var(--tap-min);
    padding: 0.48rem 0;
  }
  .composer-suggestion-text {
    font-size: 15.5px;
    line-height: 1.4;
  }
  .composer-send-btn {
    width: var(--tap-min);
    height: var(--tap-min);
  }
  .composer-share-row {
    padding: 0 0.2rem;
  }
  .site-footer {
    margin-top: 1.5rem;
    padding: 0.85rem 0.95rem calc(max(13.5rem, var(--composer-dock-h, 0px) + 2.25rem) + env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

html[data-reduced-motion="true"] *,
html[data-reduced-motion="true"] *::before,
html[data-reduced-motion="true"] *::after {
  transition-duration: 0.01ms !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
}
html[data-reduced-motion="true"] .thinking-label {
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
  color: var(--ink) !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .thinking-label {
    background: none !important;
    -webkit-text-fill-color: currentColor !important;
    color: var(--ink) !important;
  }
}

@media print {
  .confidentiality-banner {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
  }
  .composer-dock, .topbar-actions, .hamburger-btn, .drawer-overlay, .feedback-group, .door-list, .skip-links {
    display: none !important;
  }
  .resident-wrap { padding-bottom: 1rem; }
}

/* Delayed safety-windowed live draft preview */
.stream-preview {
  margin-top: 0.75rem;
  font-size: 0.98rem;
  line-height: 1.62;
  color: var(--ink);
  opacity: 0.92;
}
.stream-preview p {
  margin: 0 0 0.65rem;
}
.stream-preview p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Certified 2025 Property Tax Fund Calculator (Apple Native Minimalism)
   ========================================================================== */

.tax-calc-shell {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-top: 0.4rem;
}

.tax-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow-xs);
}

html[data-theme="dark"] .tax-panel {
  background: var(--surface);
  border-color: var(--border);
}

.tax-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.tax-panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.tax-panel-sub {
  margin: 0.22rem 0 0;
  font-size: 0.84rem;
  color: var(--ink-muted);
  line-height: 1.45;
}

.tax-address-row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.tax-address-row .composer-input {
  flex: 1 1 min(260px, 100%);
  min-width: 0;
}

.tax-status-line {
  margin-top: 0.55rem;
  font-size: 0.82rem;
  color: var(--ink-secondary);
  min-height: 1.1em;
}
.tax-status-line.is-ok { color: var(--ok); font-weight: 500; }
.tax-status-line.is-warn { color: var(--watch); }
.tax-status-line.is-err { color: var(--high); }

.tax-match-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.tax-match-btn {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  gap: 0.35rem;
  padding: 0.42rem 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.tax-match-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
}

.tax-preset-row {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tax-field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
  letter-spacing: 0.01em;
}

.tax-select {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--control-border);
  background: var(--surface-muted);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9rem;
}
html[data-theme="dark"] .tax-select {
  background: var(--surface-elevated);
}

.tax-district-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

.tax-dist-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.62rem;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  font-size: 0.76rem;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}
.tax-dist-pill.is-accent {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
  font-weight: 600;
}

.tax-advanced-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 0.75rem;
  margin-top: 0.95rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--hairline);
}

.tax-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 1.1rem;
}

.tax-label-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.tax-mode-toggle {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1.5px solid var(--control-border);
}

.tax-mode-btn {
  min-height: var(--tap-min);
  border: none;
  background: transparent;
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
}
.tax-mode-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-xs);
}

.tax-money-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--control-border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  padding: 0 0.75rem;
  min-height: 48px;
}
html[data-theme="dark"] .tax-money-wrap {
  background: var(--surface-elevated);
}
.tax-money-wrap:focus-within {
  border-color: var(--focus-outline);
  outline: 3px solid var(--focus-outline);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}
.tax-money-prefix {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-right: 0.35rem;
}
.tax-money-input {
  flex: 1;
  min-height: var(--tap-min);
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  outline: 2px solid transparent;
  padding: 0.45rem 0;
  min-width: 0;
}
.tax-money-input:focus,
.tax-money-input:focus-visible {
  outline: 2px solid transparent;
  box-shadow: none;
}

.tax-quick-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.55rem;
}
.tax-chip {
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: var(--surface);
  color: var(--ink-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tax-chip.active,
.tax-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
}

/* Results Hero Strip & Allocation Bar */
.tax-results-area {
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
}

.tax-hero-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.tax-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.05rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.tax-kpi-highlight {
  border-color: var(--accent-border);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 100%);
}

.tax-kpi-kicker {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.tax-kpi-highlight .tax-kpi-kicker {
  color: var(--accent-text);
}

.tax-kpi-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.tax-kpi-sub {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
  line-height: 1.38;
}

.tax-bar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
}

.tax-bar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.tax-stacked-bar {
  display: flex;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-muted);
  gap: 2px;
}

.tax-bar-seg {
  height: 100%;
  min-width: 4px;
  transition: width 0.24s var(--ease-out);
}

.tax-seg-schools   { background: #0052a3; }
.tax-seg-fire      { background: #0e7a52; }
.tax-seg-city      { background: #4f46e5; }
.tax-seg-sheriff   { background: #475569; }
.tax-seg-dedicated { background: #b45309; }
.tax-seg-alimony   { background: #be123c; }

html[data-theme="dark"] .tax-seg-schools   { background: #5ca9ff; }
html[data-theme="dark"] .tax-seg-fire      { background: #34d399; }
html[data-theme="dark"] .tax-seg-city      { background: #818cf8; }
html[data-theme="dark"] .tax-seg-sheriff   { background: #94a3b8; }
html[data-theme="dark"] .tax-seg-dedicated { background: #fbbf24; }
html[data-theme="dark"] .tax-seg-alimony   { background: #fb7185; }

.tax-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 0.55rem 1rem;
  margin-top: 0.9rem;
}

.tax-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.84rem;
  padding: 0.32rem 0;
  border-bottom: 1px solid var(--hairline);
}

.tax-legend-left {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  min-width: 0;
}

.tax-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.tax-legend-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
}

.tax-law-callout {
  margin-top: 0.85rem;
  padding: 0.72rem 0.92rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border-left: 3px solid var(--accent);
  font-size: 0.82rem;
  color: var(--ink-secondary);
  line-height: 1.48;
}

.tax-row-alimony {
  background: var(--accent-soft);
}

.tax-tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
}
.tax-tag-gf {
  background: var(--accent);
  color: var(--accent-ink);
}
.tax-tag-nohs {
  background: var(--watch-soft);
  color: var(--watch);
  border: 1px solid var(--watch-border);
}

/* Quarter-Cent vs Millage Offset Sliders */
.tax-sliders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
  gap: 1.1rem;
}

.tax-slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.tax-slider-val {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}

/* Full >=44px WCAG 2.5.5 touch target height on range sliders */
.tax-range {
  width: 100%;
  accent-color: var(--accent);
  height: var(--tap-min);
  min-height: var(--tap-min);
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.tax-slider-hint {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.42;
}

.tax-compare-summary {
  margin-top: 1rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.tax-cmp-cell {
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
}
.tax-cmp-lbl {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-muted);
}
.tax-cmp-val {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 0.15rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.tax-cmp-sub {
  font-size: 0.76rem;
  color: var(--ink-secondary);
  margin-top: 0.1rem;
}

.tax-action-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding: 0.95rem 1.15rem;
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
}

.tax-source-foot {
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.48;
  flex: 1 1 min(280px, 100%);
}

@media (max-width: 720px) {
  .tax-hero-strip,
  .tax-compare-summary {
    grid-template-columns: 1fr;
  }
  .tax-panel {
    padding: 1rem;
  }
  .tax-kpi-value {
    font-size: 1.48rem;
  }
}

/* ==========================================================================
   15. Windows High Contrast Mode (Forced Colors — WCAG 2.2 AA+AAA)
   ========================================================================== */
@media (forced-colors: active) {
  :focus-visible,
  .composer-pill:focus-within,
  .tax-money-wrap:focus-within,
  .composer-input:focus-visible {
    outline: 3px solid Highlight !important;
    outline-offset: 2px !important;
    box-shadow: none !important;
  }
  .btn,
  .btn-sm,
  .hamburger-btn,
  .segmented-pill,
  .seg-btn,
  .dp-step-btn,
  .dp-close-btn,
  .switcher-pill,
  .sources-chip-btn,
  .starter-btn,
  .door-btn,
  .composer-pill,
  .composer-more-btn,
  .composer-sug-chip,
  .composer-share-info-btn,
  .composer-share-details,
  .composer-share-policy-btn,
  .followup-share-opt,
  .followup-channel-seg,
  .report-chip,
  .tax-panel,
  .tax-select,
  .tax-money-wrap,
  .tax-mode-toggle,
  .tax-chip,
  .tax-match-btn,
  .drawer-sheet,
  .display-popover,
  .badge,
  .inline-cite-btn,
  .missing-box,
  .reasoning-box {
    border: 2px solid ButtonBorder !important;
    box-shadow: none !important;
  }
  .btn-primary,
  .composer-send-btn,
  .composer-accept-btn,
  .segmented-pill .mode-tab.active,
  .seg-btn.active,
  .switcher-pill.active,
  .report-chip.active,
  .followup-ch-btn.active,
  .tax-mode-btn.active,
  .tax-chip.active,
  .menu-nav-item.active,
  .skip-link {
    background: Highlight !important;
    color: HighlightText !important;
    border: 2px solid Highlight !important;
    forced-color-adjust: none;
  }
  .val-bar-fill,
  .tax-bar-seg {
    background: Highlight !important;
    border: 1px solid CanvasText !important;
    forced-color-adjust: none;
  }
  .pdf-highlight-box {
    border: 3px solid Highlight !important;
    background: transparent !important;
    forced-color-adjust: none;
  }
  .live-dot {
    background: Highlight !important;
    forced-color-adjust: none;
  }
  .thinking-label {
    background: none !important;
    -webkit-text-fill-color: CanvasText !important;
    color: CanvasText !important;
  }
}
