/* ============================================================
   EX3ME DESIGN SYSTEM — THE GLOBAL EXTREME SPORTS AUTHORITY
   Premium · Athletic · Futuristic · Aggressive · International

   Ported from the original Tailwind/globals.css build so the PHP site keeps
   the same look: black canvas, EX3ME red, gold accents, glass nav.
   ============================================================ */

:root {
  --ex3me-red: #DC1E1E;
  --ex3me-red-dark: #B91C1C;
  --ex3me-red-light: #EF4444;
  --ex3me-gold: #F59E0B;
  --ex3me-silver: #9CA3AF;
  --ex3me-bronze: #D97706;

  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

/* Dark theme (default) */
html,
html[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #0A0A0A;
  --bg-card: #111111;
  --bg-surface: #181818;
  --bg-hover: #1F1F1F;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --text-muted: #52525b;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-elevated: 0 8px 30px rgba(0, 0, 0, 0.4);
  --glass: rgba(17, 17, 17, 0.8);
  --glass-border: rgba(255, 255, 255, 0.06);
  --gradient-hero: linear-gradient(180deg, rgba(220, 30, 30, 0.06) 0%, transparent 50%);
  --input-bg: rgba(255, 255, 255, 0.05);
  --badge-bg: rgba(255, 255, 255, 0.06);
  --ring: rgba(220, 30, 30, 0.3);
  --scrollbar-track: #111;
  --scrollbar-thumb: #333;
  --scrollbar-hover: #555;
  --grid-line: rgba(255, 255, 255, 0.02);
  color-scheme: dark;
}

/* Light theme */
html[data-theme="light"] {
  --bg: #ffffff;
  --bg-elevated: #f8f8f8;
  --bg-card: #ffffff;
  --bg-surface: #f4f4f5;
  --bg-hover: #e4e4e7;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  --text-primary: #09090b;
  --text-secondary: #52525b;
  --text-tertiary: #71717a;
  --text-muted: #a1a1aa;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-elevated: 0 8px 30px rgba(0, 0, 0, 0.12);
  --glass: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.06);
  --gradient-hero: linear-gradient(180deg, rgba(220, 30, 30, 0.04) 0%, transparent 50%);
  --input-bg: rgba(0, 0, 0, 0.04);
  --badge-bg: rgba(0, 0, 0, 0.06);
  --ring: rgba(220, 30, 30, 0.2);
  --scrollbar-track: #f4f4f5;
  --scrollbar-thumb: #d4d4d8;
  --scrollbar-hover: #a1a1aa;
  --grid-line: rgba(0, 0, 0, 0.03);
  color-scheme: light;
}

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

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

img { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0; }
svg.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

:focus-visible { outline: 2px solid var(--ex3me-red); outline-offset: 2px; }

.site-main { flex: 1 0 auto; }

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeInUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse-glow { 0%, 100% { box-shadow: 0 0 5px rgba(220,30,30,0.3); } 50% { box-shadow: 0 0 20px rgba(220,30,30,0.6); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes gradient-shift { 0% { background-position: 0 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes pulse-live { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.animate-fade-in-up { animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
.animate-fade-in { animation: fadeIn 0.5s ease-out both; }
.animate-float { animation: float 3s ease-in-out infinite; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============================================================
   LAYOUT PRIMITIVES
   ============================================================ */

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.container-narrow { width: 100%; max-width: 840px; margin: 0 auto; padding: 0 16px; }
.container-tight { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px; }

.section { padding: 64px 0; }
.section-sm { padding: 40px 0; }
.section-lg { padding: 88px 0; }
.section-alt { background: var(--bg-elevated); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-divider { height: 1px; background: linear-gradient(90deg, transparent, var(--border), transparent); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 auto; min-width: 0; }
.wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.shrink-0 { flex-shrink: 0; }
.relative { position: relative; }
.hidden { display: none; }
.full-width { width: 100%; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.main-aside { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 32px; }

@media (max-width: 1000px) {
  .cols-4, .cols-5, .cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-aside { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .cols-2, .cols-3, .cols-4, .cols-5, .cols-6 { grid-template-columns: minmax(0, 1fr); }
  .section { padding: 48px 0; }
  .section-lg { padding: 56px 0; }
}

/* Spacing helpers */
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; } .mt-10 { margin-top: 40px; } .mt-12 { margin-top: 48px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; } .mb-10 { margin-bottom: 40px; } .mb-12 { margin-bottom: 48px; }
.ml-auto { margin-left: auto; }
.pt-4 { padding-top: 16px; } .pt-6 { padding-top: 24px; } .pt-8 { padding-top: 32px; }
.pb-4 { padding-bottom: 16px; } .py-2 { padding: 8px 0; } .py-4 { padding: 16px 0; } .py-6 { padding: 24px 0; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.p-4 { padding: 16px; } .p-5 { padding: 20px; } .p-6 { padding: 24px; } .p-8 { padding: 32px; }

/* Typography helpers */
.text-xs { font-size: 12px; }
.text-sm { font-size: 13.5px; }
.text-base { font-size: 16px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 21px; }
.text-2xl { font-size: 26px; }
.text-3xl { font-size: 32px; }
.text-4xl { font-size: 40px; }
.text-5xl { font-size: 52px; }
.text-6xl { font-size: 64px; }
.text-7xl { font-size: 78px; }
.text-8xl { font-size: 96px; }

.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 800; }
.mono { font-family: var(--font-mono); }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.04em; }
.tracking-wider { letter-spacing: 0.08em; }
.leading-tight { line-height: 1.15; }
.leading-relaxed { line-height: 1.7; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.muted { color: var(--text-secondary); }
.dim { color: var(--text-tertiary); }
.faint { color: var(--text-muted); }
.text-red { color: var(--ex3me-red); }
.text-gold { color: var(--ex3me-gold); }
.text-primary { color: var(--text-primary); }
.bg-card { background: var(--bg-card); }
.bg-elevated { background: var(--bg-elevated); }
.divider-top { border-top: 1px solid var(--border); }
.bordered { border: 1px solid var(--border); border-radius: 16px; }
.bordered-dashed { border: 2px dashed var(--border-strong); border-radius: 16px; }
.rounded-lg { border-radius: 12px; }
.rounded-full { border-radius: 999px; }
.overflow-hidden { overflow: hidden; }
.max-w-lg { max-width: 640px; }
.max-w-xl { max-width: 760px; }
.max-w-2xl { max-width: 880px; }

/* Decorative */
.hero {
  position: relative;
  background: var(--gradient-hero);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 60px 60px;
}
.hero-glow {
  position: absolute;
  top: -120px; left: 50%;
  width: 900px; height: 900px;
  transform: translateX(-50%);
  border-radius: 50%;
  filter: blur(200px);
  background: radial-gradient(circle, rgba(220, 30, 30, 0.08) 0%, transparent 70%);
  pointer-events: none;
}
.relative-z { position: relative; z-index: 2; }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: block;
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-elevated);
  transform: translateY(-2px);
}
.card-static:hover { transform: none; }
.card-pad { padding: 20px; }
.card-featured { border-color: rgba(220, 30, 30, 0.2); box-shadow: 0 0 0 1px rgba(220, 30, 30, 0.1); }
.card-cover {
  height: 96px;
  background: linear-gradient(135deg, rgba(220, 30, 30, 0.15), var(--bg-card));
  border-radius: 15px 15px 0 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  border: 1px solid transparent;
}

.btn-primary { padding: 12px 28px; background: var(--ex3me-red); color: #fff; }
.btn-primary:hover { background: var(--ex3me-red-light); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(220, 30, 30, 0.3); }

.btn-secondary { padding: 12px 28px; background: var(--input-bg); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); transform: translateY(-1px); }

.btn-ghost { padding: 8px 16px; background: transparent; color: var(--text-secondary); font-weight: 600; border-radius: 10px; }
.btn-ghost:hover { background: var(--input-bg); color: var(--text-primary); }

.btn-danger { padding: 12px 24px; background: transparent; color: var(--ex3me-red-light); border-color: rgba(220, 30, 30, 0.4); }
.btn-danger:hover { background: rgba(220, 30, 30, 0.1); }

.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 16px 40px; font-size: 16px; }
.btn-block { width: 100%; }

@media (max-width: 640px) {
  .btn-primary, .btn-secondary { width: 100%; padding: 14px 20px; }
  .btn-block, .btn-sm { width: auto; }
}

/* ============================================================
   GRADIENT TEXT
   ============================================================ */

.gradient-text {
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--ex3me-red) 50%, var(--ex3me-gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.gradient-text-red {
  background: linear-gradient(135deg, var(--ex3me-red) 0%, var(--ex3me-red-light) 50%, var(--ex3me-gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ============================================================
   BADGES, TAGS, PILLS
   ============================================================ */

.badge-verified,
.badge-live,
.badge-pending,
.badge-review,
.badge-evidence,
.badge-rejected,
.badge-neutral,
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-verified { background: var(--ex3me-red); color: #fff; }
.badge-live { background: #16a34a; color: #fff; }
.badge-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse-live 1.5s ease-in-out infinite; }
.badge-pending { background: rgba(245, 158, 11, 0.15); color: var(--ex3me-gold); }
.badge-review { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-evidence { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.badge-rejected { background: rgba(220, 30, 30, 0.15); color: var(--ex3me-red-light); }
.badge-neutral { background: var(--badge-bg); color: var(--text-secondary); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--badge-bg);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}
.tag-red { background: rgba(220, 30, 30, 0.12); color: var(--ex3me-red-light); }
.tag-gold { background: rgba(245, 158, 11, 0.12); color: var(--ex3me-gold); }

.eyebrow {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ex3me-red);
}
.eyebrow-gold { color: var(--ex3me-gold); }

/* ============================================================
   RANKING
   ============================================================ */

.rank-1 { color: var(--ex3me-gold); }
.rank-2 { color: #d1d5db; }
.rank-3 { color: var(--ex3me-bronze); }
.rank-plain { color: var(--text-muted); }
.rank-up { color: #16a34a; }
.rank-down { color: var(--ex3me-red-light); }
.rank-same { color: var(--text-muted); }

.form-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  background: var(--badge-bg);
  color: var(--text-muted);
}
.form-gold { background: #eab308; color: #000; }
.form-silver { background: #9ca3af; color: #000; }
.form-bronze { background: var(--ex3me-bronze); color: #fff; }

/* ============================================================
   FORM INPUTS
   ============================================================ */

.input,
textarea.input,
select.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
  outline: none;
}
.input::placeholder { color: var(--text-muted); }
.input:focus { border-color: var(--ex3me-red); box-shadow: 0 0 0 3px var(--ring); }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.6; }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 5.646a.5.5 0 0 1 .708 0L8 8.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

label.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-icon .input { padding-left: 38px; }

.checkbox-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-secondary); }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--ex3me-red); }

/* ============================================================
   NAVBAR
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.site-header .nav-row { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--ex3me-red); color: #fff; font-size: 13px; font-weight: 800;
  box-shadow: 0 4px 20px rgba(220, 30, 30, 0.35);
}
.brand-text .brand-sub { display: block; font-size: 9px; font-weight: 600; letter-spacing: 0.18em; color: var(--text-muted); text-transform: uppercase; }

/*
  Official Ex3Me lockup. The two variants are the same artwork in white and
  black, swapped by the colour theme. Painting it as a background (rather than
  two stacked <img> tags) means only the active theme's file is downloaded, and
  the fixed aspect-ratio keeps the header from jumping when the theme flips.
*/
.brand-logo {
  display: block;
  height: 40px;
  aspect-ratio: 2.966;
  background-image: url("../img/ex3me-logo-white.png");
  background-repeat: no-repeat;
  background-position: left center;
  background-size: contain;
}

[data-theme="light"] .brand-logo { background-image: url("../img/ex3me-logo-black.png"); }

.brand-mark-img { display: inline-block; vertical-align: middle; flex-shrink: 0; }

.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-link {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}
.nav-link:hover { background: var(--input-bg); color: var(--text-primary); }
.nav-link.active { color: var(--text-primary); background: var(--input-bg); }

.nav-actions { display: flex; align-items: center; gap: 10px; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  min-width: 230px;
  padding: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-elevated);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.2s ease;
  z-index: 70;
}
.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-menu a { display: block; padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.dropdown-menu a:hover { background: var(--input-bg); color: var(--text-primary); }

.nav-toggle { display: none; }
.mobile-nav { display: none; border-top: 1px solid var(--border); background: var(--bg); }
.mobile-nav.open { display: block; animation: fadeIn 0.2s ease-out both; }
.mobile-nav a { display: block; padding: 12px; border-radius: 10px; font-weight: 500; color: var(--text-secondary); }
.mobile-nav a:hover { background: var(--input-bg); color: var(--text-primary); }

@media (max-width: 1080px) {
  .nav-links, .nav-actions { display: none; }
  .nav-toggle { display: inline-flex; }
}

/* theme toggle */
.theme-toggle {
  position: relative;
  width: 52px; height: 28px;
  border-radius: 14px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.3s ease;
}
.theme-toggle:hover { border-color: var(--ex3me-red); }
html[data-theme="dark"] .theme-toggle { background: var(--ex3me-red); border-color: var(--ex3me-red); }
.theme-toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  display: flex; align-items: center; justify-content: center;
  color: #1f2937;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
html[data-theme="dark"] .theme-toggle-knob { transform: translateX(24px); }
.theme-toggle-mobile {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
}
@media (max-width: 1080px) { .theme-toggle-mobile { display: inline-flex; } }

/* ============================================================
   TABLES
   ============================================================ */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-card); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-hover); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }

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

.stat-block { text-align: center; padding: 28px 16px; }
.stat-block .stat-value { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.stat-block .stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-top: 4px; }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); padding: 12px 0; }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb .current { color: var(--text-secondary); }

.detail-row { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; padding: 6px 0; }
.detail-row dt { color: var(--text-muted); }
.detail-row dd { margin: 0; color: var(--text-primary); font-weight: 500; text-align: right; }

.empty-state { text-align: center; padding: 72px 16px; }
.empty-state .empty-icon { font-size: 40px; display: block; margin-bottom: 14px; }

.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.flash-success { background: rgba(22, 163, 74, 0.12); border-color: rgba(22, 163, 74, 0.3); color: #4ade80; }
.flash-error { background: rgba(220, 30, 30, 0.12); border-color: rgba(220, 30, 30, 0.3); color: var(--ex3me-red-light); }
.flash-info { background: var(--badge-bg); color: var(--text-secondary); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 32px; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}
.pagination a:hover { border-color: var(--border-strong); color: var(--text-primary); }
.pagination .current { background: var(--ex3me-red); border-color: var(--ex3me-red); color: #fff; }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}
.tab:hover { background: var(--input-bg); color: var(--text-primary); }
.tab.active { background: var(--ex3me-red); color: #fff; }

.avatar-circle {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--badge-bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.avatar-lg { width: 84px; height: 84px; font-size: 40px; border: 3px solid var(--bg-card); }

.value-display { font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.value-unit { font-size: 15px; color: var(--text-tertiary); margin-left: 6px; }

.certificate {
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  padding: 40px 32px;
  text-align: center;
  background: var(--bg-card);
}
.certificate .cert-brand { color: var(--ex3me-red); font-size: 12px; font-weight: 800; letter-spacing: 0.3em; text-transform: uppercase; }
.certificate .cert-rule { width: 80px; height: 2px; background: var(--ex3me-red); margin: 18px auto; }
.certificate .cert-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.certificate .cert-lines { max-width: 340px; margin: 24px auto 0; }
.certificate .cert-seal { display: inline-flex; align-items: center; gap: 8px; color: var(--ex3me-red); font-size: 12px; font-weight: 800; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .t-index { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); width: 18px; padding-top: 2px; }

.progress { height: 6px; border-radius: 3px; background: var(--badge-bg); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ex3me-red); }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #22C55E; animation: pulse-live 1.5s ease-in-out infinite; display: inline-block; }

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer { border-top: 1px solid var(--border); background: var(--bg); margin-top: auto; }
.footer-grid { display: grid; grid-template-columns: 1.5fr repeat(4, 1fr); gap: 32px; }
.footer-col h3 {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 16px;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.footer-col a { font-size: 14px; color: var(--text-secondary); }
.footer-col a:hover { color: var(--ex3me-red); }
.footer-bottom {
  margin-top: 44px; padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-muted);
}
.social-links { display: flex; gap: 14px; }
.social-links a { color: var(--text-muted); }
.social-links a:hover { color: var(--text-primary); }

@media (max-width: 900px) { .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .footer-grid { grid-template-columns: minmax(0, 1fr); } }

/* ============================================================
   ADMIN CHROME
   ============================================================ */

.admin-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.admin-side {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-side .admin-nav { display: grid; gap: 4px; }
.admin-side .admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
}
.admin-side .admin-nav a:hover { background: var(--input-bg); color: var(--text-primary); }
.admin-side .admin-nav a.active { background: var(--ex3me-red); color: #fff; }
.admin-side .admin-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-muted); padding: 8px 12px 2px;
}
.admin-main { padding: 28px 32px 64px; }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .admin-side { position: static; height: auto; }
  .admin-main { padding: 20px 16px 48px; }
}

/* Print: certificates should come out clean */
/* ============================================================
   CONSOLE ADDITIONS — sports, events, partnerships, mail, branding
   ============================================================ */

/* Layout utilities the console views lean on. `between` and `center-*` keep the
   intent readable in markup; `mt-auto` pins the sign-out block to the bottom of
   the sidebar. */
.between { justify-content: space-between; }
.center-y { align-items: center; }
.center-x { justify-content: center; }
.mt-auto { margin-top: auto; }

.tag-neutral { background: var(--badge-bg); color: var(--text-secondary); }

/* One record inside a card — used by the discipline editor so each one can be
   saved independently without nesting forms. */
.sub-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
}

/* Artwork previews: shown on the background the file is actually used on, so a
   white logo about to be uploaded for the light theme is obvious immediately. */
.brand-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.brand-preview-dark { background: #000; }
.brand-preview-light { background: #fff; }
.brand-preview img { max-width: 100%; max-height: 64px; height: auto; }

.partner-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.partner-preview img { max-width: 100%; max-height: 64px; object-fit: contain; }

/* ─── Public partners page ───────────────────────────────────── */

.partner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.partner-card { height: 100%; }

.partner-card-featured {
  border-color: rgba(220, 30, 30, 0.4);
  box-shadow: var(--shadow-elevated);
}

.partner-card-mark {
  display: flex;
  align-items: center;
  min-height: 64px;
  margin-bottom: 16px;
}

.partner-logo {
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

/* Partners added without artwork still look deliberate. */
.partner-monogram {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--ex3me-red) 0%, var(--ex3me-red-dark) 100%);
  color: #fff;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.02em;
}

/* ─── Submission date review ─────────────────────────────────── */

.date-review-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.date-review-summary {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

@media (max-width: 760px) {
  .date-review-forms { grid-template-columns: 1fr; }
}

/* ─── Mail ───────────────────────────────────────────────────── */

.mail-body {
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 420px;
  overflow: auto;
}

/* Only the help text for the selected audience is shown (see app.js). */
[data-audience-help] { display: none; }
[data-audience-help].is-active { display: block; }

/* ─── Video evidence ─────────────────────────────────────────── */

/* The public player. Kept deliberately plain: the footage is the loud part. */
.video-evidence {
  padding: 20px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.video-evidence-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.video-frame {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border-strong);
}
.video-player {
  display: block;
  width: 100%;
  max-height: 68vh;
  background: #000;
}

/* Click-to-load: no third-party request until the visitor asks for the footage. */
.video-embed-load {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: #fff;
  background-color: #0b0b0d;
  background-size: cover;
  background-position: center;
  text-align: center;
}
.video-embed-load::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.7));
}
.video-embed-play,
.video-embed-note { position: relative; z-index: 1; }
.video-embed-play {
  display: inline-flex;
  align-items: center;
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--ex3me-red);
  font-weight: 800;
  font-size: 15px;
}
.video-embed-note {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.02em;
}
.video-embed-load iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.video-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  color: var(--text-primary);
}
.video-link:hover { color: var(--ex3me-red); }
.video-link-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ex3me-red);
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}
.video-link-title { font-weight: 700; }

.video-caption { margin-top: 14px; font-size: 15px; font-weight: 600; }
.video-meta { margin-top: 4px; font-size: 12.5px; color: var(--text-tertiary); }

/* Console-side evidence panel. */
.video-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}
.video-chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ex3me-red);
  color: #fff;
  flex-shrink: 0;
}
.video-chip-body { flex: 1; min-width: 0; }
.video-preview {
  display: block;
  width: 100%;
  max-height: 320px;
  border-radius: 12px;
  background: #000;
  border: 1px solid var(--border);
}
.video-poster {
  position: relative;
  display: block;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 9;
  background: #000;
}
.video-poster img { width: 100%; height: 100%; object-fit: cover; opacity: 0.75; }
.video-poster-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.video-empty {
  padding: 16px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Evidence triage strip on the records list. */
.evidence-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.evidence-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  min-width: 130px;
}
.evidence-stat:hover { border-color: var(--ex3me-red); }
.evidence-stat-warn { border-color: rgba(245, 158, 11, 0.4); }
.evidence-stat-value { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }
.evidence-stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-tertiary); }
.evidence-strip-note { flex: 1; min-width: 220px; font-size: 12.5px; color: var(--text-tertiary); }

/* A tag that submits, and the form that carries it. */
.inline-form { display: inline; }
button.tag-button { border: 0; cursor: pointer; font-family: inherit; }
button.tag-button:hover { filter: brightness(1.25); }
.tag-green { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.tag-muted { background: var(--badge-bg); color: var(--text-tertiary); }
[data-theme="light"] .tag-green { background: rgba(22, 163, 74, 0.12); color: #15803d; }

/* ─── Certificate document ───────────────────────────────────── */

/* The sheet is paper in both themes. A certificate that changed colour with the
   visitor's theme — and printed whatever that theme was — would not be trusted,
   so it carries its own ink and stock rather than the site's tokens. */
.cert-page {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.cert-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.cert-toolbar-left,
.cert-toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cert-toolbar-ref { font-size: 12px; color: var(--text-tertiary); }

.cert-sheet {
  --ink: #14141a;
  --ink-soft: #5c5c68;
  --ink-faint: #8a8a96;
  --paper: #fffdf9;
  --paper-edge: #e5e2db;
  --rule: rgba(20, 20, 26, 0.14);
  --seal: #b01818;

  position: relative;
  overflow: hidden;
  padding: 44px 46px 36px;
  border-radius: 4px;
  border: 1px solid var(--paper-edge);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}

/* Guilloché-ish security pattern, drawn with gradients so it stays crisp at any
   print resolution and adds no weight to the page. */
.cert-pattern {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(45deg, rgba(176, 24, 24, 0.05) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, rgba(20, 20, 26, 0.035) 0 1px, transparent 1px 9px);
}

.cert-corner {
  position: absolute;
  width: 52px;
  height: 52px;
  border: 2px solid var(--seal);
  opacity: 0.75;
}
.cert-corner-tl { top: 14px; left: 14px; border-right: 0; border-bottom: 0; }
.cert-corner-tr { top: 14px; right: 14px; border-left: 0; border-bottom: 0; }
.cert-corner-bl { bottom: 14px; left: 14px; border-right: 0; border-top: 0; }
.cert-corner-br { bottom: 14px; right: 14px; border-left: 0; border-top: 0; }

.cert-provisional {
  position: relative;
  display: inline-block;
  margin-bottom: 18px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  color: #8a5a00;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.cert-sheet-provisional { border-style: dashed; }

.cert-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--rule);
  text-align: left;
}
.cert-head-brand { display: flex; align-items: center; gap: 12px; }
.cert-head-name {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--seal);
}
.cert-head-authority {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}
.cert-head-ref { text-align: right; }
.cert-head-ref-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  margin-bottom: 3px;
}
.cert-head-ref .mono { font-size: 12.5px; font-weight: 700; }

.cert-kicker {
  position: relative;
  margin-top: 30px;
  font-size: 12.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--seal);
}
.cert-sport {
  position: relative;
  margin-top: 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}

.cert-subject {
  position: relative;
  margin-top: 20px;
  font-size: 34px;
  line-height: 1.12;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.cert-value-block {
  position: relative;
  margin: 26px auto 0;
  padding: 18px 24px;
  max-width: 460px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.cert-value { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.cert-value-number {
  font-size: 60px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.04em;
}
.cert-value-unit {
  font-size: 17px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.cert-value-caption {
  margin-top: 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
}

.cert-athlete {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 26px;
  text-align: left;
}
.cert-athlete-flag { font-size: 34px; line-height: 1; }
.cert-athlete-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}
.cert-athlete-name { font-size: 24px; font-weight: 900; letter-spacing: -0.01em; }
.cert-athlete-meta { font-size: 12.5px; color: var(--ink-soft); }

.cert-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 34px;
  row-gap: 0;
  margin-top: 30px;
  text-align: left;
}
.cert-line {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dotted var(--rule);
  font-size: 13px;
}
.cert-line dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  white-space: nowrap;
}
.cert-line dd { font-weight: 600; text-align: right; color: var(--ink); }
.cert-line dd.mono { font-family: var(--font-mono); font-size: 12px; }

.cert-section-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.cert-methodology {
  position: relative;
  margin-top: 26px;
  padding: 16px 20px;
  border-radius: 8px;
  background: rgba(20, 20, 26, 0.03);
  text-align: left;
}
.cert-methodology-text {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-soft);
}

.cert-previous {
  position: relative;
  margin-top: 18px;
  text-align: left;
}
.cert-previous-text { margin-top: 6px; font-size: 13px; color: var(--ink-soft); }

.cert-signoff {
  position: relative;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 26px;
  align-items: center;
  margin-top: 30px;
  padding-top: 22px;
  border-top: 2px solid var(--rule);
  text-align: left;
}
.cert-verify-lines { margin-top: 10px; display: grid; gap: 7px; }
.cert-verify-lines > div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  font-size: 12px;
}
.cert-verify-lines dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  padding-top: 1px;
}
.cert-verify-lines dd { color: var(--ink); font-weight: 600; }
.cert-verify-url { overflow-wrap: anywhere; font-size: 11px; }

.cert-signature { display: flex; align-items: center; gap: 18px; }
.cert-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px dashed var(--seal);
  color: var(--seal);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
  transform: rotate(-8deg);
  flex-shrink: 0;
}
.cert-signature-name {
  font-family: "Snell Roundhand", "Segoe Script", cursive;
  font-size: 25px;
  line-height: 1;
  color: var(--ink);
}
.cert-signature-rule {
  display: block;
  width: 170px;
  height: 1px;
  background: var(--ink);
  margin: 8px 0 6px;
}
.cert-signature-role {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.cert-foot {
  position: relative;
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 8px;
}
.cert-foot-line { height: 3px; width: 100%; background: linear-gradient(90deg, var(--seal), transparent); }
.cert-foot p { font-size: 10.5px; line-height: 1.6; color: var(--ink-faint); }
.cert-foot-ref { letter-spacing: 0.08em; }

/* ─── Verification record under the certificate ──────────────── */

.cert-checks,
.cert-lineage {
  margin-top: 26px;
  padding: 22px 24px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.cert-checks-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.cert-check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cert-check {
  display: flex;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.cert-check:last-child { border-bottom: none; }
.cert-check-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
}
.cert-check-ok .cert-check-mark { background: rgba(34, 197, 94, 0.16); color: #4ade80; }
.cert-check-missing .cert-check-mark { background: rgba(245, 158, 11, 0.16); color: var(--ex3me-gold); }
[data-theme="light"] .cert-check-ok .cert-check-mark { background: rgba(22, 163, 74, 0.12); color: #15803d; }
.cert-check-label { display: block; font-size: 13.5px; font-weight: 600; }
.cert-check-detail { display: block; font-size: 12px; color: var(--text-tertiary); }

.cert-lineage-list { list-style: none; margin: 0; padding: 0; }
.cert-lineage-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cert-lineage-list li:last-child { border-bottom: none; }
.cert-lineage-index { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); width: 16px; }
.cert-lineage-flag { font-size: 20px; }
.cert-lineage-body { flex: 1; min-width: 0; }
.cert-lineage-name { display: block; font-size: 14px; font-weight: 600; }
.cert-lineage-ref { display: block; font-size: 11.5px; color: var(--text-muted); }
.cert-lineage-mark { text-align: right; font-size: 14px; display: grid; }

.cert-footnote {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

@media (max-width: 760px) {
  .cert-sheet { padding: 30px 20px 24px; }
  .cert-subject { font-size: 25px; }
  .cert-value-number { font-size: 42px; }
  .cert-grid { grid-template-columns: minmax(0, 1fr); }
  .cert-signoff { grid-template-columns: minmax(0, 1fr); }
  .cert-corner { display: none; }
}

@media print {
  .site-header, .site-footer, .no-print, .cert-toolbar { display: none !important; }
  body { background: #fff; color: #000; }
  .certificate { border-color: #999; }

  /* The sheet is already paper: strip the screen furniture and let the browser
     have the whole page, so "Save as PDF" produces the document and nothing else. */
  .cert-page { max-width: none; padding: 0; }
  .cert-sheet {
    border: 1px solid #999;
    box-shadow: none;
    border-radius: 0;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .cert-sheet, .cert-sheet * { color: #14141a !important; }
  .cert-head-name, .cert-kicker, .cert-seal { color: #b01818 !important; }
  .cert-value-block, .cert-foot { page-break-inside: avoid; break-inside: avoid; }
  @page { margin: 12mm; }
}

/* ============================================================
   UI/UX LAYER

   Added on top of the ported design system rather than replacing it, so every
   page already in the catalogue picks the improvements up without a rewrite.
   Three things drive this pass:

     1. The type scale is now fluid. A 96px hero headline was fine on a desktop
        and unreadable on a phone; clamp() lets one class serve both.
     2. The chrome got real states — the header reacts to scroll, the mobile nav
        is a proper drawer with a scrim, and the console gets a topbar on small
        screens instead of a sidebar that pushes the content off-canvas.
     3. Everything interactive has a visible focus ring, and the header height is
        a variable so anchors and sticky filter bars stop hiding under it.
   ============================================================ */

:root {
  --header-h: 64px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  /* One easing curve for the whole product. Anything that moves uses this. */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.22s;
}

html[data-theme="light"] {
  --shadow-header: 0 1px 0 rgba(0, 0, 0, 0.06), 0 8px 28px rgba(0, 0, 0, 0.06);
  --shadow-drawer: -18px 0 60px rgba(0, 0, 0, 0.18);
  --scrim: rgba(9, 9, 11, 0.35);
}

html[data-theme="dark"] {
  --shadow-header: 0 1px 0 rgba(255, 255, 255, 0.05), 0 12px 34px rgba(0, 0, 0, 0.55);
  --shadow-drawer: -18px 0 60px rgba(0, 0, 0, 0.7);
  --scrim: rgba(0, 0, 0, 0.62);
}

/* ── Fluid type ──────────────────────────────────────────────── */

.text-3xl { font-size: clamp(24px, 3.4vw, 32px); }
.text-4xl { font-size: clamp(28px, 4.6vw, 40px); }
.text-5xl { font-size: clamp(32px, 6vw, 52px); }
.text-6xl { font-size: clamp(34px, 7.4vw, 64px); }
.text-7xl { font-size: clamp(38px, 9vw, 78px); }
.text-8xl { font-size: clamp(44px, 11.5vw, 96px); }

h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }

/* The huge display sizes need the tracking pulled in and the leading tight, or
   they look loose next to the smaller UI text. */
.text-6xl, .text-7xl, .text-8xl { letter-spacing: -0.035em; line-height: 0.98; }

/* Headings and anchor targets must clear the sticky header. */
:target, [id] { scroll-margin-top: calc(var(--header-h) + 18px); }

/* ── Accessibility ───────────────────────────────────────────── */

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

.skip-link {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translate(-50%, -200%);
  z-index: 200;
  padding: 12px 22px;
  background: var(--ex3me-red);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  border-radius: 0 0 12px 12px;
  transition: transform var(--dur) var(--ease);
}
.skip-link:focus { transform: translate(-50%, 0); }

::selection { background: rgba(220, 30, 30, 0.28); color: var(--text-primary); }

/* Keyboard users get a ring; mouse users don't get a 2px red outline on every
   click. The class is added by app.js once a pointer is actually used. */
:focus-visible { outline: 2px solid var(--ex3me-red); outline-offset: 2px; border-radius: 6px; }
body.using-pointer :focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ── Header chrome ───────────────────────────────────────────── */

.site-header {
  transition: box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.site-header.is-scrolled { box-shadow: var(--shadow-header); }

/* The red hairline under the nav is a gradient so it fades out at the edges
   instead of stopping dead at the container. */
.site-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(220, 30, 30, 0.5), transparent);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  pointer-events: none;
}
.site-header.is-scrolled::after { opacity: 1; }

/* Utility strip: live catalogue numbers and the trust line, above the nav. It
   collapses on small screens, where the drawer carries that information. */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 12px;
  color: var(--text-tertiary);
}
.topbar .topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 34px;
}
.topbar-items { display: flex; align-items: center; gap: 18px; }
.topbar-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.topbar-item strong { color: var(--text-secondary); font-weight: 700; }
.topbar a { color: var(--text-tertiary); }
.topbar a:hover { color: var(--text-primary); }
.topbar-accent { color: var(--ex3me-red); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

@media (max-width: 1080px) { .topbar { display: none; } }

/* ── Navigation ──────────────────────────────────────────────── */

.nav-link { position: relative; }
.nav-link.active {
  color: var(--text-primary);
  background: var(--input-bg);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* The active item gets a red rule instead of an outline: it reads as a tab bar
   and stays visible in both themes. */
.nav-link.active::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--ex3me-red);
}

.nav-cta-group { display: flex; align-items: center; gap: 6px; }
.nav-divider { width: 1px; height: 22px; background: var(--border); }

.dropdown-menu { padding: 8px; }
.dropdown-menu a { display: flex; align-items: center; gap: 10px; }
.dropdown-menu .dropdown-heading {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Mobile drawer ───────────────────────────────────────────── */

/* Replaces the old inline dropdown: a right-hand panel with a scrim, grouped
   links and sticky sign-in actions at the bottom. */
.nav-scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur);
  z-index: 90;
}
.nav-scrim.open { opacity: 1; visibility: visible; }

.mobile-nav {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0;
  width: min(88vw, 380px);
  height: 100vh;
  height: 100dvh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-drawer);
  transform: translateX(100%);
  transition: transform 0.3s var(--ease);
  z-index: 100;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mobile-nav.open { transform: translateX(0); display: flex; }

.mobile-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 2;
}
.mobile-nav-body { padding: 12px 16px 20px; flex: 1; }
.mobile-nav-foot {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
}

.mobile-group-label {
  display: block;
  padding: 16px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.mobile-nav-body a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}
.mobile-nav-body a:hover,
.mobile-nav-body a.active { background: var(--input-bg); color: var(--text-primary); }
.mobile-nav-body a.active { box-shadow: inset 2px 0 0 var(--ex3me-red); }

body.drawer-open { overflow: hidden; }

.nav-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
}
.nav-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-primary);
  cursor: pointer;
  padding: 0;
}
.nav-toggle:hover { background: var(--bg-hover); }
@media (max-width: 1080px) { .nav-toggle { display: inline-flex; } }

/* ── Buttons ─────────────────────────────────────────────────── */

.btn-primary:active,
.btn-secondary:active,
.btn-ghost:active { transform: translateY(0) scale(0.99); }

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-ghost:focus-visible,
.btn-danger:focus-visible { outline: 2px solid var(--ex3me-red); outline-offset: 2px; }

.btn-primary[disabled],
.btn-secondary[disabled],
.btn-ghost[disabled],
.btn-primary.is-disabled {
  opacity: 0.5;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

/* Outlined-on-glass: for the header, where a solid red button would fight the
   primary CTA. */
.btn-glass {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.btn-glass:hover { border-color: var(--ex3me-red); color: var(--ex3me-red); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .btn-primary, .btn-secondary { width: 100%; }
  .btn-row > .btn-primary, .btn-row > .btn-secondary { flex: 1 1 100%; }
  .nav-actions .btn-primary, .nav-actions .btn-secondary { width: auto; }
}

/* ── Cards ───────────────────────────────────────────────────── */

.card { position: relative; overflow: hidden; }

/* A red bar that grows on hover — used on the discovery grids so the whole
   tile reads as one target. */
.card-accent::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--ex3me-red);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform var(--dur) var(--ease);
}
.card-accent:hover::before { transform: scaleY(1); }

.card-static { transition: none; }
.card:focus-within { border-color: var(--ex3me-red); box-shadow: 0 0 0 3px var(--ring); }

/* Section headers: eyebrow + title + action, aligned to a common baseline with
   a rule underneath. Replaces the ad-hoc flex rows on each page. */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.section-head h2 { margin: 0; }
.section-head p.lede { color: var(--text-secondary); font-size: 15px; margin-top: 8px; }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ex3me-red);
  white-space: nowrap;
}
.link-arrow svg { transition: transform var(--dur) var(--ease); }
.link-arrow:hover svg { transform: translateX(3px); }

/* ── KPI / stat tiles ────────────────────────────────────────── */

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

.kpi {
  position: relative;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
}
.kpi::after {
  content: "";
  position: absolute;
  right: -40px; top: -40px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(220, 30, 30, 0.14), transparent 70%);
}
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.kpi-value {
  margin-top: 6px;
  font-size: clamp(28px, 3.6vw, 38px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-note { margin-top: 8px; font-size: 12px; color: var(--text-tertiary); }
.kpi-link { position: absolute; inset: 0; z-index: 1; }
.kpi:hover { border-color: var(--border-strong); }

.kpi-accent { border-color: rgba(220, 30, 30, 0.35); }
.kpi-accent .kpi-value { color: var(--ex3me-red); }

/* ── Meters, chips, segmented controls ───────────────────────── */

.meter { display: grid; gap: 6px; }
.meter-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.meter-bar { height: 6px; border-radius: 3px; background: var(--badge-bg); overflow: hidden; }
.meter-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--ex3me-red); }
.meter-bar.is-gold > span { background: var(--ex3me-gold); }
.meter-bar.is-green > span { background: #16a34a; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}
.chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.chip.is-active { background: var(--ex3me-red); border-color: var(--ex3me-red); color: #fff; }

/* Sticky filter bar for discovery pages: the filters stay reachable while the
   result grid scrolls. */
.filter-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.filter-bar-inner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 0; }
.filter-bar .input { background: var(--bg-card); }

@media (max-width: 760px) {
  .filter-bar { position: static; }
  .filter-bar-inner .input, .filter-bar-inner select.input { min-width: 0 !important; flex: 1 1 100%; }
}

/* ── Toasts & flashes ────────────────────────────────────────── */

.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 14px;
  margin-bottom: 12px;
  animation: fadeInUp 0.35s var(--ease) both;
}
.flash-success { border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.08); }
.flash-error { border-color: rgba(220, 30, 30, 0.4); background: rgba(220, 30, 30, 0.08); }
.flash-warning, .flash-notice { border-color: rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.08); }

/* ── Back to top ─────────────────────────────────────────────── */

.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: var(--shadow-elevated);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: all var(--dur) var(--ease);
}
.to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { border-color: var(--ex3me-red); color: var(--ex3me-red); }

/* ── Tables ──────────────────────────────────────────────────── */

.table-wrap { position: relative; }
table.data thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elevated);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
table.data tbody tr { transition: background-color 0.15s ease; }
table.data td .row-title { font-weight: 600; color: var(--text-primary); }
table.data td .row-sub { font-size: 12px; color: var(--text-muted); }

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.table-toolbar .input { max-width: 320px; }
.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ── Admin chrome ────────────────────────────────────────────── */

.admin-shell { grid-template-columns: 264px minmax(0, 1fr); }

.admin-side .admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 0;
}

/* Group labels stick to the top of the scrolling sidebar so a long nav never
   loses its context. */
.admin-side .admin-group-label {
  position: sticky;
  top: -20px;
  background: var(--bg-elevated);
  z-index: 1;
}

.admin-side .admin-nav a { transition: background-color 0.15s ease, color 0.15s ease; }
.admin-side .admin-nav a.active { box-shadow: 0 6px 18px rgba(220, 30, 30, 0.28); }
.admin-nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--text-secondary);
}
.admin-side .admin-nav a.active .admin-nav-count { background: rgba(255, 255, 255, 0.22); color: #fff; }

.admin-main { max-width: 1500px; width: 100%; }

/* Console topbar: only exists below the sidebar breakpoint, where the sidebar
   becomes a drawer. Without it there would be no way to reach the navigation. */
.admin-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 70;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.admin-topbar-title { font-size: 14px; font-weight: 800; letter-spacing: -0.01em; }
.admin-topbar-sub { font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }

.admin-scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur);
  z-index: 90;
}
.admin-scrim.open { opacity: 1; visibility: visible; }

/* Breadcrumb + page head used by every console screen. */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.crumbs a:hover { color: var(--text-primary); }
.crumbs .sep { opacity: 0.5; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { font-size: clamp(24px, 3.2vw, 32px); font-weight: 800; letter-spacing: -0.03em; }
.page-head .lede { margin-top: 8px; font-size: 14px; color: var(--text-secondary); max-width: 68ch; }
.page-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

@media (max-width: 1080px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .admin-topbar { display: flex; }
  .admin-side {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    height: 100dvh;
    width: min(86vw, 320px);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
    box-shadow: var(--shadow-drawer);
  }
  .admin-side.open { transform: translateX(0); }
  .admin-side .admin-group-label { position: static; }
}

@media (max-width: 900px) {
  .admin-main { padding: 18px 16px 56px; }
  .page-head { align-items: flex-start; }
  .page-head-actions { width: 100%; }
  .page-head-actions .btn-primary, .page-head-actions .btn-secondary { flex: 1 1 auto; width: auto; }
}

/* ── Sidebar / shell helpers ─────────────────────────────────── */

.stack { display: grid; gap: 24px; align-content: start; }
.stack-sm { display: grid; gap: 12px; }
.sidebar-note {
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
}
.divider-bottom { border-bottom: 1px solid var(--border); }

@media (max-width: 640px) {
  .container, .container-narrow, .container-tight { padding: 0 18px; }
  .section { padding: 40px 0; }
  .section-lg { padding: 48px 0; }
  .section-head { margin-bottom: 24px; }
}

/* ── Partnership application form ─────────────────────────────── */

.pa-form-header {
  text-align: center;
  margin-bottom: 32px;
}
.pa-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, var(--radius));
  padding: 24px 28px;
  margin-bottom: 24px;
  background: var(--surface);
}
.pa-fieldset legend {
  font-weight: 700;
  font-size: 15px;
  padding: 0 12px;
  color: var(--text-primary);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  margin-bottom: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-inset, var(--surface));
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(220, 30, 30, 0.12);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.field-error { font-size: 12px; color: #ef4444; }
.pa-form-footer { text-align: center; padding-top: 8px; }
.pa-success-card {
  text-align: center;
  padding: 48px 24px;
}
.pa-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #16a34a;
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 20px;
}
.partner-tier-group { margin-bottom: 32px; }
.callout {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
}
.callout-red { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.25); color: #ef4444; }
.tag-clickable { cursor: pointer; border: none; font-family: inherit; font-size: inherit; }
.tag-clickable:hover { opacity: 0.8; }
.card-green-border { border-left: 3px solid #16a34a; }
.card-muted-border { border-left: 3px solid var(--border-strong); }
.btn-lg { padding: 14px 32px; font-size: 15px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .pa-fieldset { padding: 18px 16px; }
}

/* ── Admin detail grids (used by partnership review) ──────────── */
.detail-grid { display: flex; flex-direction: column; gap: 10px; }
.detail-row { display: flex; gap: 16px; align-items: baseline; }
.detail-label { flex: 0 0 140px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; }
.detail-value { flex: 1; font-size: 14px; color: var(--text-primary); }
.detail-section { padding-top: 8px; border-top: 1px solid var(--border); }
.detail-section:first-child { border-top: 0; padding-top: 0; }
.whitespace-pre-wrap { white-space: pre-wrap; }

/* Phase 1 Trust */
.flash-success { background: rgba(22,163,74,0.12); border: 1px solid rgba(22,163,74,0.25); color: #16a34a; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.flash-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.25); color: #ef4444; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.inline { display: inline; }
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 12px; }
.pt-4 { padding-top: 16px; }
.divider-top { border-top: 1px solid var(--border); }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.nowrap { white-space: nowrap; }
.tag-red { background: rgba(239,68,68,0.12); color: #ef4444; }
.tag-blue { background: rgba(59,130,246,0.12); color: #3b82f6; }
.tag-green { background: rgba(22,163,74,0.12); color: #16a34a; }
.tag-gold { background: rgba(234,179,8,0.12); color: #eab308; }
.tag-neutral { background: var(--surface-inset, var(--surface)); color: var(--text-muted); }
.search-bar { display: flex; gap: 8px; }
.search-bar input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-primary); font-size: 14px; }

/* ── Notification bell ────────────────────────────────────────────── */
.notif-bell { position: relative; font-size: 18px; text-decoration: none; padding: 4px 8px; border-radius: 6px; transition: background 0.2s; }
.notif-bell:hover { background: var(--surface-hover, rgba(255,255,255,0.06)); }
.notif-badge { position: absolute; top: 0; right: 0; background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; }

/* ── Challenges ───────────────────────────────────────────────────── */
.challenge-card { display: block; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text-primary); transition: border-color 0.2s, box-shadow 0.2s; }
.challenge-card:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.challenge-card-header { display: flex; align-items: center; justify-content: space-between; }
.challenge-status { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.challenge-status-pending { background: rgba(234,179,8,0.15); color: #eab308; }
.challenge-status-active { background: rgba(22,163,74,0.15); color: #16a34a; }
.challenge-status-completed { background: var(--surface-inset, var(--surface)); color: var(--text-muted); }
.challenge-status-declined { background: rgba(239,68,68,0.15); color: #ef4444; }
.challenge-code { font-family: monospace; color: var(--text-muted); font-size: 12px; }
.challenge-vs { display: flex; align-items: center; justify-content: center; gap: 24px; margin: 16px 0; }
.challenge-athlete { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.challenge-flag { font-size: 20px; }
.challenge-vs-label { font-size: 14px; font-weight: 800; color: var(--accent); letter-spacing: 0.1em; }
.challenge-meta { display: flex; flex-wrap: wrap; gap: 16px; color: var(--text-muted); font-size: 13px; margin-top: 8px; }
.challenge-battle-card { display: flex; align-items: center; justify-content: center; gap: 32px; padding: 40px 24px; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); margin: 24px 0; }
.challenge-battle-side { text-align: center; flex: 1; }
.challenge-battle-center { text-align: center; flex-shrink: 0; }
.challenge-vs-big { font-size: 36px; font-weight: 900; color: var(--accent); letter-spacing: 0.1em; }
.challenge-role-badge { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }

/* ── Badges & Achievements ────────────────────────────────────────── */
.badge-card { padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-align: center; transition: transform 0.2s, box-shadow 0.2s; }
.badge-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.badge-icon { font-size: 48px; margin-bottom: 12px; }
.badge-name { font-size: 16px; font-weight: 700; margin: 0 0 8px; }
.badge-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; line-height: 1.5; }
.badge-meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.badge-tier, .badge-rarity, .badge-points { font-size: 11px; padding: 2px 8px; border-radius: 8px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-tier { background: rgba(234,179,8,0.15); color: #eab308; }
.badge-rarity { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.badge-points { background: rgba(22,163,74,0.15); color: #16a34a; }
.badge-tier-bronze .badge-icon { filter: saturate(0.8); }
.badge-tier-silver .badge-icon { filter: saturate(0.6) brightness(1.2); }
.badge-tier-gold .badge-icon { filter: saturate(1.4) brightness(1.1); }
.badge-tier-platinum .badge-icon { filter: saturate(1.6) brightness(1.3) drop-shadow(0 0 8px rgba(234,179,8,0.3)); }

/* ── Reactions ────────────────────────────────────────────────────── */
.reaction-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.reaction-btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); cursor: pointer; font-size: 16px; transition: all 0.2s; color: var(--text-primary); }
.reaction-btn:hover { border-color: var(--accent); background: var(--surface-hover, rgba(255,255,255,0.06)); }
.reaction-btn.reaction-active { border-color: var(--accent); background: rgba(220,30,30,0.1); }
.reaction-count { font-size: 12px; font-weight: 600; color: var(--text-muted); }

/* ── Comments ─────────────────────────────────────────────────────── */
.comment-card { padding: 16px 0; border-bottom: 1px solid var(--border); }
.comment-card:last-child { border-bottom: none; }
.comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.comment-avatar { font-size: 20px; }
.comment-author { font-weight: 600; font-size: 14px; }
.comment-time { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.comment-body { font-size: 14px; line-height: 1.6; color: var(--text-secondary); }

/* ── Notifications ────────────────────────────────────────────────── */
.notification-card { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: background 0.2s; }
.notification-card:hover { background: var(--surface-hover, rgba(255,255,255,0.03)); }
.notification-unread { border-left: 3px solid var(--accent); background: rgba(220,30,30,0.04); }
.notification-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface-inset, var(--surface)); font-size: 16px; flex-shrink: 0; }
.notification-icon-challenge { background: rgba(220,30,30,0.1); }
.notification-icon-reaction { background: rgba(234,179,8,0.1); }
.notification-icon-comment { background: rgba(59,130,246,0.1); }
.notification-icon-badge { background: rgba(139,92,246,0.1); }
.notification-icon-follow { background: rgba(22,163,74,0.1); }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .challenge-battle-card { flex-direction: column; gap: 16px; padding: 24px 16px; }
    .challenge-vs { gap: 12px; }
    .badge-meta { gap: 4px; }
    .reaction-bar { gap: 4px; }
    .reaction-btn { padding: 4px 8px; font-size: 14px; }
}

/* ══════════════════════════════════════════════════════════════════
   DIRECT MESSAGING
   ══════════════════════════════════════════════════════════════════ */

.msg-shell { max-width: 1080px; }

.msg-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.msg-main { min-width: 0; }
.msg-side { display: grid; gap: 16px; position: sticky; top: 96px; }

.msg-side-title {
    font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-secondary); margin: 0 0 12px;
}

.msg-unread-pill {
    display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px;
    background: var(--ex3me-red); color: #fff; font-size: 12px; font-weight: 700;
}

.msg-stat-row { display: flex; align-items: baseline; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.msg-stat-row:last-of-type { border-bottom: 0; }
.msg-stat-value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.msg-stat-value.is-live { color: #22c55e; }
.msg-stat-label { font-size: 12px; color: var(--text-tertiary); }

/* Thread list ------------------------------------------------------ */

.msg-thread-list { display: grid; gap: 8px; }

.msg-thread {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px;
    border: 1px solid var(--border); border-radius: 14px; background: var(--bg-card);
    text-decoration: none; color: inherit; transition: border-color .15s, background .15s, transform .15s;
}
.msg-thread:hover { border-color: var(--border-strong); background: var(--bg-hover); transform: translateY(-1px); }
.msg-thread-unread { border-color: rgba(220, 30, 30, 0.4); }
.msg-thread-unread .msg-thread-preview { color: var(--text-primary); font-weight: 600; }

.msg-thread-body { flex: 1; min-width: 0; display: grid; gap: 3px; }
.msg-thread-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.msg-thread-name { font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.msg-thread-time { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; }
.msg-thread-preview {
    font-size: 13px; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.msg-avatar {
    width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-surface); border: 1px solid var(--border); font-size: 20px;
}
.msg-avatar-sm { width: 34px; height: 34px; font-size: 16px; }
.msg-avatar-xs { width: 28px; height: 28px; font-size: 14px; }

.msg-badge {
    min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
    background: var(--ex3me-red); color: #fff; font-size: 11px; font-weight: 800;
    display: inline-flex; align-items: center; justify-content: center;
}
.msg-muted { font-size: 13px; opacity: .6; }
.msg-tag { font-size: 9px; padding: 2px 6px; }

/* Room header ------------------------------------------------------ */

.msg-room-head {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.msg-room-ident { display: flex; align-items: center; gap: 14px; min-width: 0; }
.msg-back {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); color: var(--text-primary); text-decoration: none;
}
.msg-back:hover { background: var(--bg-hover); }
.msg-room-avatars { display: flex; }
.msg-room-avatars .msg-avatar { margin-left: -10px; }
.msg-room-avatars .msg-avatar:first-child { margin-left: 0; }
.msg-room-title { font-size: 20px; font-weight: 800; margin: 0; line-height: 1.2; }
.msg-room-sub { font-size: 12px; color: var(--text-tertiary); margin: 3px 0 0; display: flex; align-items: center; gap: 6px; }
.msg-room-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.msg-call-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 10px;
    border: 1px solid var(--border-strong); background: transparent; color: var(--text-primary);
    font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s;
}
.msg-call-btn:hover:not(:disabled) { background: var(--bg-hover); }
.msg-call-btn:disabled { opacity: .45; cursor: not-allowed; }
.msg-call-btn-primary { background: var(--ex3me-red); border-color: var(--ex3me-red); color: #fff; }
.msg-call-btn-primary:hover:not(:disabled) { background: var(--ex3me-red-dark); }

.msg-icon-btn {
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
    background: transparent; color: var(--text-primary); cursor: pointer; font-size: 15px;
    display: inline-flex; align-items: center; justify-content: center;
}
.msg-icon-btn:hover { background: var(--bg-hover); }

.msg-live-call {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 16px;
    border-radius: 12px; background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.35);
    color: inherit; text-decoration: none; font-size: 13px;
}
.msg-live-dot {
    width: 9px; height: 9px; border-radius: 50%; background: #22c55e; flex-shrink: 0;
    animation: msg-pulse 1.6s ease-in-out infinite;
}
@keyframes msg-pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* Stream ----------------------------------------------------------- */

.msg-room {
    display: grid; grid-template-rows: minmax(0, 1fr) auto;
    border: 1px solid var(--border); border-radius: 16px; background: var(--bg-elevated);
    overflow: hidden;
}

.msg-stream {
    display: grid; gap: 14px; align-content: start; padding: 20px;
    max-height: 58vh; overflow-y: auto; scroll-behavior: smooth;
}

.msg-empty { text-align: center; color: var(--text-tertiary); padding: 40px 20px; font-size: 14px; }

.msg-row { display: flex; gap: 10px; align-items: flex-end; }
.msg-row-mine { flex-direction: row-reverse; }
.msg-bubble-wrap { display: grid; gap: 4px; max-width: 74%; min-width: 0; }
.msg-row-mine .msg-bubble-wrap { justify-items: end; }
.msg-sender { font-size: 11px; font-weight: 700; color: var(--text-tertiary); padding-left: 4px; }

.msg-bubble {
    padding: 11px 14px; border-radius: 16px; background: var(--bg-surface);
    border: 1px solid var(--border); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere;
}
.msg-row-mine .msg-bubble { background: var(--ex3me-red); border-color: var(--ex3me-red-dark); color: #fff; }
.msg-text { margin: 0; }
.msg-meta { font-size: 11px; color: var(--text-muted); padding: 0 4px; }

.msg-attach { display: grid; gap: 8px; margin-top: 8px; }
.msg-bubble .msg-attach:only-child { margin-top: 0; }
.msg-attach-img, .msg-attach-video {
    display: block; width: 100%; max-width: 320px; border-radius: 12px;
    border: 1px solid var(--border); background: #000;
}
.msg-attach-audio { width: 100%; max-width: 320px; }
.msg-attach-file {
    display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    text-decoration: none; color: inherit; font-size: 13px;
}
.msg-row-mine .msg-attach-file { background: rgba(0,0,0,0.22); border-color: rgba(255,255,255,0.22); }
.msg-attach-icon { font-size: 18px; flex-shrink: 0; }
.msg-attach-meta { display: grid; min-width: 0; flex: 1; }
.msg-attach-meta strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-attach-meta em { font-style: normal; font-size: 11px; opacity: .7; }
.msg-attach-dl { opacity: .7; flex-shrink: 0; }

.msg-call-card {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px;
    background: var(--bg-card); border: 1px solid rgba(220, 30, 30, 0.4);
    text-decoration: none; color: inherit;
}
.msg-call-icon { font-size: 22px; }
.msg-call-card span:last-child { display: grid; }
.msg-call-card strong { font-size: 14px; }
.msg-call-card em { font-style: normal; font-size: 11px; color: var(--text-tertiary); }

/* Composer --------------------------------------------------------- */

.msg-composer { border-top: 1px solid var(--border); padding: 12px 16px 14px; background: var(--bg-card); }
.msg-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.msg-attach-btn {
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    color: var(--text-secondary); flex-shrink: 0;
}
.msg-attach-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.msg-input {
    flex: 1; resize: none; min-height: 40px; max-height: 160px; padding: 10px 12px;
    border-radius: 10px; border: 1px solid var(--border); background: var(--input-bg);
    color: var(--text-primary); font: inherit; font-size: 14px; line-height: 1.4;
}
.msg-input:focus { outline: none; border-color: var(--ring); }
.msg-send-btn {
    width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--ex3me-red);
    color: #fff; cursor: pointer; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.msg-send-btn:hover { background: var(--ex3me-red-dark); }
.msg-send-btn:disabled { opacity: .5; cursor: wait; }
.msg-composer-hint {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 8px; font-size: 11px; color: var(--text-tertiary);
}
.msg-attach-name { font-weight: 600; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg-call-list { display: grid; gap: 6px; }
.msg-call-row {
    display: flex; align-items: center; gap: 12px; padding: 9px 0;
    border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; font-size: 13px;
}
.msg-call-row:last-child { border-bottom: 0; }
.msg-call-row-main { display: grid; flex: 1; min-width: 0; }
.msg-call-row-main em { font-style: normal; font-size: 11px; color: var(--text-tertiary); }

/* People picker ---------------------------------------------------- */

.msg-people {
    display: grid; gap: 6px; margin-top: 10px; max-height: 320px; overflow-y: auto;
    padding: 4px; border: 1px solid var(--border); border-radius: 12px;
}
.msg-person {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
    cursor: pointer; transition: background .12s;
}
.msg-person:hover { background: var(--bg-hover); }
.msg-person input { display: none; }
.msg-person-body { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.msg-person-name { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.msg-person-handle { font-size: 11px; color: var(--text-tertiary); }
.msg-person-check { opacity: 0; color: var(--ex3me-red); flex-shrink: 0; }
.msg-person input:checked ~ .msg-person-check { opacity: 1; }
.msg-person:has(input:checked) { background: rgba(220, 30, 30, 0.08); border: 1px solid rgba(220, 30, 30, 0.3); }

/* ══════════════════════════════════════════════════════════════════
   VOICE & VIDEO CALLS
   ══════════════════════════════════════════════════════════════════ */

.call-shell { max-width: 1100px; padding-top: 92px; }

.call-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; margin-bottom: 18px;
}
.call-bar-left { display: flex; align-items: center; gap: 12px; }
.call-dot {
    width: 11px; height: 11px; border-radius: 50%; background: #22c55e; flex-shrink: 0;
    animation: msg-pulse 1.6s ease-in-out infinite;
}
.call-dot.is-off { background: var(--text-muted); animation: none; }
.call-title { font-size: 19px; font-weight: 800; margin: 0; display: flex; align-items: baseline; gap: 10px; }
.call-timer { font-size: 13px; font-weight: 600; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.call-sub { font-size: 12px; color: var(--text-tertiary); margin: 3px 0 0; }

.call-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px;
    margin-bottom: 20px;
}

.call-tile {
    position: relative; aspect-ratio: 16 / 10; border-radius: 16px; overflow: hidden;
    background: #0b0b0b; border: 1px solid var(--border);
}
.call-tile.is-paused::after {
    content: 'Paused'; position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; color: var(--text-tertiary); font-size: 13px;
}
.call-tile-video { position: absolute; inset: 0; }
.call-tile-video video { width: 100% !important; height: 100% !important; object-fit: cover; }
.call-tile-local { border-color: var(--border-strong); }
.call-tile-name {
    position: absolute; left: 10px; bottom: 10px; padding: 4px 10px; border-radius: 999px;
    background: rgba(0,0,0,0.6); color: #fff; font-size: 12px; font-weight: 600;
    backdrop-filter: blur(6px);
}

.call-join-hint {
    aspect-ratio: 16 / 10; border-radius: 16px; border: 1px dashed var(--border-strong);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; color: var(--text-tertiary); font-size: 13px; text-align: center; padding: 20px;
}
.call-join-spinner {
    width: 26px; height: 26px; border-radius: 50%;
    border: 2px solid var(--border-strong); border-top-color: var(--ex3me-red);
    animation: call-spin .8s linear infinite;
}
@keyframes call-spin { to { transform: rotate(360deg); } }

.call-controls { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.call-ctl {
    display: inline-flex; align-items: center; gap: 7px; padding: 11px 18px; border-radius: 999px;
    border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary);
    font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s;
}
.call-ctl:hover { background: var(--bg-hover); }
.call-ctl.is-off { background: rgba(220, 30, 30, 0.14); border-color: rgba(220, 30, 30, 0.5); }
.call-ctl.is-on { background: rgba(34, 197, 94, 0.14); border-color: rgba(34, 197, 94, 0.5); }
.call-ctl-end { background: var(--ex3me-red); border-color: var(--ex3me-red); color: #fff; }
.call-ctl-end:hover { background: var(--ex3me-red-dark); }

.call-note { text-align: center; font-size: 12px; color: var(--text-tertiary); margin: 16px 0 0; }
.call-note.is-error { color: var(--ex3me-red-light); }

.call-fatal {
    text-align: center; padding: 60px 24px; border: 1px solid var(--border);
    border-radius: 16px; background: var(--bg-card);
}
.call-fatal h2 { font-size: 20px; font-weight: 800; margin: 0 0 8px; }
.call-fatal p { color: var(--text-secondary); font-size: 14px; margin: 0 0 18px; }

@media (max-width: 900px) {
    .msg-grid { grid-template-columns: minmax(0, 1fr); }
    .msg-side { position: static; order: 2; }
    .msg-bubble-wrap { max-width: 88%; }
    .msg-stream { max-height: none; }
    .call-shell { padding-top: 84px; }
}

@media (max-width: 640px) {
    .msg-room-actions form { display: contents; }
    .msg-call-btn span { display: none; }
    .msg-call-btn { padding: 9px 12px; }
    .msg-thread { padding: 12px; gap: 10px; }
    .msg-avatar { width: 36px; height: 36px; font-size: 17px; }
    .call-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════
   GLOBAL INCOMING-CALL RINGER
   Rides along on every page so a call finds a member wherever they are.
   ══════════════════════════════════════════════════════════════════ */

/* Beats the mobile drawer, the scrim and the to-top button. */
.ringer { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; }
.ringer[hidden] { display: none !important; }
body.ringer-open { overflow: hidden; }

.ringer-scrim {
    position: absolute; inset: 0;
    background: rgba(6, 6, 8, 0.72);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
    animation: ringer-fade 0.18s ease-out;
}

.ringer-card {
    position: relative; z-index: 1;
    width: min(370px, 100%);
    padding: 32px 26px 20px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border-strong, var(--border));
    border-radius: var(--radius-lg, 22px);
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
    animation: ringer-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

/* Two rings expanding out of the avatar — the visual half of the ringtone. */
.ringer-pulse { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 86px; height: 86px; margin-bottom: 14px; }
.ringer-pulse::before,
.ringer-pulse::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    border: 2px solid var(--ex3me-red, #dc1e1e);
    animation: ringer-ring 1.9s ease-out infinite;
}
.ringer-pulse::after { animation-delay: 0.95s; }

.ringer-avatar {
    position: relative; z-index: 1;
    display: flex; align-items: center; justify-content: center;
    width: 68px; height: 68px; border-radius: 50%;
    font-size: 30px; font-weight: 800; line-height: 1; color: #fff;
    background: linear-gradient(140deg, var(--ex3me-red, #dc1e1e), var(--ex3me-red-dark, #a01414));
}

.ringer-kicker { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ex3me-red, #dc1e1e); }
.ringer-title { margin: 6px 0 0; font-size: 22px; font-weight: 800; color: var(--text-primary); }
.ringer-sub { margin: 6px 0 0; font-size: 13px; color: var(--text-tertiary); }

.ringer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.ringer-form { display: block; margin: 0; }
.ringer-form button { width: 100%; }

.ringer-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 12px 16px; width: 100%;
    border-radius: var(--radius, 14px); border: 1px solid var(--border);
    background: var(--bg-hover, rgba(255, 255, 255, 0.06)); color: var(--text-primary);
    font-size: 14px; font-weight: 700; font-family: inherit; cursor: pointer;
    transition: background 0.18s, border-color 0.18s, transform 0.12s;
}
.ringer-btn:hover { border-color: var(--border-strong, var(--border)); }
.ringer-btn:active { transform: scale(0.98); }
.ringer-btn:focus-visible { outline: 2px solid var(--ex3me-red, #dc1e1e); outline-offset: 2px; }

.ringer-btn-accept { background: var(--ex3me-red, #dc1e1e); border-color: var(--ex3me-red, #dc1e1e); color: #fff; }
.ringer-btn-accept:hover { background: var(--ex3me-red-dark, #a01414); border-color: var(--ex3me-red-dark, #a01414); }
.ringer-btn-decline:hover { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.45); color: #ef4444; }

.ringer-silence {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 14px; padding: 6px 12px;
    border: 0; border-radius: 999px; background: transparent;
    color: var(--text-tertiary); font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
    transition: background 0.18s, color 0.18s;
}
.ringer-silence:hover { background: var(--bg-hover, rgba(255, 255, 255, 0.06)); color: var(--text-secondary); }
.ringer-silence.is-silenced { color: var(--ex3me-red, #dc1e1e); }

.ringer-hint { margin: 14px 0 0; font-size: 11px; color: var(--text-tertiary); opacity: 0.75; }

@keyframes ringer-ring {
    0% { transform: scale(0.84); opacity: 0.8; }
    100% { transform: scale(1.55); opacity: 0; }
}
@keyframes ringer-pop {
    from { transform: translateY(14px) scale(0.96); opacity: 0; }
}
@keyframes ringer-fade {
    from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ringer-card,
    .ringer-scrim { animation: none; }
    .ringer-pulse::before,
    .ringer-pulse::after { animation: none; opacity: 0.28; }
}

@media (max-width: 480px) {
    .ringer-card { padding: 26px 20px 16px; }
    .ringer-actions { grid-template-columns: 1fr; }
    /* Accept stays first in the tab order and on top of the stack. */
    .ringer-actions #ringer-accept { order: -1; }
}


