/* ChapterForge design system. Layered so Tailwind utilities always win.
   Brand colours come from the organization (--org-* raw, --kh-brand/--kh-accent
   contrast-guarded per mode; injected by templates/_theme_vars.html). Everything
   else is a neutral palette with light and dark values switched by html.dark. */
@layer base, components;

/* ---------------------------------------------------------------- tokens */
:root {
  /* Follow ChapterForge's own theme, not the device's: otherwise a phone in dark
     mode paints dialogs and form controls dark-on-light pages (white text on
     white). html.dark switches this to dark. */
  color-scheme: light;
  /* Friendly aliases for the organization's brand colours. */
  --primary-color: var(--org-primary, #6b2d8c);
  --secondary-color: var(--org-secondary, #f5faf6);
  --accent-color: var(--kh-accent, var(--org-accent, #1b6ac9));

  /* Light mode surfaces. */
  --kh-canvas: #faf9f6;
  --kh-sunken: #f4f3ef;
  --kh-card: #ffffff;
  --kh-card-raised: #ffffff;
  --kh-ink: #111827;
  --kh-body: #374151;
  --kh-muted: #4b5563;
  --kh-faint: #9ca3af;
  --kh-line: #e5e7eb;
  --kh-field: #d1d5db;
  --kh-field-bg: #ffffff;
  --kh-placeholder: #6b7280;
  --kh-glass: rgba(255, 255, 255, 0.85);
  /* Cards carry a hairline of the brand colour (Milestone 16 harmony). */
  --kh-shadow-card: 0 0 0 1px var(--kh-card-border-tint, rgba(17, 24, 39, 0.05)), 0 1px 2px rgba(17, 24, 39, 0.04), 0 10px 28px -14px rgba(17, 24, 39, 0.16);
  --kh-radius-card: 16px;
  --kh-radius-control: 10px;
  --kh-shadow-lift: 0 0 0 1px rgba(17, 24, 39, 0.06), 0 2px 4px rgba(17, 24, 39, 0.05), 0 22px 44px -18px rgba(17, 24, 39, 0.26);

  /* Status & category hues (text on tinted background), all AA in light mode. */
  --hue-neutral-fg: #374151; --hue-neutral-bg: #f3f4f6;
  --hue-green-fg: #17794d;   --hue-green-bg: #e8f6ef;   --hue-green-line: #9fd3b4;
  --hue-amber-fg: #92400e;   --hue-amber-bg: #fff4de;
  --hue-red-fg: #9f1c1c;     --hue-red-bg: #fdf2f2;     --hue-red-line: #f1c4c4;
  --hue-teal-fg: #0f766e;    --hue-teal-bg: #e3f5f1;
  --hue-rose-fg: #be185d;    --hue-rose-bg: #fdebf3;
  --hue-violet-fg: #6d28d9;  --hue-violet-bg: #f3eefe;
  --hue-cyan-fg: #0e7490;    --hue-cyan-bg: #e6f6f9;
  --hue-blue-fg: #1d5fa8;    --hue-blue-bg: #e6f0fc;
  --hue-plum-fg: #6b2d8c;    --hue-plum-bg: #f3e9f8;
  --hue-ink-bg: #1f2937;     --hue-ink-fg: #ffffff;

  --kh-font-display: "Plus Jakarta Sans", "Inter", -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --kh-font-body: "Inter", -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --kh-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  /* Milestone 22: how popovers, modals and drawers roll out and back. */
  --kh-roll: cubic-bezier(0.16, 1, 0.3, 1);
  --kh-roll-ms: 250ms;
  /* The Heart avatar frame (stretches to the avatar's box). */
  --kh-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M50 95C47 95 44.5 93.5 42 91.5C24 77.5 3 60 3 35.5C3 19 15 6 30 6C38.5 6 45.5 10 50 16.5C54.5 10 61.5 6 70 6C85 6 97 19 97 35.5C97 60 76 77.5 58 91.5C55.5 93.5 53 95 50 95Z'/%3E%3C/svg%3E");
}

html.dark {
  color-scheme: dark;
  /* Dark mode surfaces. */
  --kh-canvas: #0b1120;
  --kh-sunken: #0e1628;
  --kh-card: #162032;
  --kh-card-raised: #1c283d;
  --kh-ink: #f8fafc;
  --kh-body: #cbd5e1;
  --kh-muted: #94a3b8;
  --kh-faint: #64748b;
  --kh-line: #263349;
  --kh-field: #334155;
  --kh-field-bg: #0f1a2c;
  --kh-placeholder: #7c8aa0;
  --kh-glass: rgba(11, 17, 32, 0.82);
  --kh-shadow-card: 0 0 0 1px var(--kh-card-border-tint, rgba(148, 163, 184, 0.10)), 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 30px -16px rgba(0, 0, 0, 0.6);
  --kh-shadow-lift: 0 0 0 1px rgba(148, 163, 184, 0.14), 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 48px -18px rgba(0, 0, 0, 0.7);

  --hue-neutral-fg: #cbd5e1; --hue-neutral-bg: #1e2a3f;
  --hue-green-fg: #6ee7b7;   --hue-green-bg: rgba(16, 185, 129, 0.15);  --hue-green-line: rgba(110, 231, 183, 0.35);
  --hue-amber-fg: #fcd34d;   --hue-amber-bg: rgba(245, 158, 11, 0.15);
  --hue-red-fg: #fca5a5;     --hue-red-bg: rgba(239, 68, 68, 0.14);     --hue-red-line: rgba(252, 165, 165, 0.35);
  --hue-teal-fg: #5eead4;    --hue-teal-bg: rgba(20, 184, 166, 0.15);
  --hue-rose-fg: #f9a8d4;    --hue-rose-bg: rgba(236, 72, 153, 0.15);
  --hue-violet-fg: #c4b5fd;  --hue-violet-bg: rgba(139, 92, 246, 0.17);
  --hue-cyan-fg: #67e8f9;    --hue-cyan-bg: rgba(6, 182, 212, 0.15);
  --hue-blue-fg: #93c5fd;    --hue-blue-bg: rgba(59, 130, 246, 0.16);
  --hue-plum-fg: #d8b4fe;    --hue-plum-bg: rgba(168, 85, 247, 0.16);
  --hue-ink-bg: #334155;     --hue-ink-fg: #f8fafc;

  /* Hover tints like bg-black/5 become light tints on dark surfaces. */
  --color-black: #ffffff;
}

/* ---------------------------------------------------------------- base */
@layer base {
  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
  body {
    margin: 0;
    font-family: var(--kh-font-body);
    font-size: 17px;
    line-height: 1.5;
    color: var(--kh-ink);
    background: var(--kh-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    transition: background-color 0.25s, color 0.25s;
  }
  h1, h2, h3, h4, legend, summary, button, .font-display {
    font-family: var(--kh-font-display);
    letter-spacing: -0.011em;
  }
  h1, h2, h3 { font-family: var(--kh-font-heading, var(--kh-font-display)); }
  h1 { letter-spacing: -0.022em; }
  a { color: inherit; }
  ::selection { background: color-mix(in srgb, var(--accent-color) 28%, transparent); }
  :focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; border-radius: 6px; }
}

/* ---------------------------------------------------------------- components */
@layer components {
  /* Neutral button (card-coloured, hairline border). */
  .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    padding: 0 16px;
    background: var(--kh-card);
    color: var(--kh-ink);
    border: 1px solid var(--kh-line);
    border-radius: var(--kh-radius-control);
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
    font-family: var(--kh-font-display);
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, box-shadow 0.15s, transform 0.15s var(--kh-ease), border-color 0.15s;
  }
  .btn:hover { background: color-mix(in srgb, var(--kh-ink) 4%, var(--kh-card)); border-color: var(--kh-field); box-shadow: 0 2px 6px rgba(17, 24, 39, 0.08); }
  .btn:active { transform: scale(0.97); }

  /* Brand-coloured buttons get the same feel. */
  button.bg-brand, a.bg-brand, button.bg-ink {
    transition: filter 0.15s, transform 0.15s var(--kh-ease), box-shadow 0.15s;
  }
  button.bg-brand:hover, a.bg-brand:hover { filter: brightness(1.07); box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--kh-brand) 60%, transparent); }
  button.bg-brand:active, a.bg-brand:active { transform: scale(0.97); }

  /* Text fields: 44px+, 16px text so iOS doesn't zoom on focus. */
  .field {
    display: block;
    width: 100%;
    height: 44px;
    box-sizing: border-box;
    padding: 0 12px;
    background: var(--kh-field-bg);
    color: var(--kh-ink);
    border: 1px solid var(--kh-field);
    border-radius: var(--kh-radius-control);
    font: inherit;
    font-size: 16px;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
  }
  .field::placeholder { color: var(--kh-placeholder); }
  .field:hover { border-color: color-mix(in srgb, var(--kh-field) 70%, var(--kh-ink)); }
  .field:focus { outline: none; border-color: var(--accent-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 22%, transparent); }
  select.field option { background: var(--kh-card); color: var(--kh-ink); }

  /* The sign-in pages keep their measured geometry (4px controls). */
  .auth-page { line-height: 1.25; }
  .auth-page .btn { border-radius: 4px; border-color: #c8c8c8; border-bottom-color: #b5b5b5; font-size: 17px; }
  .auth-page .field { border-radius: 4px; border-color: #c4c4c4; padding: 0 10px; }
  .dark .auth-page .btn, .dark .auth-page .field { border-color: var(--kh-field); }

  .card-link { display: block; text-decoration: none; color: inherit; }

  /* Swipeable pill rows (category filters, campaign tabs): no scrollbar line. */
  nav.overflow-x-auto { scrollbar-width: none; }
  nav.overflow-x-auto::-webkit-scrollbar { display: none; }

  /* Dialogs: theme colours instead of the browser's Canvas/CanvasText. */
  dialog { color: var(--kh-ink); background-color: var(--kh-card); }

  /* Monogram badge shown when an organization has no crest uploaded. */
  .kh-monogram {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: var(--org-on-primary, #ffffff);
    background:
      radial-gradient(circle at 28% 16%, rgba(255, 255, 255, 0.12), transparent 45%),
      linear-gradient(135deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 55%, var(--org-accent, #1b6ac9)));
    font-family: var(--kh-font-display);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.28), 0 6px 16px -8px rgba(17, 24, 39, 0.45);
    user-select: none;
  }
  /* Uploaded crests can be any shape: fit them inside a clean white disc. */
  .kh-crest { border-radius: 999px; object-fit: contain; background: #ffffff; }

  /* Card hover lift used across the dashboard and hub. */
  .kh-lift { transition: transform 0.22s var(--kh-ease), box-shadow 0.22s var(--kh-ease); }
  .group:hover .kh-lift, .kh-lift:hover { transform: translateY(-3px); box-shadow: var(--kh-shadow-lift); }

  /* Frosted glass bars. */
  .kh-glass {
    background: var(--kh-glass);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
  }

  /* Formatted message bodies and replies (see src/format.rs). */
  .prose-kin { color: var(--kh-body); }
  .prose-kin p { margin: 0 0 0.75em; }
  .prose-kin p:last-child, .prose-kin ul:last-child { margin-bottom: 0; }
  .prose-kin ul { list-style: disc; padding-left: 1.4em; margin: 0 0 0.75em; }
  .prose-kin li { margin: 0.15em 0; }
  .prose-kin li::marker { color: var(--accent-color); }
  .prose-kin strong { font-weight: 700; color: var(--kh-ink); }
  .prose-kin em { font-style: italic; }

  /* @mentions in Group Chat. */
  .mention {
    color: var(--accent-color);
    background: color-mix(in srgb, var(--accent-color) 14%, transparent);
    border-radius: 6px;
    padding: 0 3px;
    font-weight: 700;
  }
  .mention-me { color: var(--kh-on-brand, #ffffff); background: var(--kh-brand); }

  /* ---- Group Chat bubbles ---- */
  .kh-bubble {
    position: relative;
    max-width: 100%;
    border-radius: 18px;
    border-top-left-radius: 6px;
    padding: 8px 12px;
    background: var(--kh-card);
    color: var(--kh-ink);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--kh-line) 80%, transparent), 0 1px 2px rgba(17, 24, 39, 0.05);
  }
  .chat-line[data-mine] .kh-bubble {
    border-top-left-radius: 18px;
    border-top-right-radius: 6px;
    background: var(--kh-brand);
    color: var(--kh-on-brand, #ffffff);
    box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--kh-brand) 55%, transparent);
  }
  .chat-line[data-mine] .kh-bubble blockquote { color: inherit; opacity: 0.8; border-color: currentColor; }
  .chat-line[data-mine] .kh-bubble .mention { color: inherit; background: color-mix(in srgb, currentColor 18%, transparent); }
  .chat-line.is-mentioned .kh-bubble { box-shadow: 0 0 0 2px var(--accent-color), 0 6px 16px -8px color-mix(in srgb, var(--accent-color) 60%, transparent); }

  /* ---- Animated custom checkbox (To-Dos) ---- */
  .kh-check {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin: 0;
    border-radius: 7px;
    border: 2px solid var(--kh-field);
    background: var(--kh-field-bg);
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: background-color 0.18s var(--kh-ease), border-color 0.18s, transform 0.12s var(--kh-ease), box-shadow 0.18s;
  }
  .kh-check::after {
    content: "";
    width: 11px;
    height: 6px;
    border-left: 2.5px solid #ffffff;
    border-bottom: 2.5px solid #ffffff;
    transform: translateY(-1px) rotate(-45deg) scale(0);
    transition: transform 0.22s var(--kh-ease);
  }
  .kh-check:hover { border-color: var(--accent-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 16%, transparent); }
  .kh-check:active { transform: scale(0.9); }
  .kh-check:checked { background: #22a06b; border-color: #22a06b; animation: kh-pop 0.28s var(--kh-ease); }
  .kh-check:checked::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
  .kh-check:disabled { opacity: 0.55; cursor: not-allowed; }
  .kh-check:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }

  /* Pills for assignee / due dates / categories. */
  .kh-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    background: var(--hue-neutral-bg);
    color: var(--hue-neutral-fg);
  }

  /* Progress bars fill smoothly when HTMX swaps a list. */
  .kh-progress { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--kh-ink) 8%, transparent); overflow: hidden; }
  .kh-progress > span { display: block; height: 100%; border-radius: inherit; transition: width 0.5s var(--kh-ease); }

  /* Celebratory badge pills on the Spotlight wall. */
  .kh-badge { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px;
    font-family: var(--kh-font-display); font-size: 13px; font-weight: 700; white-space: nowrap; }

  /* Spotlight header: a warm rose-to-gold wash over the card colour, with
     a sprinkle of confetti. Both hues have light and dark values. */
  .kh-spotlight-head { background: linear-gradient(135deg, var(--hue-rose-bg) 0%, var(--hue-amber-bg) 100%), var(--kh-card); }
  .kh-confetti { position: absolute; inset: 0; pointer-events: none; opacity: 0.55;
    background:
      radial-gradient(circle at 12% 22%, var(--hue-rose-fg) 0 2.5px, transparent 3.5px),
      radial-gradient(circle at 78% 14%, var(--hue-amber-fg) 0 2px, transparent 3px),
      radial-gradient(circle at 64% 70%, var(--hue-violet-fg) 0 2px, transparent 3px),
      radial-gradient(circle at 90% 58%, var(--hue-teal-fg) 0 2.5px, transparent 3.5px),
      radial-gradient(circle at 40% 8%, var(--hue-blue-fg) 0 1.5px, transparent 2.5px),
      radial-gradient(circle at 28% 88%, var(--hue-amber-fg) 0 1.5px, transparent 2.5px); }

  /* Emoji reaction pills. "Mine" uses the contrast-checked brand colour. */
  .kh-react { display: inline-flex; align-items: center; gap: 5px; height: 34px; min-width: 44px; padding: 0 11px;
    justify-content: center; border-radius: 999px; border: 1px solid var(--kh-line); background: var(--kh-card);
    color: var(--kh-ink); font-family: var(--kh-font-display); font-size: 13.5px; font-weight: 700; cursor: pointer;
    transition: background-color 0.15s var(--kh-ease), border-color 0.15s var(--kh-ease), transform 0.15s var(--kh-ease); }
  .kh-react:hover { border-color: var(--kh-field); background: var(--kh-sunken); }
  .kh-react:active { transform: scale(0.94); }
  .kh-react:focus-visible { outline: 2px solid var(--kh-brand); outline-offset: 2px; }
  .kh-react[aria-pressed="true"] { border-color: color-mix(in srgb, var(--kh-brand) 55%, var(--kh-card));
    background: color-mix(in srgb, var(--kh-brand) 13%, var(--kh-card)); }
  .kh-react-emoji { font-size: 16px; line-height: 1; }
  .kh-react[aria-pressed="true"] .kh-react-emoji { animation: kh-pop 0.35s var(--kh-ease); }

  /* Badge chooser in the post form (radio buttons styled as tiles). */
  .kh-badge-choice { display: block; cursor: pointer; }
  .kh-badge-choice-face { display: flex; align-items: center; gap: 7px; height: 44px; padding: 0 12px; border-radius: 12px;
    border: 1.5px solid var(--kh-line); background: var(--kh-card); color: var(--kh-body);
    font-family: var(--kh-font-display); font-size: 14px; font-weight: 600; transition: all 0.15s var(--kh-ease); }
  .kh-badge-choice:hover .kh-badge-choice-face { border-color: var(--kh-field); }
  .peer:checked + .kh-badge-choice-face { border-color: var(--choice-fg); background: var(--choice-bg); color: var(--choice-fg); font-weight: 700; }
  .peer:focus-visible + .kh-badge-choice-face { outline: 2px solid var(--kh-brand); outline-offset: 2px; }
  .kh-badge-choice--soror .kh-badge-choice-face { border-style: dashed; border-color: #f59e0b; }
  .kh-badge-choice--soror .peer:checked + .kh-badge-choice-face { border-style: solid; box-shadow: 0 0 14px rgba(245, 158, 11, 0.35); }

  /* Digital membership pass: painted in the organization's colours (text uses
     --org-on-primary, the band --org-on-secondary), flips to a QR code. The
     QR always sits on a white plate so door scanners can read it in dark mode. */
  .kh-pass { perspective: 1600px; --pass-dot-green: #34d399; --pass-dot-blue: #7cb8ff; --pass-dot-violet: #c4b5fd; --pass-dot-amber: #fbbf24; }
  .kh-pass-inner { position: relative; aspect-ratio: 5 / 7.2; transform-style: preserve-3d; transition: transform 0.7s var(--kh-ease); cursor: pointer; }
  .kh-pass.is-flipped .kh-pass-inner { transform: rotateY(180deg); }
  .kh-pass-face { position: absolute; inset: 0; overflow: hidden; border-radius: 26px; color: var(--org-on-primary);
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
    background:
      radial-gradient(90% 55% at 100% 0%, color-mix(in srgb, var(--org-accent) 26%, transparent), transparent 70%),
      linear-gradient(155deg, color-mix(in srgb, var(--org-primary) 86%, var(--kh-shade-ink, #080612)) 0%,
        color-mix(in srgb, color-mix(in srgb, var(--org-primary) 78%, var(--org-accent)) 82%, var(--kh-shade-ink, #080612)) 100%);
    box-shadow: 0 26px 50px -20px rgba(17, 24, 39, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.16); }
  .dark .kh-pass-face { box-shadow: 0 26px 60px -18px rgba(0, 0, 0, 0.85), inset 0 0 0 1px rgba(255, 255, 255, 0.2); }
  .kh-pass-back { transform: rotateY(180deg); }
  .kh-pass-sheen { position: absolute; inset: 0; pointer-events: none;
    background:
      repeating-radial-gradient(circle at 0% 100%, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 10px),
      linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.16) 45%, transparent 60%); }
  .kh-pass-chip { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 12px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.28);
    font-family: var(--kh-font-display); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
  /* Gold chip on the pass: dark amber ink on pale gold reads on any brand colour. */
  .kh-pass-chip--soror { background: linear-gradient(135deg, #fef3c7, #fcd34d); border-color: #f59e0b; color: #78350f;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.55); }
  .kh-pass-band { position: relative; background: var(--org-secondary); color: var(--org-on-secondary); }
  .kh-qr-plate { background: #ffffff; border-radius: 18px; padding: 10px; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.5); }
  .kh-qr { display: block; width: 100%; height: auto; }

  /* Officer Check-In Station: camera viewfinder, result chime colours, roster buttons. */
  .kh-scanner { position: relative; overflow: hidden; aspect-ratio: 4 / 3; max-height: 62vh; border-radius: 18px; background: #0b1120; color: #f8fafc;
    transition: box-shadow 0.25s var(--kh-ease); }
  .kh-scanner-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.3s; }
  .kh-scanner[data-state="live"] .kh-scanner-video { opacity: 1; }
  .kh-scanner-idle { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 18px; }
  .kh-scanner[data-state="live"] .kh-scanner-idle { display: none; }
  .kh-scanner-frame { position: absolute; inset: 16% 22%; border-radius: 18px; pointer-events: none; opacity: 0; transition: opacity 0.3s;
    box-shadow: 0 0 0 999px rgba(11, 17, 32, 0.35); border: 3px solid rgba(255, 255, 255, 0.9); }
  .kh-scanner[data-state="live"] .kh-scanner-frame { opacity: 1; }
  .kh-scanner[data-flash="ok"] { box-shadow: 0 0 0 4px #22c55e, 0 0 30px 4px rgba(34, 197, 94, 0.55); }
  .kh-scanner[data-flash="ok"] .kh-scanner-frame { border-color: #4ade80; }
  .kh-scanner[data-flash="no"] { box-shadow: 0 0 0 4px #f59e0b; }
  .kh-scan-result { animation: kh-pop 0.35s var(--kh-ease); }
  .kh-scan-icon[data-hue="green"] { background: #18794e; }
  .kh-scan-icon[data-hue="amber"] { background: #a15c07; }
  .kh-scan-icon[data-hue="red"] { background: #b91c1c; }
  .kh-checkin-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 40px; min-width: 116px; padding: 0 16px;
    border-radius: 999px; font-family: var(--kh-font-display); font-size: 14.5px; font-weight: 700; cursor: pointer;
    background: var(--kh-brand); color: var(--kh-on-brand); transition: filter 0.15s, transform 0.15s; }
  .kh-checkin-btn:hover { filter: brightness(1.08); }
  .kh-checkin-btn:active { transform: scale(0.96); }
  .kh-checkin-btn.is-in { background: #18794e; color: #ffffff; }

  /* Heritage vault: a warm, editorial wash around the crest. */
  .kh-heritage-hero { background:
      radial-gradient(70% 90% at 50% 0%, color-mix(in srgb, var(--kh-brand) 15%, transparent), transparent 70%),
      linear-gradient(180deg, var(--hue-amber-bg), var(--kh-card) 75%), var(--kh-card); }
  .kh-heritage-rays { position: absolute; inset: -40% -10% auto; height: 120%; pointer-events: none; opacity: 0.5;
    background: repeating-conic-gradient(from 0deg at 50% 38%, color-mix(in srgb, var(--kh-brand) 9%, transparent) 0deg 5deg, transparent 5deg 15deg);
    -webkit-mask-image: radial-gradient(circle at 50% 38%, #000 0%, transparent 60%); mask-image: radial-gradient(circle at 50% 38%, #000 0%, transparent 60%); }
  .kh-heritage-halo { position: absolute; inset: -14px; border-radius: 999px;
    border: 2px solid color-mix(in srgb, var(--org-accent) 55%, transparent);
    box-shadow: 0 0 0 10px color-mix(in srgb, var(--org-primary) 10%, transparent), 0 0 0 11px color-mix(in srgb, var(--org-primary) 30%, transparent); }
  .kh-motto { color: var(--org-on-primary);
    background: linear-gradient(120deg, var(--org-primary), color-mix(in srgb, var(--org-primary) 70%, var(--org-accent))); box-shadow: var(--kh-shadow-lift); }
  .kh-motto-mark { position: absolute; top: -48px; left: 18px; font-family: Georgia, "Times New Roman", serif; font-size: 220px; line-height: 1; opacity: 0.14; }
  .kh-dropcap > p:first-child::first-letter { float: left; margin: 6px 10px 0 0; font-family: var(--kh-font-display); font-size: 3.6em;
    font-weight: 800; line-height: 0.82; color: var(--kh-brand); }

  /* Fundraising thermometer: a glass tube that fills in the chapter's colours
     (decorative), plus an accessible horizontal bar. Both animate in once. */
  .kh-thermo { position: relative; width: 34px; height: 156px; display: flex; flex-direction: column; align-items: center; }
  .kh-thermo-tube { position: relative; flex: 1; width: 16px; border-radius: 999px 999px 0 0; overflow: hidden;
    background: color-mix(in srgb, var(--kh-ink) 8%, var(--kh-card)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--kh-ink) 12%, transparent); }
  .kh-thermo-mercury { position: absolute; inset: auto 0 0; height: var(--fill); border-radius: 999px 999px 0 0;
    background: linear-gradient(0deg, var(--org-primary), var(--org-accent)); animation: kh-rise 1.4s var(--kh-ease) both; }
  .kh-thermo-bulb { width: 34px; height: 34px; margin-top: -4px; border-radius: 999px; background: var(--org-primary);
    box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--org-primary) 70%, #000), 0 6px 14px -6px var(--org-primary); }
  .kh-thermo-bar { height: 14px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--kh-ink) 8%, var(--kh-card)); }
  .kh-thermo-bar > span { display: block; height: 100%; width: var(--fill); border-radius: inherit; position: relative; overflow: hidden;
    background: linear-gradient(90deg, var(--org-primary), var(--org-accent)); animation: kh-grow 1.4s var(--kh-ease) both; }
  .kh-thermo-bar > span::after { content: ""; position: absolute; inset: 0;
    background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.35) 50%, transparent 80%); animation: kh-shine 2.8s 1.4s ease-in-out infinite; }
  @media (max-width: 420px) { .kh-thermo { display: none; } }

  /* Chapter recaps: editorial headings and the leadership note. */
  .kh-recap h2 { font-family: var(--kh-font-display); font-size: 1.45em; font-weight: 800; line-height: 1.2; color: var(--kh-ink); margin: 0 0 0.2em; }
  .kh-recap h3 { font-family: var(--kh-font-display); font-size: 1.12em; font-weight: 800; color: var(--kh-ink); margin: 1.3em 0 0.3em;
    padding-top: 0.9em; border-top: 1px solid var(--kh-line); }
  .kh-recap h4 { font-family: var(--kh-font-display); font-size: 0.98em; font-weight: 700; color: var(--kh-brand); margin: 0.9em 0 0.2em; }
  .kh-recap blockquote { margin: 0.8em 0 1em; padding: 0.7em 1em; border-left: 4px solid var(--kh-brand); border-radius: 0 12px 12px 0;
    background: color-mix(in srgb, var(--kh-brand) 9%, var(--kh-card)); color: var(--kh-ink); font-style: italic; }
  .kh-recap ul { margin: 0.3em 0 0.5em; }
  .kh-recap p { margin: 0.4em 0; }
  /* The published page already shows the title in its header. */
  .kh-recap-detail > h2:first-of-type { display: none; }

  /* Toast (copy confirmations). */
  .kh-toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60; max-width: min(440px, calc(100vw - 30px));
    transform: translate(-50%, 16px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 14px;
    background: var(--hue-ink-bg); color: var(--hue-ink-fg); font-weight: 600; font-size: 15px; box-shadow: var(--kh-shadow-lift);
    transition: opacity 0.25s var(--kh-ease), transform 0.25s var(--kh-ease); }
  .kh-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
  @media (min-width: 768px) { .kh-toast { bottom: 28px; } }

  /* Avatars (templates/_avatar.html): ring colour, then a thin gap in the
     card colour, then the photo or initials, all in the person's chosen shape. */
  .kh-av { --ring: var(--org-primary); position: relative; display: inline-flex; flex-shrink: 0; padding: 2px; background: var(--ring);
    font-family: var(--kh-font-display); font-weight: 700; line-height: 1; }
  .kh-av-inner { display: flex; width: 100%; height: 100%; padding: 1.5px; background: var(--kh-card); }
  .kh-av-inner > img, .kh-av-initials { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center;
    object-fit: cover; color: #ffffff; letter-spacing: 0.02em; }
  .kh-av--circle, .kh-av--circle > *, .kh-av--circle img, .kh-av--circle .kh-av-initials { border-radius: 999px; }
  .kh-av--rounded-square { border-radius: 30%; }
  .kh-av--rounded-square > .kh-av-inner { border-radius: 27%; }
  .kh-av--rounded-square img, .kh-av--rounded-square .kh-av-initials { border-radius: 24%; }
  .kh-av--diamond, .kh-av--diamond > *, .kh-av--diamond img, .kh-av--diamond .kh-av-initials {
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
  .kh-av--diamond { padding: 3px; }
  .kh-av--diamond > .kh-av-inner { padding: 2.5px; }
  .kh-av--diamond .kh-av-initials { font-size: 0.82em; }
  .kh-av--hexagon, .kh-av--hexagon > *, .kh-av--hexagon img, .kh-av--hexagon .kh-av-initials {
    clip-path: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0 50%); }
  .kh-av--hexagon { padding: 2.5px; }
  .kh-av--hexagon > .kh-av-inner { padding: 2px; }
  /* Heart (Milestone 22): the ring, the gap and the photo are each masked
     with the same heart, drawn once as an SVG path that stretches to any
     avatar size. It is plump with a shallow notch, so a centred face keeps
     its forehead and chin. Glows are drop-shadows on the wrapper, so they
     follow the heart like every other frame. */
  .kh-av--heart, .kh-av--heart > *, .kh-av--heart img, .kh-av--heart .kh-av-initials {
    -webkit-mask: var(--kh-heart) center / 100% 100% no-repeat; mask: var(--kh-heart) center / 100% 100% no-repeat; }
  .kh-av--heart { padding: 3px; }
  .kh-av--heart > .kh-av-inner { padding: 2.5px; }
  .kh-av--heart .kh-av-initials { padding-bottom: 7%; font-size: 0.82em; }
  .kh-ring--primary { --ring: var(--org-primary); }
  .kh-ring--accent { --ring: var(--org-accent); }
  .kh-ring--gold { --ring: linear-gradient(135deg, #f5d77a, #c9971c); }
  .kh-ring--emerald { --ring: #10b981; }
  .kh-ring--rose { --ring: linear-gradient(135deg, #fbcfe8, #ec4899); }
  .kh-ring--amethyst { --ring: linear-gradient(135deg, #c4b5fd, #7c3aed); }
  .kh-ring--neutral { --ring: color-mix(in srgb, var(--kh-ink) 22%, var(--kh-card)); }

  /* Milestone 23: the glow was dialled back about 15% (blur and alpha), so
     it stays the showpiece without spilling onto the text beside it. */
  /* Soror of the Month (Milestone 15, turned up in Milestone 21): the royal
     centerpiece. Layers, back to front: a slowly turning gold, champagne and
     brand-colour halo; a breathing champagne ring; a three-step golden glow
     (a drop-shadow on the wrapper, so it follows every frame shape); a gold
     ring; five twinkling sparkles; and a crown perched on the top-right edge.
     It replaces every prestige tier frame (see templates/_avatar.html). */
  .kh-soror { --kh-gold-a: #fbbf24; --kh-gold-b: #d97706; --kh-glow: rgba(245, 158, 11, 0.51); --kh-champagne: #f7e7c4;
    --kh-royal: color-mix(in srgb, var(--org-primary) 70%, #7c3aed);
    position: relative; display: inline-flex; flex: none; align-items: center; justify-content: center; vertical-align: middle; isolation: isolate;
    filter: drop-shadow(0 0 1.3px var(--kh-gold-a)) drop-shadow(0 0 4.25px var(--kh-glow)) drop-shadow(0 0 10px color-mix(in srgb, var(--kh-royal) 38%, transparent)); }
  .dark .kh-soror { --kh-gold-a: #fde68a; --kh-gold-b: #f59e0b; --kh-glow: rgba(251, 191, 36, 0.55); --kh-champagne: #fff3d6;
    --kh-royal: color-mix(in srgb, var(--org-primary) 55%, #c4b5fd); }
  .kh-soror > .kh-av { --ring: linear-gradient(135deg, #fff3d6, #fde68a 22%, #f59e0b 50%, #b45309 78%, #fde68a); }
  .kh-soror-halo { position: absolute; inset: -17%; z-index: -1; border-radius: 999px; pointer-events: none; opacity: 0.72;
    background: conic-gradient(from 0deg, var(--kh-gold-a), var(--kh-champagne), var(--kh-royal), var(--kh-gold-b), var(--kh-champagne), var(--kh-gold-a));
    -webkit-mask: radial-gradient(closest-side, transparent 58%, #000 72%, transparent 100%);
    mask: radial-gradient(closest-side, transparent 58%, #000 72%, transparent 100%);
    animation: kh-soror-turn 9s linear infinite; }
  .kh-soror::after { content: ""; position: absolute; inset: -9%; z-index: -1; border-radius: 999px; pointer-events: none;
    border: 1.5px solid color-mix(in srgb, var(--kh-champagne) 72%, transparent); animation: kh-soror-breathe 2.8s ease-out infinite; }
  .kh-sparkle { position: absolute; z-index: 2; width: 30%; max-width: 15px; min-width: 6px; aspect-ratio: 1; pointer-events: none;
    background: linear-gradient(135deg, #fffbeb, var(--kh-gold-a) 45%, var(--kh-gold-b));
    clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
    animation: kh-twinkle 2.4s ease-in-out infinite; }
  .kh-sparkle:nth-of-type(2) { top: -14%; left: 4%; width: 24%; }
  .kh-sparkle:nth-of-type(3) { bottom: -8%; left: -12%; width: 22%; animation-delay: 0.6s; }
  .kh-sparkle:nth-of-type(4) { top: 30%; left: -18%; width: 16%; animation-delay: 1.3s; }
  .kh-sparkle:nth-of-type(5) { bottom: -12%; right: 2%; width: 26%; animation-delay: 1.8s; }
  .kh-sparkle:nth-of-type(6) { top: 46%; right: -18%; width: 18%; animation-delay: 0.95s; }
  .kh-soror-crown { position: absolute; z-index: 3; top: -24%; right: -20%; width: 54%; min-width: 15px; aspect-ratio: 1; pointer-events: none;
    display: block; transform: rotate(18deg); transform-origin: 40% 80%;
    filter: drop-shadow(0 1px 1px rgba(120, 53, 15, 0.45)) drop-shadow(0 0 4px rgba(253, 230, 138, 0.9));
    animation: kh-crown-float 3.2s ease-in-out infinite; }
  .kh-soror-crown > svg, .kh-aura-star > svg { display: block; width: 100%; height: 100%; overflow: visible; }
  @keyframes kh-twinkle { 0%, 100% { opacity: 0.2; transform: scale(0.55) rotate(0deg); } 50% { opacity: 1; transform: scale(1.05) rotate(25deg); } }
  @keyframes kh-soror-turn { to { transform: rotate(360deg); } }
  @keyframes kh-soror-breathe { 0% { opacity: 0.77; transform: scale(0.94); } 70%, 100% { opacity: 0; transform: scale(1.19); } }
  @keyframes kh-crown-float { 0%, 100% { transform: rotate(18deg) translateY(0); } 50% { transform: rotate(14deg) translateY(-7%); } }

  /* Prestige tier frames (Milestone 21), unlocked by Pride Points and worn
     automatically unless the member switches them off in My Profile:
       New Flame      0-49     the plain border (no wrapper at all)
       Rising Star    50-149   a warm ring with a slow shimmer
       Chapter Pillar 150-349  a double metallic ring
       Royal Beacon   350-699  a soft halo in the organization's accent colour
       Legacy Crown       700-1,499    an animated regal gradient rim and a star badge
       Sovereign Luminary 1,500-2,999  a royal prism border with a soft celestial pulse
       Eternal Crest      3,000+       a pearl rim, a faint turning iridescent aura
                                       and the eternal crest star
     Rings replace the avatar's own ring colour; halos are drop-shadows on the
     wrapper so they follow circle, square, diamond and hexagon frames. */
  /* The wrapper carries the avatar's own size classes (templates/_avatar.html),
     so every halo, ring, crown and star below is measured from the avatar's
     exact box, never from a stretched row. */
  .kh-aura { position: relative; display: inline-flex; flex: none; align-items: center; justify-content: center; vertical-align: middle; }
  .kh-aura--rising-star > .kh-av { --ring: linear-gradient(115deg, #f59e0b, #fcd34d 20%, #fff7d6 32%, #fb923c 50%, #fcd34d 70%, #f59e0b);
    background-size: 280% 100%; animation: kh-aura-shimmer 5s linear infinite; }
  .kh-aura--chapter-pillar > .kh-av { --ring: linear-gradient(135deg, #f8fafc, #94a3b8 30%, #e2e8f0 52%, #64748b 78%, #cbd5e1);
    padding: 2.5px; box-shadow: 0 0 0 1.5px var(--kh-card), 0 0 0 3px #94a3b8; }
  .kh-aura--chapter-pillar { filter: drop-shadow(0 1px 1.5px rgba(71, 85, 105, 0.35)); }
  /* Diamond, hexagon and heart frames clip box-shadows: their second ring is a tight shadow instead. */
  .kh-aura--chapter-pillar:has(> .kh-av--diamond, > .kh-av--hexagon, > .kh-av--heart) {
    filter: drop-shadow(0 0 0.6px var(--kh-card)) drop-shadow(0 0 0.6px var(--kh-card)) drop-shadow(0 0 1px #94a3b8) drop-shadow(0 0 1px #64748b); }
  .kh-aura--royal-beacon { --kh-beacon: var(--org-accent);
    filter: drop-shadow(0 0 2px color-mix(in srgb, var(--kh-beacon) 85%, transparent)) drop-shadow(0 0 8px color-mix(in srgb, var(--kh-beacon) 55%, transparent));
    animation: kh-aura-beacon 3.6s ease-in-out infinite; }
  .dark .kh-aura--royal-beacon { --kh-beacon: color-mix(in srgb, var(--org-accent) 70%, #ffffff); }
  .kh-aura--royal-beacon > .kh-av { --ring: linear-gradient(135deg, color-mix(in srgb, var(--kh-beacon) 55%, #ffffff), var(--kh-beacon)); }
  .kh-aura--legacy-crown { filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.55)) drop-shadow(0 0 7px color-mix(in srgb, var(--org-primary) 45%, transparent)); }
  .kh-aura--legacy-crown > .kh-av { padding: 2.5px;
    --ring: linear-gradient(120deg, #fde68a, #f59e0b 18%, var(--org-primary) 38%, var(--org-accent) 56%, #f59e0b 76%, #fde68a);
    background-size: 300% 100%; animation: kh-aura-shimmer 6s linear infinite; }
  .kh-aura-star { position: absolute; z-index: 2; right: -12%; bottom: -10%; width: 40%; min-width: 11px; max-width: 22px; aspect-ratio: 1; pointer-events: none;
    display: block; padding: 9%; border-radius: 999px; background: linear-gradient(135deg, #fde68a, #f59e0b); box-shadow: 0 0 0 1.5px var(--kh-card);
    box-sizing: border-box; }
  .kh-aura-star > svg { fill: #78350f; }
  /* Sovereign Luminary (Milestone 22): about a year of showing up. A deep
     violet-to-sky prism flows around the rim while a starlight glow breathes. */
  .kh-aura--sovereign-luminary { --kh-lum: color-mix(in srgb, var(--org-primary) 55%, #7c3aed);
    filter: drop-shadow(0 0 2px rgba(196, 181, 253, 0.8)) drop-shadow(0 0 7px color-mix(in srgb, var(--kh-lum) 50%, transparent));
    animation: kh-aura-celestial 4.8s ease-in-out infinite; }
  .dark .kh-aura--sovereign-luminary { --kh-lum: color-mix(in srgb, var(--org-primary) 40%, #a78bfa); }
  .kh-aura--sovereign-luminary > .kh-av { padding: 3px;
    --ring: linear-gradient(120deg, #4c1d95, #7c3aed 14%, #38bdf8 30%, #f0abfc 46%, #fde68a 60%, #7c3aed 80%, #4c1d95);
    background-size: 300% 100%; animation: kh-aura-flow 8s linear infinite; }
  /* Eternal Crest (Milestone 22): the multi-year legends. A mother-of-pearl
     rim, a faint iridescent aura turning slowly behind it, and a crest star.
     Quiet on purpose: it never competes with the Soror of the Month. */
  .kh-aura--eternal-crest { isolation: isolate;
    filter: drop-shadow(0 0 1.3px rgba(255, 255, 255, 0.77)) drop-shadow(0 0 5px rgba(165, 180, 252, 0.47)); }
  .kh-aura--eternal-crest::after { content: ""; position: absolute; inset: -14.5%; z-index: -1; border-radius: 999px; pointer-events: none; opacity: 0.51;
    background: conic-gradient(from 0deg, #a5f3fc, #c4b5fd, #fbcfe8, #fde68a, #a7f3d0, #a5f3fc);
    -webkit-mask: radial-gradient(closest-side, transparent 60%, #000 76%, transparent 100%);
    mask: radial-gradient(closest-side, transparent 60%, #000 76%, transparent 100%);
    animation: kh-soror-turn 16s linear infinite; }
  .kh-aura--eternal-crest > .kh-av { padding: 3px;
    --ring: linear-gradient(120deg, #fdf2f8, #67e8f9 16%, #a78bfa 32%, #f9a8d4 48%, #fcd34d 64%, #6ee7b7 82%, #fdf2f8);
    background-size: 300% 100%; animation: kh-aura-flow 11s linear infinite; }
  .kh-aura--eternal-crest > .kh-aura-star {
    background: linear-gradient(135deg, #ecfeff, #c4b5fd 48%, #f9a8d4); box-shadow: 0 0 0 1.5px var(--kh-card), 0 0 5px rgba(196, 181, 253, 0.77); }
  .kh-aura--eternal-crest > .kh-aura-star > svg { fill: #4c1d95; }
  .kh-aura--sovereign-luminary > .kh-aura-star { background: linear-gradient(135deg, #ede9fe, #a78bfa 55%, #7c3aed); }
  .kh-aura--sovereign-luminary > .kh-aura-star > svg { fill: #2e1065; }
  /* Star badges grow with the tier (Milestone 23): 14px, 16px, 20px. On the
     smallest avatars they shrink in step, so a star never swallows a face. */
  .kh-aura--legacy-crown > .kh-aura-star { width: min(14px, 42%); min-width: 0; max-width: none; right: -10%; bottom: -8%; }
  .kh-aura--sovereign-luminary > .kh-aura-star { width: min(16px, 48%); min-width: 0; max-width: none; right: -11%; bottom: -9%; }
  .kh-aura--eternal-crest > .kh-aura-star { width: min(20px, 56%); min-width: 0; max-width: none; right: -13%; bottom: -11%; }
  /* A 300%-wide gradient moved by 150% travels exactly one full repeat, so the loop never jumps. */
  @keyframes kh-aura-flow { from { background-position: 0% 50%; } to { background-position: 150% 50%; } }
  @keyframes kh-aura-celestial { 0%, 100% { filter: drop-shadow(0 0 2px rgba(196, 181, 253, 0.75)) drop-shadow(0 0 5px color-mix(in srgb, var(--kh-lum) 38%, transparent)); }
    50% { filter: drop-shadow(0 0 3px rgba(221, 214, 254, 0.95)) drop-shadow(0 0 12px color-mix(in srgb, var(--kh-lum) 62%, transparent)); } }

  /* Leadership Halo (Milestone 22): Admin, Lead Admin and Developer. One soft
     ring of the organization's own colour behind the avatar, breathing once
     every four seconds. It tells leadership apart at a glance, and stops
     there: no ring change, no badge, a fraction of Royal Beacon's glow and
     nothing like the Soror of the Month centerpiece. It sits under whatever
     tier frame she has earned. */
  .kh-lead { --kh-lead-c: var(--org-primary); isolation: isolate; }
  .dark .kh-lead { --kh-lead-c: color-mix(in srgb, var(--org-primary) 55%, #ffffff); }
  .kh-lead::before { content: ""; position: absolute; inset: -12%; z-index: -1; border-radius: 999px; pointer-events: none;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--kh-lead-c) 55%, transparent) 62%, color-mix(in srgb, var(--kh-lead-c) 26%, transparent) 80%, transparent 100%);
    animation: pulse-gentle 4s ease-in-out infinite; }
  @keyframes pulse-gentle { 0%, 100% { opacity: 0.4; transform: scale(0.95); } 50% { opacity: 0.85; transform: scale(1.04); } }
  @keyframes kh-aura-shimmer { from { background-position: 0% 50%; } to { background-position: 280% 50%; } }
  @keyframes kh-aura-beacon { 0%, 100% { filter: drop-shadow(0 0 2px color-mix(in srgb, var(--kh-beacon) 85%, transparent)) drop-shadow(0 0 6px color-mix(in srgb, var(--kh-beacon) 40%, transparent)); }
    50% { filter: drop-shadow(0 0 2.5px color-mix(in srgb, var(--kh-beacon) 95%, transparent)) drop-shadow(0 0 11px color-mix(in srgb, var(--kh-beacon) 65%, transparent)); } }
  /* Directory: the crown pill and the Moderator+ Crown / Remove button.
     Amber ink on pale gold (light) and pale gold on deep amber (dark). */
  .kh-soror-pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 800;
    color: #78350f; background: linear-gradient(135deg, #fef3c7, #fde68a); box-shadow: inset 0 0 0 1px #f59e0b; }
  .dark .kh-soror-pill { color: #fde68a; background: rgba(245, 158, 11, 0.16); box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.55); }
  /* The gleaming pill next to her name (Chat, DMs, boards, Pride Wall,
     directory, profile cards): a slow band of light crosses it. The band
     sits between the pill's colour and its text, so the words never fade. */
  .kh-soror-pill--gleam { position: relative; isolation: isolate; overflow: hidden; white-space: nowrap; vertical-align: middle;
    box-shadow: inset 0 0 0 1px #f59e0b, 0 0 0 2px rgba(245, 158, 11, 0.14), 0 1px 6px -1px rgba(245, 158, 11, 0.55); }
  .dark .kh-soror-pill--gleam { box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.6), 0 0 8px -1px rgba(251, 191, 36, 0.5); }
  .kh-soror-pill--gleam::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.75) 50%, transparent 65%); background-size: 250% 100%;
    animation: kh-pill-gleam 3.4s ease-in-out infinite; }
  .dark .kh-soror-pill--gleam::after { background-image: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.22) 50%, transparent 65%); }
  .kh-soror-pill--name { margin-left: 4px; padding: 0 8px; font-family: var(--kh-font-display); font-size: 11.5px; line-height: 1.65; letter-spacing: 0.01em; }
  @keyframes kh-pill-gleam { 0%, 55% { background-position: 130% 0; } 100% { background-position: -130% 0; } }
  .kh-soror-btn { height: 36px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--kh-line); background: var(--kh-card); color: var(--kh-ink);
    font-family: var(--kh-font-display); font-size: 13.5px; font-weight: 700; white-space: nowrap; transition: all 0.15s var(--kh-ease); }
  .kh-soror-btn:hover { border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18); }
  .kh-soror-btn.is-on { border-color: #f59e0b; color: #78350f; background: #fef3c7; }
  .dark .kh-soror-btn.is-on { color: #fde68a; background: rgba(245, 158, 11, 0.16); border-color: rgba(251, 191, 36, 0.6); }
  .kh-soror-btn:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
  .kh-dir-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .kh-dir-filter > .relative { flex-basis: 220px; }
  .kh-crown { display: inline-block; margin-left: 4px; font-size: 0.95em; line-height: 1; vertical-align: -0.05em; cursor: help;
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.55)); }
  @media (prefers-reduced-motion: reduce) {
    .kh-sparkle { animation: none; opacity: 0.9; }
    .kh-soror-halo, .kh-soror::after, .kh-soror-crown, .kh-aura, .kh-aura > .kh-av, .kh-aura::after, .kh-lead::before, .kh-soror-pill--gleam::after { animation: none; }
    .kh-lead::before { opacity: 0.6; }
    .kh-soror::after { opacity: 0.6; }
  }

  /* Persona Studio preview panes: one forced light, one forced dark (the
     page passes the matching contrast-checked brand colours inline). */
  .kh-scheme-light { --kh-sunken: #f4f3ef; --kh-card: #ffffff; --kh-ink: #111827; --kh-body: #374151; --kh-muted: #4b5563;
    --kh-line: #e5e7eb; --hue-neutral-fg: #374151; --hue-neutral-bg: #f3f4f6; --hue-teal-fg: #0f766e; --hue-teal-bg: #e3f5f1; color-scheme: light; background: var(--kh-card); color: var(--kh-ink); }
  .kh-scheme-dark { --kh-sunken: #0e1628; --kh-card: #162032; --kh-ink: #f8fafc; --kh-body: #cbd5e1; --kh-muted: #94a3b8;
    --kh-line: #263349; --hue-neutral-fg: #cbd5e1; --hue-neutral-bg: #1e2a3f; --hue-teal-fg: #5eead4; --hue-teal-bg: rgba(20, 184, 166, 0.15); color-scheme: dark; background: var(--kh-card); color: var(--kh-ink); }
  /* Persona Studio choices (radio tiles). */
  .kh-choice { display: block; cursor: pointer; }
  .kh-choice-face { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 6px 10px; border-radius: 14px;
    border: 1.5px solid var(--kh-line); background: var(--kh-card); color: var(--kh-body);
    font-family: var(--kh-font-display); font-size: 13px; font-weight: 600; text-align: center; transition: all 0.15s var(--kh-ease); }
  .kh-choice:hover .kh-choice-face { border-color: var(--kh-field); }
  .peer:checked + .kh-choice-face { border-color: var(--kh-brand); background: color-mix(in srgb, var(--kh-brand) 10%, var(--kh-card)); color: var(--kh-ink); font-weight: 700; }
  .peer:focus-visible + .kh-choice-face { outline: 2px solid var(--kh-brand); outline-offset: 2px; }

  /* Personal "vibe" title under a name. --kh-accent is contrast-checked. */
  .kh-vibe { display: block; font-style: italic; font-weight: 600; color: var(--kh-accent); line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Empty states (templates/_empty.html). */
  .kh-empty-icon { background: color-mix(in srgb, var(--kh-brand) 12%, var(--kh-card)); box-shadow: 0 0 0 6px color-mix(in srgb, var(--kh-brand) 5%, transparent); }

  /* A new spotlight pops onto the wall. */
  #spotlight-list > article { transition: opacity 0.4s var(--kh-ease), transform 0.4s var(--kh-ease); }
  #spotlight-list > article.htmx-added { opacity: 0; transform: translateY(-8px) scale(0.98); }

  /* New content from HTMX fades in. */
  .chat-line, #comment-list > li, [id^="rsvp-"], section[id^="list-"], [id^="spotlight-replies-"] > li { transition: opacity 0.3s var(--kh-ease), transform 0.3s var(--kh-ease); }
  .chat-line.htmx-added, #comment-list > li.htmx-added, [id^="spotlight-replies-"] > li.htmx-added { opacity: 0; transform: translateY(6px); }

  /* ------------------------------------------------ Global Chapter & Org Calendar (M12) */
  /* Kinds: org-wide (brand, contrast-guarded), room events (blue), deadlines (amber). */
  .kh-cal-org { --cal-fg: var(--kh-brand); --cal-bg: color-mix(in srgb, var(--kh-brand) 12%, var(--kh-card)); --cal-dot: var(--kh-brand); }
  .kh-cal-room { --cal-fg: var(--hue-blue-fg); --cal-bg: var(--hue-blue-bg); --cal-dot: #3b82f6; }
  .kh-cal-todo { --cal-fg: var(--hue-amber-fg); --cal-bg: var(--hue-amber-bg); --cal-dot: #f59e0b; }

  .kh-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--kh-sunken); border: 1px solid var(--kh-line); }
  .kh-seg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 999px; font: 700 14px/1.3 var(--kh-font-display);
    color: var(--kh-muted); text-decoration: none; transition: background 0.15s var(--kh-ease), color 0.15s var(--kh-ease); }
  .kh-seg-btn:hover { color: var(--kh-ink); }
  .kh-seg-btn[aria-pressed="true"] { background: var(--kh-card-raised); color: var(--kh-ink); box-shadow: 0 1px 3px rgba(17, 24, 39, 0.14); }
  .kh-cal-nav { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 999px;
    font-size: 24px; line-height: 1; color: var(--kh-body); text-decoration: none; transition: background 0.15s; }
  .kh-cal-nav:hover { background: color-mix(in srgb, var(--kh-ink) 7%, transparent); }
  .kh-pillrow { scrollbar-width: none; }
  .kh-pillrow::-webkit-scrollbar { display: none; }
  .kh-cal-pill { display: inline-flex; flex-shrink: 0; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 999px; white-space: nowrap;
    border: 1px solid var(--kh-line); background: var(--kh-card); color: var(--kh-body); font: 600 14px/1.3 var(--kh-font-display); text-decoration: none;
    transition: border-color 0.15s, background 0.15s; }
  .kh-cal-pill:hover { border-color: var(--kh-field); }
  .kh-cal-pill[aria-current="true"] { background: var(--kh-ink); border-color: var(--kh-ink); color: var(--kh-card); }
  .kh-cal-dot { display: inline-block; width: 8px; height: 8px; flex-shrink: 0; border-radius: 999px; background: var(--cal-dot); }
  .kh-cal-pill[aria-current="true"] .kh-cal-dot { box-shadow: 0 0 0 2px var(--kh-card); }

  .kh-cal-grid { border: 1px solid var(--kh-line); border-radius: 16px; overflow: hidden; background: var(--kh-card); }
  .kh-cal-head, .kh-cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .kh-cal-head { background: var(--kh-sunken); }
  .kh-cal-head > span { padding: 7px 0; text-align: center; font: 700 11.5px/1.2 var(--kh-font-display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--kh-muted); }
  .kh-cal-week { border-top: 1px solid var(--kh-line); }
  .kh-cal-day { position: relative; min-width: 0; min-height: 58px; border-left: 1px solid var(--kh-line); }
  .kh-cal-day:first-child { border-left: 0; }
  .kh-cal-day.is-out { background: color-mix(in srgb, var(--kh-sunken) 75%, var(--kh-card)); }
  .kh-cal-day > .kh-cal-num { margin: 5px; }
  .kh-cal-daybtn { display: flex; width: 100%; height: 100%; min-height: inherit; flex-direction: column; align-items: flex-start; padding: 5px;
    text-align: left; cursor: pointer; transition: background 0.15s; }
  .kh-cal-daybtn:hover { background: color-mix(in srgb, var(--kh-brand) 6%, transparent); }
  .kh-cal-daybtn:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: -2px; }
  .kh-cal-num { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; border-radius: 999px;
    font: 700 13.5px/1 var(--kh-font-display); color: var(--kh-body); }
  .kh-cal-day.is-out .kh-cal-num { color: var(--kh-muted); font-weight: 600; }
  .kh-cal-day.is-today .kh-cal-num { background: var(--kh-brand); color: var(--kh-on-brand); }
  .kh-cal-chips { display: none; }
  .kh-cal-dots { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0 0 4px; }
  .kh-cal-chip { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 2px 6px; border-radius: 6px;
    background: var(--cal-bg); color: var(--cal-fg); font: 600 12px/1.35 var(--kh-font-display); }
  .kh-cal-more { padding-left: 4px; font: 700 11.5px/1.3 var(--kh-font-display); color: var(--kh-muted); }
  @media (min-width: 768px) {
    .kh-cal-day { min-height: 104px; }
    .kh-cal-chips { display: grid; width: 100%; gap: 3px; margin-top: 3px; }
    .kh-cal-dots { display: none; }
  }

  /* Day details (HTML popover: top layer, centred, no JavaScript needed). */
  .kh-pop { margin: auto; width: min(440px, calc(100vw - 28px)); max-height: min(72vh, 560px); overflow: auto; padding: 18px;
    border: 0; border-radius: 18px; background: var(--kh-card); color: var(--kh-ink); box-shadow: var(--kh-shadow-lift); }
  .kh-pop::backdrop { background: rgba(17, 24, 39, 0.4); }

  .kh-cal-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--kh-line);
    background: var(--kh-card); color: inherit; text-decoration: none; transition: border-color 0.15s, background 0.15s; }
  .kh-cal-row:hover { border-color: var(--kh-field); background: var(--kh-sunken); }
  .kh-cal-bar { width: 4px; align-self: stretch; flex-shrink: 0; border-radius: 4px; background: var(--cal-dot); }
  .kh-cal-tag { display: inline-flex; flex-shrink: 0; align-items: center; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
    background: var(--cal-bg); color: var(--cal-fg); font: 700 12px/1.45 var(--kh-font-display); }
  @media (max-width: 479px) { .kh-cal-row .kh-cal-tag { display: none; } }

  .kh-agenda-day { display: flex; align-items: flex-start; gap: 12px; }
  .kh-agenda-date { width: 52px; flex-shrink: 0; padding: 6px 0; border-radius: 12px; text-align: center; background: var(--kh-sunken); }
  .kh-agenda-date span { display: block; font: 700 11.5px/1.2 var(--kh-font-display); letter-spacing: 0.06em; color: var(--kh-muted); }
  .kh-agenda-date strong { display: block; font: 800 21px/1.15 var(--kh-font-display); color: var(--kh-ink); }
  .kh-agenda-date.is-today { background: var(--kh-brand); }
  .kh-agenda-date.is-today span, .kh-agenda-date.is-today strong { color: var(--kh-on-brand); }

  .kh-rsvp { display: inline-flex; height: 38px; align-items: center; gap: 7px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--kh-line);
    background: var(--kh-card); color: var(--kh-body); font: 700 14.5px/1 var(--kh-font-display); transition: transform 0.1s, background 0.15s; }
  .kh-rsvp:active { transform: scale(0.97); }
  .kh-rsvp-count { padding: 2px 7px; border-radius: 999px; background: color-mix(in srgb, currentColor 13%, transparent); font-size: 12.5px; }
  .kh-rsvp--going[aria-pressed="true"] { background: #18794e; border-color: #18794e; color: #ffffff; }
  .kh-rsvp--maybe[aria-pressed="true"] { background: #e0a020; border-color: #e0a020; color: #1f2937; }
  .kh-rsvp--out[aria-pressed="true"] { background: #5b6472; border-color: #5b6472; color: #ffffff; }

  /* ------------------------------------------------ Feedback button & dialog (M15) */
  /* A quiet card-coloured pill so it never competes with the Messages button. */
  .kh-fb-fab { display: inline-flex; height: 46px; min-width: 46px; align-items: center; justify-content: center; gap: 7px; padding: 0 12px;
    border-radius: 999px; border: 1px solid var(--kh-line); background: var(--kh-card); color: var(--kh-ink);
    font-family: var(--kh-font-display); font-size: 14px; font-weight: 700;
    box-shadow: 0 10px 22px -12px rgba(17, 24, 39, 0.45), 0 1px 3px rgba(17, 24, 39, 0.12);
    transition: transform 0.18s var(--kh-ease), box-shadow 0.18s var(--kh-ease), border-color 0.18s; }
  .kh-fb-fab:hover { transform: translateY(-2px); border-color: var(--kh-field); }
  .kh-fb-fab:active { transform: scale(0.96); }
  .kh-fb-fab:focus-visible { outline: 3px solid var(--kh-accent); outline-offset: 3px; }
  .kh-fb-fab-label { display: none; }
  @media (min-width: 768px) { .kh-fb-fab { padding: 0 16px 0 13px; } .kh-fb-fab-label { display: inline; } }
  .kh-fb-dialog { margin: auto auto 0; width: 100%; max-width: 100%; max-height: 92vh; overflow-y: auto; padding: 22px;
    border-radius: 22px 22px 0 0; background: var(--kh-card); color: var(--kh-ink); box-shadow: var(--kh-shadow-lift); }
  .kh-fb-dialog::backdrop { background: rgba(17, 24, 39, 0.45); backdrop-filter: blur(2px); }
  @media (min-width: 640px) { .kh-fb-dialog { margin: auto; max-width: 480px; border-radius: 20px; } }
  .kh-fb-mark { display: flex; width: 44px; height: 44px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 14px;
    font-size: 22px; background: color-mix(in srgb, var(--kh-brand) 12%, var(--kh-card)); }
  .kh-fb-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 999px; background: var(--kh-sunken); }
  .kh-fb-option { display: block; cursor: pointer; }
  .kh-fb-option-face { display: flex; height: 40px; align-items: center; justify-content: center; gap: 6px; border-radius: 999px;
    color: var(--kh-body); font-family: var(--kh-font-display); font-size: 14.5px; font-weight: 600; text-align: center; transition: all 0.15s var(--kh-ease); }
  .kh-fb-option:hover .kh-fb-option-face { color: var(--kh-ink); }
  .peer:checked + .kh-fb-option-face { background: var(--kh-card); color: var(--kh-ink); font-weight: 800;
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.16), inset 0 0 0 1.5px var(--kh-brand); }
  .peer:focus-visible + .kh-fb-option-face { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
  .kh-fb-sent { padding: 10px 4px 4px; }
  .kh-fb-sent-mark { display: inline-flex; width: 64px; height: 64px; align-items: center; justify-content: center; border-radius: 999px; font-size: 30px;
    background: var(--hue-green-bg); box-shadow: 0 0 0 8px color-mix(in srgb, var(--hue-green-bg) 45%, transparent); animation: kh-pop 0.35s var(--kh-ease); }

  /* Global search (M15): the dashboard bar, its dropdown and the results page. */
  .kh-search-icon { position: absolute; top: 0; left: 16px; display: flex; height: 52px; align-items: center; color: var(--kh-muted); pointer-events: none; }
  .kh-search-input { width: 100%; height: 52px; padding: 0 18px 0 46px; border-radius: 999px; border: 1.5px solid var(--kh-line);
    background: var(--kh-card); color: var(--kh-ink); font-size: 16px; box-shadow: var(--kh-shadow-card); transition: border-color 0.15s, box-shadow 0.15s; }
  .kh-search-input::placeholder { color: var(--kh-muted); opacity: 1; }
  .kh-search-input:focus { outline: none; border-color: var(--kh-brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--kh-brand) 18%, transparent), var(--kh-shadow-card); }
  .kh-search-dropdown { position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 35; max-height: min(70vh, 560px); overflow-y: auto;
    border-radius: 18px; border: 1px solid var(--kh-line); background: var(--kh-card); box-shadow: var(--kh-shadow-lift); }
  .kh-search-dropdown:empty, .kh-search-dropdown.is-closed { display: none; }
  .kh-search-note { padding: 16px 18px; font-size: 14.5px; color: var(--kh-muted); }
  .kh-search-groups { padding: 6px; }
  .kh-search-page .kh-search-groups { display: grid; gap: 14px; padding: 0; }
  .kh-search-page .kh-search-group { border-radius: 18px; background: var(--kh-card); box-shadow: var(--kh-shadow-card); padding: 6px; }
  .kh-search-page .kh-search-note { border-radius: 18px; background: var(--kh-card); box-shadow: var(--kh-shadow-card); }
  .kh-search-heading { padding: 10px 12px 4px; font-family: var(--kh-font-display); font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--kh-muted); }
  .kh-search-hit { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 12px; color: var(--kh-ink); text-decoration: none; transition: background 0.12s; }
  .kh-search-hit:hover, .kh-search-hit:focus-visible { background: var(--kh-sunken); }
  .kh-search-hit:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: -2px; }
  .kh-search-glyph { display: flex; width: 32px; height: 32px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 10px;
    background: color-mix(in srgb, var(--kh-brand) 10%, var(--kh-card)); color: var(--kh-brand); font-family: var(--kh-font-display); font-size: 15px; font-weight: 800; }
  .kh-search-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--kh-font-display); font-size: 15px; font-weight: 700; }
  .kh-search-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; color: var(--kh-muted); }
  .kh-search-all { display: block; margin: 0 6px 6px; padding: 10px 12px; border-radius: 12px; border-top: 1px solid var(--kh-line);
    font-family: var(--kh-font-display); font-size: 14.5px; font-weight: 700; color: var(--kh-accent); text-decoration: none; }
  .kh-search-all:hover { background: var(--kh-sunken); }

  /* Dev Console feedback inbox. */
  .kh-fb-stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 16px; background: var(--kh-card);
    box-shadow: var(--kh-shadow-card, 0 1px 3px rgba(17, 24, 39, 0.1)); border-left: 4px solid var(--stat-fg); }
  .kh-fb-stat-num { font-family: var(--kh-font-display); font-size: 28px; font-weight: 800; line-height: 1.1; color: var(--stat-fg); font-variant-numeric: tabular-nums; }
  .kh-fb-stat-label { font-family: var(--kh-font-display); font-size: 13.5px; font-weight: 700; color: var(--kh-body); }
  .kh-fb-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .kh-fb-tab { flex-shrink: 0; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--kh-line); background: var(--kh-card);
    color: var(--kh-body); font-family: var(--kh-font-display); font-size: 14px; font-weight: 600; text-decoration: none; transition: all 0.15s var(--kh-ease); }
  .kh-fb-tab:hover { color: var(--kh-ink); border-color: var(--kh-field); }
  .kh-fb-tab[aria-current="page"] { background: var(--kh-brand); border-color: var(--kh-brand); color: var(--kh-on-brand); font-weight: 700; }
  .kh-fb-tab:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
  .kh-fb-org { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700;
    color: var(--hue-teal-fg); background: var(--hue-teal-bg); }
  .kh-fb-meta { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--kh-sunken); font-size: 14px; }
  .kh-fb-meta > div { display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
  .kh-fb-meta dt { font-weight: 700; color: var(--kh-muted); }
  .kh-fb-meta dd { color: var(--kh-ink); min-width: 0; }

  /* ------------------------------------------------ Sisterhood Messages drawer (M12) */
  .kh-dm-fab { display: flex; width: 58px; height: 58px; align-items: center; justify-content: center; border-radius: 999px; color: var(--kh-on-brand);
    background: linear-gradient(135deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 55%, var(--accent-color)));
    box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--primary-color) 75%, transparent), 0 2px 6px rgba(17, 24, 39, 0.22), inset 0 0 0 1.5px rgba(255, 255, 255, 0.22);
    transition: transform 0.18s var(--kh-ease), box-shadow 0.18s var(--kh-ease); }
  .kh-dm-fab:hover { transform: translateY(-2px) scale(1.03); }
  .kh-dm-fab:active { transform: scale(0.96); }
  .kh-dm-fab:focus-visible { outline: 3px solid var(--kh-accent); outline-offset: 3px; }
  .kh-dm-badge { position: absolute; top: -5px; right: -5px; min-width: 23px; height: 23px; padding: 0 6px; border-radius: 999px;
    background: #d6164d; color: #ffffff; font: 800 12.5px/23px var(--kh-font-display); text-align: center; box-shadow: 0 0 0 2.5px var(--kh-canvas); }
  .kh-dm-badge.has-unread { animation: kh-pop 0.35s var(--kh-ease); }
  .kh-dm-fab:has(.kh-dm-badge.has-unread:not([hidden]))::after { content: ""; position: absolute; inset: -3px; border-radius: 999px;
    border: 2px solid color-mix(in srgb, var(--primary-color) 60%, #d6164d); animation: kh-dm-pulse 2.4s var(--kh-ease) infinite; pointer-events: none; }

  .kh-dm-drawer { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--kh-card); color: var(--kh-ink);
    padding-top: env(safe-area-inset-top); }
  @media (min-width: 768px) {
    .kh-dm-drawer { inset: auto 24px 96px auto; width: 400px; height: min(640px, calc(100vh - 128px)); padding-top: 0; overflow: hidden;
      border-radius: 20px; border: 1px solid var(--kh-line); box-shadow: var(--kh-shadow-lift); transform-origin: bottom right; }
  }
  .kh-dm-panel { display: flex; height: 100%; min-height: 0; flex-direction: column; }
  .kh-dm-head { display: flex; flex-shrink: 0; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; border-bottom: 1px solid var(--kh-line);
    background: linear-gradient(180deg, color-mix(in srgb, var(--kh-brand) 9%, var(--kh-card)), var(--kh-card)); }
  .kh-dm-mark { display: flex; width: 38px; height: 38px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 12px;
    background: var(--kh-brand); color: var(--kh-on-brand); }
  .kh-dm-x { display: flex; width: 36px; height: 36px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 999px;
    font-size: 25px; line-height: 1; color: var(--kh-muted); transition: background 0.15s; }
  .kh-dm-x:hover { background: color-mix(in srgb, var(--kh-ink) 8%, transparent); color: var(--kh-ink); }
  .kh-dm-new { display: inline-flex; height: 34px; flex-shrink: 0; align-items: center; gap: 4px; padding: 0 12px 0 9px; border-radius: 999px;
    background: var(--kh-brand); color: var(--kh-on-brand); font: 700 14px/1 var(--kh-font-display); }
  .kh-dm-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .kh-dm-list { margin: 0; padding: 6px; list-style: none; }
  .kh-dm-row { display: flex; width: 100%; align-items: center; gap: 11px; padding: 10px; border-radius: 14px; text-align: left; transition: background 0.15s; }
  .kh-dm-row:hover { background: var(--kh-sunken); }
  .kh-dm-row.is-unread { background: color-mix(in srgb, var(--kh-brand) 7%, var(--kh-card)); }
  .kh-dm-row:focus-visible, .kh-dm-person:has(input:focus-visible) { outline: 2px solid var(--kh-accent); outline-offset: -2px; }
  /* Group faces: two overlapping avatars in a square, like a little cluster. */
  .kh-dm-stack { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
  .kh-dm-stack > :is(.kh-av, .kh-soror, .kh-aura) { position: absolute; }
  .kh-dm-stack > :is(.kh-av, .kh-soror, .kh-aura):nth-child(1) { top: 0; left: 0; }
  .kh-dm-stack > :is(.kh-av, .kh-soror, .kh-aura):nth-child(2) { right: 0; bottom: 0; box-shadow: 0 0 0 2px var(--kh-card); border-radius: 999px; }
  .kh-dm-stack > :is(.kh-av, .kh-soror, .kh-aura):nth-child(n + 3) { display: none; }
  .kh-dm-stack > :is(.kh-av, .kh-soror, .kh-aura):only-child { inset: 0; margin: auto; }
  .kh-dm-head .kh-dm-stack { width: 38px; height: 38px; }
  .kh-dm-count { min-width: 21px; height: 21px; flex-shrink: 0; padding: 0 6px; border-radius: 999px; background: var(--kh-brand); color: var(--kh-on-brand);
    font: 800 11.5px/21px var(--kh-font-display); text-align: center; }
  .kh-dm-person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; cursor: pointer; transition: background 0.15s; }
  .kh-dm-person:hover { background: var(--kh-sunken); }
  .kh-dm-person:has(input:checked) { background: color-mix(in srgb, var(--kh-brand) 10%, var(--kh-card)); }
  .kh-dm-check { display: flex; width: 24px; height: 24px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 999px;
    border: 2px solid var(--kh-field); color: transparent; font: 800 13px/1 var(--kh-font-display); }
  .kh-dm-person input:checked ~ .kh-dm-check { background: var(--kh-brand); border-color: var(--kh-brand); color: var(--kh-on-brand); }
  .kh-dm-chip { display: inline-flex; height: 28px; align-items: center; gap: 5px; padding: 0 10px; border-radius: 999px; background: var(--kh-brand);
    color: var(--kh-on-brand); font: 700 13px/1 var(--kh-font-display); }
  .kh-dm-compose { position: relative; display: flex; flex-shrink: 0; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--kh-line);
    background: var(--kh-card); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .kh-dm-input { height: 42px; min-height: 42px; max-height: 140px; resize: none; overflow-y: hidden; padding-top: 9px; padding-bottom: 9px;
    border-radius: 20px; line-height: 22px; }
  .kh-dm-input.is-tall { overflow-y: auto; }
  textarea.kh-dm-input[rows="2"] { height: 64px; }
  .kh-dm-send { display: flex; width: 42px; height: 42px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 999px;
    background: var(--kh-brand); color: var(--kh-on-brand); transition: transform 0.1s; }
  .kh-dm-send:active { transform: scale(0.94); }
  .kh-dm-feed { display: flex; flex-direction: column; gap: 9px; padding: 14px 12px 8px; background: var(--kh-sunken); }
  .kh-dm-msg { display: flex; align-items: flex-end; gap: 8px; }
  .kh-dm-msg.is-mine { justify-content: flex-end; }
  .kh-dm-msg-col { display: flex; min-width: 0; max-width: 80%; flex-direction: column; align-items: flex-start; }
  .kh-dm-msg.is-mine .kh-dm-msg-col { align-items: flex-end; }
  .kh-dm-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; margin: 0 4px 2px; font-size: 12.5px; line-height: 1.3; }
  .kh-dm-bubble { padding: 8px 12px; border-radius: 16px 16px 16px 5px; background: var(--kh-card); color: var(--kh-ink); box-shadow: var(--kh-shadow-card);
    font-size: 15px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
  .kh-dm-msg.is-mine .kh-dm-bubble { border-radius: 16px 16px 5px 16px; background: var(--kh-brand); color: var(--kh-on-brand); box-shadow: none; }
  .kh-dm-time { margin: 2px 4px 0; font-size: 11.5px; color: var(--kh-muted); }
  .kh-dm-msg.htmx-added { opacity: 0; transform: translateY(6px); }
  .kh-dm-msg { transition: opacity 0.25s var(--kh-ease), transform 0.25s var(--kh-ease); }
  .kh-dm-text { display: block; }
  .kh-dm-bubble .kh-voice + .kh-dm-text { margin-top: 6px; }

  /* ------------------------------------------------ Voice notes (M13) */
  /* Player: Play/Pause, scrubber, length. --kh-p is the played share (JS). */
  .kh-voice { --kh-p: 0%; display: inline-flex; width: 100%; min-width: 0; max-width: 340px; align-items: center; gap: 10px; padding: 6px 12px 6px 6px;
    border-radius: 999px; border: 1px solid color-mix(in srgb, var(--kh-brand) 24%, transparent);
    background: color-mix(in srgb, var(--kh-brand) 9%, var(--kh-card)); color: var(--kh-ink); vertical-align: middle; }
  .kh-voice--lg { max-width: 460px; padding: 8px 16px 8px 8px; }
  .kh-voice-btn { display: flex; width: 36px; height: 36px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 999px;
    background: var(--kh-brand); color: var(--kh-on-brand); transition: transform 0.12s var(--kh-ease); }
  .kh-voice--lg .kh-voice-btn { width: 44px; height: 44px; }
  .kh-voice-btn:active { transform: scale(0.92); }
  .kh-voice-btn:focus-visible, .kh-voice-seek:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
  .kh-voice-btn svg { width: 18px; height: 18px; }
  .kh-voice-pause, .kh-voice.is-playing .kh-voice-play { display: none; }
  .kh-voice.is-playing .kh-voice-pause { display: block; }
  .kh-voice-mic { flex-shrink: 0; font-size: 13px; line-height: 1; }
  .kh-voice-seek { flex: 1 1 auto; min-width: 60px; height: 6px; margin: 0; border-radius: 999px; cursor: pointer; -webkit-appearance: none; appearance: none;
    background: linear-gradient(to right, var(--kh-brand) var(--kh-p), color-mix(in srgb, var(--kh-brand) 22%, transparent) var(--kh-p)); }
  .kh-voice-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 999px; background: var(--kh-brand);
    box-shadow: 0 0 0 2px var(--kh-card); }
  .kh-voice-seek::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 999px; background: var(--kh-brand); box-shadow: 0 0 0 2px var(--kh-card); }
  .kh-voice-time { min-width: 34px; flex-shrink: 0; text-align: right; font: 700 12.5px/1 var(--kh-font-display); font-variant-numeric: tabular-nums; color: var(--kh-body); }
  /* Inside the sender's own brand-coloured bubble. */
  .kh-voice--on-brand { border-color: color-mix(in srgb, var(--kh-on-brand) 35%, transparent); background: color-mix(in srgb, var(--kh-on-brand) 14%, transparent);
    color: var(--kh-on-brand); }
  .kh-voice--on-brand .kh-voice-btn { background: var(--kh-on-brand); color: var(--kh-brand); }
  .kh-voice--on-brand .kh-voice-seek { background: linear-gradient(to right, var(--kh-on-brand) var(--kh-p), color-mix(in srgb, var(--kh-on-brand) 30%, transparent) var(--kh-p)); }
  .kh-voice--on-brand .kh-voice-seek::-webkit-slider-thumb { background: var(--kh-on-brand); box-shadow: none; }
  .kh-voice--on-brand .kh-voice-seek::-moz-range-thumb { background: var(--kh-on-brand); box-shadow: none; }
  .kh-voice--on-brand .kh-voice-time { color: var(--kh-on-brand); }

  /* Recorder: mic button; while recording a bar covers the composer. */
  .kh-rec { display: flex; flex-shrink: 0; align-items: center; }
  .kh-mic { display: flex; width: 42px; height: 42px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 999px;
    background: color-mix(in srgb, var(--kh-brand) 10%, var(--kh-card)); color: var(--kh-brand); transition: background 0.15s, transform 0.12s; }
  .kh-mic:hover { background: color-mix(in srgb, var(--kh-brand) 18%, var(--kh-card)); }
  .kh-mic:active { transform: scale(0.94); }
  .kh-mic:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
  .kh-rec-bar { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 0 6px 0 14px; border-radius: 24px;
    background: var(--kh-card); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, #dc2626 45%, transparent); }
  .kh-dm-compose .kh-rec-bar { border-radius: 0; }
  .kh-rec-dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 999px; background: #dc2626; animation: kh-rec-pulse 1.2s ease-in-out infinite; }
  .kh-rec.is-uploading .kh-rec-dot { animation: none; background: var(--kh-muted); }
  .kh-rec-label { font: 700 14px/1 var(--kh-font-display); color: var(--hue-red-fg); }
  .kh-rec-time { font: 700 14.5px/1 var(--kh-font-display); font-variant-numeric: tabular-nums; color: var(--kh-ink); white-space: nowrap; }
  .kh-rec-max { color: var(--kh-muted); font-weight: 600; }
  .kh-rec-cancel { margin-left: auto; padding: 7px 12px; border-radius: 999px; font: 700 14px/1 var(--kh-font-display); color: var(--kh-body); }
  .kh-rec-cancel:hover { background: color-mix(in srgb, var(--kh-ink) 8%, transparent); }
  .kh-rec-send { height: 36px; flex-shrink: 0; padding: 0 14px; border-radius: 999px; background: #c81e1e; color: #ffffff;
    font: 700 14px/1 var(--kh-font-display); white-space: nowrap; }
  .kh-rec.is-uploading .kh-rec-send { opacity: 0.6; }
  @media (max-width: 420px) { .kh-rec-label, .kh-rec-max { display: none; } }
  /* The DM drawer is narrow at every screen size. */
  .kh-dm-compose .kh-rec-label, .kh-dm-compose .kh-rec-max { display: none; }
  .kh-dm-compose .kh-rec-bar { gap: 8px; padding: 0 10px 0 14px; }
  /* "attach" (new board posts): the bar and the attached clip sit inline. */
  .kh-rec--attach { flex-wrap: wrap; gap: 10px; }
  .kh-rec--attach .kh-rec-bar { position: static; padding: 5px 5px 5px 14px; border-radius: 999px; }
  .kh-rec-attached { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border-radius: 999px;
    background: var(--hue-green-bg); color: var(--hue-green-fg); font: 700 14px/1.2 var(--kh-font-display); }
  .kh-rec-attached .kh-rec-cancel { margin-left: 0; color: var(--hue-green-fg); }

  /* ------------------------------------------------ Alerts bell (M14) */
  .kh-alerts-badge { position: absolute; top: -2px; right: -3px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
    background: #d6164d; color: #ffffff; font: 800 11px/19px var(--kh-font-display); text-align: center; box-shadow: 0 0 0 2px var(--kh-card); }
  .kh-alerts-panel { position: absolute; right: 0; z-index: 40; margin-top: 10px; width: 360px; max-height: min(72vh, 560px); overflow-y: auto;
    border-radius: 16px; background: var(--kh-card); color: var(--kh-ink); box-shadow: var(--kh-shadow-lift); overscroll-behavior: contain; }
  @media (max-width: 479px) {
    .kh-alerts-panel { position: fixed; left: 10px; right: 10px; top: 68px; width: auto; margin-top: 0; }
  }
  .kh-alerts-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--kh-line); background: var(--kh-card); }
  .kh-alerts-list { margin: 0; padding: 6px; list-style: none; }
  .kh-alert { display: flex; align-items: flex-start; gap: 12px; padding: 10px; border-radius: 12px; color: inherit; text-decoration: none; transition: background 0.15s; }
  .kh-alert:hover { background: var(--kh-sunken); }
  .kh-alert.is-unread { background: color-mix(in srgb, var(--kh-brand) 7%, var(--kh-card)); }
  .kh-alert:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: -2px; }
  .kh-alert-icon { display: flex; width: 36px; height: 36px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 11px; font-size: 17px; }
  .kh-alert-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    font: 600 14.5px/1.35 var(--kh-font-body); color: var(--kh-ink); }
  .kh-alert.is-unread .kh-alert-title { font-weight: 700; }
  .kh-alert-body { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 1px;
    font-size: 13.5px; line-height: 1.4; color: var(--kh-muted); }
  .kh-alert-meta { display: block; margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--kh-muted); }
  .kh-alert-dot { width: 9px; height: 9px; flex-shrink: 0; margin-top: 6px; border-radius: 999px; background: var(--kh-brand); }

  /* ------------------------------------------------ Customize Room (M14) */
  .kh-customize { border-radius: 20px; border: 2px dashed color-mix(in srgb, var(--kh-brand) 40%, var(--kh-line)); padding: 16px;
    background: color-mix(in srgb, var(--kh-brand) 4%, var(--kh-canvas)); }
  .kh-customize-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
  .kh-custom-card { border-radius: 16px; background: var(--kh-card); padding: 14px; box-shadow: var(--kh-shadow-card); }
  .kh-move { padding: 6px 11px; border-radius: 999px; border: 1px solid var(--kh-line); background: var(--kh-card); color: var(--kh-ink);
    font: 700 13.5px/1 var(--kh-font-display); transition: border-color 0.15s; }
  .kh-move:hover:not(:disabled) { border-color: var(--kh-field); }
  .kh-move:disabled { opacity: 0.4; cursor: not-allowed; }
  .kh-restore { border-radius: 14px; background: var(--kh-card); padding: 12px 14px; box-shadow: var(--kh-shadow-card); }

  /* Chapter badge (Directory, profile). */
  .kh-chapter-badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px;
    background: var(--hue-teal-bg); color: var(--hue-teal-fg); font: 700 12.5px/1.6 var(--kh-font-display); white-space: nowrap; }
}

/* ---------------------------------------------------------------- dark-mode mapping
   Unlayered rules (they beat layered utilities): white surfaces in templates
   become the dark card colour; white text on coloured fills stays white. */
.dark .bg-white { background-color: var(--kh-card); }
.dark .bg-white\/60 { background-color: color-mix(in srgb, var(--kh-card) 60%, transparent); }
.dark .bg-white\/70 { background-color: color-mix(in srgb, var(--kh-card) 70%, transparent); }
.dark .bg-white\/80 { background-color: color-mix(in srgb, var(--kh-card) 80%, transparent); }
.dark .bg-white\/95 { background-color: color-mix(in srgb, var(--kh-card) 95%, transparent); }
.dark .ring-white { --tw-ring-color: var(--kh-card); }
@media (min-width: 40rem) { .dark .sm\:bg-white { background-color: var(--kh-card); } }
.dark .aria-\[current\=page\]\:bg-white[aria-current="page"] { background-color: var(--kh-card-raised); }
.dark .aria-pressed\:bg-white[aria-pressed="true"] { background-color: var(--kh-card-raised); }
.dark .shadow-\[0_1px_3px_rgba\(17\,24\,39\,0\.15\)\] { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.dark .kh-crest { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); }
.dark img:not(.kh-crest):not([data-photo]) { filter: none; }

/* On the chat page the composer sits above the tab bar, so the bar joins the
   page's column instead of floating over it (unlayered: beats `fixed`). */
.chat-page [data-mobile-nav] { position: static; flex-shrink: 0; }

/* The floating Messages button never covers the end of a page: pages get
   room below their last card (phones: above the tab bar too). On the room
   chat page it sits above the composer instead. */
body:not(.chat-page):has(#dm-fab) main { padding-bottom: 170px; }
@media (min-width: 768px) { body:not(.chat-page):has(#dm-fab) main { padding-bottom: 104px; } }
.chat-page .kh-dm-fab { bottom: 168px; }
@media (min-width: 768px) { .chat-page .kh-dm-fab { bottom: 104px; } }
.kh-dm-drawer[hidden], .kh-dm-badge[hidden] { display: none; }
/* Phones: the drawer covers the screen, so the page behind doesn't scroll. */
@media (max-width: 767px) { html.kh-dm-open, html.kh-dm-open body { overflow: hidden; } html.kh-dm-open :is(.kh-dm-fab, .kh-fb-fab) { visibility: hidden; } }
.chat-page .kh-fb-fab { bottom: 168px; }
@media (min-width: 768px) { .chat-page .kh-fb-fab { bottom: 104px; } }

/* ================================================================ Milestone 16
   Brand & Visual Identity. Unlayered so the vibe variables beat Tailwind's
   theme layer. Every colour below is decorative (tints, borders, glows,
   gradients behind white or on-primary text); body text keeps the
   contrast-guarded --kh-ink / --kh-brand / --kh-accent. */

/* ---- Headings follow the vibe's heading face everywhere. */
:is(h1, h2, h3) { font-family: var(--kh-font-heading, var(--kh-font-display)); }

/* ---- Brand vibes (html[data-vibe], from organizations.brand_vibe). */
html[data-vibe="regal-editorial"] {
  --kh-font-heading: "Playfair Display", Georgia, "Times New Roman", serif;
  --kh-font-display: "Plus Jakarta Sans", "Inter", -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --kh-font-body: "Plus Jakarta Sans", "Inter", -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --kh-radius-card: 12px;
  --kh-radius-control: 8px;
  /* Fine gold/accent hairlines instead of grey ones. */
  --kh-line: color-mix(in srgb, var(--org-accent) 22%, #e5e7eb);
}
html.dark[data-vibe="regal-editorial"] { --kh-line: color-mix(in srgb, var(--org-accent) 24%, #263349); }
html[data-vibe="regal-editorial"] :is(h1, h2, h3) { letter-spacing: 0; }
html[data-vibe="regal-editorial"] .shadow-card { box-shadow: 0 0 0 1px color-mix(in srgb, var(--org-accent) 26%, transparent), 0 1px 2px rgba(17, 24, 39, 0.04), 0 10px 26px -16px rgba(17, 24, 39, 0.18); }
html.dark[data-vibe="regal-editorial"] .shadow-card { box-shadow: 0 0 0 1px color-mix(in srgb, var(--org-accent) 30%, transparent), 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 30px -16px rgba(0, 0, 0, 0.6); }

html[data-vibe="modern-luxe"] {
  --kh-font-heading: "Outfit", "Plus Jakarta Sans", -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --kh-font-display: "Outfit", "Plus Jakarta Sans", -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --kh-radius-card: 18px;
  --kh-radius-control: 12px;
}
/* Frosted glass header and a metallic sheen on brand buttons. */
html[data-vibe="modern-luxe"] .kh-glass { backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5); }
html[data-vibe="modern-luxe"] :is(button, a).bg-brand { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), inset 0 -1px 0 rgba(0, 0, 0, 0.14), 0 6px 16px -10px color-mix(in srgb, var(--kh-brand) 70%, transparent); }

html[data-vibe="warm-welcoming"] {
  --kh-font-heading: "DM Sans", "Inter", -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --kh-font-display: "DM Sans", "Inter", -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --kh-font-body: "DM Sans", "Inter", -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --kh-radius-card: 22px;
  --kh-radius-control: 14px;
  /* Warm tinted canvas and highlights. */
  --kh-canvas: color-mix(in srgb, var(--org-accent) 4%, #fbf7f1);
  --kh-sunken: color-mix(in srgb, var(--org-accent) 7%, #f6f1ea);
}
html.dark[data-vibe="warm-welcoming"] {
  --kh-canvas: color-mix(in srgb, var(--org-accent) 4%, #0d1220);
  --kh-sunken: color-mix(in srgb, var(--org-accent) 6%, #101829);
}

/* ---- Colour harmony across every vibe: sunken panels carry a whisper of
   the primary colour, and the active tab glows in it. */
html:not([data-vibe="warm-welcoming"]) { --kh-sunken: color-mix(in srgb, var(--org-primary) 4%, #f4f3ef); }
html.dark:not([data-vibe="warm-welcoming"]) { --kh-sunken: color-mix(in srgb, var(--org-primary) 7%, #0e1628); }
nav[aria-label="Main"] a[aria-current="page"] { box-shadow: var(--kh-nav-glow); }
[data-mobile-nav] a[aria-current="page"] > span:first-child { box-shadow: var(--kh-nav-glow); }
.kh-glass { box-shadow: inset 0 -1px 0 var(--kh-card-border-tint); }

/* ---- Surface textures (html[data-texture]): a fixed layer behind the page,
   3-5% strong, so it never competes with text. */
html[data-texture] body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; }
html[data-texture="silk-gradient"] body::before {
  background:
    radial-gradient(70% 55% at 8% -5%, color-mix(in srgb, var(--org-primary) 7%, transparent), transparent 70%),
    radial-gradient(55% 45% at 100% 12%, color-mix(in srgb, var(--org-accent) 6%, transparent), transparent 70%),
    radial-gradient(80% 60% at 50% 115%, color-mix(in srgb, var(--org-primary) 5%, transparent), transparent 70%);
}
html.dark[data-texture="silk-gradient"] body::before { opacity: 1.6; }
html[data-texture="botanical-watermark"] body::before, .kh-tex-botanical {
  background-color: var(--org-primary);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='%23000'%3E%3Cpath d='M38 92c-4-24 9-44 31-52-1 24-12 43-31 52z'/%3E%3Cpath d='M41 94c11-6 22-17 28-30' fill='none' stroke='%23000' stroke-width='2'/%3E%3Cpath d='M128 150c-20-3-33-18-34-38 19 4 32 18 34 38z'/%3E%3Ccircle cx='138' cy='44' r='6'/%3E%3Ccircle cx='150' cy='40' r='5'/%3E%3Ccircle cx='144' cy='54' r='5'/%3E%3Ccircle cx='131' cy='54' r='5'/%3E%3Ccircle cx='128' cy='41' r='5'/%3E%3Cpath d='M14 160c6-13 18-19 30-17-6 12-18 19-30 17z'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 180px 180px repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='%23000'%3E%3Cpath d='M38 92c-4-24 9-44 31-52-1 24-12 43-31 52z'/%3E%3Cpath d='M41 94c11-6 22-17 28-30' fill='none' stroke='%23000' stroke-width='2'/%3E%3Cpath d='M128 150c-20-3-33-18-34-38 19 4 32 18 34 38z'/%3E%3Ccircle cx='138' cy='44' r='6'/%3E%3Ccircle cx='150' cy='40' r='5'/%3E%3Ccircle cx='144' cy='54' r='5'/%3E%3Ccircle cx='131' cy='54' r='5'/%3E%3Ccircle cx='128' cy='41' r='5'/%3E%3Cpath d='M14 160c6-13 18-19 30-17-6 12-18 19-30 17z'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 180px 180px repeat;
}
html[data-texture="crest-lattice"] body::before, .kh-tex-lattice {
  background-color: var(--org-primary);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.2'%3E%3Cpath d='M28 2 54 28 28 54 2 28z'/%3E%3Cpath d='M28 16 40 28 28 40 16 28z'/%3E%3C/g%3E%3Ccircle cx='28' cy='28' r='2' fill='%23000'/%3E%3C/svg%3E") 0 0 / 56px 56px repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.2'%3E%3Cpath d='M28 2 54 28 28 54 2 28z'/%3E%3Cpath d='M28 16 40 28 28 40 16 28z'/%3E%3C/g%3E%3Ccircle cx='28' cy='28' r='2' fill='%23000'/%3E%3C/svg%3E") 0 0 / 56px 56px repeat;
}
html[data-texture="botanical-watermark"] body::before { opacity: 0.045; }
html[data-texture="crest-lattice"] body::before { opacity: 0.04; }
html.dark[data-texture="botanical-watermark"] body::before, html.dark[data-texture="crest-lattice"] body::before {
  background-color: color-mix(in srgb, var(--org-primary) 50%, #ffffff); opacity: 0.05;
}

/* ---- Crest display styles (templates/_crest.html). */
.kh-crest-frame { position: relative; display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; }
.kh-crest-frame > .kh-crest-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.kh-crest-frame > .kh-crest-mono { width: 100%; height: 100%; }
.kh-crest-frame--floating > .kh-crest-img { filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.3)); }
/* (Fixed padding: percentages would follow the parent's width, not the crest's.) */
.kh-crest-frame--medallion { border-radius: 999px; background: #ffffff; padding: 6px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--org-accent) 62%, #ffffff), 0 0 0 11px color-mix(in srgb, var(--org-accent) 20%, transparent), 0 18px 40px -14px rgba(0, 0, 0, 0.45); }
.kh-crest-frame--medallion > .kh-crest-img { border-radius: 999px; }
.kh-crest-frame--medallion > .kh-crest-mono { box-shadow: none; }
.kh-crest-frame--emblem-card { border-radius: 28%; padding: 10px; background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px) saturate(1.3); -webkit-backdrop-filter: blur(12px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.75); box-shadow: inset 0 1px 0 #ffffff, 0 22px 44px -18px rgba(0, 0, 0, 0.5); }
.kh-crest-frame--emblem-card > .kh-crest-mono { border-radius: 24%; }

/* ---- Shared band: the cover banner or a rich multi-stop brand gradient
   (the hero paints it on itself, so its text is measured against it). */
.kh-portal-band, .kh-hero-bg {
  background:
    radial-gradient(60% 90% at 88% 10%, color-mix(in srgb, var(--org-accent) 22%, transparent), transparent 65%),
    radial-gradient(50% 80% at 8% 100%, color-mix(in srgb, var(--org-secondary) 14%, transparent), transparent 70%),
    var(--kh-gradient-header);
}
.kh-hero {
  background:
    radial-gradient(60% 90% at 88% 10%, color-mix(in srgb, var(--org-accent) 12%, transparent), transparent 65%),
    radial-gradient(50% 80% at 8% 100%, color-mix(in srgb, var(--org-secondary) 10%, transparent), transparent 70%),
    var(--kh-gradient-hero);
}
.has-banner.kh-portal-band {
  background: linear-gradient(180deg, rgba(10, 8, 20, 0.12), rgba(10, 8, 20, 0.3)), var(--kh-banner) center / cover no-repeat, var(--kh-gradient-header);
}
.kh-band-texture { position: absolute; inset: 0; pointer-events: none; opacity: 0.08; background-color: #ffffff;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.2'%3E%3Cpath d='M28 2 54 28 28 54 2 28z'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 56px 56px repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.2'%3E%3Cpath d='M28 2 54 28 28 54 2 28z'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 56px 56px repeat; }
html[data-texture="clean"] .kh-band-texture, .has-banner > .kh-band-texture { display: none; }

/* ---- Dashboard hero. Text is on-primary over the gradient (the gradient
   stays at least 70% primary), and white over a banner's dark scrim. */
.kh-hero { color: var(--org-on-primary); isolation: isolate; }
/* Over a photo: white text on a scrim that is at least 62% dark everywhere,
   so even a very bright image stays above 4.5:1. */
.kh-hero.has-banner { color: #ffffff;
  background: linear-gradient(100deg, rgba(10, 8, 20, 0.8) 0%, rgba(10, 8, 20, 0.66) 55%, rgba(10, 8, 20, 0.62) 100%), var(--kh-banner) center / cover no-repeat, #1a1626; }
.kh-hero.has-banner .kh-hero-name, .kh-hero.has-banner .kh-hero-tagline { text-shadow: 0 2px 14px rgba(0, 0, 0, 0.45); }
.kh-hero-name { letter-spacing: -0.02em; }
html[data-vibe="regal-editorial"] .kh-hero-name { letter-spacing: 0; font-weight: 700; }
.kh-hero-tagline { font-weight: 500; opacity: 0.95; }
html[data-vibe="regal-editorial"] .kh-hero-tagline { font-family: var(--kh-font-heading); font-style: italic; }
.kh-hero-emblem { position: absolute; right: 18px; bottom: 16px; width: 64px; height: 64px; object-fit: contain; opacity: 0.9;
  padding: 8px; border-radius: 18px; background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); pointer-events: none; }
@media (max-width: 767px) { .kh-hero-emblem { top: 14px; right: 14px; bottom: auto; width: 46px; height: 46px; padding: 6px; border-radius: 14px; } }

/* ---- Sign-in Welcome Portal. */
/* The banner (or brand gradient) washes the top of the page edge to edge and
   melts into the background, so the crest sits on it and the card below
   stays on a calm surface. */
.kh-portal-band { position: absolute; inset: 0 0 auto; height: 230px; z-index: -1; overflow: hidden; opacity: 0.45;
  -webkit-mask-image: linear-gradient(#000 30%, transparent); mask-image: linear-gradient(#000 30%, transparent); }
html.dark .kh-portal-band { opacity: 0.6; }
/* No cover banner yet: a soft glow of the brand colours instead of a full
   band, so the sign-in stays calm until there's a photo to show off. */
.kh-portal-band:not(.has-banner), html.dark .kh-portal-band:not(.has-banner) { opacity: 1; height: 420px; -webkit-mask-image: none; mask-image: none;
  background:
    radial-gradient(60% 70% at 50% 0%, color-mix(in srgb, var(--org-primary) 8%, transparent), transparent 70%),
    radial-gradient(40% 50% at 85% 10%, color-mix(in srgb, var(--org-accent) 6%, transparent), transparent 70%); }
.kh-portal-band.has-banner { opacity: 0.75; }
.kh-portal-band > .kh-band-texture { display: none; }
@media (min-width: 480px) { .kh-portal-band { height: 270px; } }
.kh-portal-crest { position: relative; }
.kh-portal-tagline { font-family: var(--kh-font-heading, var(--kh-font-display)); font-size: 15.5px; font-weight: 600; line-height: 1.4; color: var(--kh-muted); }
html[data-vibe="regal-editorial"] .kh-portal-tagline { font-style: italic; }
/* The sign-in card keeps its calm, measured shape (10 px corners, a soft
   two-part shadow) in every vibe; frosted where it overlaps the band. */
@media (min-width: 480px) {
  .kh-portal-card { background: color-mix(in srgb, var(--kh-card) 97%, transparent); border-radius: 10px;
    backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
    box-shadow: rgba(0, 0, 0, 0.05) 0 -1px 10px 0, rgba(0, 0, 0, 0.1) 0 1px 4px 0; }
  html.dark .kh-portal-card { box-shadow: 0 0 0 1px var(--kh-card-border-tint), 0 1px 4px rgba(0, 0, 0, 0.5); }
}
/* Sign-in: the organization's secondary colour is the page (when it's light
   enough for dark text; see Theme::auth_canvas), and only the heading takes
   the vibe's display face; buttons and labels stay in the steady UI font. */
html:not(.dark) body.auth-page { --kh-canvas: var(--kh-auth-canvas, #faf9f6); background: var(--kh-canvas); }
body.auth-page { --kh-font-display: "Plus Jakarta Sans", "Inter", -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif; }

/* ---- Secondary emblem accents. */
.kh-emblem-rule { position: relative; display: flex; align-items: center; justify-content: center; height: 30px; }
.kh-emblem-rule::before { content: ""; position: absolute; inset: 50% 0 auto; height: 1px; background: var(--kh-gradient-hairline); opacity: 0.55; }
.kh-emblem-rule > img { position: relative; width: 30px; height: 30px; object-fit: contain; padding: 3px; border-radius: 999px; background: var(--kh-canvas); }
.kh-emblem-badge { object-fit: contain; filter: drop-shadow(0 4px 10px rgba(17, 24, 39, 0.18)); }
.kh-pass-emblem { position: absolute; right: 18px; top: 44%; width: 92px; height: 92px; object-fit: contain; opacity: 0.2; pointer-events: none; }

/* ---- Brand Studio (settings). */
.kh-studio-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kh-palette { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; border: 1.5px solid var(--kh-line); background: var(--kh-card);
  text-align: left; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s var(--kh-ease); }
.kh-palette:hover { border-color: var(--kh-field); transform: translateY(-1px); }
.kh-palette[aria-pressed="true"] { border-color: var(--kh-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--kh-brand) 18%, transparent); }
.kh-palette-chips { display: flex; height: 26px; overflow: hidden; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.08); }
.kh-palette-chips > span { flex: 1; }
.kh-palette-name { font: 700 13px/1.3 var(--kh-font-display); color: var(--kh-ink); }
.kh-option-grid { display: grid; gap: 10px; }
@media (min-width: 640px) { .kh-option-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
.kh-option { display: block; cursor: pointer; }
.kh-option-face { display: flex; height: 100%; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--kh-line);
  background: var(--kh-card); color: var(--kh-body); transition: all 0.15s var(--kh-ease); }
.kh-option:hover .kh-option-face { border-color: var(--kh-field); }
.peer:checked + .kh-option-face { border-color: var(--kh-brand); background: color-mix(in srgb, var(--kh-brand) 8%, var(--kh-card)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--kh-brand) 14%, transparent); }
.peer:focus-visible + .kh-option-face { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-option-title { font: 700 15px/1.3 var(--kh-font-display); color: var(--kh-ink); }
.kh-option-note { font-size: 13px; line-height: 1.4; color: var(--kh-muted); }
.kh-texture-sample { position: relative; height: 40px; border-radius: 10px; overflow: hidden; background: var(--kh-sunken); }
.kh-texture-sample > span { position: absolute; inset: 0; opacity: 0.35; }
.kh-texture-sample > .kh-tex-silk { opacity: 1; background: radial-gradient(70% 90% at 0% 0%, color-mix(in srgb, var(--org-primary) 30%, transparent), transparent 70%), radial-gradient(60% 90% at 100% 100%, color-mix(in srgb, var(--org-accent) 26%, transparent), transparent 70%); }

/* The live mini-preview: its own little page that follows the Studio's
   choices (data-vibe / data-texture on the frame, colours inline). */
.kh-preview {
  /* Re-derived here so they follow the colours being picked. */
  --kh-gradient-header: linear-gradient(135deg, var(--org-primary) 0%, color-mix(in srgb, var(--org-primary) 80%, var(--org-accent)) 60%, color-mix(in srgb, var(--org-primary) 68%, var(--org-accent)) 100%);
  --kh-card-border-tint: color-mix(in srgb, var(--org-primary) 13%, transparent);
  --kh-gradient-hero: linear-gradient(135deg,
    color-mix(in srgb, var(--org-primary) 86%, var(--kh-shade-ink)) 0%,
    color-mix(in srgb, color-mix(in srgb, var(--org-primary) 80%, var(--org-accent)) 84%, var(--kh-shade-ink)) 60%,
    color-mix(in srgb, color-mix(in srgb, var(--org-primary) 68%, var(--org-accent)) 82%, var(--kh-shade-ink)) 100%);
  position: relative; overflow: hidden; border-radius: 18px; isolation: isolate; color: var(--kh-ink); background: var(--kh-canvas);
  box-shadow: 0 0 0 1px var(--kh-line), 0 18px 40px -24px rgba(17, 24, 39, 0.4); font-family: var(--kh-font-body); }
.kh-preview .kh-preview-tex { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.kh-preview[data-texture="silk-gradient"] .kh-preview-tex { background: radial-gradient(70% 55% at 8% 0%, color-mix(in srgb, var(--org-primary) 9%, transparent), transparent 70%), radial-gradient(55% 45% at 100% 20%, color-mix(in srgb, var(--org-accent) 8%, transparent), transparent 70%); }
.kh-preview[data-texture="botanical-watermark"] .kh-preview-tex { opacity: 0.06; }
.kh-preview[data-texture="crest-lattice"] .kh-preview-tex { opacity: 0.05; }
.kh-preview[data-texture="clean"] .kh-preview-tex { display: none; }
.kh-preview[data-vibe="regal-editorial"] { --kh-font-heading: "Playfair Display", Georgia, serif; --kh-font-display: "Plus Jakarta Sans", system-ui, sans-serif; --kh-font-body: "Plus Jakarta Sans", system-ui, sans-serif; --kh-radius-card: 12px; --kh-line: color-mix(in srgb, var(--org-accent) 22%, #e5e7eb); }
.kh-preview.kh-scheme-dark[data-vibe="regal-editorial"] { --kh-line: color-mix(in srgb, var(--org-accent) 24%, #263349); }
.kh-preview[data-vibe="modern-luxe"] { --kh-font-heading: "Outfit", system-ui, sans-serif; --kh-font-display: "Outfit", system-ui, sans-serif; --kh-font-body: "Inter", system-ui, sans-serif; --kh-radius-card: 18px; }
.kh-preview[data-vibe="warm-welcoming"] { --kh-font-heading: "DM Sans", system-ui, sans-serif; --kh-font-display: "DM Sans", system-ui, sans-serif; --kh-font-body: "DM Sans", system-ui, sans-serif; --kh-radius-card: 22px; }
.kh-preview.kh-scheme-light { --kh-canvas: #faf9f6; }
.kh-preview.kh-scheme-dark { --kh-canvas: #0b1120; }
.kh-preview .kh-preview-hero { position: relative; overflow: hidden; color: var(--org-on-primary); border-radius: calc(var(--kh-radius-card) + 2px); isolation: isolate; }
.kh-preview .kh-preview-hero.has-banner { color: #ffffff; }
.kh-preview .kh-preview-card { border-radius: var(--kh-radius-card); background: var(--kh-card); box-shadow: 0 0 0 1px color-mix(in srgb, var(--org-primary) 14%, transparent), 0 8px 22px -14px rgba(17, 24, 39, 0.3); }
.kh-preview .kh-preview-h { font-family: var(--kh-font-heading); }
.kh-preview[data-vibe="regal-editorial"] .kh-preview-card { box-shadow: 0 0 0 1px color-mix(in srgb, var(--org-accent) 30%, transparent); }
.kh-preview .kh-preview-btn { display: inline-flex; height: 34px; align-items: center; padding: 0 14px; border-radius: 999px; background: var(--kh-brand); color: var(--kh-on-brand); font: 700 13px/1 var(--kh-font-display); }
.kh-preview .kh-preview-pill { display: inline-flex; padding: 2px 9px; border-radius: 999px; font: 700 12px/1.6 var(--kh-font-display); color: var(--kh-brand); background: color-mix(in srgb, var(--kh-brand) 12%, var(--kh-card)); }
.kh-preview .kh-preview-tab { padding: 5px 11px; border-radius: 999px; font: 600 12.5px/1 var(--kh-font-display); color: var(--kh-body); }
.kh-preview .kh-preview-tab.is-on { background: var(--kh-card); color: var(--kh-ink); box-shadow: 0 0 0 1px color-mix(in srgb, var(--org-primary) 22%, transparent), 0 6px 18px -8px color-mix(in srgb, var(--org-primary) 60%, transparent); }
.kh-preview .kh-crest-frame { --org-accent: var(--pv-accent, var(--org-accent)); }
.kh-upload-thumb { display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 12px; background: var(--kh-sunken); box-shadow: inset 0 0 0 1px var(--kh-line); }
.kh-upload-thumb > img { width: 100%; height: 100%; object-fit: cover; }
.kh-upload-thumb.is-contain > img { object-fit: contain; padding: 6px; }

/* ---- Welcome Portal tabs and request confirmation (Milestone 18). */
.kh-portal-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 18px; padding: 4px; border-radius: 999px; background: var(--kh-sunken); }
.kh-portal-tabs > a { display: flex; height: 40px; align-items: center; justify-content: center; border-radius: 999px; text-decoration: none;
  color: var(--kh-body); font: 600 15px/1 var(--kh-font-display); transition: all 0.15s var(--kh-ease); }
.kh-portal-tabs > a:hover { color: var(--kh-ink); }
.kh-portal-tabs > a[aria-selected="true"] { background: var(--kh-card); color: var(--kh-ink); font-weight: 800;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.16), inset 0 0 0 1.5px var(--kh-brand); }
.kh-portal-tabs > a:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-portal-sent { padding: 8px 0 4px; }
/* "Keep me signed in" (Milestone 19). */
.kh-remember { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--kh-body); font-size: 15px; line-height: 1.35; }
.kh-remember input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--kh-brand); cursor: pointer; }
.kh-remember input:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-portal-sent-mark { display: inline-flex; width: 68px; height: 68px; align-items: center; justify-content: center; border-radius: 999px; font-size: 32px;
  background: color-mix(in srgb, var(--kh-brand) 12%, var(--kh-card)); box-shadow: 0 0 0 8px color-mix(in srgb, var(--kh-brand) 6%, transparent); }
/* ---- Pride Points & Prestige Tiers (Milestone 18). Each tier sets
   --tier-fg / --tier-bg from the hue palette (AA in light and dark). */
.kh-tier { display: inline-flex; align-items: center; gap: 4px; width: fit-content; padding: 2px 9px; border-radius: 999px;
  color: var(--tier-fg, var(--kh-ink)); background: var(--tier-bg, var(--hue-neutral-bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tier-fg, var(--kh-ink)) 25%, transparent);
  font: 700 12.5px/1.6 var(--kh-font-body); white-space: nowrap; }
.kh-tier-lg { padding: 4px 13px; font-size: 15px; font-family: var(--kh-font-display); }
.kh-pride-number { font: 800 34px/1 var(--kh-font-display); color: var(--kh-ink); letter-spacing: -0.02em; }
.kh-pride-bar { height: 10px; border-radius: 999px; background: var(--kh-sunken); overflow: hidden;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--kh-ink) 8%, transparent); }
.kh-pride-bar > span { display: block; height: 100%; min-width: 6px; border-radius: inherit; background: var(--tier-fg, var(--kh-brand)); transition: width 0.4s var(--kh-ease); }
.kh-pride-ladder { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--kh-body); }
.kh-pride-ladder > li[aria-current] { font-weight: 800; color: var(--kh-ink); }

/* Pending Membership Requests: count bubbles. */
.kh-nav-count, .kh-requests-count { display: inline-flex; min-width: 20px; height: 20px; align-items: center; justify-content: center; padding: 0 6px;
  border-radius: 999px; background: var(--hue-red-fg); color: #fff; font: 800 12px/1 var(--kh-font-body); }
.dark .kh-nav-count, .dark .kh-requests-count { color: #111827; }
.kh-nav-count { margin-left: 6px; vertical-align: 1px; }
.kh-requests-count.is-zero { background: var(--hue-neutral-bg); color: var(--kh-muted, #6b7280); }
.kh-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---- Rooms hub (Milestone 18). */
.kh-pill-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; }
.kh-pill-tab { cursor: pointer; }
.kh-pill-tab > span { display: inline-flex; height: 36px; align-items: center; padding: 0 15px; border-radius: 999px; border: 1px solid var(--kh-line);
  background: var(--kh-card); color: var(--kh-body); font: 600 14.5px/1 var(--kh-font-display); transition: all 0.15s var(--kh-ease); }
.kh-pill-tab:hover > span { color: var(--kh-ink); border-color: var(--kh-field); }
.kh-pill-tab > .peer:checked + span { background: var(--kh-brand); border-color: var(--kh-brand); color: var(--kh-on-brand); font-weight: 700; box-shadow: var(--kh-nav-glow); }
.kh-pill-tab > .peer:focus-visible + span { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-tool-badges { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; margin-bottom: 0; padding: 0; list-style: none; }
.kh-tool-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font: 600 12.5px/1.6 var(--kh-font-display);
  color: var(--kh-body); background: var(--kh-sunken); box-shadow: inset 0 0 0 1px var(--kh-line); }

/* ---- Most Recent Activity (Milestone 17). */
.kh-activity { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.kh-activity > li { min-width: 0; }
.kh-activity-line { overflow-wrap: anywhere; }
.kh-activity-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px; border-radius: 14px; color: var(--kh-ink); text-decoration: none;
  transition: background 0.15s; }
.kh-activity-row:hover { background: var(--kh-sunken); }
.kh-activity-row:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: -2px; }
.kh-activity-face { position: relative; flex-shrink: 0; display: flex; }
.kh-activity-icon { display: flex; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: 12px; font-size: 18px; }
.kh-activity-kind { position: absolute; right: -6px; bottom: -4px; display: flex; width: 20px; height: 20px; align-items: center; justify-content: center;
  border-radius: 999px; font-size: 11px; background: var(--kh-card); box-shadow: 0 0 0 2px var(--kh-card), 0 1px 3px rgba(17, 24, 39, 0.2); }
.kh-activity-line { display: block; font-size: 14.5px; line-height: 1.35; color: var(--kh-body); }
.kh-activity-line strong { font-family: var(--kh-font-display); font-weight: 700; color: var(--kh-ink); }
.kh-activity-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px;
  font-family: var(--kh-font-display); font-size: 15.5px; font-weight: 700; color: var(--kh-ink); }
.kh-activity-place { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 1px 9px; border-radius: 999px; font: 700 12.5px/1.6 var(--kh-font-display);
  color: var(--kh-brand); background: color-mix(in srgb, var(--kh-brand) 12%, var(--kh-card)); }
.kh-activity-place.is-chapter { color: var(--hue-teal-fg); background: var(--hue-teal-bg); }
.kh-activity-go { align-self: center; color: var(--kh-muted); font-weight: 700; opacity: 0; transition: opacity 0.15s, transform 0.15s var(--kh-ease); }
.kh-activity-row:hover .kh-activity-go, .kh-activity-row:focus-visible .kh-activity-go { opacity: 1; transform: translateX(2px); }

@keyframes kh-grow { from { width: 0; } }
@keyframes kh-rise { from { height: 0; } }
@keyframes kh-shine { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }

@keyframes kh-dm-pulse {
  0% { transform: scale(0.96); opacity: 0.85; }
  70%, 100% { transform: scale(1.32); opacity: 0; }
}
@keyframes kh-rec-pulse {
  50% { opacity: 0.35; transform: scale(0.8); }
}
/* No MediaRecorder (older browsers): no microphone buttons. */
html.kh-no-voice .kh-mic { display: none; }
@keyframes kh-dm-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
}

@keyframes kh-pop {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .kh-thermo-bar > span::after { animation: none !important; display: none; }
}

/* ==== Milestone 20: profile quick-card, chat actions & reactions, emoji picker ====
   Everything is drawn from the mode-aware neutrals and the contrast-checked
   brand colours (--kh-brand / --kh-accent / --kh-on-brand), so it reads in
   Light and Dark for any organization palette. */

/* ---- Clickable avatars and names (templates/_avatar.html: who / name) ---- */
.kh-qc-trigger { position: relative; margin: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit;
  text-align: inherit; letter-spacing: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.kh-qc-trigger--av { display: inline-flex; flex: none; align-items: center; justify-content: center; border-radius: 14px; transition: transform 0.15s var(--kh-ease), filter 0.15s var(--kh-ease); }
.kh-qc-trigger--av:hover { transform: translateY(-1px) scale(1.05); filter: drop-shadow(0 4px 8px rgba(17, 24, 39, 0.22)); }
.kh-qc-trigger--av:active { transform: scale(0.97); }
.kh-qc-trigger--name { display: inline; max-width: 100%; border-radius: 4px; text-decoration: underline; text-decoration-color: transparent;
  text-decoration-thickness: 1.5px; text-underline-offset: 3px; transition: text-decoration-color 0.15s var(--kh-ease); }
.kh-qc-trigger--name:hover { text-decoration-color: currentColor; }
.kh-qc-trigger:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
/* Cards whose title link covers the whole card: keep the triggers on top. */
.kh-qc-raise .kh-qc-trigger { z-index: 2; }

/* ---- The quick-card modal ---- */
.kh-qc-dialog { width: min(420px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); margin: auto; padding: 0; border: 0;
  border-radius: 22px; background: transparent; color: var(--kh-ink); overflow: visible; }
.kh-qc-dialog::backdrop { background: rgba(17, 24, 39, 0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.kh-qc { position: relative; max-height: calc(100dvh - 24px); overflow: hidden auto; padding: 0 20px 20px; border-radius: 22px;
  background: var(--kh-card); box-shadow: var(--kh-shadow-lift); overscroll-behavior: contain; }
.kh-qc-band { height: 88px; margin: 0 -20px;
  background: linear-gradient(135deg, var(--org-primary) 0%, color-mix(in srgb, var(--org-primary) 72%, var(--org-accent)) 100%); }
.kh-qc-close { position: absolute; top: 10px; right: 10px; display: flex; width: 36px; height: 36px; align-items: center; justify-content: center;
  border-radius: 999px; background: rgba(17, 24, 39, 0.62); color: #ffffff; font-size: 23px; line-height: 1; cursor: pointer; transition: background 0.15s; }
.kh-qc-close:hover { background: rgba(17, 24, 39, 0.82); }
.kh-qc-close:focus-visible, .kh-qc-primary:focus-visible, .kh-qc-link:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-qc-head { margin-top: -50px; text-align: center; }
.kh-qc-avatar { display: inline-flex; padding: 5px; border-radius: 999px; background: var(--kh-card); }
.kh-qc-name { margin-top: 6px; font-family: var(--kh-font-display); font-size: 22px; font-weight: 800; line-height: 1.2; letter-spacing: -0.01em;
  color: var(--kh-ink); overflow-wrap: anywhere; }
.kh-qc-pronouns { font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--kh-muted); }
.kh-qc-badges { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; }
.kh-qc-bio { margin-top: 14px; text-align: center; font-size: 14.5px; line-height: 1.5; color: var(--kh-body); white-space: pre-line; overflow-wrap: anywhere; }
.kh-qc-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 16px 0 0; padding: 14px; border-radius: 14px; background: var(--kh-sunken); }
.kh-qc-facts dt { font-size: 12.5px; color: var(--kh-muted); }
.kh-qc-facts dd { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--kh-ink); overflow-wrap: anywhere; }
.kh-qc-contact { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--kh-line); border-radius: 14px; }
.kh-qc-contact h3 { font-family: var(--kh-font-display); font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--kh-muted); }
.kh-qc-contact dl { margin: 4px 0 0; }
.kh-qc-contact dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14.5px; }
.kh-qc-contact dl > div + div { border-top: 1px solid color-mix(in srgb, var(--kh-line) 70%, transparent); }
.kh-qc-contact dt { flex-shrink: 0; color: var(--kh-muted); }
.kh-qc-contact dd { min-width: 0; margin: 0; text-align: right; font-weight: 600; color: var(--kh-ink); overflow-wrap: anywhere; }
.kh-qc-link { color: var(--kh-accent); text-decoration: underline; text-underline-offset: 2px; border-radius: 4px; }
.kh-qc-note { margin-top: 8px; font-size: 13px; line-height: 1.4; color: var(--kh-muted); }
.kh-qc-actions { margin-top: 16px; }
.kh-qc-primary { display: flex; width: 100%; height: 48px; align-items: center; justify-content: center; gap: 8px; border-radius: 999px;
  background: var(--kh-brand); color: var(--kh-on-brand); font-family: var(--kh-font-display); font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--kh-brand) 70%, transparent); transition: transform 0.12s var(--kh-ease), filter 0.15s; }
.kh-qc-primary:hover { filter: brightness(1.06); }
.kh-qc-primary:active { transform: scale(0.98); }

/* ---- My Profile: "Show my phone and social" row ---- */
.kh-switch-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--kh-line); border-radius: 14px; cursor: pointer; }
.kh-switch-row .kh-check { margin-top: 1px; }
.kh-switch-row:focus-within { border-color: var(--kh-accent); }

/* ---- Group Chat: message actions (react, reply, delete) ---- */
.kh-chat-actions { position: absolute; top: -8px; z-index: 5; display: none; align-items: center; gap: 1px; padding: 3px; border-radius: 999px;
  background: var(--kh-card-raised); box-shadow: var(--kh-shadow-lift); }
.chat-line:not([data-mine]) > .kh-chat-actions { left: 56px; }
.chat-line[data-mine] > .kh-chat-actions { right: 56px; }
@media (max-width: 479px) { .chat-line[data-mine] > .kh-chat-actions { right: 14px; } }
.chat-line:focus-within > .kh-chat-actions, .chat-line.is-active > .kh-chat-actions { display: flex; }
@media (hover: hover) { .chat-line:hover > .kh-chat-actions { display: flex; } }
.kh-chat-act { display: inline-flex; width: 32px; height: 32px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 999px;
  color: var(--kh-muted); font-size: 17px; line-height: 1; cursor: pointer; transition: background-color 0.12s, color 0.12s, transform 0.12s var(--kh-ease); }
.kh-chat-act:hover { background: var(--kh-sunken); color: var(--kh-ink); }
.kh-chat-act--emoji:hover { transform: scale(1.18); }
.kh-chat-act:active { transform: scale(0.92); }
.kh-chat-act:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 1px; }
.kh-chat-act--danger:hover { background: var(--hue-red-bg); color: var(--hue-red-fg); }
.kh-chat-actions-sep { width: 1px; height: 18px; margin: 0 3px; background: var(--kh-line); }
@media (pointer: coarse) { .kh-chat-act { width: 38px; height: 38px; font-size: 19px; } }
@media (hover: none) { [data-chat-bubble] { cursor: pointer; } }

/* Reaction pills under a message: only emoji someone has used. */
.kh-chat-rx { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.kh-chat-rx:not(:has(button)) { display: none; }
.chat-line[data-mine] .kh-chat-rx { justify-content: flex-end; }
.kh-react--sm { height: 26px; min-width: 0; gap: 4px; padding: 0 8px; font-size: 12.5px; }
.kh-react--sm .kh-react-emoji { font-size: 14px; }

/* ---- Emoji picker (templates/_emoji.html) ---- */
.kh-emoji { display: flex; flex-shrink: 0; align-items: center; }
.kh-emoji-btn { display: flex; width: 42px; height: 42px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 999px;
  font-size: 22px; line-height: 1; cursor: pointer; transition: background 0.15s, transform 0.12s; }
.kh-emoji-btn:hover, .kh-emoji-btn[aria-expanded="true"] { background: color-mix(in srgb, var(--kh-brand) 14%, var(--kh-card)); }
.kh-emoji-btn:active { transform: scale(0.94); }
.kh-emoji-btn:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-emoji-pop { position: absolute; right: 6px; bottom: calc(100% + 8px); z-index: 30; width: min(340px, calc(100vw - 20px)); padding: 8px;
  border-radius: 16px; background: var(--kh-card-raised); color: var(--kh-ink); box-shadow: var(--kh-shadow-lift); animation: kh-dm-in 0.16s var(--kh-ease); }
.kh-emoji-pop[hidden] { display: none; }
.kh-emoji-tabs { display: flex; gap: 4px; padding-bottom: 7px; border-bottom: 1px solid var(--kh-line); overflow-x: auto; scrollbar-width: none; }
.kh-emoji-tab { flex: 1 0 auto; padding: 5px 9px; border-radius: 999px; white-space: nowrap; font-family: var(--kh-font-display); font-size: 12.5px;
  font-weight: 700; color: var(--kh-muted); cursor: pointer; }
.kh-emoji-tab:hover { color: var(--kh-ink); background: var(--kh-sunken); }
.kh-emoji-tab[aria-selected="true"] { background: color-mix(in srgb, var(--kh-brand) 14%, var(--kh-card)); color: var(--kh-ink); }
.kh-emoji-tab:focus-visible, .kh-emoji-grid button:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 1px; }
.kh-emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; max-height: 196px; padding-top: 7px; overflow-y: auto; }
.kh-emoji-grid button { display: flex; aspect-ratio: 1; align-items: center; justify-content: center; border-radius: 9px; font-size: 22px; line-height: 1;
  cursor: pointer; transition: background-color 0.1s, transform 0.1s var(--kh-ease); }
.kh-emoji-grid button:hover { background: var(--kh-sunken); transform: scale(1.15); }

/* A quoted reply inside your own (brand-coloured) bubble: readable on any brand colour. */
.chat-line[data-mine] .kh-bubble blockquote { color: var(--kh-on-brand); opacity: 1; border-color: color-mix(in srgb, var(--kh-on-brand) 70%, transparent);
  background: color-mix(in srgb, var(--kh-on-brand) 16%, transparent); }

/* Message boxes: one-line placeholder (the emoji and mic buttons share the row on phones). */
#chat-body::placeholder, .kh-dm-input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 479px) {
  .kh-emoji-btn { width: 36px; height: 42px; }
  #chat-form .kh-mic { width: 38px; }
}

/* ==== Milestone 21: leadership time-savers, My Action Items, Bookmarks Vault,
   the print packet. Colours come from the mode-aware neutrals, the hue pairs
   and the contrast-checked brand colours, so everything reads in Light and
   Dark for any organization palette. ==== */

.kh-code { padding: 1px 6px; border-radius: 6px; background: var(--kh-sunken); color: var(--kh-ink);
  font: 600 0.92em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
.kh-file-input::file-selector-button { margin-right: 10px; height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--kh-line);
  background: var(--kh-card); color: var(--kh-ink); font: 700 14px var(--kh-font-display); cursor: pointer; }

/* ---- Bookmark toggle (templates/_bookmark.html) ---- */
.kh-bm-form { display: inline-flex; margin: 0; }
.kh-bm { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border: 0; border-radius: 999px;
  background: transparent; color: var(--kh-muted); cursor: pointer; transition: color 0.15s var(--kh-ease), background-color 0.15s var(--kh-ease), transform 0.15s var(--kh-ease); }
.kh-bm > svg { width: 20px; height: 20px; }
.kh-bm:hover { color: var(--kh-brand); background: color-mix(in srgb, var(--kh-brand) 10%, transparent); }
.kh-bm:active { transform: scale(0.9); }
.kh-bm.is-on { color: var(--kh-brand); }
.kh-bm.is-on > svg { animation: kh-pop 0.28s var(--kh-ease); }
.kh-bm:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }

/* ---- My Action Items strip (templates/_action_items.html) ---- */
.kh-actions-box, .kh-actions-clear { border-radius: 18px; background: var(--kh-card); box-shadow: var(--kh-shadow-card);
  border: 1px solid var(--kh-card-border-tint, var(--kh-line)); }
.kh-actions-clear { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0; padding: 11px 16px; font-size: 15px; color: var(--kh-ink); }
.kh-actions-clear-sub { color: var(--kh-muted); }
.kh-actions-summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; list-style: none; border-radius: 18px; }
.kh-actions-summary::-webkit-details-marker { display: none; }
.kh-actions-summary:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-actions-title { font: 800 15.5px/1.2 var(--kh-font-display); color: var(--kh-ink); }
.kh-actions-total { display: inline-flex; min-width: 24px; height: 24px; align-items: center; justify-content: center; padding: 0 7px; border-radius: 999px;
  background: var(--kh-brand); color: var(--kh-on-brand); font: 800 13px/1 var(--kh-font-display); }
.kh-actions-hint { font-size: 13.5px; color: var(--kh-muted); }
.kh-actions-chevron { width: 18px; height: 18px; margin-left: auto; color: var(--kh-muted); transition: transform 0.2s var(--kh-ease); }
.kh-actions-box[open] .kh-actions-chevron { transform: rotate(180deg); }
.kh-actions-list { display: grid; gap: 8px; margin: 0; padding: 0 12px 12px; list-style: none; }
@media (min-width: 768px) { .kh-actions-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kh-action-pill { display: flex; align-items: center; gap: 10px; height: 100%; min-height: 56px; padding: 8px 12px; border-radius: 14px;
  background: var(--pill-bg, var(--hue-neutral-bg)); color: var(--kh-ink); text-decoration: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pill-fg, var(--kh-muted)) 22%, transparent);
  transition: transform 0.15s var(--kh-ease), box-shadow 0.15s var(--kh-ease); }
a.kh-action-pill:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--pill-fg) 55%, transparent), var(--kh-shadow-card); }
a.kh-action-pill:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-action-count { display: inline-flex; flex: none; min-width: 34px; height: 34px; align-items: center; justify-content: center; padding: 0 8px; border-radius: 999px;
  background: var(--kh-card); color: var(--pill-fg, var(--kh-muted)); font: 800 16px/1 var(--kh-font-display);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--pill-fg, var(--kh-muted)) 28%, transparent); }
.kh-action-text { display: grid; min-width: 0; flex: 1; }
.kh-action-label { font: 700 14px/1.3 var(--kh-font-display); color: var(--kh-ink); }
.kh-action-next { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; line-height: 1.35; color: var(--kh-body); }
.kh-action-flag { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--hue-red-bg); color: var(--hue-red-fg); font: 700 11.5px/1.6 var(--kh-font-body); white-space: nowrap; }
.kh-action-go { flex: none; color: var(--pill-fg); font-weight: 800; }
.kh-action-pill.is-done { --pill-fg: var(--hue-green-fg); background: var(--hue-neutral-bg); }
.kh-action-pill.is-done .kh-action-label, .kh-action-pill.is-done .kh-action-next { color: var(--kh-muted); }

/* ---- Chapter Health scorecard (templates/recaps/recaps.html) ---- */
.kh-health-wrap { overflow-x: auto; border: 1px solid var(--kh-line); border-radius: 14px; }
.kh-health { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.kh-health th, .kh-health td { padding: 10px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--kh-line); color: var(--kh-body); }
.kh-health thead th { background: var(--kh-sunken); color: var(--kh-muted); font: 700 12px/1.3 var(--kh-font-display); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.kh-health tbody tr:last-child > * { border-bottom: 0; }
.kh-health tbody th { font-weight: 400; min-width: 150px; }
.kh-health .kh-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kh-health td strong { color: var(--kh-ink); font-family: var(--kh-font-display); }
.kh-health-pill { height: 26px; padding: 0 11px; font-size: 13px; font-weight: 700; white-space: nowrap; }
@media (max-width: 719px) {
  /* Phones: each chapter becomes a card, each number a labelled row. */
  .kh-health-wrap { border: 0; overflow: visible; }
  .kh-health thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .kh-health, .kh-health tbody, .kh-health tr, .kh-health th, .kh-health td { display: block; }
  .kh-health tbody tr { margin-bottom: 10px; padding: 6px 0; border: 1px solid var(--kh-line); border-radius: 14px; }
  .kh-health tbody th, .kh-health td { border-bottom: 0; padding: 5px 14px; }
  .kh-health td { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; text-align: right; white-space: normal; }
  .kh-health td::before { content: attr(data-label); flex: none; color: var(--kh-muted); font-size: 13px; text-align: left; }
}

/* ---- Tool tabs on /recaps ---- */
.kh-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; border-radius: 999px; background: var(--kh-sunken); width: fit-content; max-width: 100%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--kh-ink) 6%, transparent); }
.kh-tab { display: inline-flex; height: 40px; align-items: center; gap: 7px; padding: 0 18px; border-radius: 999px; color: var(--kh-body);
  font: 700 14.5px/1 var(--kh-font-display); text-decoration: none; white-space: nowrap; transition: background-color 0.15s var(--kh-ease), color 0.15s var(--kh-ease); }
.kh-tab:hover { color: var(--kh-ink); }
.kh-tab[aria-selected="true"] { background: var(--kh-brand); color: var(--kh-on-brand); box-shadow: var(--kh-nav-glow); }
.kh-tab:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-print-link { position: absolute; right: 16px; bottom: 16px; z-index: 2; display: inline-flex; height: 32px; align-items: center; gap: 6px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--kh-line); background: var(--kh-card); color: var(--kh-accent); font: 700 13px/1 var(--kh-font-display);
  text-decoration: none; transition: border-color 0.15s var(--kh-ease); }
.kh-print-link:hover { border-color: var(--kh-accent); }
.kh-print-link > svg { width: 15px; height: 15px; }

/* ---- Remind Non-Responders (templates/schedule/_event.html) ---- */
.kh-remind-btn { display: inline-flex; height: 36px; align-items: center; gap: 6px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--hue-amber-fg) 40%, transparent); background: var(--hue-amber-bg); color: var(--hue-amber-fg);
  font: 700 14px/1 var(--kh-font-display); white-space: nowrap; transition: filter 0.15s var(--kh-ease), transform 0.15s var(--kh-ease); }
.kh-remind-btn:hover { filter: brightness(0.97); transform: translateY(-1px); }
.kh-remind-btn:disabled { opacity: 0.6; cursor: progress; }
.kh-remind-btn:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-remind-done { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 7px; margin-top: 10px; padding: 8px 12px; border-radius: 12px;
  background: var(--hue-green-bg); color: var(--hue-green-fg); font-size: 14.5px; }
.kh-remind-sub { color: var(--kh-body); font-size: 13px; }

/* ---- Print / Save Executive Packet (templates/recaps/print.html) ---- */
.kh-print-body { margin: 0; min-height: 100vh; background: #eceae4; color: #111827; }
.kh-print-toolbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 18px;
  background: #ffffff; border-bottom: 1px solid #e5e7eb; box-shadow: 0 2px 10px -6px rgba(17, 24, 39, 0.35); }
.kh-print-back { color: var(--kh-accent); font: 700 14.5px/1 var(--kh-font-display); text-decoration: none; }
.kh-print-back:hover { text-decoration: underline; }
.kh-print-hint { margin: 0 auto 0 0; color: #4b5563; font-size: 13.5px; }
.kh-print-btn { display: inline-flex; height: 42px; align-items: center; gap: 8px; padding: 0 20px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--kh-brand); color: var(--kh-on-brand); font: 700 15px/1 var(--kh-font-display); }
.kh-print-btn > svg { width: 18px; height: 18px; }
.kh-print-btn:focus-visible, .kh-print-back:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-packet { max-width: 8.5in; margin: 26px auto 60px; padding: 0.7in 0.8in 0.6in; background: #ffffff; color: #1f2937;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08), 0 18px 44px -20px rgba(17, 24, 39, 0.35); font-size: 11.5pt; line-height: 1.55; }
@media (max-width: 700px) { .kh-packet { margin: 0; padding: 26px 20px 30px; } }
.kh-packet-brand { display: flex; align-items: center; gap: 14px; }
.kh-packet-crest { width: 64px; height: 64px; flex: none; }
.kh-packet-org { margin: 0; color: #111827; font: 800 15pt/1.2 var(--kh-font-display); letter-spacing: -0.01em; }
.kh-packet-tagline { margin: 2px 0 0; color: #4b5563; font-size: 10pt; font-style: italic; }
.kh-packet-kind { margin: 0 0 0 auto; padding: 4px 12px; border-radius: 999px; white-space: nowrap; color: var(--org-on-primary); background: var(--org-primary);
  font: 700 8.5pt/1.5 var(--kh-font-display); letter-spacing: 0.14em; text-transform: uppercase; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.kh-packet-rule { height: 4px; margin: 16px 0 18px; border-radius: 2px; background: linear-gradient(90deg, var(--org-primary) 0 62%, var(--org-accent) 62% 86%, var(--org-secondary) 86%);
  box-shadow: inset 0 0 0 0.5px rgba(17, 24, 39, 0.15); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.kh-packet-title { margin: 0; color: #111827; font: 800 24pt/1.12 var(--kh-font-display); letter-spacing: -0.02em; }
.kh-packet-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 18px; margin: 16px 0 0; padding: 12px 0; border-top: 1px solid #d1d5db; border-bottom: 1px solid #d1d5db; }
@media (max-width: 700px) { .kh-packet-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kh-packet-meta dt { color: #4b5563; font: 700 7.5pt/1.4 var(--kh-font-display); letter-spacing: 0.12em; text-transform: uppercase; }
.kh-packet-meta dd { margin: 1px 0 0; color: #111827; font-size: 10.5pt; font-weight: 600; }
.kh-packet-body { margin-top: 20px; color: #1f2937; }
.kh-packet-body h3 { padding-bottom: 4px; border-bottom: 1.5px solid color-mix(in srgb, var(--org-primary) 30%, #ffffff); color: #111827; }
.kh-packet-body h4 { color: var(--kh-brand); }
.kh-packet-body ul { padding-left: 1.2em; list-style: disc; }
.kh-packet-body li { margin: 0.2em 0; }
.kh-packet-body blockquote { border-left-color: var(--org-primary); background: #f6f5f1; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.kh-packet-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; padding-top: 10px; border-top: 1px solid #d1d5db; color: #4b5563; font-size: 8.5pt; }

@page { size: auto; margin: 16mm 15mm 18mm; }
@media print {
  /* Any page: the app chrome and floating widgets never reach the paper. */
  .kh-glass, [data-mobile-nav], #install-banner, .kh-dm, #feedback-fab, .kh-fb-fab, #preview-toast, dialog, .kh-toast, .kh-print-toolbar { display: none !important; }
  html, body, .kh-print-body { background: #ffffff !important; }
  .kh-packet { max-width: none; margin: 0; padding: 0; box-shadow: none; }
  /* Clean page breaks: headings stay with what follows, items don't split. */
  .kh-packet-head { break-inside: avoid; }
  .kh-packet-body h2, .kh-packet-body h3, .kh-packet-body h4 { break-after: avoid-page; page-break-after: avoid; }
  .kh-packet-body li, .kh-packet-body blockquote, .kh-packet-body p { break-inside: avoid; page-break-inside: avoid; orphans: 3; widows: 3; }
  .kh-packet-foot { break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
}

/* ---- My Profile: what each prestige tier frame looks like on your avatar ---- */
.kh-frame-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 0; padding: 14px 8px 10px; list-style: none;
  border: 1px solid var(--kh-line); border-radius: 14px; background: var(--kh-sunken); }
.kh-frame-row > li { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; text-align: center; }
.kh-frame-row > li[aria-current="true"] { background: var(--kh-card); box-shadow: 0 0 0 1.5px var(--kh-brand); }
.kh-frame-name { margin-top: 8px; color: var(--kh-ink); font: 700 12.5px/1.25 var(--kh-font-display); }
.kh-frame-pts { color: var(--kh-muted); font-size: 11.5px; }
@media (max-width: 479px) { .kh-frame-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ==== Milestone 22: seven prestige tiers, social links, smooth rollouts and
   tactile presses ====
   The avatar frames themselves (Heart, Sovereign Luminary, Eternal Crest and
   the Leadership Halo) live with the other avatar rules above. */

/* ---- My Profile: exact progress, and the whole climb to Eternal Crest ---- */
.kh-pride-scale { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; font-size: 12.5px; color: var(--kh-muted); }
.kh-pride-scale > strong { color: var(--kh-ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.kh-pride-journey { overflow-x: auto; padding: 6px 2px 4px; scrollbar-width: thin; }
.kh-pride-journey-in { position: relative; min-width: 470px; }
.kh-pride-track { position: absolute; top: 15px; left: calc(100% / 14); right: calc(100% / 14); height: 4px; border-radius: 999px;
  background: var(--kh-sunken); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--kh-ink) 9%, transparent); }
.kh-pride-track > span { display: block; width: var(--journey, 0%); height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--kh-brand), var(--kh-accent)); transition: width 0.5s var(--kh-roll); }
.kh-pride-journey ol { position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.kh-pride-journey li { display: grid; justify-items: center; align-content: start; gap: 1px; padding: 0 2px; text-align: center; }
.kh-pride-stop { display: flex; width: 34px; height: 34px; margin-bottom: 4px; align-items: center; justify-content: center; border-radius: 999px;
  background: var(--kh-card); box-shadow: inset 0 0 0 1.5px var(--kh-line); font-size: 16px; line-height: 1; filter: grayscale(1); opacity: 0.55; }
.kh-pride-journey li.is-reached .kh-pride-stop { filter: none; opacity: 1; box-shadow: inset 0 0 0 1.5px var(--kh-brand); }
.kh-pride-journey li[aria-current] .kh-pride-stop { box-shadow: inset 0 0 0 1.5px var(--kh-brand), 0 0 0 2px var(--kh-card), 0 0 0 4px var(--kh-brand); }
.kh-pride-stop-name { color: var(--kh-body); font: 700 11.5px/1.2 var(--kh-font-display); }
.kh-pride-journey li[aria-current] .kh-pride-stop-name { color: var(--kh-ink); font-weight: 800; }
.kh-pride-stop-pts { color: var(--kh-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
/* Seven frames to preview now: one row on wide screens, 4 + 3 on phones. */
.kh-frame-row { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.kh-frame-name { font-size: 12px; }
@media (max-width: 767px) { .kh-frame-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---- Social profiles: tints, the quick-card buttons, the My Profile boxes.
   Glyphs take a mode-aware hue (AA on its own faint tint in Light and Dark). */
.kh-qc-social--instagram { --soc: var(--hue-rose-fg); }
.kh-qc-social--facebook { --soc: var(--hue-blue-fg); }
.kh-qc-social--tiktok { --soc: var(--kh-ink); }
.kh-qc-social--linkedin { --soc: var(--hue-blue-fg); }
.kh-qc-social--website { --soc: var(--hue-teal-fg); }
.kh-qc-socials { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 14px 0 0; padding: 0; list-style: none; }
.kh-qc-social { display: flex; width: 58px; flex-direction: column; align-items: center; gap: 4px; padding: 4px 0 2px; border-radius: 12px;
  color: var(--kh-body); text-decoration: none; -webkit-tap-highlight-color: transparent; transition: transform 140ms ease, color 150ms ease; }
.kh-qc-social-mark { display: flex; width: 42px; height: 42px; align-items: center; justify-content: center; border-radius: 999px;
  color: var(--soc, var(--kh-accent)); background: color-mix(in srgb, var(--soc, var(--kh-accent)) 11%, var(--kh-card));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--soc, var(--kh-accent)) 30%, transparent);
  transition: transform 140ms ease, box-shadow 180ms ease, background-color 150ms ease; }
.kh-qc-social-name { font: 600 11px/1.2 var(--kh-font-display); letter-spacing: 0.01em; }
.kh-qc-social:hover { color: var(--kh-ink); }
.kh-qc-social:hover .kh-qc-social-mark { transform: translateY(-2px); background: color-mix(in srgb, var(--soc, var(--kh-accent)) 19%, var(--kh-card));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--soc, var(--kh-accent)) 50%, transparent), 0 8px 14px -9px var(--soc, var(--kh-accent)); }
.kh-qc-social:active { transform: scale(0.94); }
.kh-qc-social:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-social-field { position: relative; }
.kh-social-field > .field { padding-left: 46px; }
.kh-social-mark { position: absolute; top: 50%; left: 7px; display: flex; width: 30px; height: 30px; margin-top: -15px; align-items: center; justify-content: center;
  border-radius: 999px; color: var(--soc, var(--kh-accent)); background: color-mix(in srgb, var(--soc, var(--kh-accent)) 12%, var(--kh-card)); pointer-events: none; }

/* ---- Smooth rollouts. Everything that pops over the page eases in and back
   out with opacity + translateY + scale on one curve (--kh-roll) instead of
   appearing and vanishing in a single frame.

   Modals (Create Room / Event / Poll, the profile quick-card, the bug
   reporter, Install App ...) are <dialog>s, and the Messages drawer toggles
   [hidden]. Both leave with `display: none`, so their exit is a transition
   that carries `display` (and the top layer, `overlay`) along with
   `allow-discrete`; `@starting-style` gives the entrance its first frame.
   Browsers without those features simply show and hide as before. */
dialog { opacity: 0; transform: translateY(16px) scale(0.96);
  transition: opacity var(--kh-roll-ms) var(--kh-roll), transform var(--kh-roll-ms) var(--kh-roll),
    overlay var(--kh-roll-ms) allow-discrete, display var(--kh-roll-ms) allow-discrete; }
dialog[open] { opacity: 1; transform: none; }
@starting-style { dialog[open] { opacity: 0; transform: translateY(16px) scale(0.96); } }
dialog::backdrop { opacity: 0;
  transition: opacity var(--kh-roll-ms) ease, overlay var(--kh-roll-ms) allow-discrete, display var(--kh-roll-ms) allow-discrete; }
dialog[open]::backdrop { opacity: 1; }
@starting-style { dialog[open]::backdrop { opacity: 0; } }
/* The bug reporter grows out of its bottom-left button, the quick-card from the centre. */
.kh-fb-dialog { transform-origin: bottom left; }
@media (max-width: 639px) { dialog.kh-fb-dialog, dialog#install-sheet { transform: translateY(28px); } dialog.kh-fb-dialog[open], dialog#install-sheet[open] { transform: none; } }

/* Calendar day details (an HTML popover). */
.kh-pop { opacity: 0; transform: translateY(12px) scale(0.96);
  transition: opacity var(--kh-roll-ms) var(--kh-roll), transform var(--kh-roll-ms) var(--kh-roll),
    overlay var(--kh-roll-ms) allow-discrete, display var(--kh-roll-ms) allow-discrete; }
.kh-pop:popover-open { opacity: 1; transform: none; }
@starting-style { .kh-pop:popover-open { opacity: 0; transform: translateY(12px) scale(0.96); } }

/* Floating Messages drawer (bottom-right): rolls up out of its button. */
.kh-dm-drawer { transition: opacity 260ms var(--kh-roll), transform 260ms var(--kh-roll), display 260ms allow-discrete; }
.kh-dm-drawer[hidden] { opacity: 0; transform: translateY(18px) scale(0.96); pointer-events: none; }
@starting-style { .kh-dm-drawer:not([hidden]) { opacity: 0; transform: translateY(18px) scale(0.96); } }

/* Header dropdowns (avatar menu, alerts bell). <details> hides its panel the
   instant it closes, so app.js holds it open for the length of the exit
   (.is-closing) and then closes it. */
details[data-menu] > :not(summary) { transform-origin: top right; }
details[data-menu][open] > :not(summary) { animation: kh-roll-in 240ms var(--kh-roll) both; }
details[data-menu].is-closing > :not(summary) { animation: kh-roll-out 200ms var(--kh-roll) both; pointer-events: none; }
@keyframes kh-roll-in { from { opacity: 0; transform: translateY(-10px) scale(0.95); } }
@keyframes kh-roll-out { to { opacity: 0; transform: translateY(-8px) scale(0.96); } }
/* Small in-page popovers ride the same curve. */
.kh-emoji-pop { transform-origin: bottom right; animation: kh-dm-in 220ms var(--kh-roll); }

/* ---- Tactile presses. Every button, interactive card and action pill sinks
   a little while it's held (scale 0.97) and, on the way down, sends out one
   brief ring (app.js adds .kh-tap on pointerdown) so a tap is confirmed even
   when the page takes a moment to answer.

   The defaults sit in the lowest layer: any component with its own press or
   hover motion keeps it, and Tailwind utilities still win. */
@layer base {
  :where(button, [role="button"], summary, .btn, a.bg-brand, .kh-lift, .kh-pill-tab > span, .kh-choice-face, .kh-fb-option-face,
         a[class*="rounded-full"], label[class*="rounded-full"], [data-press]) {
    transition: transform 140ms ease, box-shadow 180ms ease; -webkit-tap-highlight-color: transparent; }
  :where(button, [role="button"], summary, .btn, a.bg-brand, .kh-pill-tab > span, .kh-choice-face, .kh-fb-option-face,
         a[class*="rounded-full"], label[class*="rounded-full"], [data-press]):where(:active):where(:not(:disabled, [aria-disabled="true"])) {
    transform: scale(0.97); }
}
/* Interactive cards lift on hover; pressed, they settle back down. */
.kh-lift:active, .group:active .kh-lift { transform: translateY(-1px) scale(0.985); box-shadow: var(--kh-shadow-card); }
.kh-pill-tab:active > span, .kh-choice:active > .kh-choice-face, .kh-fb-option:active > .kh-fb-option-face { transform: scale(0.97); }
/* The ring: an outline, so it follows each control's own corners and never
   touches layout, shadows or anything drawn inside the control. */
.kh-tap { animation: kh-tap 420ms ease-out; }
@keyframes kh-tap {
  0% { outline: 2px solid color-mix(in srgb, var(--kh-accent, #1b6ac9) 60%, transparent); outline-offset: 0; }
  100% { outline: 2px solid transparent; outline-offset: 7px; }
}
/* On a brand-coloured button the ring takes the button's colour instead. */
.kh-tap:is(.bg-brand, .kh-qc-primary, .kh-dm-fab, .kh-dm-send) { animation-name: kh-tap-brand; }
@keyframes kh-tap-brand {
  0% { outline: 2px solid color-mix(in srgb, var(--kh-brand, #6b2d8c) 65%, transparent); outline-offset: 0; }
  100% { outline: 2px solid transparent; outline-offset: 8px; }
}
@media (prefers-reduced-motion: reduce) { .kh-tap { animation: none; } }

/* ------------------------------------------------ Card Table (Milestone 24)
   A room's board: stages side by side (scrolling sideways on small screens),
   cards that slide in where they land, and a detail slide-over. The stage
   colour (--col) is only ever an accent bar or ring, never text. */
.kh-bd-progress { margin-top: 16px; padding: 16px 18px; border-radius: var(--kh-radius-card); background: var(--kh-card); box-shadow: var(--kh-shadow-card); }
.kh-bd-progress-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 15.5px; color: var(--kh-muted); }
.kh-bd-progress-line strong { font-family: var(--kh-font-display); font-size: 22px; font-weight: 800; letter-spacing: -0.01em; color: var(--kh-ink); }
.kh-bd-bar { height: 12px; margin-top: 10px; }
.kh-bd-bar > span { background: linear-gradient(90deg, var(--org-accent), color-mix(in srgb, var(--org-accent) 55%, var(--org-primary))); transition: width 0.7s var(--kh-ease); }
.kh-bd-progress.is-complete .kh-bd-bar > span { background: #22a06b; }
.kh-bd-progress-note { margin-top: 6px; font-size: 12.5px; color: var(--kh-muted); }

.kh-bd-wrap { margin-top: 16px; }
.kh-bd { display: flex; align-items: flex-start; gap: 14px; min-height: 460px; overflow-x: auto; padding: 4px 2px 18px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.kh-bd-col { position: relative; flex: 0 0 min(300px, 84vw); scroll-snap-align: start; display: flex; flex-direction: column; min-width: 0; padding: 12px 10px 10px;
  border-radius: 16px; border: 1px solid var(--kh-line); border-top: 4px solid var(--col, var(--kh-field)); background: var(--kh-sunken);
  transition: background-color 0.18s var(--kh-ease), box-shadow 0.18s var(--kh-ease); }
@media (min-width: 1180px) { .kh-bd-col { flex: 1 1 0; min-width: 240px; max-width: 360px; } }
.kh-bd-col.is-over { background: color-mix(in srgb, var(--col) 9%, var(--kh-sunken)); box-shadow: 0 0 0 2px var(--col); }
.kh-bd-col-head { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.kh-bd-col-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--kh-font-display); font-size: 15.5px; font-weight: 800; letter-spacing: -0.005em; color: var(--kh-ink); }
.kh-bd-done-mark { flex: none; font-size: 13px; font-weight: 800; color: var(--hue-green-fg); }
.kh-bd-count { flex: none; margin-left: auto; min-width: 26px; height: 22px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px;
  background: color-mix(in srgb, var(--col) 16%, var(--kh-card)); color: var(--kh-ink); font-family: var(--kh-font-display); font-size: 12.5px; font-weight: 800; }
.kh-bd-col-menu { flex: none; }
.kh-bd-col-menu > summary { display: flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 999px; color: var(--kh-muted); cursor: pointer; list-style: none; }
.kh-bd-col-menu > summary::-webkit-details-marker, .kh-bd-col-new summary::-webkit-details-marker { display: none; }
.kh-bd-col-menu > summary:hover, .kh-bd-col-menu[open] > summary { background: color-mix(in srgb, var(--kh-ink) 8%, transparent); color: var(--kh-ink); }
.kh-bd-col-menu > .kh-bd-col-form { position: absolute; top: 46px; right: 8px; z-index: 30; width: min(250px, calc(100% - 16px)); padding: 14px; border-radius: 14px; background: var(--kh-card); box-shadow: var(--kh-shadow-lift); }
.kh-bd-label { display: block; margin-bottom: 4px; font-family: var(--kh-font-display); font-size: 13.5px; font-weight: 600; color: var(--kh-ink); }
.kh-bd-swatches { display: flex; flex-wrap: wrap; gap: 9px; padding: 3px; }
.kh-bd-swatches label { cursor: pointer; }
.kh-bd-swatches label > span { display: block; width: 24px; height: 24px; border-radius: 999px; transition: transform 0.15s var(--kh-ease); }
.kh-bd-swatches input:checked + span { box-shadow: 0 0 0 2px var(--kh-card), 0 0 0 4px var(--kh-ink); }
.kh-bd-swatches input:focus-visible + span { outline: 2px solid var(--kh-accent); outline-offset: 5px; }
.kh-bd-swatches label:hover > span { transform: scale(1.1); }

.kh-bd-cards { display: grid; gap: 8px; min-height: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.kh-bd-card { position: relative; padding: 10px 10px 8px; border-radius: 12px; background: var(--kh-card); box-shadow: 0 0 0 1px var(--kh-line), 0 1px 2px rgba(17, 24, 39, 0.05);
  cursor: grab; transition: transform 0.2s var(--kh-ease), box-shadow 0.2s var(--kh-ease), opacity 0.2s var(--kh-ease); }
.kh-bd-card:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px var(--kh-field), 0 8px 18px -10px rgba(17, 24, 39, 0.3); }
.kh-bd-card:active { cursor: grabbing; }
.kh-bd-card.is-dragging { opacity: 0.35; transform: scale(0.98); }
.kh-bd-card-in { animation: kh-bd-in 0.42s var(--kh-roll) both; }
@keyframes kh-bd-in { from { opacity: 0; transform: translateY(-12px) scale(0.95); } to { opacity: 1; transform: none; } }
.kh-bd-card-open { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; color: var(--kh-ink); cursor: pointer; border-radius: 6px; }
.kh-bd-card-open:hover .kh-bd-card-title { color: var(--kh-brand); }
.kh-bd-card-open:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 3px; }
.kh-bd-card-title { display: block; font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; transition: color 0.15s; }
.kh-bd-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.kh-bd-steps { background: var(--hue-neutral-bg); color: var(--hue-neutral-fg); font-family: var(--kh-font-display); }
.kh-bd-steps.is-complete { background: var(--hue-green-bg); color: var(--hue-green-fg); }
.kh-bd-note-mark { display: inline-flex; color: var(--kh-muted); }
.kh-bd-assignee { margin-left: auto; display: inline-flex; }
.kh-bd-assignee > span:first-child { display: flex; width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 999px; color: #fff; font-family: var(--kh-font-display); font-size: 9.5px; font-weight: 700; }
.kh-bd-moves { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 7px; border-top: 1px solid color-mix(in srgb, var(--kh-line) 70%, transparent); }
.kh-bd-move { display: inline-flex; width: 46px; height: 34px; align-items: center; justify-content: center; border-radius: 999px; border: 1px solid var(--kh-line); background: var(--kh-card);
  color: var(--kh-body); font-size: 17px; line-height: 1; cursor: pointer; transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.15s var(--kh-ease); }
.kh-bd-move:hover { border-color: var(--kh-brand); background: color-mix(in srgb, var(--kh-brand) 10%, var(--kh-card)); color: var(--kh-ink); }
.kh-bd-move:active { transform: scale(0.94); }
.kh-bd-move:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-bd-marker { height: 46px; border-radius: 12px; border: 2px dashed var(--col); background: color-mix(in srgb, var(--col) 10%, transparent); list-style: none; pointer-events: none; }
.kh-bd-empty { margin-top: 2px; padding: 12px 10px; border-radius: 12px; border: 1px dashed var(--kh-field); text-align: center; font-size: 13.5px; color: var(--kh-muted); }
.kh-bd-add { display: flex; gap: 6px; margin-top: 10px; }
.kh-bd-add-input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px dashed var(--kh-field); background: var(--kh-card); color: var(--kh-ink); font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s; }
.kh-bd-add-input::placeholder { color: var(--kh-placeholder); font-weight: 600; }
.kh-bd-add-input:focus { outline: none; border-style: solid; border-color: var(--accent-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 22%, transparent); }
.kh-bd-add-btn { display: inline-flex; flex: none; width: 40px; height: 40px; align-items: center; justify-content: center; border-radius: 10px; background: var(--kh-brand); color: var(--kh-on-brand); cursor: pointer; }
.kh-bd-col-new { border-style: dashed; border-top: 1px dashed var(--kh-field); border-color: var(--kh-field); background: transparent; }
.kh-bd-col-new summary { display: flex; align-items: center; gap: 6px; min-height: 30px; font-family: var(--kh-font-display); font-size: 15px; font-weight: 700; color: var(--kh-ink); cursor: pointer; list-style: none; }
.kh-bd-col-new .kh-bd-col-form { margin-top: 10px; }
.kh-bd-award { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; padding: 7px 14px; border-radius: 999px; background: var(--hue-green-bg); color: var(--hue-green-fg); font-size: 14.5px;
  animation: kh-bd-in 0.42s var(--kh-roll) both; }
.kh-bd-stage-dot { display: inline-block; width: 10px; height: 10px; border-radius: 999px; }
.kh-bd-step-x { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 999px; color: var(--kh-muted); font-size: 20px; line-height: 1; cursor: pointer; }
.kh-bd-step-x:hover { background: var(--hue-red-bg); color: var(--hue-red-fg); }

/* The card detail slide-over: in from the right edge, full height. */
dialog.kh-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(480px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; padding: 0; border: 0;
  overflow-y: auto; border-radius: 20px 0 0 20px; box-shadow: var(--kh-shadow-lift); opacity: 1; transform: translateX(100%); }
dialog.kh-drawer[open] { transform: none; }
@starting-style { dialog.kh-drawer[open] { opacity: 1; transform: translateX(100%); } }
dialog.kh-drawer::backdrop { background: rgba(17, 24, 39, 0.45); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
@media (max-width: 520px) { dialog.kh-drawer { border-radius: 0; } }
.kh-drawer-inner { padding: 20px 20px calc(30px + env(safe-area-inset-bottom)); }
.kh-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.kh-drawer-close { flex: none; width: 38px; height: 38px; border-radius: 999px; color: var(--kh-muted); font-size: 26px; line-height: 1; cursor: pointer; transition: background-color 0.15s; }
.kh-drawer-close:hover { background: color-mix(in srgb, var(--kh-ink) 8%, transparent); color: var(--kh-ink); }

@media (prefers-reduced-motion: reduce) {
  .kh-bd-card-in, .kh-bd-award { animation: none; }
  .kh-bd-card, .kh-bd-bar > span, dialog.kh-drawer { transition: none; }
}

/* ------------------------------------------------ Chapter Media & Photo Vault (Milestone 24) */
.kh-vault-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; margin: 14px 0 0; padding: 0; list-style: none; }
@media (min-width: 640px) { .kh-vault-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); } }
.kh-vault-tile { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border-radius: 14px; background: var(--kh-card); box-shadow: var(--kh-shadow-card); }
.kh-vault-thumb { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 0; overflow: hidden; background: var(--kh-sunken); cursor: zoom-in; }
.kh-vault-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s var(--kh-ease); }
.kh-vault-thumb:hover img { transform: scale(1.04); }
.kh-vault-thumb:focus-visible { outline: 3px solid var(--kh-accent); outline-offset: -3px; }
.kh-vault-noview { display: flex; width: 100%; height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--kh-muted); font-size: 13px; cursor: default; }
.kh-vault-meta { display: grid; gap: 5px; padding: 10px 12px 12px; min-width: 0; }
.kh-vault-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; color: var(--kh-ink); }
.kh-vault-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--kh-muted); }
.kh-vault-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; line-height: 1.4; color: var(--kh-body); }
.kh-vault-dl { display: inline-flex; height: 34px; align-items: center; justify-content: center; gap: 6px; margin-top: 3px; border-radius: 999px; border: 1px solid var(--kh-line); background: var(--kh-card);
  color: var(--kh-ink); font-family: var(--kh-font-display); font-size: 13.5px; font-weight: 700; text-decoration: none; transition: border-color 0.15s, background-color 0.15s; }
.kh-vault-dl:hover { border-color: var(--kh-brand); background: color-mix(in srgb, var(--kh-brand) 8%, var(--kh-card)); }
dialog.kh-lightbox { width: min(1100px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); margin: auto; padding: 0; border: 0; border-radius: 18px; overflow: hidden; box-shadow: var(--kh-shadow-lift); }
dialog.kh-lightbox::backdrop { background: rgba(8, 10, 18, 0.78); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.kh-lightbox-stage { display: flex; align-items: center; justify-content: center; min-height: 160px; background: #0b0f19; }
.kh-lightbox-stage img { display: block; max-width: 100%; max-height: calc(100dvh - 170px); object-fit: contain; }
.kh-lightbox-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; }
@media print { dialog.kh-drawer, dialog.kh-lightbox { display: none !important; } }

/* ---- Platform system notice (Milestone 25): a slim, dismissible strip above
   the header of every signed-in page. Colours are the shared hue pairs, so
   the text reads at AA in light and dark. ---- */
#platform-banner:empty { display: none; }
.kh-platform-banner { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px 8px 15px; color: var(--banner-fg); background: var(--banner-bg);
  border-bottom: 1px solid color-mix(in srgb, var(--banner-fg) 22%, transparent); font-size: 14.5px; line-height: 1.45; }
.dark .kh-platform-banner { background: color-mix(in srgb, var(--banner-fg) 14%, var(--kh-canvas)); }
.kh-platform-banner-text { flex: 1; min-width: 0; margin: 0 auto; max-width: 1100px; text-align: center; overflow-wrap: anywhere; }
.kh-platform-banner-text strong { font-weight: 700; }
.kh-platform-banner-x { flex: none; width: 28px; height: 28px; border-radius: 999px; font-size: 20px; line-height: 1; color: inherit; cursor: pointer; }
.kh-platform-banner-x:hover { background: color-mix(in srgb, var(--banner-fg) 16%, transparent); }
.kh-platform-banner-x:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }

/* ---- Compliance Tracker (Milestone 25): requirements down, chapters across.
   The requirement column stays put while the chapters scroll sideways. ---- */
.kh-cmp-wrap { overflow-x: auto; border: 1px solid var(--kh-line); border-radius: 14px; }
.kh-cmp { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14.5px; }
.kh-cmp th, .kh-cmp td { padding: 11px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--kh-line); color: var(--kh-body); }
.kh-cmp thead th { background: var(--kh-sunken); color: var(--kh-muted); font: 700 12px/1.3 var(--kh-font-display); letter-spacing: 0.06em; text-transform: uppercase; vertical-align: bottom; }
.kh-cmp tbody tr:last-child > * { border-bottom: 0; }
.kh-cmp tfoot > tr > * { background: var(--kh-sunken); border-top: 1px solid var(--kh-line); border-bottom: 0; vertical-align: middle; }
.kh-cmp .kh-cmp-req { position: sticky; left: 0; z-index: 1; min-width: 230px; max-width: 340px; font-weight: 400; background: var(--kh-card); box-shadow: 1px 0 0 var(--kh-line); }
.kh-cmp thead .kh-cmp-req, .kh-cmp tfoot .kh-cmp-req { background: var(--kh-sunken); }
.kh-cmp .kh-cmp-chapter, .kh-cmp .kh-cmp-cell { min-width: 112px; text-align: center; }
.kh-cmp .kh-cmp-num { text-align: right; white-space: nowrap; vertical-align: middle; }
.kh-cmp-box { display: flex; flex-direction: column; align-items: center; gap: 4px; transition: opacity 0.15s; }
.kh-cmp-box.htmx-request { opacity: 0.55; }
.kh-cmp-check { position: relative; display: inline-flex; cursor: pointer; }
.kh-cmp-check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.kh-cmp-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--kh-muted); background: var(--kh-field-bg);
  color: transparent; transition: background 0.15s, border-color 0.15s, transform 0.15s; }
.kh-cmp-mark svg { width: 18px; height: 18px; }
.kh-cmp-check:hover .kh-cmp-mark { border-color: var(--kh-ink); }
.kh-cmp-check input:checked + .kh-cmp-mark { background: #17794d; border-color: #17794d; color: #ffffff; }
.dark .kh-cmp-check input:checked + .kh-cmp-mark { background: #34d399; border-color: #34d399; color: #052e1c; }
.kh-cmp-check input:active + .kh-cmp-mark { transform: scale(0.92); }
.kh-cmp-check input:focus-visible + .kh-cmp-mark { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-cmp-who { max-width: 118px; font-size: 11.5px; line-height: 1.25; color: var(--kh-muted); text-align: center; }
.kh-cmp-save { font-size: 12.5px; font-weight: 600; color: var(--kh-accent); text-decoration: underline; cursor: pointer; }
.kh-cmp-count { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font: 700 13px/1 var(--kh-font-display);
  font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--hue-neutral-fg); background: var(--hue-neutral-bg); }
.kh-cmp-count.is-complete { color: var(--hue-green-fg); background: var(--hue-green-bg); }
@media (max-width: 719px) {
  /* Phones: each requirement becomes a card, each chapter a labelled row. */
  .kh-cmp-wrap { border: 0; overflow: visible; }
  .kh-cmp thead, .kh-cmp tfoot { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .kh-cmp, .kh-cmp tbody, .kh-cmp tr, .kh-cmp th, .kh-cmp td { display: block; }
  .kh-cmp tbody tr { margin-bottom: 12px; padding: 6px 0; border: 1px solid var(--kh-line); border-radius: 14px; }
  .kh-cmp tbody th, .kh-cmp tbody td { border-bottom: 0; padding: 6px 14px; }
  .kh-cmp .kh-cmp-req { position: static; max-width: none; box-shadow: none; background: transparent; }
  .kh-cmp tbody .kh-cmp-cell, .kh-cmp tbody .kh-cmp-num { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; text-align: right; }
  .kh-cmp tbody .kh-cmp-cell::before { content: attr(data-label); flex: 1; min-width: 0; text-align: left; font-weight: 600; color: var(--kh-ink); }
  .kh-cmp tbody .kh-cmp-num::before { content: "Chapters done"; color: var(--kh-muted); font-size: 13px; }
  .kh-cmp-box { flex-direction: row-reverse; }
  .kh-cmp-who { max-width: 150px; text-align: right; }
}

/* ---- Member Terminology Label pills (Milestone 25): Brand Studio and the
   Provision dialog. The chosen one is filled with the brand colour, and its
   text is the contrast-checked "on brand" colour in both modes. ---- */
.kh-term-pill { display: inline-flex; align-items: center; height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--kh-line);
  background: var(--kh-card); color: var(--kh-body); font: 600 14.5px/1 var(--kh-font-display); cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s; }
.kh-term-pill:hover { border-color: var(--kh-field); color: var(--kh-ink); }
.kh-term-pill[aria-pressed="true"] { background: var(--kh-brand); border-color: var(--kh-brand); color: var(--kh-on-brand); }
.kh-term-pill:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }

/* ==== Milestone 26 ========================================================
   Every colour below is a design token (or a mix of tokens), so light and
   dark mode both come from the same rules, and brand colours are the
   contrast-guarded --kh-brand / --kh-accent, never the raw organization hex. */

/* ---- Ops Hub: the executive tool banner at the top of /recaps ---- */
.kh-exec { position: relative; overflow: hidden; padding: 18px; border-radius: 22px; box-shadow: var(--kh-shadow-lift);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--kh-brand) 13%, transparent), transparent 58%),
    radial-gradient(120% 140% at 100% 100%, color-mix(in srgb, var(--kh-accent) 11%, transparent), transparent 55%),
    var(--kh-card); }
.kh-exec::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--kh-brand), var(--kh-accent)); }
.kh-exec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 14px; margin-bottom: 12px; }
.kh-exec-eyebrow { font: 800 13px/1.2 var(--kh-font-display); letter-spacing: 0.16em; text-transform: uppercase; color: var(--kh-brand); }
.kh-exec-note { font-size: 13.5px; color: var(--kh-muted); }
.kh-exec-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(214px, 1fr)); }
.kh-exec-tool { position: relative; display: flex; align-items: center; gap: 13px; min-height: 78px; padding: 13px 15px; border-radius: 16px;
  border: 1px solid var(--kh-line); background: var(--kh-card-raised); color: var(--kh-ink); text-decoration: none;
  transition: transform 0.18s var(--kh-ease, ease), border-color 0.18s, box-shadow 0.18s; }
.kh-exec-tool:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--kh-brand) 45%, var(--kh-line)); box-shadow: var(--kh-shadow-card); }
.kh-exec-tool:active { transform: scale(0.985); }
.kh-exec-tool:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-exec-icon { display: flex; flex-shrink: 0; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 14px;
  color: var(--kh-brand); background: color-mix(in srgb, var(--kh-brand) 12%, var(--kh-card)); transition: background 0.18s, color 0.18s; }
.kh-exec-icon svg { width: 25px; height: 25px; }
.kh-exec-text { display: block; min-width: 0; }
.kh-exec-title { display: block; font: 800 16.5px/1.22 var(--kh-font-display); letter-spacing: -0.01em; color: var(--kh-ink); }
.kh-exec-sub { display: block; margin-top: 3px; font-size: 13px; line-height: 1.35; color: var(--kh-muted); }
/* The open tool: a brand outline, a filled icon and a gradient underline. */
.kh-exec-tool[aria-selected="true"] { border-color: var(--kh-brand); box-shadow: 0 0 0 1px var(--kh-brand), var(--kh-shadow-card); }
.kh-exec-tool[aria-selected="true"] .kh-exec-icon { background: var(--kh-brand); color: var(--kh-on-brand); }
.kh-exec-tool[aria-selected="true"]::after { content: ""; position: absolute; left: 16px; right: 16px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, var(--kh-brand), var(--kh-accent)); }
@media (max-width: 520px) {
  .kh-exec { padding: 14px; border-radius: 18px; }
  .kh-exec-grid { grid-template-columns: 1fr; }
  .kh-exec-tool { min-height: 66px; }
}
@media (prefers-reduced-motion: reduce) { .kh-exec-tool { transition: none; } .kh-exec-tool:hover { transform: none; } }

/* ---- Treasury: Platform Plan & Billing ---- */
.kh-plan-now { position: relative; overflow: hidden; }
.kh-plan-now::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--kh-brand), var(--kh-accent)); }
.kh-plan-save { display: inline-block; margin-left: 2px; padding: 1px 8px; border-radius: 999px; font: 700 12px/1.5 var(--kh-font-display);
  color: var(--hue-green-fg); background: var(--hue-green-bg); }
.kh-plans { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(226px, 1fr)); margin: 0; padding: 0; list-style: none; }
.kh-plan { position: relative; display: flex; flex-direction: column; padding: 20px 18px 18px; border-radius: 18px; border: 1px solid var(--kh-line);
  background: var(--kh-card); box-shadow: var(--kh-shadow-card); }
.kh-plan.is-popular { border-color: var(--kh-brand); box-shadow: 0 0 0 1px var(--kh-brand), var(--kh-shadow-lift);
  background: linear-gradient(180deg, color-mix(in srgb, var(--kh-brand) 7%, var(--kh-card)), var(--kh-card) 46%); }
.kh-plan-flag { position: absolute; top: -12px; left: 16px; padding: 3px 12px; border-radius: 999px; font: 800 12px/1.5 var(--kh-font-display);
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--kh-on-brand); background: var(--kh-brand); }
.kh-plan.is-current:not(.is-popular) { border-color: var(--hue-green-line, var(--kh-field)); }
.kh-plan-current { display: flex; height: 42px; align-items: center; justify-content: center; border-radius: 999px; font: 700 14.5px/1 var(--kh-font-display);
  color: var(--hue-green-fg); background: var(--hue-green-bg); }
/* Monthly | Annual: the section's data-plan-cycle picks which prices show. */
[data-plan-cycle="monthly"] .kh-price-annual, [data-plan-cycle="annual"] .kh-price-monthly { display: none; }

.kh-compare-wrap { overflow-x: auto; border: 1px solid var(--kh-line); border-radius: 16px; background: var(--kh-card); box-shadow: var(--kh-shadow-card); }
.kh-compare { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 14.5px; }
.kh-compare th, .kh-compare td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--kh-line); color: var(--kh-body); }
.kh-compare tbody tr:last-child th, .kh-compare tbody tr:last-child td { border-bottom: 0; }
.kh-compare thead th { font: 800 14px/1.3 var(--kh-font-display); color: var(--kh-ink); background: var(--kh-sunken); }
.kh-compare tbody th { width: 30%; font: 700 14.5px/1.35 var(--kh-font-display); color: var(--kh-ink); }
.kh-compare .is-ours { background: color-mix(in srgb, var(--kh-brand) 7%, var(--kh-card)); }
.kh-compare thead .is-ours { color: var(--kh-brand); background: color-mix(in srgb, var(--kh-brand) 12%, var(--kh-card)); }
.kh-compare-price { display: block; font: 800 19px/1.2 var(--kh-font-display); font-variant-numeric: tabular-nums; color: var(--kh-ink); }
.kh-compare-save { display: inline-block; margin-top: 5px; padding: 2px 9px; border-radius: 10px; font-size: 12.5px; font-weight: 700; line-height: 1.4;
  color: var(--hue-green-fg); background: var(--hue-green-bg); }
.kh-compare-yes { font-weight: 700; color: var(--hue-green-fg); }
.kh-compare-no { color: var(--kh-muted); }

/* ---- First-Run Setup Wizard ---- */
.kh-wizard-rail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.kh-wizard-link { display: flex; align-items: center; gap: 10px; height: 100%; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--kh-line);
  background: var(--kh-card); color: var(--kh-ink); text-decoration: none; transition: border-color 0.15s; }
.kh-wizard-link:hover { border-color: var(--kh-field); }
.kh-wizard-link:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-wizard-num { display: flex; flex-shrink: 0; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 999px;
  font: 800 14px/1 var(--kh-font-display); color: var(--kh-muted); background: var(--kh-sunken); }
.kh-wizard-step[data-state="current"] .kh-wizard-link { border-color: var(--kh-brand); box-shadow: 0 0 0 1px var(--kh-brand); }
.kh-wizard-step[data-state="current"] .kh-wizard-num { color: var(--kh-on-brand); background: var(--kh-brand); }
.kh-wizard-step[data-state="done"] .kh-wizard-num { color: var(--hue-green-fg); background: var(--hue-green-bg); }
.kh-wizard-palette { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 13px 0 8px; border-radius: 999px; border: 1px solid var(--kh-line);
  background: var(--kh-card); color: var(--kh-body); font: 600 13.5px/1 var(--kh-font-display); cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.kh-wizard-palette:hover { border-color: var(--kh-field); color: var(--kh-ink); }
.kh-wizard-palette[aria-pressed="true"] { border-color: var(--kh-brand); box-shadow: 0 0 0 1px var(--kh-brand); color: var(--kh-ink); }
.kh-wizard-palette:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-wizard-swatches { display: inline-flex; }
.kh-wizard-swatches i { width: 16px; height: 16px; margin-left: -4px; border-radius: 999px; border: 1.5px solid var(--kh-card); box-shadow: 0 0 0 1px var(--kh-line); }
.kh-wizard-swatches i:first-child { margin-left: 0; }
.kh-wizard-choice { display: block; cursor: pointer; }
.kh-wizard-choice-face { display: block; height: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--kh-line); background: var(--kh-card);
  transition: border-color 0.15s, box-shadow 0.15s; }
.kh-wizard-choice:hover .kh-wizard-choice-face { border-color: var(--kh-field); }
.kh-wizard-choice .peer:checked + .kh-wizard-choice-face { border-color: var(--kh-brand); box-shadow: 0 0 0 1px var(--kh-brand);
  background: color-mix(in srgb, var(--kh-brand) 7%, var(--kh-card)); }
.kh-wizard-choice .peer:focus-visible + .kh-wizard-choice-face { outline: 2px solid var(--kh-accent); outline-offset: 2px; }

/* ---- Dashboard: "Subscribe to Live Calendar" ---- */
.kh-subscribe-btn { display: inline-flex; height: 42px; align-items: center; gap: 7px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--kh-brand);
  background: var(--kh-card); color: var(--kh-brand); font: 700 14.5px/1 var(--kh-font-display); cursor: pointer; transition: background 0.15s; }
.kh-subscribe-btn:hover { background: color-mix(in srgb, var(--kh-brand) 9%, var(--kh-card)); }
.kh-subscribe-btn:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; }
.kh-subscribe-btn svg { width: 18px; height: 18px; }

/* ---- "Give the Developer a Kudos" (Milestone 27) --------------------------
   The warm panel in the Feedback window and the highlight card on /dev. Amber
   text on the amber wash is 7:1 in light mode and 9:1 in dark mode. */
.kh-kudos { margin-top: 14px; padding: 13px 14px 12px; border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--hue-amber-fg) 26%, transparent);
  background: linear-gradient(135deg, var(--hue-amber-bg) 0%, var(--hue-rose-bg) 100%), var(--kh-card); }
.kh-kudos-text { font-size: 14px; line-height: 1.4; color: var(--kh-body); }
.kh-kudos-text strong { font-family: var(--kh-font-display); font-weight: 800; color: var(--kh-ink); }
.kh-kudos-btn { display: flex; width: 100%; min-height: 46px; margin-top: 10px; padding: 8px 16px; align-items: center; justify-content: center; gap: 7px;
  border-radius: 999px; background: var(--hue-amber-fg); color: var(--kh-card);
  font-family: var(--kh-font-display); font-size: 15.5px; font-weight: 800; text-align: center;
  box-shadow: 0 8px 18px -10px var(--hue-amber-fg); transition: transform 0.18s var(--kh-ease), filter 0.18s; }
.kh-kudos-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.kh-kudos-btn:active { transform: scale(0.97); }
.kh-kudos-btn:focus-visible { outline: 3px solid var(--kh-accent); outline-offset: 3px; }
.kh-kudos-btn:disabled { opacity: 0.7; cursor: progress; }
.kh-kudos-btn > span { font-size: 19px; }
.kh-kudos-note { margin-top: 8px; }
.kh-kudos-note > summary { display: inline-block; cursor: pointer; padding: 3px 0; font-size: 13.5px; font-weight: 700; color: var(--hue-amber-fg);
  text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--hue-amber-fg) 45%, transparent); text-underline-offset: 3px; list-style: none; }
.kh-kudos-note > summary::-webkit-details-marker { display: none; }
.kh-kudos-note > summary:focus-visible { outline: 2px solid var(--kh-accent); outline-offset: 2px; border-radius: 4px; }
.kh-fb-or { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--kh-muted); }
.kh-fb-or::before, .kh-fb-or::after { content: ""; flex: 1; height: 1px; background: var(--kh-line); }
.kh-kudos-quote { padding: 9px 13px; border-left: 4px solid var(--hue-amber-fg); border-radius: 0 12px 12px 0; background: var(--hue-amber-bg);
  font-size: 15.5px; line-height: 1.5; color: var(--kh-ink); white-space: pre-line; }
.kh-kudos-stat { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-radius: 20px; color: var(--kh-ink); text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--hue-amber-fg) 26%, transparent);
  background: linear-gradient(135deg, var(--hue-amber-bg) 0%, var(--hue-rose-bg) 100%), var(--kh-card);
  box-shadow: var(--kh-shadow-card); transition: transform 0.18s var(--kh-ease); }
.kh-kudos-stat:hover { transform: translateY(-2px); }
.kh-kudos-stat:focus-visible { outline: 3px solid var(--kh-accent); outline-offset: 3px; }
.kh-kudos-stat-mark { display: flex; width: 54px; height: 54px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 16px;
  font-size: 28px; background: var(--kh-card); box-shadow: 0 1px 3px rgba(17, 24, 39, 0.12); }
.kh-kudos-stat-label { display: block; font-family: var(--kh-font-display); font-size: 18px; font-weight: 800; line-height: 1.25; }
.kh-kudos-stat-detail { display: block; margin-top: 2px; font-size: 14px; line-height: 1.4; color: var(--kh-body); }
.kh-kudos-stat-num { flex-shrink: 0; font-family: var(--kh-font-display); font-size: 44px; font-weight: 800; line-height: 1; color: var(--hue-amber-fg); font-variant-numeric: tabular-nums; }
@media (max-width: 479px) { .kh-kudos-stat { padding: 14px; gap: 11px; } .kh-kudos-stat-mark { width: 44px; height: 44px; font-size: 23px; } .kh-kudos-stat-num { font-size: 36px; } }
@media print { .kh-kudos, .kh-kudos-stat { display: none !important; } }
