/* ===========================================================================
   Crye web design system — implementation of DESIGN.md (repo root).
   DESIGN.md is the spec; this file is the only place it becomes CSS.

   GLOBAL as of the 2026-08-05 review: loaded for every page from base.html,
   after brand.css and after the Tailwind layer, so its tokens and components
   win. It is now the single source for BOTH the new crye-* components and the
   legacy class names the 30 existing templates already use (.btn-primary,
   .badge-success, .tag-warning, .nav-link, .th/.td, .page-title …), so those
   templates pick up the new system with no markup change and there is exactly
   one definition of each class.

   Every colour is verified for WCAG AA against the surface it actually sits
   on. Do not eyeball-adjust a value; re-run the contrast check first.
   =========================================================================== */

/* --- The two CryeStatic display cuts brand.css never declared. These are the
   condensed heavy weights that carry hierarchy. --- */
@font-face {
  font-family: "Crye Header";
  src: url("../fonts/CryeStatic-Header.ttf") format("truetype");
  font-weight: 100 900; font-style: normal; font-display: swap;
  ascent-override: 95%; descent-override: 25%; line-gap-override: 0%;
}
@font-face {
  font-family: "Crye Subheader";
  src: url("../fonts/CryeStatic-Subheader.ttf") format("truetype");
  font-weight: 100 900; font-style: normal; font-display: swap;
  ascent-override: 95%; descent-override: 25%; line-gap-override: 0%;
}

/* ===========================================================================
   TOKENS
   =========================================================================== */

:root {
  /* --- Type scale, golden ratio (φ = 1.618) anchored on a 17px body.
     The heading ladder is exact φ steps: 17 → 27.5 → 44.5.
     Supporting sizes sit on √φ half-steps (×1.272) so they interleave
     without the full φ jump, which is too violent for UI at small sizes. --- */
  --fs-display:    44px;   /* body × φ²  */
  --fs-section:    27px;   /* body × φ   */
  --fs-subsection: 21px;   /* body × √φ  */
  --fs-card-title: 19px;
  --fs-body:       17px;   /* the anchor */
  --fs-body-sm:    15px;
  --fs-label:      13px;
  --fs-data:       15px;
  --fs-data-xl:    34px;

  /* Surfaces — light */
  --crye-surface-0: #F2F0ED;
  --crye-surface-1: #FFFFFF;
  --crye-surface-2: #FFFFFF;
  --crye-surface-3: #FFFFFF;
  --crye-hairline:  #E2DFDB;
  --crye-card-border: rgba(0, 0, 0, 0.09);
  /* Hover must be SEEN (owner 2026-08-06): surfaces 1–3 are all white in
     light mode, so hovers that swapped surfaces were invisible. Dedicated
     tokens — a fill one clear step darker than the resting surface, a
     gentler one for whole cards, and a strengthened border. */
  --crye-hover-fill:   #EAE7E3;
  --crye-hover-card:   #F7F5F2;
  --crye-hover-border: rgba(0, 0, 0, 0.30);

  /* Text — pure black at four opacities, raised so nothing looks washed out. */
  --crye-text-1: rgba(0, 0, 0, 0.94);
  --crye-text-2: rgba(0, 0, 0, 0.76);
  --crye-text-3: rgba(0, 0, 0, 0.62);
  --crye-text-4: rgba(0, 0, 0, 0.38);

  /* Action. Gold is only 3.0:1 on white, so light mode splits the token:
     -fill is a SURFACE (black on it = 7.1:1); -text is a darkened cut. */
  --crye-gold-fill:  #CC8800;
  --crye-gold-text:  #966400;
  --crye-on-gold:    #000000;
  --crye-gold-hover: #B87A00;
  /* Primary BUTTONS read white-on-gold (owner ruling 2026-08-05). White on
     #CC8800 is 2.96:1, so buttons take a deeper gold cut where white text
     reaches 4.74:1. Badges keep the bright fill + black. */
  --crye-gold-btn:       #9E6800;
  --crye-gold-btn-hover: #8F5F00;
  --crye-on-gold-btn:    #FFFFFF;

  /* --- Field accents. Gold stays primary; these give the page colour rhythm
     without a second action colour. Values are tuned per theme for AA. --- */
  --crye-green:  #5E7D45;
  --crye-khaki:  #867453;
  --crye-orange: #A96227;
  --crye-green-fill:  rgba(94, 125, 69, 0.16);
  --crye-khaki-fill:  rgba(134, 116, 83, 0.16);
  --crye-orange-fill: rgba(169, 98, 39, 0.16);
  --crye-green-on-fill:  #536E3D;
  --crye-khaki-on-fill:  #766649;
  --crye-orange-on-fill: #955622;
  --crye-green-wash:  rgba(94, 125, 69, 0.06);
  --crye-khaki-wash:  rgba(134, 116, 83, 0.06);
  --crye-orange-wash: rgba(169, 98, 39, 0.06);
  --crye-gold-wash:   rgba(204, 136, 0, 0.06);
  /* Conversational question side. White on this blue is 5.19:1. */
  --crye-message-blue: #0969DA;
  --crye-on-message-blue: #FFFFFF;
  --crye-message-label-fill: rgba(0, 0, 0, 0.14);

  /* Semantic */
  --crye-success: #2C854B;
  --crye-warning: #9B6818;
  --crye-danger:  #C2352B;
  --crye-success-fill: rgba(44, 133, 75, 0.16);
  --crye-warning-fill: rgba(155, 104, 24, 0.16);
  --crye-danger-fill:  rgba(194, 53, 43, 0.16);
  --crye-neutral-fill: rgba(0, 0, 0, 0.07);

  /* Elevation — softer (wider blur) and deeper than the first pass. */
  --crye-shadow-1: 0 2px 10px rgba(0,0,0,0.09),  0 1px 2px rgba(0,0,0,0.06);
  --crye-shadow-2: 0 10px 28px rgba(0,0,0,0.13), 0 2px 8px rgba(0,0,0,0.08);
  --crye-shadow-3: 0 28px 72px rgba(0,0,0,0.20), 0 10px 24px rgba(0,0,0,0.12);
  --crye-scrim: rgba(15, 14, 13, 0.60);

  /* Shape */
  --crye-r-xs: 6px;  --crye-r-sm: 10px; --crye-r-md: 14px;
  --crye-r-lg: 20px; --crye-r-xl: 28px; --crye-r-pill: 9999px;

  /* Spacing — 8px base */
  --crye-s-xxs: 4px;  --crye-s-xs: 8px;   --crye-s-sm: 12px;
  --crye-s-md: 16px;  --crye-s-lg: 24px;  --crye-s-xl: 32px;
  --crye-s-xxl: 48px; --crye-s-section: 64px;

  /* --- Bridge to the existing token names, so every untouched Tailwind
     utility in the templates follows the new system automatically. --- */
  --radius: var(--crye-r-md);
  --background: var(--crye-surface-0);
  --foreground: var(--crye-text-1);
  --card: var(--crye-surface-1);
  --card-foreground: var(--crye-text-1);
  --popover: var(--crye-surface-2);
  --popover-foreground: var(--crye-text-1);
  --primary: var(--crye-gold-text);
  --primary-foreground: var(--crye-on-gold);
  --secondary: var(--crye-surface-2);
  --secondary-foreground: var(--crye-text-1);
  --muted: var(--crye-surface-0);
  --muted-foreground: var(--crye-text-3);
  --accent: var(--crye-surface-0);
  --accent-foreground: var(--crye-text-1);
  --destructive: var(--crye-danger);
  --destructive-foreground: #FFFFFF;
  --success: var(--crye-success);
  --success-foreground: #FFFFFF;
  --warning: var(--crye-warning);
  --warning-foreground: #FFFFFF;
  --border: var(--crye-hairline);
  --input: var(--crye-hairline);
  --ring: var(--crye-gold-fill);
  --sidebar: var(--crye-surface-0);
  --sidebar-foreground: var(--crye-text-1);
  --sidebar-accent: var(--crye-surface-2);
  --sidebar-border: var(--crye-hairline);
}

.dark {
  /* Surfaces — the brand warm-gray ramp continued below #4E4C4A, holding the
     brand rule R = G+2, B = G-2. surface-0 is pushed well below surface-1 so
     the page reads as clearly behind the cards. */
  --crye-surface-0: #131110;
  --crye-surface-1: #22201E;
  --crye-surface-2: #2C2A28;
  --crye-surface-3: #383634;
  --crye-hairline:  rgba(255, 255, 255, 0.10);
  --crye-card-border: rgba(255, 255, 255, 0.08);
  /* Hover tokens (owner 2026-08-06): one step above the dark surfaces, plus
     the strengthened border that marks the hovered element in both themes. */
  --crye-hover-fill:   #403E3C;
  --crye-hover-card:   var(--crye-surface-2);
  --crye-hover-border: rgba(255, 255, 255, 0.28);

  --crye-text-1: rgba(255, 255, 255, 0.96);
  --crye-text-2: rgba(255, 255, 255, 0.80);
  --crye-text-3: rgba(255, 255, 255, 0.66);
  --crye-text-4: rgba(255, 255, 255, 0.38);

  --crye-gold-fill:  #E09A18;
  --crye-gold-text:  #E09A18;
  --crye-on-gold:    #000000;
  --crye-gold-hover: #F0A82A;
  /* Same deep cut in the dark theme — white stays 4.7:1; hover lifts. */
  --crye-gold-btn:       #9E6800;
  --crye-gold-btn-hover: #A86F00;
  --crye-on-gold-btn:    #FFFFFF;

  --crye-green:  #6F9351;
  --crye-khaki:  #C2A878;
  --crye-orange: #D97E33;
  --crye-green-fill:  rgba(111, 147, 81, 0.22);
  --crye-khaki-fill:  rgba(194, 168, 120, 0.20);
  --crye-orange-fill: rgba(217, 126, 51, 0.22);
  --crye-green-on-fill:  #84AF60;
  --crye-khaki-on-fill:  #C2A878;
  --crye-orange-on-fill: #ED8937;
  --crye-green-wash:  rgba(111, 147, 81, 0.07);
  --crye-khaki-wash:  rgba(194, 168, 120, 0.06);
  --crye-orange-wash: rgba(217, 126, 51, 0.07);
  --crye-gold-wash:   rgba(224, 154, 24, 0.07);
  --crye-message-blue: #0969DA;
  --crye-on-message-blue: #FFFFFF;
  --crye-message-label-fill: rgba(0, 0, 0, 0.14);

  --crye-success: #5BC97F;
  --crye-warning: #E8B44A;
  --crye-danger:  #FF6B63;
  --crye-success-fill: rgba(44, 133, 75, 0.28);
  --crye-warning-fill: rgba(155, 104, 24, 0.30);
  --crye-danger-fill:  rgba(194, 53, 43, 0.30);
  --crye-neutral-fill: rgba(255, 255, 255, 0.10);

  /* Deeper and wider — a shadow has to survive against a dark ground. */
  --crye-shadow-1: 0 2px 10px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.30);
  --crye-shadow-2: 0 10px 28px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.35);
  --crye-shadow-3: 0 28px 72px rgba(0,0,0,0.68), 0 10px 24px rgba(0,0,0,0.45);
  --crye-scrim: rgba(10, 9, 8, 0.76);

  --destructive-foreground: #000000;
  --success-foreground: #000000;
  --warning-foreground: #000000;
  --ring: var(--crye-gold-fill);
}

/* ===========================================================================
   BASE
   =========================================================================== */

body {
  background: var(--crye-surface-0);
  color: var(--crye-text-1);
  font-size: var(--fs-body);
  line-height: 1.55;
}
/* brand.css scales the root font-size up at wide viewports; the φ scale is
   absolute, so pin it back and let the scale do the work. */
html { font-size: 16px; }

/* ===========================================================================
   TYPOGRAPHY
   =========================================================================== */

.crye-display, .page-title {
  font-family: "Crye Supertype", "Crye Copy", sans-serif;
  font-size: var(--fs-display); font-weight: 400;
  line-height: 1.05; letter-spacing: -0.5px;
  text-transform: uppercase; color: var(--crye-text-1);
}
.crye-section {
  font-family: "Crye Header", "Crye Copy", sans-serif;
  font-size: var(--fs-section); font-weight: 800;
  line-height: 1.15; letter-spacing: 0.2px;
  text-transform: uppercase; color: var(--crye-text-1);
}
.crye-subsection {
  font-family: "Crye Subheader", "Crye Copy", sans-serif;
  font-size: var(--fs-subsection); font-weight: 700;
  line-height: 1.25; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--crye-text-2);
}
.crye-card-title {
  font-family: "Crye Copy", sans-serif;
  font-size: var(--fs-card-title); font-weight: 600;
  line-height: 1.35; letter-spacing: -0.1px; color: var(--crye-text-1);
}
/* The customer's question inside any card (Flagged Answers, Suggested
   Answers, search results…) — one shared size so every surface that shows
   question-then-answer reads the same (owner 2026-08-06). */
.crye-question {
  font-family: "Crye Copy", sans-serif;
  font-size: var(--fs-card-title); font-weight: 600;
  line-height: 1.4; color: var(--crye-text-1);
  white-space: pre-wrap;
}
.crye-body    { font-size: var(--fs-body); line-height: 1.55; color: var(--crye-text-1); }
.crye-body-sm { font-size: var(--fs-body-sm); line-height: 1.5; color: var(--crye-text-2); }
.crye-label {
  font-family: "Crye Caption", ui-monospace, monospace;
  font-size: var(--fs-label); font-weight: 600;
  line-height: 1.2; letter-spacing: 0.9px;
  text-transform: uppercase; color: var(--crye-text-3);
}
.crye-data {
  font-family: "Crye Caption", ui-monospace, monospace;
  font-size: var(--fs-data); line-height: 1.45; letter-spacing: 0.2px;
  font-variant-numeric: tabular-nums;
}
.crye-data-xl {
  font-family: "Crye Caption", ui-monospace, monospace;
  font-size: var(--fs-data-xl); line-height: 1.1; letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums; color: var(--crye-text-1);
}
.crye-muted, .page-sub { color: var(--crye-text-3); }
.page-sub { font-size: var(--fs-body); line-height: 1.55; margin-top: 6px; }

/* A section heading with a rule, so major blocks visibly separate. */
.crye-section-head {
  display: flex; align-items: baseline; gap: var(--crye-s-sm);
  padding-bottom: var(--crye-s-xs);
  border-bottom: 2px solid var(--crye-card-border);
  margin-bottom: var(--crye-s-md);
}
.crye-section-head[data-accent="gold"]   { border-bottom-color: var(--crye-gold-fill); }
.crye-section-head[data-accent="green"]  { border-bottom-color: var(--crye-green); }
.crye-section-head[data-accent="khaki"]  { border-bottom-color: var(--crye-khaki); }
.crye-section-head[data-accent="orange"] { border-bottom-color: var(--crye-orange); }

/* ===========================================================================
   ELEVATION
   =========================================================================== */

.crye-e0 { background: var(--crye-surface-0); box-shadow: none; }
.crye-e1 { background: var(--crye-surface-1); box-shadow: none; }
.crye-e2 { background: var(--crye-surface-2); box-shadow: var(--crye-shadow-2); }
.crye-e3 { background: var(--crye-surface-3); box-shadow: var(--crye-shadow-3); }

/* ===========================================================================
   COMPONENTS
   =========================================================================== */

/* --- Card. Resting = surface + faint border, NO shadow (owner 2026-08-06:
   every list page was reading as a field of floating cards, and pages with
   cards-in-cards like Suggested Answers need the outer card quiet). Shadow
   enters at the raised level (.crye-raised) and above; hover still lifts. --- */
.card {
  background: var(--crye-surface-1);
  border: 1px solid var(--crye-card-border);
  border-radius: var(--crye-r-lg);
  color: var(--crye-text-1);
}
.card-pad { padding: var(--crye-s-lg); }
.card-interactive { transition: box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease; }
.card-interactive:hover {
  background: var(--crye-hover-card);
  box-shadow: var(--crye-shadow-2);
  border-color: var(--crye-hover-border);
}
.card-header {
  display: flex; align-items: center; gap: var(--crye-s-sm); flex-wrap: wrap;
  padding: var(--crye-s-md) var(--crye-s-lg);
  border-bottom: 1px solid var(--crye-card-border);
}

/* --- Accented cards. A faint wash plus a 3px leading rule. This is the
   answer to "wall of text": colour groups the page without any card
   becoming loud, and body text keeps 12:1+ contrast on every wash. --- */
.card[data-accent] { border-left-width: 3px; }
.card[data-accent="gold"]   { border-left-color: var(--crye-gold-fill);  background: linear-gradient(var(--crye-gold-wash), var(--crye-gold-wash)), var(--crye-surface-1); }
.card[data-accent="green"]  { border-left-color: var(--crye-green);      background: linear-gradient(var(--crye-green-wash), var(--crye-green-wash)), var(--crye-surface-1); }
.card[data-accent="khaki"]  { border-left-color: var(--crye-khaki);      background: linear-gradient(var(--crye-khaki-wash), var(--crye-khaki-wash)), var(--crye-surface-1); }
.card[data-accent="orange"] { border-left-color: var(--crye-orange);     background: linear-gradient(var(--crye-orange-wash), var(--crye-orange-wash)), var(--crye-surface-1); }

/* --- Inset panel. A recessed level-0 surface — the same treatment inputs
   get, so it reads as "form chrome": legends, disclosures, quiet furniture
   inside a card. NOT for content (owner 2026-08-06) — answer bodies and
   other content sections inside a card use .crye-raised instead. --- */
.crye-inset {
  background: var(--crye-surface-0);
  border: 1px solid var(--crye-card-border);
  border-radius: var(--crye-r-md);
  padding: var(--crye-s-md);
}

/* --- Raised panel. The way to subdivide a card with CONTENT: the section
   lifts one level UP (surface-2 + shadow-2, the next card height) instead of
   recessing. Answer bodies in the shared card recipe (Flagged Answers,
   Suggested Answers, both kinds of search results) sit on this. --- */
.crye-raised {
  background: var(--crye-surface-2);
  box-shadow: var(--crye-shadow-2);
  border: 1px solid var(--crye-card-border);
  border-radius: var(--crye-r-md);
  padding: var(--crye-s-md);
}

/* --- Q&A exchange. The question and response keep left-aligned copy while
   occupying opposite sides, like a familiar message thread. Labels belong
   inside their message; evidence and controls remain outside. --- */
.crye-exchange {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--crye-s-md);
}
.crye-message {
  width: 92%;
  max-width: 56rem;
  text-align: left;
}
.crye-message--question {
  width: 88%;
  max-width: 52rem;
  margin-left: auto;
  align-self: flex-end;
  color: var(--crye-on-message-blue);
  background: var(--crye-message-blue);
  border-color: var(--crye-message-blue);
}
.crye-message--question.crye-question,
.crye-message--question .crye-question {
  color: var(--crye-on-message-blue);
}
.crye-message--answer,
.crye-message--note {
  margin-right: auto;
  align-self: flex-start;
}
.crye-message-meta {
  width: 92%;
  max-width: 56rem;
  margin-right: auto;
  color: var(--crye-text-3);
  font-size: var(--fs-label);
  text-align: left;
}
.crye-message-meta--question {
  width: 88%;
  max-width: 52rem;
  margin-right: 0;
  margin-left: auto;
  text-align: right;
}
.crye-message .crye-message-label {
  display: block;
  width: max-content;
  margin: 0 0 var(--crye-s-xs);
}
.crye-message--question .crye-message-label {
  margin-left: auto;
  color: var(--crye-on-message-blue);
  background: var(--crye-message-label-fill);
  border: 1px solid rgba(255, 255, 255, 0.24);
}
.crye-message-divider {
  width: 100%;
  margin: var(--crye-s-xl) 0 var(--crye-s-lg);
  border-top: 1px solid var(--crye-hairline);
}
.crye-exchange > .crye-message-divider {
  margin-top: var(--crye-s-md);
  margin-bottom: var(--crye-s-xs);
}
/* Separate review records need a stronger break than turns in one thread. */
.crye-record-stack > * + * { margin-top: var(--crye-s-section); }

@media (max-width: 640px) {
  .crye-message,
  .crye-message-meta { width: 96%; }
}

/* --- Stat tile. Resting like .card — no shadow (owner 2026-08-06). --- */
.stat {
  background: var(--crye-surface-1);
  border: 1px solid var(--crye-card-border);
  border-radius: var(--crye-r-lg);
  padding: var(--crye-s-lg);
}
.stat > .crye-data-xl { margin-top: var(--crye-s-xs); }
.stat > .crye-body-sm { margin-top: var(--crye-s-xxs); color: var(--crye-text-3); }
.stat[data-accent="gold"]   { border-top: 3px solid var(--crye-gold-fill); }
.stat[data-accent="green"]  { border-top: 3px solid var(--crye-green); }
.stat[data-accent="khaki"]  { border-top: 3px solid var(--crye-khaki); }
.stat[data-accent="orange"] { border-top: 3px solid var(--crye-orange); }

/* --- Buttons. Every button is a pill, minimum 42px tall. --- */
.btn, .btn-primary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--crye-s-xs);
  min-height: 42px; padding: 10px 22px;
  border: 1px solid transparent; border-radius: var(--crye-r-pill);
  font-family: "Crye Copy", sans-serif;
  font-size: var(--fs-body-sm); font-weight: 600; letter-spacing: 0.1px;
  cursor: pointer; text-decoration: none;
  background: var(--crye-surface-2);
  border-color: var(--crye-card-border);
  color: var(--crye-text-1);
  transition: background-color 140ms ease, box-shadow 140ms ease, transform 60ms ease;
}
.btn:hover, .btn-danger:hover {
  background: var(--crye-hover-fill);
  border-color: var(--crye-hover-border);
}
.btn:active, .btn-primary:active, .btn-danger:active { transform: translateY(1px); }
.btn:focus-visible, .btn-primary:focus-visible, .btn-danger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crye-gold-fill) 45%, transparent);
}
.btn:disabled, .btn-primary:disabled, .btn-danger:disabled { opacity: 0.4; pointer-events: none; }

.btn[data-variant="primary"], .btn-primary {
  background: var(--crye-gold-btn); color: var(--crye-on-gold-btn);
  border-color: transparent;
}
.btn[data-variant="primary"]:hover, .btn-primary:hover { background: var(--crye-gold-btn-hover); color: var(--crye-on-gold-btn); }
/* The step between primary and neutral (owner request 2026-08-05): gold
   outline + gold text, filling to solid gold on hover. For the action you
   want noticed without it being THE action of the screen. */
.btn[data-variant="outline"] {
  background: var(--crye-gold-wash);
  border-color: color-mix(in srgb, var(--crye-gold-fill) 55%, transparent);
  color: var(--crye-gold-text);
  font-weight: 600;
}
.btn[data-variant="outline"]:hover {
  background: var(--crye-gold-btn);
  border-color: transparent;
  color: var(--crye-on-gold-btn);
}
/* Ghost keeps a faint border on purpose. A fully borderless low-emphasis
   button is indistinguishable from stray bold text the moment it wraps onto
   its own line — which is exactly what happened to the view toggle. */
.btn[data-variant="ghost"] { background: transparent; border-color: var(--crye-card-border); color: var(--crye-text-2); }
.btn[data-variant="ghost"]:hover {
  background: var(--crye-hover-fill);
  border-color: var(--crye-hover-border);
  color: var(--crye-text-1);
}
.btn[data-variant="danger"], .btn-danger {
  background: var(--crye-danger-fill); color: var(--crye-danger);
  border-color: color-mix(in srgb, var(--crye-danger) 40%, transparent);
}
.btn[data-size="sm"] { min-height: 34px; padding: 6px 16px; font-size: var(--fs-label); }
.btn[data-size="icon"] { min-height: 42px; width: 42px; padding: 0; }

/* --- Badges. ONE system: always filled, always a pill, always the label
   face. Legacy .badge-* and .tag-* names alias onto it so the existing
   templates stop rendering two competing chip styles. --- */
.badge, .badge-primary, .badge-gold, .badge-success, .badge-warning,
.badge-danger, .tag, .tag-success, .tag-warning, .tag-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  width: fit-content; flex-shrink: 0;
  padding: 5px 11px;
  border: none; border-radius: var(--crye-r-pill);
  font-family: "Crye Caption", ui-monospace, monospace;
  font-size: var(--fs-label); font-weight: 600; line-height: 1.2;
  letter-spacing: 0.7px; text-transform: uppercase; white-space: nowrap;
  background: var(--crye-neutral-fill); color: var(--crye-text-2);
}
.badge[data-tone="success"], .badge-success, .tag-success { background: var(--crye-success-fill); color: var(--crye-success); }
.badge[data-tone="warning"], .badge-warning, .tag-warning { background: var(--crye-warning-fill); color: var(--crye-warning); }
.badge[data-tone="danger"],  .badge-danger,  .tag-danger  { background: var(--crye-danger-fill);  color: var(--crye-danger); }
.badge[data-tone="action"],  .badge-primary, .badge-gold  { background: var(--crye-gold-fill);    color: var(--crye-on-gold); }
.badge[data-tone="green"]  { background: var(--crye-green-fill);  color: var(--crye-green-on-fill); }
.badge[data-tone="khaki"]  { background: var(--crye-khaki-fill);  color: var(--crye-khaki-on-fill); }
.badge[data-tone="orange"] { background: var(--crye-orange-fill); color: var(--crye-orange-on-fill); }

/* A badge that IS a link (the "N cases" count on a recurring ask): same
   shape, but it reads as a small button — a resting border, and hover
   darkens fill + border like every button (owner 2026-08-06, no underline). */
a.badge {
  text-decoration: none;
  border: 1px solid var(--crye-card-border);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
a.badge:hover {
  background: var(--crye-hover-fill);
  border-color: var(--crye-hover-border);
  color: var(--crye-text-1);
}

/* --- Source card. One quiet bordered card per citation under an answer:
   channel pill (tool name demoted to its tooltip) + linked ref, and the
   full quote only on channels where the quote IS the evidence — Official
   Answer / Company Fact / Past Case / Manual (owner 2026-08-06). --- */
.crye-source {
  border: 1px solid var(--crye-card-border);
  border-radius: var(--crye-r-md);
  padding: var(--crye-s-sm) var(--crye-s-md);
  background: var(--crye-surface-1);
}
.crye-source + .crye-source { margin-top: 6px; }
.crye-source-quote {
  margin-top: 4px;
  color: var(--crye-text-3);
  font-style: italic;
}

/* --- Confidence scale. Inside the neutral Confidence badge, the active step
   (star included) wears an inverted inner pill — text colour becomes the
   fill, surface colour becomes the text — so which of the three is lit
   reads at a glance instead of hiding in font weight (owner 2026-08-06). --- */
.conf-active {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 8px; margin: -1px 0;
  border-radius: var(--crye-r-pill);
  background: var(--crye-text-1);
  color: var(--crye-surface-0);
  font-weight: 600;
}

/* --- Inputs --- */
.input, .cp-select {
  min-height: 42px; padding: 10px 14px;
  background: var(--crye-surface-0);
  border: 1px solid var(--crye-hairline);
  border-radius: var(--crye-r-sm);
  color: var(--crye-text-1); font-size: var(--fs-body); font-family: inherit;
}
.input::placeholder { color: var(--crye-text-4); }
.input:focus, .cp-select:focus {
  outline: none; border-color: var(--crye-gold-fill);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crye-gold-fill) 45%, transparent);
}
.cp-select {
  width: 100%; cursor: pointer; appearance: none;
  padding-right: 34px; font-size: var(--fs-body-sm); font-weight: 500;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* --- Tables --- */
.crye-table { width: 100%; border-collapse: collapse; }
.crye-table th, .th {
  padding: 14px var(--crye-s-md);
  text-align: left;
  font-family: "Crye Caption", ui-monospace, monospace;
  font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.9px;
  text-transform: uppercase; color: var(--crye-text-3);
  border-bottom: 1px solid var(--crye-hairline); white-space: nowrap;
}
.crye-table td, .td {
  padding: 16px var(--crye-s-md);
  font-size: var(--fs-body-sm); line-height: 1.5;
  color: var(--crye-text-1);
  border-top: 1px solid var(--crye-card-border);
}
.crye-table tbody tr:first-child td { border-top: none; }
.crye-table .num, .crye-table th.num {
  text-align: right;
  font-family: "Crye Caption", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}
.crye-table tbody tr[data-href] { cursor: pointer; }
.crye-table tbody tr:hover td { background: var(--crye-neutral-fill); }
/* A row whose first cell is a drill-in link (Topics sub-topics): the link
   must read as a link on hover — gold + underline riding the row highlight
   (owner 2026-08-06: "can't tell they are links"). */
.crye-table a.crye-row-link { color: var(--crye-text-1); font-weight: 500; text-decoration: none; }
.crye-table tbody tr:hover a.crye-row-link {
  color: var(--crye-gold-text);
  text-decoration: underline; text-underline-offset: 3px;
}
.crye-dense .crye-table td, .crye-dense .crye-table th { padding-top: 9px; padding-bottom: 9px; }

/* --- Meter --- */
.crye-meter {
  height: 8px; width: 100%;
  background: var(--crye-neutral-fill);
  border-radius: var(--crye-r-pill); overflow: hidden;
}
.crye-meter > span { display: block; height: 100%; background: var(--crye-gold-fill); border-radius: var(--crye-r-pill); }
.crye-meter[data-accent="green"]  > span { background: var(--crye-green); }
.crye-meter[data-accent="khaki"]  > span { background: var(--crye-khaki); }
.crye-meter[data-accent="orange"] > span { background: var(--crye-orange); }

/* --- Notice. Neutral surface; the badge carries the tone. A large
   warning-tinted panel reads as a field of gold and competes with the
   action colour. --- */
.crye-notice {
  display: flex; align-items: flex-start; gap: var(--crye-s-sm);
  padding: var(--crye-s-md) var(--crye-s-lg);
  border-radius: var(--crye-r-lg);
  background: var(--crye-surface-1);
  border: 1px solid var(--crye-card-border);
  box-shadow: var(--crye-shadow-1);
  color: var(--crye-text-2);
}
.crye-notice > .badge { margin-top: 2px; }

/* --- Ops banner (superuser, every page). The one place a tinted panel is
   the point: it has to be seen, not read past. Both states are loud —
   danger for broken/data-loss, warning for new items waiting. The badge
   goes solid so it survives the tint; its text colour flips per theme
   because gold is a fill, not a light-mode text colour. --- */
.ops-banner {
  border-width: 1px; border-left-width: 5px; border-style: solid;
}
/* Body copy stays ink in both tones: gold text on a gold fill is the one
   combination that fails to read. The fill, the 5px edge and the solid
   badge carry the tone. */
.ops-banner > p { color: var(--crye-text-1); }
.ops-banner > p a { color: var(--crye-text-1); }
.ops-banner > .btn { margin-left: auto; color: var(--crye-text-2); }
.ops-banner > .badge { border-style: solid; border-width: 1px; }

.ops-banner[data-tone="danger"] {
  background: var(--crye-danger-fill);
  border-color: var(--crye-danger);
  color: var(--crye-danger);
}
.ops-banner[data-tone="danger"] > .badge {
  background: var(--crye-danger); border-color: var(--crye-danger); color: #FFFFFF;
}
.ops-banner[data-tone="warning"] {
  background: var(--crye-warning-fill);
  border-color: var(--crye-warning);
  color: var(--crye-warning);
}
.ops-banner[data-tone="warning"] > .badge {
  background: var(--crye-warning); border-color: var(--crye-warning); color: #FFFFFF;
}
/* Dark-theme gold is bright (#E8B44A): white on it fails, ink passes. */
.dark .ops-banner[data-tone="warning"] > .badge,
.dark .ops-banner[data-tone="danger"] > .badge {
  color: #14120F;
}

/* --- Empty state --- */
.crye-empty {
  padding: var(--crye-s-xxl);
  border-radius: var(--crye-r-lg);
  background: var(--crye-surface-0);
  border: 1px dashed var(--crye-hairline);
  color: var(--crye-text-3); text-align: center;
  font-size: var(--fs-body); line-height: 1.55;
}

/* --- "About this screen". Styled as an obvious control: real border, its own
   surface, a rotating chevron and a hover state. The first version read as
   plain text and nobody could tell it opened. --- */
.crye-about {
  border-radius: var(--crye-r-lg);
  background: var(--crye-surface-1);
  border: 1px solid var(--crye-card-border);
  box-shadow: var(--crye-shadow-1);
}
.crye-about > summary {
  display: flex; align-items: center; gap: var(--crye-s-xs);
  padding: var(--crye-s-sm) var(--crye-s-md) var(--crye-s-sm) var(--crye-s-lg);
  cursor: pointer; list-style: none; user-select: none;
  font-family: "Crye Caption", ui-monospace, monospace;
  font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.9px;
  text-transform: uppercase; color: var(--crye-text-2);
  border-radius: var(--crye-r-lg);
  transition: background-color 140ms ease, color 140ms ease;
}
.crye-about > summary::-webkit-details-marker { display: none; }
.crye-about > summary::before {
  content: ""; width: 18px; height: 18px; flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E") center/contain no-repeat;
}
.crye-about > summary::after {
  content: ""; margin-left: auto; width: 20px; height: 20px; flex-shrink: 0;
  background: currentColor;
  transition: transform 180ms ease;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
}
.crye-about[open] > summary::after { transform: rotate(180deg); }
.crye-about > summary:hover { background: var(--crye-hover-fill); color: var(--crye-text-1); }
.crye-about > summary:focus-visible {
  outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--crye-gold-fill) 45%, transparent);
}
.crye-about > div {
  padding: var(--crye-s-xs) var(--crye-s-lg) var(--crye-s-md);
  font-size: var(--fs-body); line-height: 1.6; color: var(--crye-text-2);
  max-width: 72ch;
}

/* --- Slide-over drawer (DESIGN.md § Drawers & modals + § Detail-in-drawer).
   Level 3 over the scrim, rounded on the LEADING edge only — the panel is
   flush with the right edge of the viewport, so rounding that side would
   float it off the screen edge for no reason. The host lives in base.html
   and is shared by every list; only the body content changes. --- */
.crye-drawer-host[hidden] { display: none; }
.crye-drawer-host {
  position: fixed; inset: 0; z-index: 60;
  display: flex; justify-content: flex-end;
}
.crye-drawer-scrim {
  position: absolute; inset: 0;
  background: var(--crye-scrim);
  opacity: 0; transition: opacity 180ms ease;
}
.crye-drawer {
  position: relative;
  display: flex; flex-direction: column;
  width: min(480px, 100vw);
  height: 100%;
  /* Owner call 2026-08-05: the drawer reads as a slice of the page, not a
     lifted panel — canvas background in both themes; the scrim + shadow
     carry the separation. */
  background: var(--crye-surface-0);
  box-shadow: var(--crye-shadow-3);
  border-top-left-radius: var(--crye-r-xl);
  border-bottom-left-radius: var(--crye-r-xl);
  color: var(--crye-text-1);
  transform: translateX(100%); transition: transform 220ms cubic-bezier(.32,.72,0,1);
}
/* The working cut (records, forms): 60% of the browser, never under 640px. */
.crye-drawer[data-size="wide"] { width: min(max(60vw, 640px), 100vw); }

/* The drawer floor IS the canvas color now, so anything painted with the
   "recessed" tokens (bg-muted, bg-card — chat bubbles, tool-call boxes,
   coverage cards) would melt into it. Remap those tokens inside the drawer:
   recessed/card content lifts to the lightest surface instead. This is the
   same inversion the inputs get, applied to every fragment automatically. */
.crye-drawer {
  --muted: var(--crye-surface-1);
  --card: var(--crye-surface-1);
  --accent: var(--crye-surface-1);
}

/* Forms in a drawer sit in a raised card (owner decision 2026-08-05, chose
   the strict height convention over canvas-level fields): the .card class
   goes on the <form> itself, and inputs keep their normal recessed
   treatment. No drawer-specific input rules exist on purpose. */
.crye-drawer-host[data-open] .crye-drawer-scrim { opacity: 1; }
.crye-drawer-host[data-open] .crye-drawer { transform: translateX(0); }

/* Side padding is generous on purpose (owner call 2026-08-05: 3× the old
   32px) — at 60vw the content column breathes instead of hugging the edges.
   Steps down when the drawer is at its 640px floor, and again on mobile. */
.crye-drawer { --crye-drawer-pad-x: 96px; }
.crye-drawer-head {
  display: flex; align-items: flex-start; gap: var(--crye-s-sm);
  padding: var(--crye-s-lg) var(--crye-drawer-pad-x) var(--crye-s-md);
  border-bottom: 1px solid var(--crye-hairline);
}
.crye-drawer-head > .crye-drawer-title { flex: 1; min-width: 0; }
.crye-drawer-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: var(--crye-s-lg) var(--crye-drawer-pad-x) var(--crye-s-xl);
}
/* Below ~1100px viewport the wide drawer sits at its 640px floor — 96px a
   side would squeeze the content column to ~450px. */
@media (max-width: 1100px) {
  .crye-drawer { --crye-drawer-pad-x: var(--crye-s-xl); }
}
/* The footer is where the "open full page" affordance lives — the standalone
   route always exists, and the drawer must always offer it. */
.crye-drawer-foot {
  display: flex; align-items: center; gap: var(--crye-s-xs); flex-wrap: wrap;
  padding: var(--crye-s-md) var(--crye-s-xl);
  border-top: 1px solid var(--crye-hairline);
  background: var(--crye-surface-2);
  border-bottom-left-radius: var(--crye-r-xl);
}
.crye-drawer-close {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; margin: -6px -10px 0 0;
  border: 1px solid var(--crye-card-border); border-radius: var(--crye-r-pill);
  background: transparent; color: var(--crye-text-2); cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}
.crye-drawer-close:hover { background: var(--crye-hover-fill); color: var(--crye-text-1); }
.crye-drawer-close:focus-visible {
  outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--crye-gold-fill) 45%, transparent);
}
/* Skeleton shown while the partial is in flight. */
.crye-drawer-loading {
  display: block; height: 14px; border-radius: var(--crye-r-pill);
  background: var(--crye-neutral-fill);
  animation: crye-pulse 1.2s ease-in-out infinite;
}
.crye-drawer-loading + .crye-drawer-loading { margin-top: var(--crye-s-sm); }
@keyframes crye-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Inline notice at the top of a drawer body — save confirmations, re-embed
   warnings, validation errors. Lives INSIDE the panel: the page-top message
   banner can't be seen behind an open drawer. */
.crye-drawer-notice {
  display: flex; align-items: flex-start; gap: var(--crye-s-xs);
  padding: var(--crye-s-sm) var(--crye-s-md);
  margin-bottom: var(--crye-s-md);
  border-radius: var(--crye-r-sm);
  font-size: var(--fs-body-sm); line-height: 1.5;
  background: var(--crye-neutral-fill); color: var(--crye-text-1);
}
.crye-drawer-notice[data-tone="success"] { background: var(--crye-success-fill); color: var(--crye-success); }
.crye-drawer-notice[data-tone="warning"] { background: var(--crye-warning-fill); color: var(--crye-warning); }
.crye-drawer-notice[data-tone="danger"]  { background: var(--crye-danger-fill);  color: var(--crye-danger); }

/* Toast — the one message that must outlive a closing drawer ("deleted").
   Bottom-center, level 3, self-dismissing. */
.crye-toast {
  position: fixed; bottom: 28px; left: 50%; z-index: 70;
  transform: translate(-50%, 12px); opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
  padding: 12px 20px;
  border-radius: var(--crye-r-pill);
  background: var(--crye-surface-3);
  border: 1px solid var(--crye-card-border);
  box-shadow: var(--crye-shadow-3);
  color: var(--crye-text-1); font-size: var(--fs-body-sm); font-weight: 600;
  max-width: min(90vw, 480px);
}
.crye-toast[data-show] { transform: translate(-50%, 0); opacity: 1; }

/* A labelled block inside a drawer or a read-only detail view: the uppercase
   label above its value. Same shape as the form-field stack it replaces. */
.crye-field > .crye-label { display: block; margin-bottom: var(--crye-s-xxs); }
.crye-field + .crye-field { margin-top: var(--crye-s-lg); }
.crye-field p { white-space: pre-line; }

@media (max-width: 640px) {
  .crye-drawer { width: 100vw; border-radius: 0; }
  .crye-drawer-foot { border-radius: 0; }
  .crye-drawer-head, .crye-drawer-body, .crye-drawer-foot { padding-left: var(--crye-s-md); padding-right: var(--crye-s-md); }
}

/* --- Chat composer. Pinned over the scrolling transcript, so it takes
   level 2 (the "floats above content" level) — raised surface + shadow,
   never the recessed input treatment, which would melt into the canvas
   (owner call 2026-08-05: the outline alone wasn't enough). --- */
.crye-composer {
  background: var(--crye-surface-2);
  border: 1px solid var(--crye-card-border);
  border-radius: var(--crye-r-lg);
  box-shadow: var(--crye-shadow-2);
  padding: var(--crye-s-md) var(--crye-s-lg);
}
.crye-composer:focus-within {
  border-color: var(--crye-gold-fill);
  box-shadow: var(--crye-shadow-2),
              0 0 0 3px color-mix(in srgb, var(--crye-gold-fill) 35%, transparent);
}

/* --- Sidebar nav --- */
/* Nav highlight needs its own tokens: --crye-surface-2 is white in light mode,
   invisible inside the white sidebar card (owner 2026-08-06). Light uses the
   warm page grays; dark keeps the raised surface it already had. */
:root {
  --crye-nav-hover: #F2F0ED;
  --crye-nav-active: #EAE6E1;
}
.dark {
  --crye-nav-hover: var(--crye-surface-2);
  --crye-nav-active: var(--crye-surface-2);
}
.nav-link, .nav-link-active {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--crye-r-sm);
  font-size: var(--fs-body-sm); color: var(--crye-text-2);
  text-decoration: none; transition: background-color 120ms ease, color 120ms ease;
}
.nav-link:hover { background: var(--crye-nav-hover); color: var(--crye-text-1); }
/* No leading gold bar (owner ruling 2026-08-05) — the raised surface, gold
   text and weight carry the active state on their own. */
.nav-link-active {
  background: var(--crye-nav-active); color: var(--crye-gold-text); font-weight: 600;
}

/* --- Sidebar card treatment (owner 2026-08-06) ---
   Quieter than a regular .card: no shadow (light) and no border (dark), and on
   desktop the whole rail dims until hovered or keyboard-focused so it doesn't
   compete with the working area. */
#sidebar { box-shadow: none; }
.dark #sidebar { border-color: transparent; }
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  #sidebar { opacity: 0.6; transition: opacity 160ms ease; }
  #sidebar:hover, #sidebar:focus-within { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #sidebar { transition: none; }
}
.nav-section {
  padding: 0 12px; margin-bottom: 6px;
  font-family: "Crye Caption", ui-monospace, monospace;
  font-size: 12px; font-weight: 600; letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--crye-text-4);
}

/* --- Prose --- */
.prose-dark {
  font-size: var(--fs-body); line-height: 1.65; color: var(--crye-text-1);
}
.prose-dark a { color: var(--crye-gold-text); text-decoration: underline; text-underline-offset: 3px; }
.prose-dark ul { list-style: disc; padding-left: 1.4em; }
.prose-dark ol { list-style: decimal; padding-left: 1.4em; }
.prose-dark li { margin: 0.3em 0; }
.prose-dark p  { margin: 0.6em 0; }
.prose-dark table { width: 100%; border-collapse: collapse; }
.prose-dark td, .prose-dark th { border: 1px solid var(--crye-card-border); padding: 8px 10px; }
.cp-markdown { font-size: var(--fs-body); line-height: 1.65; }

/* --- Breadcrumb. House is home (Chat); a chevron separates nodes. --- */
.crye-crumb {
  display: flex;
  align-items: center;
  gap: var(--crye-s-xs);
  font-size: var(--fs-body-sm);
  min-width: 0;
}
.crye-crumb-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--crye-text-3);
  transition: color 140ms ease;
}
.crye-crumb-home:hover { color: var(--crye-text-1); }
.crye-crumb-home:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crye-gold-fill) 45%, transparent);
  border-radius: var(--crye-r-xs);
}
.crye-crumb-sep {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--crye-text-3);
  line-height: 0;
}
.crye-crumb-sep svg {
  width: 14px;
  height: 14px;
}
.crye-crumb-current {
  font-weight: 600;
  color: var(--crye-text-1);
  min-width: 0;
}

/* --- Layout rhythm --- */
.crye-stack-sm > * + * { margin-top: var(--crye-s-sm); }
.crye-stack    > * + * { margin-top: var(--crye-s-md); }
.crye-stack-lg > * + * { margin-top: var(--crye-s-xl); }
.crye-stack-xl > * + * { margin-top: var(--crye-s-xxl); }
.crye-grid {
  display: grid; gap: var(--crye-s-md);
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.crye-chips { display: flex; flex-wrap: wrap; gap: var(--crye-s-xs); align-items: center; }

/* Feedback buttons (chat): the faintest per-action tint at rest; hover
   saturates the fill; active is an INSET ring (box-shadow, not border —
   the row must never shift) plus a stronger tint. Each button carries
   its accent in --fb-accent. Hover uses !important so it beats .btn:hover. */
.fb-tint-up   { --fb-accent: var(--crye-success); background: color-mix(in srgb, var(--crye-success) 7%, transparent) !important; }
.fb-tint-down { --fb-accent: var(--crye-danger);  background: color-mix(in srgb, var(--crye-danger) 7%, transparent) !important; }
.fb-tint-ask  { --fb-accent: var(--crye-warning); background: color-mix(in srgb, var(--crye-warning) 7%, transparent) !important; }
.fb-tint-up:hover, .fb-tint-down:hover, .fb-tint-ask:hover {
  background: color-mix(in srgb, var(--fb-accent) 28%, transparent) !important;
  border-color: color-mix(in srgb, var(--fb-accent) 50%, transparent);
}
.thumb-active {
  box-shadow: inset 0 0 0 2px var(--fb-accent, var(--primary));
  background: color-mix(in srgb, var(--fb-accent, var(--primary)) 16%, transparent) !important;
  color: var(--crye-text-1) !important;
}
.thumb-active:hover {
  background: color-mix(in srgb, var(--fb-accent, var(--primary)) 34%, transparent) !important;
}

/* Long-content clamp (Flagged Answers bot-answer panel): cap the height and
   fade out; the page script appends a "Show full answer" button when clipped.
   Gradient fades to the raised-panel surface it sits on. */
.crye-clamp { position: relative; max-height: 18rem; overflow: hidden; }
.crye-clamp::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3.5rem;
  background: linear-gradient(to bottom, transparent, var(--crye-surface-2));
  pointer-events: none;
}

/* Scroll-edge fade: a bottom gradient on scrolling containers hinting there
   is more below. Pure CSS (a sticky pseudo-element pinned to the scrollport
   bottom): while content remains below it overlays the last 2rem; scrolled
   to the end it comes to rest over the container's own bottom padding, so
   the final line is never left faded. Theme-aware for free — it fades to
   --scroll-fade-to (default --background); containers on a card surface set
   --scroll-fade-to: var(--card). No JS, no scroll listeners. The drawer
   body (canvas background) gets it as part of the component.

   --scroll-fade-inset: sticky insets resolve against the CONTENT box, so a
   scroll container that carries its own bottom padding (drawer body,
   sidebar nav, graph panel) pins the fade padding-height above the visual
   bottom, leaving a gap. Set the inset to that container's own bottom
   padding: the pin line and the rest position both drop by it, keeping the
   fade flush while scrolling and over the padding at the end. Containers
   whose padding lives on an inner wrapper (main, chat) leave it at 0. */
.crye-scroll-fade::after,
.crye-drawer-body::after {
  content: "";
  display: block;
  position: sticky;
  bottom: calc(-1 * var(--scroll-fade-inset, 0px));
  height: 2rem;
  margin-top: calc(-2rem + var(--scroll-fade-inset, 0px));
  margin-bottom: calc(-1 * var(--scroll-fade-inset, 0px));
  background: linear-gradient(to bottom, transparent,
                              var(--scroll-fade-to, var(--background)));
  pointer-events: none;
}
.crye-drawer-body { --scroll-fade-inset: var(--crye-s-xl); }

@media (prefers-reduced-motion: reduce) {
  .card-interactive, .btn, .btn-primary, .crye-about > summary,
  .crye-about > summary::after, .nav-link, .crye-crumb-home,
  .crye-drawer, .crye-drawer-scrim, .crye-drawer-close, .crye-toast { transition: none; }
  .crye-drawer-loading { animation: none; }
}
