/* ─────────────────────────────────────────────────────────────
   HDRM — "Dead Wax" brand (HDRM_4_Concepts_Refined_Brand_Boards, #02)
   Palette (the approved logo's values, HDRM_Dead_Wax_Typography_Kit):
            Night #0A0A0A · Wax #F4E7C6 · Charcoal #1F1F1F · Copper #C67F56 ·
            Signal #00E5D4 · Orange #FF8A3C
   Type:    Inter (headlines/body) · JetBrains Mono (labels/data).
   Dark ("Night") is the default; light is "Wax" — cream paper.
   Every page reads these tokens, so this block restyles the app.
   ───────────────────────────────────────────────────────────── */

/* Brand fonts (approved with the Dead Wax identity): Inter (headlines + body; the logo's HDRM
   is Inter Display Black, outlined) and JetBrains Mono (labels, data, technical text). Both free
   and open source; loaded from Google Fonts in each page head. HEADROOM's width-matched treatment
   lives in the logo artwork, not in CSS. */

:root {
  /* Brand colors (constant in both themes) */
  --night:  #0A0A0A;
  --wax:    #F4E7C6;
  --charcoal: #1F1F1F;
  --copper: #C67F56;
  --signal: #00E5D4;
  --orange: #FF8A3C;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Light = "Wax": cream paper, night ink. Contrast ≥4.5:1 for text roles. */
  --bg:        #F4E7C6;
  --surface:   #FAF2DC;
  --surface-2: #E8D9B0;
  --border:    rgba(10, 10, 10, 0.12);
  --text:      #0A0A0A;
  --muted:     #4A4130;
  --faint:     #5C513C;
  --accent:    #0B6862;   /* Signal, deepened for cream: 5.3:1 on bg, 6.0 on surface */
  --accent-strong: #08524D;
  --on-accent: #ffffff;
  --up:        #0B6862;
  --down:      #A33F15;   /* rust — "less", never the brand orange: ≥4.7:1 */
  --warn:      #8A4A26;   /* Copper, deepened */
  --copper-text: #8A4A26; /* copper as TEXT (eyebrows, ranks) at AA on cream */
  --card-shadow: 0 1px 0 rgba(11,11,11,.04), 0 6px 18px -10px rgba(60,40,20,.18);

  /* Type scale (5 steps — every inline font-size maps to one of these) */
  --fs-2xs: 11px;
  --fs-xs:  12px;
  --fs-sm:  13px;
  --fs-md:  14px;
  --fs-lg:  16px;
  --fs-xl:  22px;
  --fs-h1:  clamp(32px, 3.2vw, 42px);   /* kit: H1 42px desktop / 32px mobile */

  /* Shape & space */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --tap: 40px;            /* minimum touch target */

  /* Sidebar is Night in BOTH themes (brand board "Platform UI"). */
  --sidebar:       #0A0A0A;
  --sidebar-text:  #F4E7C6;
  --sidebar-muted: #A0967E;
}

html.dark {
  --bg:        #0A0A0A;   /* Night */
  --surface:   #141311;
  --surface-2: #1F1F1F;   /* Record Charcoal */
  --border:    rgba(244, 231, 198, 0.09);
  --text:      #F4E7C6;   /* Wax */
  --muted:     #BDB296;
  --faint:     #978D77;   /* ≥4.5:1 on --surface */
  --accent:    #00E5D4;   /* Signal */
  --accent-strong: #5CF0E4;
  --on-accent: #0A0A0A;
  --up:        #00E5D4;
  --down:      #E8664A;   /* rust — "less"; the brand Orange is kept for "hot" */
  --warn:      #C67F56;   /* Copper */
  --copper-text: #C67F56;
  --card-shadow: none;
}

body {
  -webkit-font-smoothing: antialiased;
  font-family: var(--font-sans);
  color: var(--text);
  transition: background-color .3s ease, color .3s ease;
}

/* Headlines: Inter ExtraBold with its Display optical size, tight. */
#sidebar .font-bold,
h1, h2 {
  font-family: var(--font-sans);
  font-weight: 800;
  font-optical-sizing: auto;
  letter-spacing: -0.03em;
}

/* Labels & data captions: JetBrains Mono, uppercase, wide — "TACTILE / CULTURAL / CURIOUS". */
.k-label, th, .text-xs.uppercase:not(h1):not(h2):not(h3), .text-\[10px\].uppercase, .text-\[11px\].uppercase {
  font-family: var(--font-mono);
  letter-spacing: 0.08em;   /* kit: metadata +0.08em */
}
.k-label { font-size: 11px; font-weight: 500; text-transform: uppercase; color: var(--faint); }

/* Wordmark: HDRM + spaced HEADROOM under it. */
.hdrm-mark { display: inline-flex; align-items: center; gap: 10px; color: var(--sidebar-text); text-decoration: none; }
.hdrm-mark .word { font-family: var(--font-sans); font-weight: 700; font-size: 19px; letter-spacing: 0.06em; line-height: 1; }
.hdrm-mark .sub  { display: block; font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.42em; color: var(--sidebar-muted); margin-top: 4px; }
.hdrm-symbol { flex: none; }

/* ── Sidebar (modernized, themed in both modes) ───────────────── */
#sidebar {
  background: var(--sidebar) !important;
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
#sidebar .border-b,
#sidebar .border-t { border-color: rgba(255, 255, 255, 0.07) !important; }
#sidebar-nav .nav-link,
#sidebar a {
  color: var(--sidebar-muted);
  border-radius: 10px;
  transition: background-color .15s ease, color .15s ease;
}
#sidebar-nav .nav-link:hover,
#sidebar a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
/* Active link (JS adds bg-gray-700) → accent treatment */
#sidebar-nav .nav-link.bg-gray-700 {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 16%, transparent), transparent) !important;
  color: #fff !important;
  box-shadow: inset 2px 0 0 var(--accent);
}

/* ── Dark theme: remap the utility classes the app actually uses ──
   Selector specificity (html.dark .x = 0,1,2) beats a bare utility
   (0,1,0) and a hover variant (0,2,0) without !important, so base
   surfaces flip while non-color hover behaviour is untouched. */
/* Page containers = base bg. Qualified with .bg-white so these beat the
   generic .bg-white → surface remap below (both carry bg-white). */
html.dark body.bg-white { background: var(--bg); color: var(--text); }
html.dark main.bg-white { background: var(--bg); }

/* Surfaces / cards sit on the base bg */
html.dark .bg-white,
html.dark .bg-gray-50,
html.dark .bg-gray-100 { background-color: var(--surface); }

/* Text ramp */
html.dark .text-gray-900,
html.dark .text-gray-800 { color: var(--text); }
html.dark .text-gray-700,
html.dark .text-gray-600 { color: #b6c2d0; }
html.dark .text-gray-500 { color: var(--muted); }
html.dark .text-gray-400 { color: var(--faint); }
/* Dark indigo text (AI Insights header + body) is invisible on the dark card —
   lift it to readable. Kept off .text-indigo-700 (avatar initials on a light
   chip) and the already-light 300/400 label shades. */
html.dark .text-indigo-950,
html.dark .text-indigo-900 { color: var(--text); }
html.dark .text-indigo-800 { color: #c7d2fe; }

/* Borders */
html.dark .border-gray-50,
html.dark .border-gray-100,
html.dark .border-gray-200,
html.dark .border-gray-300 { border-color: var(--border); }

/* Brighten status colors for legibility on dark surfaces */
html.dark .text-green-700,
html.dark .text-green-600,
html.dark .text-green-500 { color: #34d399; }
html.dark .text-red-600,
html.dark .text-red-500 { color: #f87171; }
html.dark .text-yellow-700,
html.dark .text-yellow-600 { color: #fbbf24; }

/* Soft banners & info/insight panels rendered with tint classes */
html.dark .bg-green-50  { background-color: rgba(52, 211, 153, 0.10); }
html.dark .bg-red-50    { background-color: rgba(248, 113, 113, 0.10); }
html.dark .bg-yellow-50 { background-color: rgba(251, 191, 36, 0.10); }
html.dark .bg-blue-50   { background-color: rgba(96, 165, 250, 0.10); }
html.dark .bg-indigo-50 { background-color: rgba(129, 140, 248, 0.12); }
html.dark .bg-purple-50 { background-color: rgba(168, 85, 247, 0.12); }
html.dark .bg-amber-50  { background-color: rgba(251, 191, 36, 0.10); }
html.dark .bg-orange-50 { background-color: rgba(251, 146, 60, 0.10); }
html.dark .bg-pink-50   { background-color: rgba(244, 114, 182, 0.10); }
html.dark .border-indigo-100,
html.dark .border-indigo-200 { border-color: rgba(129, 140, 248, 0.32); }
html.dark .border-blue-100,
html.dark .border-green-100,
html.dark .border-amber-100 { border-color: var(--border); }

/* Inline-styled route blocks (built as HTML strings with hex colors):
   remap the common inline palette centrally so they theme without editing
   every route. Inline styles need !important to beat. Both spaced and
   unspaced forms are matched. */
/* Card / panel backgrounds → surface */
html.dark [style*="background:white"],
html.dark [style*="background: white"],
html.dark [style*="background:#fff"],
html.dark [style*="background: #fff"],
html.dark [style*="background:#ffffff"],
html.dark [style*="background:#f9fafb"],
html.dark [style*="background: #f9fafb"],
html.dark [style*="background:#f3f4f6"],
html.dark [style*="background: #f3f4f6"],
html.dark [style*="background:#f8fafc"],
html.dark [style*="background:#fafafa"] {
  background-color: var(--surface) !important;
}
/* Strategy card TYPE tints → dark tints that keep the colour coding */
html.dark [style*="background:#f0fdf4"] { background-color: rgba(22, 163, 74, 0.13) !important; }  /* Release  */
html.dark [style*="background:#eff6ff"] { background-color: rgba(37, 99, 235, 0.14) !important; }  /* Marketing */
html.dark [style*="background:#f5f3ff"] { background-color: rgba(124, 58, 237, 0.16) !important; } /* PR */
html.dark [style*="background:#fff7ed"] { background-color: rgba(234, 88, 12, 0.13) !important; }  /* Event */
html.dark [style*="background:#fefce8"] { background-color: rgba(202, 138, 4, 0.15) !important; }  /* Studio */
html.dark [style*="background:#eef2ff"] { background-color: rgba(99, 102, 241, 0.14) !important; } /* Custom */
/* Recessed rows / inputs → surface-2 */
html.dark [style*="background:#e5e7eb"],
html.dark [style*="background:#f9fafb"][style*="border"] {
  background-color: var(--surface-2) !important;
}
/* Near-black inline text → primary text */
html.dark [style*="color:#111"],
html.dark [style*="color: #111"],
html.dark [style*="color:#1f2937"],
html.dark [style*="color: #1f2937"],
html.dark [style*="color:#0f172a"],
html.dark [style*="color:#0f1720"],
html.dark [style*="color:#374151"],
html.dark [style*="color: #374151"] {
  color: var(--text) !important;
}
/* Mid-gray inline text → muted */
html.dark [style*="color:#6b7280"],
html.dark [style*="color: #6b7280"],
html.dark [style*="color:#4b5563"],
html.dark [style*="color:#9ca3af"],
html.dark [style*="color: #9ca3af"],
html.dark [style*="color:#555"],
html.dark [style*="color: #555"],
html.dark [style*="color:#6366f1"] {
  color: var(--muted) !important;
}
/* Type-tint card borders → neutral so pastel edges don't glare on dark */
html.dark [style*="#bbf7d0"], html.dark [style*="#bfdbfe"], html.dark [style*="#ddd6fe"],
html.dark [style*="#fed7aa"], html.dark [style*="#fef08a"], html.dark [style*="#c7d2fe"],
html.dark [style*="#e2e8f0"] { border-color: var(--border) !important; }
/* Inline borders */
html.dark [style*="border:1px solid #e5e7eb"],
html.dark [style*="border: 1px solid #e5e7eb"],
html.dark [style*="border:1px solid #d1d5db"],
html.dark [style*="border-bottom:1px solid #f3f4f6"],
html.dark [style*="border:1px solid #f3f4f6"] {
  border-color: var(--border) !important;
}
/* Accent links in inline blocks keep the accent, not muted */
html.dark a[style*="color:#6366f1"] { color: var(--accent) !important; }

/* Native form controls in dark mode (selects, option lists, inputs) */
html.dark select,
html.dark select option,
html.dark input,
html.dark textarea {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
html.dark input::placeholder,
html.dark textarea::placeholder { color: var(--faint); }
html.dark input[type="checkbox"],
html.dark input[type="radio"] { accent-color: var(--accent); }

/* ── Modern card polish (both themes) ─────────────────────────── */
.rounded-lg, .rounded-xl { transition: border-color .2s ease, box-shadow .2s ease, transform .15s ease; }
html.dark .shadow-sm { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }

/* ── Theme toggle button ──────────────────────────────────────── */
#theme-toggle {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  color: var(--sidebar-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
#theme-toggle:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
#theme-toggle .sun  { display: none; }
#theme-toggle .moon { display: inline-flex; }
html.dark #theme-toggle .sun  { display: inline-flex; }
html.dark #theme-toggle .moon { display: none; }
#theme-toggle svg { color: var(--accent); }

/* ── Responsive sidebar drawer (unchanged behaviour) ──────────── */
@media (max-width: 767px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
  }
  #sidebar.drawer-open { transform: translateX(0); }
}
@media (min-width: 768px) {
  #sidebar { transform: none !important; }
}

/* Admin role-preview: full bar on desktop only; compact dropdown on mobile. */
@media (max-width: 767px) {
  .role-preview-desktop { display: none !important; }
}

/* ── Artist page "pro" components (from the Sept 2026 mockup, Main.dc.html) ──
   Token-driven, so they read correctly in both themes without html.dark
   overrides. Prefix k- keeps them clear of Tailwind class names. */
.k-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.k-lift { transition: transform .15s ease, box-shadow .15s ease; }
.k-lift:hover { transform: translateY(-2px); box-shadow: 0 12px 30px -14px rgba(0,0,0,.45); }
.k-num { font-family: var(--font-sans); font-feature-settings: 'tnum'; }
.k-chip { border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.k-muted { color: var(--muted); }
.k-faint { color: var(--faint); }
.k-text { color: var(--text); }
.k-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.k-up { color: var(--up); }
.k-down { color: var(--down); }
.k-btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; font-size: 12.5px; font-weight: 600;
  border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; }
.k-btn:hover { background: var(--surface-2); }
.k-btn-primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.k-btn-primary:hover { background: var(--accent-strong); }
.k-btn:disabled { opacity: .45; cursor: not-allowed; }
.k-grid-hero { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; }
.k-hero { display: flex; align-items: center; gap: 22px; padding: 24px 26px; flex-wrap: wrap; }
.k-tab { font-size: 11px; font-weight: 600; padding: 5px 11px; border-radius: 999px; border: 1px solid transparent;
  background: transparent; color: var(--faint); cursor: pointer; }
.k-tab.on { border-color: var(--border); background: var(--surface-2); color: var(--text); }
@media (max-width: 900px) {
  .k-grid-hero { grid-template-columns: minmax(0, 1fr); }
  .k-hero { padding: 18px; gap: 16px; }
  .k-hero-stats { width: 100%; justify-content: space-between; }
  .k-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
}
/* Balanced row: children share the width equally; an empty child (a block the
   route returned as '') drops out, so the row never leaves a hole. */
.k-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 20px; align-items: stretch; margin-bottom: 2rem; }
.k-row > :empty { display: none; }
@media (max-width: 900px) { .k-row { grid-auto-flow: row; } }
.k-row > div > .k-card { height: 100%; margin-bottom: 0 !important; }
/* Two balanced columns of cards (account, team). */
.k-cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 20px; align-items: start; }
/* Long forms: sections flow into two columns as cards, no ragged gaps. */
.k-masonry { column-count: 2; column-gap: 20px; }
.k-masonry > * { break-inside: avoid; margin: 0 0 20px; }
.k-masonry > div:not(.k-span) { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; }
.k-masonry > .k-span { column-span: all; }
@media (max-width: 900px) {
  .k-cols-2 { grid-template-columns: minmax(0, 1fr); }
  .k-masonry { column-count: 1; }
}

/* ── Pass 3: one heading + card language across the whole site ──────────────
   Older section headings were small gray ALL-CAPS labels; the new design uses
   sentence-case titles. Restyled here so every page/role matches at once
   (text content is unchanged — only presentation). */
h2.uppercase.tracking-wide {
  text-transform: none; letter-spacing: -0.01em;
  font-size: 15px; font-weight: 700; color: var(--text) !important;
}
/* Tailwind white boxes adopt the card shape and theme colors. */
.bg-white.rounded-xl, .bg-white.rounded-lg.border { background: var(--surface); border-color: var(--border) !important; border-radius: 16px; box-shadow: none; }

/* Tinted badges with readable contrast in BOTH themes (WCAG AA ≥ 4.5:1):
   dark text on a soft tint in light mode, light text in dark mode. */
.k-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.k-tag-gold   { background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.5); color: #92400e; }
.k-tag-orange { background: rgba(249,115,22,.13); border-color: rgba(249,115,22,.5); color: #9a3412; }
.k-tag-blue   { background: rgba(59,130,246,.13); border-color: rgba(59,130,246,.5); color: #1e40af; }
html.dark .k-tag-gold   { color: #fcd34d; }
html.dark .k-tag-orange { color: #fdba74; }
html.dark .k-tag-blue   { color: #93c5fd; }
/* Tailwind yellows are ~2:1 on white — unreadable. Darker in light, brighter in dark. */
.text-yellow-500, .text-yellow-600 { color: #a16207 !important; }
html.dark .text-yellow-500, html.dark .text-yellow-600, html.dark .text-yellow-700 { color: #fcd34d !important; }
html.dark .bg-yellow-50 { background: rgba(245,158,11,.12) !important; }
html.dark .border-yellow-200 { border-color: rgba(245,158,11,.4) !important; }

/* Readable Tailwind grays/greens/reds (were 2.5–3.3:1 on white). The html.dark
   overrides above still win in dark mode. */
html:not(.dark) .text-gray-400, html:not(.dark) .text-gray-300 { color: var(--faint); }
html:not(.dark) .text-green-500, html:not(.dark) .text-green-600 { color: var(--up); }
html:not(.dark) .text-red-400, html:not(.dark) .text-red-500 { color: var(--down); }
html:not(.dark) .text-amber-600 { color: #b45309; }
html:not(.dark) .text-blue-500 { color: #1d4ed8; }
html.dark .text-blue-500, html.dark .text-blue-600 { color: #93c5fd; }

/* ── Layout guard: the page must never scroll sideways ───────────────────────
   Root causes are fixed where they occur (a bare `1fr` track can't shrink below
   its content — use minmax(0, 1fr); flex rows need flex-wrap). This block is the
   backstop so the next one can't reach the user as a sideways scroll:
     • wide media/controls are capped at their container;
     • long unbroken words and links wrap instead of pushing the layout wider;
     • html/body clip any remaining sideways overflow. `clip` (not `hidden`) so
       neither element becomes a scroll container and sticky/fixed bars keep working.
   NOTE: clip hides overflow rather than revealing it — it is a safety net, not a
   substitute for fixing the cause (scripts/audit.js guards the known ones). */
html, body { max-width: 100%; overflow-x: clip; }
main img, main video, main iframe, main canvas, main svg { max-width: 100%; }
main select, main input:not([type=checkbox]):not([type=radio]), main textarea { max-width: 100%; }
main h1, main h2, main h3, main h4, main p, main li, main a, main label, main span { overflow-wrap: anywhere; }

/* Hover highlights: Tailwind's hover:bg-gray-50/100 are near-white, which made a
   hovered row unreadable in dark mode. A subtle tint in both themes instead. */
html.dark .hover\:bg-gray-50:hover, html.dark .hover\:bg-gray-100:hover,
html.dark .hover\:bg-blue-50:hover, html.dark .hover\:bg-green-50:hover { background-color: var(--surface-2) !important; }
html:not(.dark) .hover\:bg-gray-50:hover { background-color: var(--surface-2); }
.lb-compact .lb-detail { display: none !important; }
/* Leaderboard stat cells are narrow: keep the change badge on one line and drop
   the repeated "WoW" word (the footnote under the leaderboard explains it). */
.lb-detail .inline-flex { white-space: nowrap; }
.lb-detail .inline-flex .font-normal { display: none; }
html.dark .text-indigo-600 { color: var(--accent); }

/* ── Dead Wax: light "Wax" theme ──────────────────────────────────────────────
   Light mode used to leave Tailwind's white/gray surfaces as-is. On Wax (cream)
   paper those read as cold white patches, so map them to the warm tokens.
   (Dark mode is mapped by the html.dark rules above.) */
html:not(.dark) body.bg-white { background: var(--bg); color: var(--text); }
html:not(.dark) main.bg-white { background: var(--bg); }
html:not(.dark) .bg-white,
html:not(.dark) .bg-gray-50,
html:not(.dark) .bg-gray-100 { background-color: var(--surface); }
html:not(.dark) .text-gray-900, html:not(.dark) .text-gray-800 { color: var(--text); }
html:not(.dark) .text-gray-700, html:not(.dark) .text-gray-600, html:not(.dark) .text-gray-500 { color: var(--muted); }
html:not(.dark) .border-gray-50, html:not(.dark) .border-gray-100,
html:not(.dark) .border-gray-200, html:not(.dark) .border-gray-300 { border-color: var(--border); }
html:not(.dark) [style*="background:white"], html:not(.dark) [style*="background: white"],
html:not(.dark) [style*="background:#fff"], html:not(.dark) [style*="background: #fff"],
html:not(.dark) [style*="background:#ffffff"], html:not(.dark) [style*="background:#f9fafb"],
html:not(.dark) [style*="background: #f9fafb"], html:not(.dark) [style*="background:#f3f4f6"],
html:not(.dark) [style*="background:#f8fafc"], html:not(.dark) [style*="background:#fafafa"] { background-color: var(--surface) !important; }
html:not(.dark) select, html:not(.dark) input, html:not(.dark) textarea { background-color: var(--surface); color: var(--text); border-color: var(--border); }
html:not(.dark) input[type="checkbox"], html:not(.dark) input[type="radio"] { accent-color: var(--accent); }

/* ── Dead Wax: brand accents replace the old indigo everywhere ──────────────── */
.text-indigo-600, .text-indigo-700, a.text-indigo-600 { color: var(--accent) !important; }
.bg-indigo-600, .bg-gray-900.text-white.rounded { background-color: var(--accent) !important; color: var(--on-accent) !important; }
.hover\:bg-indigo-700:hover { background-color: var(--accent-strong) !important; }
.bg-indigo-50 { background-color: color-mix(in srgb, var(--accent) 12%, transparent) !important; }
.border-indigo-100, .border-indigo-200 { border-color: color-mix(in srgb, var(--accent) 35%, transparent) !important; }
html.dark .text-indigo-800, html.dark .text-indigo-900, html.dark .text-indigo-950 { color: var(--text); }
[style*="color:#6366f1"], [style*="color: #6366f1"] { color: var(--accent) !important; }
[style*="background:#6366f1"], [style*="background: #6366f1"], [style*="background:#4f46e5"] { background: var(--accent) !important; color: var(--on-accent) !important; }
/* Status: up = Signal, down = Orange, warn = Copper (both themes via tokens). */
html.dark .text-green-700, html.dark .text-green-600, html.dark .text-green-500 { color: var(--up); }
html.dark .text-red-600, html.dark .text-red-500 { color: var(--down); }
html.dark .bg-green-50 { background-color: color-mix(in srgb, var(--up) 11%, transparent); }
html.dark .bg-red-50 { background-color: color-mix(in srgb, var(--down) 11%, transparent); }
#theme-toggle:hover, #sidebar-nav .nav-link:hover, #sidebar a:hover { color: var(--wax); }
::selection { background: color-mix(in srgb, var(--signal) 35%, transparent); }

/* The admin Role Preview bar is fixed at the top (desktop): keep the sidebar (logo) below it. */
@media (min-width: 768px) { html.rp-on #sidebar { top: 37px; height: calc(100vh - 37px); } }
/* Alert priority edges: High = Orange, Medium = Copper. */
.border-l-red-400 { border-left-color: var(--orange) !important; }
.border-l-yellow-400 { border-left-color: var(--copper) !important; }
/* Wordmark keeps full Wax (it's a link, but not a menu item). */
#sidebar a.hdrm-mark, #sidebar a.hdrm-mark:hover { color: var(--sidebar-text); background: none; }
/* Table headers read as board labels. */
th { text-transform: uppercase; font-size: 10.5px; font-weight: 700; }

/* ═════════════════════════════════════════════════════════════════════════════
   COMPONENT KIT — HDRM "Dead Wax"
   One standard per component. Pages build these as HTML strings; helpers for
   delta / alert / empty state live in src/lib/ui.js.
   ═════════════════════════════════════════════════════════════════════════════ */

/* ── Keyboard focus (WCAG 2.4.7): visible everywhere, both themes ─────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
#sidebar :focus-visible { outline-color: var(--signal); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent) !important; outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ── Type helpers ─────────────────────────────────────────────────────────── */
.k-h1 { font-size: var(--fs-h1); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; color: var(--text); margin: 0; }
.k-eyebrow { font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: .14em; text-transform: uppercase; color: var(--copper-text); margin-bottom: 6px; }
.k-rank { color: var(--copper-text); }
.k-flat { color: var(--faint); }
.k-ok  { color: var(--up); }
.k-mid { color: var(--warn); }
.k-low { color: var(--down); }
.k-hot { color: var(--orange); }

/* Mono labels stay on one line and small. */
.k-label { font-size: 11px; letter-spacing: .08em; overflow-wrap: normal; }
th { font-size: 10px; letter-spacing: .06em; }

/* ── Buttons: .k-btn (secondary) · .k-btn-primary · .k-btn-danger · .k-btn-ghost · .k-btn-sm ── */
.k-btn { min-height: var(--tap); justify-content: center; font-family: var(--font-sans); text-decoration: none; transition: background-color .15s ease, border-color .15s ease, transform .05s ease; }
.k-btn:active:not(:disabled) { transform: translateY(1px); }
.k-btn-danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, transparent); background: transparent; }
.k-btn-danger:hover { background: color-mix(in srgb, var(--down) 10%, transparent); }
.k-btn-ghost { border-color: transparent; }
.k-btn-sm { min-height: 32px; padding: 5px 11px; font-size: var(--fs-xs); }
.k-btn-block { width: 100%; }
.k-btn[aria-busy="true"] { opacity: .7; cursor: progress; pointer-events: none; }
.k-btn[aria-busy="true"]::after { content: ''; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: k-spin .7s linear infinite; }
@keyframes k-spin { to { transform: rotate(360deg); } }
/* Any submit button shows "busy" while its form posts (set by layout.html). */

/* ── Fields: .k-input / .k-select / .k-textarea ───────────────────────────── */
.k-input, .k-select, .k-textarea {
  min-height: var(--tap); padding: 8px 12px; font: inherit; font-size: var(--fs-md);
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.k-textarea { min-height: 96px; }
.k-input::placeholder, .k-textarea::placeholder { color: var(--faint); }
.k-input[aria-invalid="true"], .k-select[aria-invalid="true"] { border-color: var(--down); }
.k-input:disabled, .k-select:disabled { opacity: .55; cursor: not-allowed; }
html:not(.dark) input::placeholder, html:not(.dark) textarea::placeholder { color: var(--faint); }
@media (max-width: 767px) { input, select, textarea { font-size: 16px !important; } } /* stops iOS zoom-on-focus */

/* ── Alerts: .k-alert + -ok / -warn / -bad / -info / -neutral ─────────────── */
.k-alert { font-size: var(--fs-sm); border-radius: var(--radius-sm); padding: 10px 12px; border: 1px solid var(--border); margin-bottom: 14px; color: var(--text); }
.k-alert-ok   { background: color-mix(in srgb, var(--up) 10%, transparent);   border-color: color-mix(in srgb, var(--up) 40%, transparent); }
.k-alert-warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.k-alert-bad  { background: color-mix(in srgb, var(--down) 10%, transparent); border-color: color-mix(in srgb, var(--down) 45%, transparent); }
.k-alert-info { background: color-mix(in srgb, var(--accent) 9%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.k-alert-neutral { background: var(--surface-2); }

/* ── Tags: semantic .k-tag-ok / -warn / -bad / -info / -hot / -neutral ────── */
.k-tag-ok      { background: color-mix(in srgb, var(--up) 12%, transparent);    border-color: color-mix(in srgb, var(--up) 45%, transparent);    color: var(--up); }
.k-tag-warn    { background: color-mix(in srgb, var(--warn) 13%, transparent);  border-color: color-mix(in srgb, var(--warn) 50%, transparent);  color: var(--copper-text); }
.k-tag-bad     { background: color-mix(in srgb, var(--down) 12%, transparent);  border-color: color-mix(in srgb, var(--down) 50%, transparent);  color: var(--down); }
.k-tag-info    { background: color-mix(in srgb, var(--accent) 11%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); }
.k-tag-hot     { background: color-mix(in srgb, var(--orange) 14%, transparent); border-color: color-mix(in srgb, var(--orange) 55%, transparent); color: var(--orange); }
.k-tag-neutral { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
html:not(.dark) .k-tag-hot { color: #9A4310; }
/* Old colour-named tags keep working, now in the brand palette. */
.k-tag-gold, html.dark .k-tag-gold { background: color-mix(in srgb, var(--warn) 13%, transparent); border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: var(--copper-text); }
.k-tag-orange, html.dark .k-tag-orange { background: color-mix(in srgb, var(--orange) 14%, transparent); border-color: color-mix(in srgb, var(--orange) 55%, transparent); color: var(--orange); }
html:not(.dark) .k-tag-orange { color: #9A4310; }
.k-tag-blue, html.dark .k-tag-blue { background: color-mix(in srgb, var(--accent) 11%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); }

/* ── Avatars (initials) ───────────────────────────────────────────────────── */
.k-avatar, .bg-indigo-100.text-indigo-700, .bg-indigo-100 { background: var(--surface-2) !important; color: var(--text) !important; }

/* ── Tables: .k-table inside .k-scroll ────────────────────────────────────── */
.k-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.k-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.k-table th { text-align: left; padding: 8px 12px 8px 0; color: var(--faint); border-bottom: 1px solid var(--border); }
.k-table td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.k-table tbody tr:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
/* Every table in the app scrolls sideways on a phone instead of crushing its columns. */
@media (max-width: 640px) {
  main table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  main table td, main table th { min-width: 96px; }
}

/* ── Tabs: .k-tab · on / [aria-selected=true] ─────────────────────────────── */
.k-tab { min-height: 30px; font-size: var(--fs-2xs); }
.k-tab:hover { color: var(--text); }
.k-tab[aria-selected="true"] { border-color: var(--border); background: var(--surface-2); color: var(--text); }
@media (max-width: 767px) { .k-tab { min-height: 36px; padding: 6px 12px; } }

/* ── Empty states: .k-empty ───────────────────────────────────────────────── */
.k-empty, .py-8.text-center.text-sm.text-gray-400 { text-align: center; padding: 28px 16px; color: var(--muted); font-size: var(--fs-md); }
.k-empty p { margin: 0; }
.k-empty-cta { margin-top: 12px; }

/* ── Cards: light-mode lift + a copper-glow hero variant ──────────────────── */
html:not(.dark) .k-card, html:not(.dark) .bg-white.rounded-xl, html:not(.dark) .bg-white.rounded-lg.border { box-shadow: var(--card-shadow); }
.k-hero-glow { background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--copper) 14%, transparent), transparent 60%), var(--surface); }

/* ── Phones: tap targets ──────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .k-btn { min-height: 44px; }
  .k-btn-sm { min-height: 40px; }
  main input[type="checkbox"], main input[type="radio"] { width: 20px; height: 20px; }
}

/* ── Leftovers from the old palette → brand ───────────────────────────────── */
html.dark .text-gray-700, html.dark .text-gray-600 { color: var(--muted); }
.text-blue-500, .text-blue-600, html.dark .text-blue-500, html.dark .text-blue-600 { color: var(--accent) !important; }
.text-indigo-500 { color: var(--accent) !important; }
.text-yellow-500, .text-yellow-600 { color: var(--warn) !important; }
html.dark .text-yellow-500, html.dark .text-yellow-600, html.dark .text-yellow-700 { color: var(--warn) !important; }
html:not(.dark) .text-amber-600 { color: #8A4A26; }
html:not(.dark) .text-green-500, html:not(.dark) .text-green-600, html:not(.dark) .text-green-700 { color: var(--up); }
html:not(.dark) .text-red-400, html:not(.dark) .text-red-500, html:not(.dark) .text-red-600, html:not(.dark) .text-red-700 { color: var(--down); }
/* Tailwind tinted banners (old pages) render as kit alerts. */
.bg-red-50.border    { background: color-mix(in srgb, var(--down) 10%, transparent) !important; border-color: color-mix(in srgb, var(--down) 45%, transparent) !important; }
.bg-green-50.border  { background: color-mix(in srgb, var(--up) 10%, transparent) !important;   border-color: color-mix(in srgb, var(--up) 40%, transparent) !important; }
.bg-yellow-50.border, .bg-amber-50.border { background: color-mix(in srgb, var(--warn) 12%, transparent) !important; border-color: color-mix(in srgb, var(--warn) 45%, transparent) !important; }
.bg-indigo-50.border, .bg-blue-50.border  { background: color-mix(in srgb, var(--accent) 9%, transparent) !important; border-color: color-mix(in srgb, var(--accent) 35%, transparent) !important; }

/* Wordmark sub-label readable size. */
.hdrm-mark .sub { font-size: 9.5px; letter-spacing: .38em; }

/* ── Page titles: the board's bigger, friendlier voice (one rule for every page) ── */
main h1 { font-size: var(--fs-h1) !important; font-weight: 800; letter-spacing: -0.038em; line-height: 1.06; }
main h1.text-xl { font-size: var(--fs-xl) !important; }
main h2 { font-size: var(--fs-lg); }

/* ── Texture: subtle film grain over everything + a record-groove watermark ── */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}
html:not(.dark) body::before { opacity: .06; mix-blend-mode: multiply; }
.k-grooves { background-image: repeating-radial-gradient(circle at 100% 0%, transparent 0 7px, color-mix(in srgb, var(--wax) 5%, transparent) 7px 8px); }

/* Leaderboard stat cells are narrow: the WoW/DoD word is explained by the footnote. */
.lb-detail .k-num .k-faint { display: none; }

/* Official logo in the sidebar header. */
#sidebar a.hdrm-logo, #sidebar a.hdrm-logo:hover { background: none; padding: 0; border-radius: 0; display: block; line-height: 0; }
#sidebar a.hdrm-logo img { display: block; max-width: 100%; height: auto; }

/* ── Kit type roles ─────────────────────────────────────────────────────────── */
.k-kpi { font-family: var(--font-sans); font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1; }
.k-num { font-variant-numeric: tabular-nums; }
#sidebar-nav .nav-link { font-weight: 600; letter-spacing: -0.01em; }            /* UI labels / nav: 600 */
.k-meta { font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
code, kbd, samp { font-family: var(--font-mono); font-size: .92em; }

/* The menu column runs the FULL height of the page (to the end of the data), not just the
   screen: the sidebar itself is pinned, so its Night colour is also painted down the page
   behind it. Both themes. Matches the sidebar width (w-60 = 15rem). */
@media (min-width: 768px) {
  .hdrm-shell { background: linear-gradient(to right, var(--sidebar) 0, var(--sidebar) 15rem, transparent 15rem); }
  .hdrm-shell::before { content: ''; position: absolute; top: 0; bottom: 0; left: 15rem; width: 1px; background: rgba(255,255,255,.07); pointer-events: none; }
  .hdrm-shell { position: relative; }
}

/* Sidebar text always uses the Night-sidebar palette, in BOTH themes (the light-mode grey remaps
   would otherwise turn the user's name dark-on-dark). */
#sidebar .text-gray-100, #sidebar .text-gray-200, #sidebar .text-gray-300 { color: var(--sidebar-text) !important; }
#sidebar .text-gray-400, #sidebar .text-gray-500, #sidebar .text-gray-600 { color: var(--sidebar-muted) !important; }

/* ── About / AI Insights: always 4–7 lines, a clean vertical rectangle ───────────
   Min 4 lines tall, max 7; longer text is faded out with a "Read more" (see layout.html). */
.k-clip { line-height: 1.65; min-height: calc(1.65em * 4); max-height: calc(1.65em * 7); overflow: hidden; }
.k-clip p { margin: 0 0 .5em; }
.k-clip.k-open { max-height: none; }
.k-clip.k-fade { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 2.4em), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 2.4em), transparent); }
.k-more { color: var(--accent); font-weight: 600; font-size: var(--fs-xs); background: none; border: none; cursor: pointer; padding: 8px 0 0; min-height: 0; }
.k-more[hidden] { display: none; }

/* ── Platform Links: readable on both themes (was pale-on-pale) ──────────────── */
.plat-links a { background: var(--surface-2) !important; border: 1px solid var(--border) !important; }
.plat-links a:hover { border-color: var(--accent) !important; background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)) !important; }
.plat-links a span { color: var(--text) !important; font-weight: 600; font-size: var(--fs-xs); }
.plat-links a svg { color: var(--text) !important; }
.plat-links a:hover svg, .plat-links a:hover span { color: var(--accent) !important; }

/* News: select-several bar */
.k-selbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); position: sticky; top: 8px; z-index: 5; }
.news-sel, #news-all { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
