/* ==========================================================================
   phreaks 2600 — shared stylesheet
   One hand-written CSS file for the whole intranet. No frameworks, no build.
   Structure:
     1.  Design tokens (dark default + light override)
     2.  Reset & base elements
     3.  Layout primitives (container, grid, stack, page shell)
     4.  App shell (topnav, footer)
     5.  Typography helpers
     6.  Buttons
     7.  Forms (inputs, selects, textareas, validation, formset rows)
     8.  Badges, difficulty pills, tag chips, avatars, role badges
     9.  Cards
     10. Tables
     11. Pagination / load-more
     12. Empty states
     13. Flash / toast messages
     14. Code + rendered-markdown (GitHub-Dark)
     15. Misc components (stat tile, breadcrumbs, dropdown, tabs, progress,
         filter bar, spoiler, dev role switcher)
     16. Utilities
   ========================================================================== */

/* 1. ---------------------------------------------------------------- TOKENS */
:root, [data-theme="dark"] {
  /* Brand accent — identical in both themes. Red is punctuation, never a surface. */
  --accent:          #ef4444;
  --accent-hover:    #dc2626;
  --accent-contrast: #ffffff;
  --accent-soft:     rgba(239, 68, 68, 0.14);
  --accent-ring:     rgba(239, 68, 68, 0.45);

  /* Dark theme (default) — cohesive slate scale: bg darkest, surfaces step up */
  --bg:         #0f1521;
  --surface:    #171f2e;
  --surface-2:  #212c3e;
  --border:     #2a3547;
  --border-strong: #3a475c;
  --text:       #f3f4f6;
  --text-muted: #9aa7b8;
  --text-faint: #6b7686;

  /* Feedback hues (shared, tuned per theme where needed) */
  --ok:      #56d364;
  --ok-soft: rgba(86, 211, 100, 0.14);
  --warn:      #f0883e;
  --warn-soft: rgba(240, 136, 62, 0.14);
  --danger:      #ff7b72;
  --danger-soft: rgba(255, 123, 114, 0.14);
  --info:      #79c0ff;
  --info-soft: rgba(121, 192, 255, 0.14);

  /* Category badge hues (muted, harmonious, never red) */
  --cat-web:     #79c0ff;
  --cat-crypto:  #d2a8ff;
  --cat-forensics: #7ee787;
  --cat-stego:   #f0883e;
  --cat-reverse: #ffa657;
  --cat-pwn:     #ff7b72;
  --cat-osint:   #56d364;
  --cat-hardware:#8b949e;
  --cat-misc:    #6e7681;

  /* Difficulty hues */
  --diff-easy:   #56d364;
  --diff-medium: #f0883e;
  --diff-hard:   #ffa657;
  --diff-insane: var(--accent);

  /* GitHub-Dark code palette — identical in both themes (code stays dark) */
  --code-bg:       #0d1117;
  --code-border:   #30363d;
  --code-text:     #e6edf3;
  --code-comment:  #8b949e;
  --code-keyword:  #ff7b72;
  --code-function: #79c0ff;
  --code-string:   #a5d6ff;
  --code-entity:   #d2a8ff;
  --code-added:    #7ee787;
  --code-number:   #f0883e;

  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Radius, spacing, shadow, layout */
  --radius-sm: 0.375rem;
  --radius:    0.5rem;
  --radius-lg: 0.75rem;
  --radius-pill: 999px;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow:    0 6px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.55);
  /* subtle top edge-highlight that gives surfaces depth */
  --hairline: rgba(255,255,255,0.05);
  --lift: 0 4px 14px rgba(0,0,0,0.35);

  --nav-h: 56px;
  --content-max: 1120px;

  color-scheme: dark;
}

/* Light theme — via manual toggle OR system preference.
   Selector is un-scoped ([data-theme="light"], not :root[...]) so the overrides
   cascade into ANY subtree carrying data-theme, enabling scoped theming. */
[data-theme="light"] {
  --bg:         #ffffff;
  --surface:    #f9fafb;
  --surface-2:  #f3f4f6;
  --border:     #e5e7eb;
  --border-strong: #d1d5db;
  --text:       #111827;
  --text-muted: #4b5563;
  --text-faint: #9ca3af;

  --accent-soft: rgba(239, 68, 68, 0.10);

  /* Feedback hues re-tuned for light bg contrast */
  --ok:      #1a7f37;   --ok-soft: rgba(26, 127, 55, 0.10);
  --warn:    #bc4c00;   --warn-soft: rgba(188, 76, 0, 0.10);
  --danger:  #cf222e;   --danger-soft: rgba(207, 34, 46, 0.10);
  --info:    #0969da;   --info-soft: rgba(9, 105, 218, 0.10);

  /* Category hues darkened for AA text contrast on light tints */
  --cat-web:     #0969da;
  --cat-crypto:  #8250df;
  --cat-forensics: #1a7f37;
  --cat-stego:   #bc4c00;
  --cat-reverse: #9a5b00;
  --cat-pwn:     #cf222e;
  --cat-osint:   #1a7f37;
  --cat-hardware:#57606a;
  --cat-misc:    #6e7681;

  --diff-easy:   #1a7f37;
  --diff-medium: #bc4c00;
  --diff-hard:   #9a5b00;

  --shadow-sm: 0 1px 2px rgba(17,24,39,0.05);
  --shadow:    0 6px 24px rgba(17,24,39,0.09);
  --shadow-lg: 0 16px 48px rgba(17,24,39,0.13);
  --hairline: rgba(255,255,255,0.9);
  --lift: 0 6px 20px rgba(17,24,39,0.10);

  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:#ffffff; --surface:#f9fafb; --surface-2:#f3f4f6;
    --border:#e5e7eb; --border-strong:#d1d5db;
    --text:#111827; --text-muted:#4b5563; --text-faint:#9ca3af;
    --accent-soft: rgba(239,68,68,0.10);
    --ok:#1a7f37; --ok-soft:rgba(26,127,55,0.10);
    --warn:#bc4c00; --warn-soft:rgba(188,76,0,0.10);
    --danger:#cf222e; --danger-soft:rgba(207,34,46,0.10);
    --info:#0969da; --info-soft:rgba(9,105,218,0.10);
    --cat-web:#0969da; --cat-crypto:#8250df; --cat-forensics:#1a7f37;
    --cat-stego:#bc4c00; --cat-reverse:#9a5b00; --cat-pwn:#cf222e;
    --cat-osint:#1a7f37; --cat-hardware:#57606a; --cat-misc:#6e7681;
    --diff-easy:#1a7f37; --diff-medium:#bc4c00; --diff-hard:#9a5b00;
    --shadow-sm:0 1px 2px rgba(17,24,39,0.06);
    --shadow:0 4px 16px rgba(17,24,39,0.08);
    --shadow-lg:0 12px 40px rgba(17,24,39,0.12);
    color-scheme: light;
  }
}

/* 2. ------------------------------------------------------------ RESET/BASE */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* sticky footer: main grows to fill, footer sits at the viewport bottom on short pages */
body > main { flex: 1 0 auto; }
body > .footer { margin-top: auto; }
h1,h2,h3,h4,h5,h6 { line-height: 1.2; font-weight: 640; letter-spacing: -0.02em; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { padding-left: 1.25rem; }
hr { border: none; border-top: 1px solid var(--border); margin: var(--space-5) 0; }

/* Visible focus everywhere — accessibility requirement */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* 3. ------------------------------------------------------ LAYOUT PRIMITIVES */
.container { width: 100%; max-width: var(--content-max); margin-inline: auto; padding-inline: var(--space-5); }
@media (min-width: 720px) { .container { padding-inline: var(--space-6); } }
.container-narrow { max-width: 760px; }
.page { padding-block: var(--space-6) var(--space-8); }
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-6); }
.row { display: flex; gap: var(--space-3); align-items: center; }
.row-wrap { flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.spacer { flex: 1 1 auto; }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (min-width: 861px) and (max-width: 1040px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Dashboard-style 2-column main/side */
.layout-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-6); align-items: start; }
.layout-main-side > * { min-width: 0; }
@media (max-width: 960px) { .layout-main-side { grid-template-columns: 1fr; } }

/* 4. ------------------------------------------------------------- APP SHELL */
.topnav {
  position: sticky; top: 0; z-index: 40;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topnav__inner {
  height: 100%; max-width: var(--content-max); margin-inline: auto;
  padding-inline: var(--space-4);
  display: flex; align-items: center; gap: var(--space-5);
}
.brand { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.brand img { height: 34px; width: auto; }
.brand__word { font-family: var(--font-mono); font-size: 15px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.brand__word .num { color: var(--accent); }
.brand:hover { text-decoration: none; }

.nav-links { display: flex; align-items: center; gap: var(--space-1); flex: 1 1 auto; }
.nav-links a {
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  padding: 6px 10px; border-radius: var(--radius-sm); line-height: 1;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.nav-links a[aria-current="page"]::after {
  content: ""; display: block; height: 2px; margin-top: 4px; border-radius: 2px; background: var(--accent);
}

.nav-right { display: flex; align-items: center; gap: var(--space-2); flex: none; }

.nav-search {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 10px; width: 200px; color: var(--text-faint);
}
.nav-search input { border: none; background: none; outline: none; width: 100%; font-size: 13px; }
.nav-search kbd {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* Mobile nav toggle */
.nav-toggle { display: none; }
@media (max-width: 780px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: var(--space-3); display: none;
  }
  .nav-links.is-open { display: flex; }
  .nav-search { display: none; }
}

.footer {
  border-top: 1px solid var(--border); color: var(--text-faint);
  font-size: 13px; padding-block: var(--space-5); margin-top: var(--space-8);
}
.footer__inner { max-width: var(--content-max); margin-inline: auto; padding-inline: var(--space-4);
  display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; justify-content: space-between; }
.footer a { color: var(--text-muted); }
.footer .footer__links { display: flex; gap: var(--space-4); flex-wrap: wrap; }

/* Signed-out topnav variant */
.topnav--guest .nav-right { margin-left: auto; }

/* 5. ------------------------------------------------------------- TYPOGRAPHY */
.h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2rem); }
.h2 { font-size: 1.35rem; }
.h3 { font-size: 1.1rem; }
.page-title { font-size: clamp(1.4rem, 1.1rem + 1.3vw, 1.72rem); font-weight: 640; letter-spacing: -0.03em; }
.eyebrow { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.lead { font-size: 1.05rem; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
.numeric { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.section-head h2 { font-size: 1.1rem; white-space: nowrap; letter-spacing: -0.02em; }
.section-head .faint { text-align: right; }
.section-head .link-more { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.section-head .link-more:hover { color: var(--accent); }

/* Editorial "ruled" section header — mono index + label + hairline + action.
   Reads as an authored technical document, not a generic card grid. */
.rule-head { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); }
.rule-head__idx { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); letter-spacing: 0.02em; flex: none; }
.rule-head h2 { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; flex: none; text-transform: none; white-space: nowrap; }
.rule-head__line { flex: 1 1 auto; height: 1px; background: var(--border); }
.rule-head__action { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); flex: none; }
.rule-head__action:hover { color: var(--accent); text-decoration: none; }

/* Divided stat bar — one panel, hairline-separated cells (not 4 floating boxes) */
.statbar { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: inset 0 1px 0 var(--hairline), var(--shadow-sm); overflow: hidden; }
.statbar__cell { padding: var(--space-4) var(--space-5); border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 7px; }
.statbar__cell:first-child { border-left: none; }
.statbar__label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-faint); }
.statbar__value { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; line-height: 1; }
.statbar__meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); display: inline-flex; align-items: center; gap: 5px; }
.statbar__meta.up { color: var(--ok); }
.statbar__meta.down { color: var(--danger); }
@media (max-width: 720px) {
  .statbar { grid-template-columns: repeat(2, 1fr); }
  .statbar__cell:nth-child(3) { border-left: none; }
  .statbar__cell:nth-child(n+3) { border-top: 1px solid var(--border); }
}

/* Page header bar — title left, mono meta right, hairline under. Toolbar feel. */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; padding-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.pagehead__meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); display: flex; gap: var(--space-3); align-items: center; }
.pagehead__meta .dot { color: var(--border-strong); }

/* Challenge detail header — robust, non-overlapping */
.chal-head { padding-bottom: var(--space-4); border-bottom: 1px solid var(--border); margin-bottom: var(--space-6); }
.chal-head__tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: var(--space-3); }
.chal-head__row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.chal-head__row h1 { min-width: 0; margin: 0; }
.chal-head__row .btn { flex: none; margin-top: 4px; }
.chal-head__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-3); font-family: var(--font-mono); font-size: 12.5px; color: var(--text-faint); }
.chal-head__meta a { color: var(--text-muted); }
.chal-head__meta .dot { color: var(--border-strong); }

/* 6. --------------------------------------------------------------- BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-size: 14px; font-weight: 550; line-height: 1; letter-spacing: -0.01em;
  padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .06s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: 0 1px 2px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-contrast); }

.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: color-mix(in srgb, var(--surface-2) 80%, var(--text) 6%); }

.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger:hover { background: var(--danger-soft); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-google {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
  padding: 12px 18px; font-size: 15px; font-weight: 550;
}
.btn-google:hover { background: var(--surface-2); }
.btn-google .g-mark { width: 18px; height: 18px; }

/* 7. ----------------------------------------------------------------- FORMS */
.field { display: block; }
.field + .field { margin-top: var(--space-4); }
.label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 6px; }
.label .req { color: var(--accent); margin-left: 2px; }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }

.input, .select, .textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 14px; line-height: 1.4;
  transition: border-color .12s, box-shadow .12s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
.textarea { resize: vertical; min-height: 120px; font-family: var(--font-mono); font-size: 13px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

.input-group { display: flex; align-items: stretch; }
.input-group .prefix { display: inline-flex; align-items: center; white-space: nowrap; padding: 0 10px; background: var(--surface-2); border: 1px solid var(--border-strong); border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--text-faint); font-family: var(--font-mono); font-size: 13px; }
.input-group .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* Validation */
.field.is-error .input, .field.is-error .select, .field.is-error .textarea { border-color: var(--danger); }
.field.is-error .input:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.field.is-valid .input { border-color: var(--ok); }
.field-msg { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 5px; }
.field.is-error .field-msg { color: var(--danger); }
.field.is-valid .field-msg { color: var(--ok); }

.checkbox, .radio { display: flex; align-items: flex-start; gap: var(--space-2); font-size: 14px; cursor: pointer; }
.checkbox input, .radio input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; }
.switch-row + .switch-row { border-top: 1px solid var(--border); }

/* Formset repeatable rows (Django formsets) */
.formset { display: flex; flex-direction: column; gap: var(--space-2); }
.formset-row {
  display: flex; gap: var(--space-2); align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}
.formset-row .handle { color: var(--text-faint); cursor: grab; flex: none; }
.formset-row .input, .formset-row .select { flex: 1 1 auto; }
.formset-row .btn { flex: none; }
.formset-row.is-empty { border-style: dashed; color: var(--text-faint); }

/* 8. ---------------------------------------------- BADGES / PILLS / CHIPS / AVATAR */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: var(--radius-pill); letter-spacing: 0.01em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
/* Category badges — tinted bg + colored text, never red */
.badge--web      { color: var(--cat-web);      background: color-mix(in srgb, var(--cat-web) 15%, transparent); }
.badge--crypto   { color: var(--cat-crypto);   background: color-mix(in srgb, var(--cat-crypto) 15%, transparent); }
.badge--forensics{ color: var(--cat-forensics);background: color-mix(in srgb, var(--cat-forensics) 15%, transparent); }
.badge--stego,
.badge--stegano  { color: var(--cat-stego);    background: color-mix(in srgb, var(--cat-stego) 15%, transparent); }
.badge--reverse  { color: var(--cat-reverse);  background: color-mix(in srgb, var(--cat-reverse) 15%, transparent); }
.badge--pwn      { color: var(--cat-pwn);      background: color-mix(in srgb, var(--cat-pwn) 15%, transparent); }
.badge--osint    { color: var(--cat-osint);    background: color-mix(in srgb, var(--cat-osint) 15%, transparent); }
.badge--hardware { color: var(--cat-hardware); background: color-mix(in srgb, var(--cat-hardware) 18%, transparent); }
.badge--misc     { color: var(--cat-misc);     background: color-mix(in srgb, var(--cat-misc) 18%, transparent); }

/* Difficulty pills */
.pill {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 4px 9px; border-radius: var(--radius-sm); letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.pill--easy   { color: var(--diff-easy);   background: color-mix(in srgb, var(--diff-easy) 15%, transparent);   border-color: color-mix(in srgb, var(--diff-easy) 30%, transparent); }
.pill--medium { color: var(--diff-medium); background: color-mix(in srgb, var(--diff-medium) 15%, transparent); border-color: color-mix(in srgb, var(--diff-medium) 30%, transparent); }
.pill--hard   { color: var(--diff-hard);   background: color-mix(in srgb, var(--diff-hard) 15%, transparent);   border-color: color-mix(in srgb, var(--diff-hard) 30%, transparent); }
.pill--insane { color: var(--accent);      background: var(--accent-soft);                                      border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* Tag chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: var(--radius-sm);
}
.chip::before { content: "#"; color: var(--text-faint); }
.chip--removable { padding-right: 4px; }
.chip .chip-x { color: var(--text-faint); cursor: pointer; border: none; background: none; padding: 0 2px; line-height: 1; }
.chip .chip-x:hover { color: var(--danger); }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* Role badges */
.role {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: var(--radius-sm); line-height: 1;
}
.role--admin      { color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.role--maintainer { color: var(--info); background: var(--info-soft); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); }
.role--member     { color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); }

/* Avatars */
.avatar { position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex: none;
  background: var(--surface-2); color: var(--text-muted); font-family: var(--font-mono); font-weight: 600; font-size: 13px;
  border: 1px solid var(--border); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 26px; height: 26px; font-size: 11px; }
.avatar--lg { width: 72px; height: 72px; font-size: 26px; }
.avatar--xl { width: 104px; height: 104px; font-size: 36px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.user-inline { display: inline-flex; align-items: center; gap: var(--space-2); }
.user-inline .name { font-weight: 550; }
.user-inline .handle { color: var(--text-faint); font-family: var(--font-mono); font-size: 12px; }

/* 9. ----------------------------------------------------------------- CARDS */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--hairline), var(--shadow-sm);
}
.card__body { padding: var(--space-5); }
.card__head { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.card__head h3 { font-size: 0.98rem; letter-spacing: -0.015em; }
.card__foot { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); }
.card--link { display: block; color: inherit; transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease; }
.card--link:hover { border-color: var(--border-strong); text-decoration: none; transform: translateY(-2px); box-shadow: inset 0 1px 0 var(--hairline), var(--lift); }
.card--accent { border-left: 3px solid var(--accent); }

/* Challenge card */
.challenge-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); }
.challenge-card__top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.challenge-card__title { font-size: 1.02rem; font-weight: 600; color: var(--text); }
.challenge-card a.challenge-card__title:hover { color: var(--accent); }
.challenge-card__meta { display: flex; align-items: center; gap: var(--space-3); font-size: 12.5px; color: var(--text-faint); font-family: var(--font-mono); }
.challenge-card__solve { display: inline-flex; align-items: center; gap: 5px; }

/* 10. --------------------------------------------------------------- TABLES */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.table thead th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table td.numeric, .table th.numeric { text-align: right; }
.table .rank { font-family: var(--font-mono); color: var(--text-faint); }

/* 11. ------------------------------------------------- PAGINATION / LOAD MORE */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: var(--space-5); }
.pagination a, .pagination span {
  min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 10px; border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font-mono);
  color: var(--text-muted); border: 1px solid transparent;
}
.pagination a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.pagination [aria-current="page"] { background: var(--accent); color: var(--accent-contrast); }
.pagination .ellipsis { color: var(--text-faint); }
.pagination .disabled { opacity: .4; pointer-events: none; }
.load-more { display: flex; justify-content: center; margin-top: var(--space-5); }

/* 12. ---------------------------------------------------------- EMPTY STATES */
.empty {
  text-align: center; padding: var(--space-8) var(--space-5);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-muted);
}
.empty .empty__icon { color: var(--text-faint); margin: 0 auto var(--space-3); }
.empty .empty__icon svg { width: 40px; height: 40px; }
.empty h3 { color: var(--text); font-size: 1.05rem; margin-bottom: 6px; }
.empty p { max-width: 40ch; margin: 0 auto var(--space-4); font-size: 14px; }

/* 13. ------------------------------------------------------- FLASH / TOAST */
.flash {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); font-size: 14px;
}
.flash__icon { flex: none; margin-top: 1px; }
.flash__icon svg { width: 18px; height: 18px; }
.flash__body { flex: 1 1 auto; }
.flash__body strong { display: block; font-weight: 600; }
.flash .flash__close { flex: none; background: none; border: none; color: var(--text-faint); cursor: pointer; }
.flash--success { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); background: var(--ok-soft); }
.flash--success .flash__icon { color: var(--ok); }
.flash--error   { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: var(--danger-soft); }
.flash--error .flash__icon { color: var(--danger); }
.flash--warning { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: var(--warn-soft); }
.flash--warning .flash__icon { color: var(--warn); }
.flash--info    { border-color: color-mix(in srgb, var(--info) 40%, var(--border)); background: var(--info-soft); }
.flash--info .flash__icon { color: var(--info); }

/* Toast stack (transient, JS-dismissable) */
.toast-stack { position: fixed; bottom: var(--space-4); right: var(--space-4); z-index: 60; display: flex; flex-direction: column; gap: var(--space-2); max-width: 360px; }
.toast-stack .flash { box-shadow: var(--shadow); }

/* 14. -------------------------------------- CODE + RENDERED MARKDOWN (GH-Dark) */
code, kbd, pre, samp { font-family: var(--font-mono); }
:not(pre) > code {
  background: var(--code-bg); color: var(--code-string);
  border: 1px solid var(--code-border); border-radius: var(--radius-sm);
  padding: 1px 5px; font-size: 0.86em;
}
pre {
  background: var(--code-bg); color: var(--code-text);
  border: 1px solid var(--code-border); border-radius: var(--radius);
  padding: var(--space-4); overflow-x: auto; font-size: 13px; line-height: 1.6;
}
pre code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }
.code-block { position: relative; }
.code-block .code-copy { position: absolute; top: 8px; right: 8px; }
/* Token classes for the hand-highlighted samples */
.tok-comment  { color: var(--code-comment); font-style: italic; }
.tok-keyword  { color: var(--code-keyword); }
.tok-function { color: var(--code-function); }
.tok-string   { color: var(--code-string); }
.tok-entity   { color: var(--code-entity); }
.tok-added    { color: var(--code-added); }
.tok-number   { color: var(--code-number); }

/* Rendered markdown body */
.markdown { font-size: 15px; line-height: 1.7; }
.markdown > * + * { margin-top: var(--space-4); }
.markdown h1 { font-size: 1.6rem; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.markdown h2 { font-size: 1.3rem; margin-top: var(--space-6); padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 1.1rem; margin-top: var(--space-5); }
.markdown a { text-decoration: underline; text-underline-offset: 2px; }
.markdown ul, .markdown ol { padding-left: 1.4rem; }
.markdown li + li { margin-top: 4px; }
.markdown blockquote {
  border-left: 3px solid var(--border-strong); padding: 2px 0 2px var(--space-4);
  color: var(--text-muted); margin-left: 0;
}
.markdown img { border-radius: var(--radius); border: 1px solid var(--border); }
.markdown table { width: 100%; border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.markdown table th, .markdown table td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.markdown table th { background: var(--surface-2); }
.markdown hr { margin: var(--space-5) 0; }

/* 15. ----------------------------------------------------- MISC COMPONENTS */
/* Stat tile */
.stat { display: flex; flex-direction: column; gap: 8px; padding: var(--space-4) var(--space-5); }
.stat__label { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.09em; }
.stat__value { font-family: var(--font-mono); font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; line-height: 1; }
.stat__delta { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; font-size: 11px; font-family: var(--font-mono); color: var(--text-faint); }
.stat__delta.up, .stat__delta.down { padding: 2px 8px; border-radius: var(--radius-pill); }
.stat__delta.up { color: var(--ok); background: var(--ok-soft); }
.stat__delta.down { color: var(--danger); background: var(--danger-soft); }

/* Breadcrumbs */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--text-faint); font-family: var(--font-mono); margin-bottom: var(--space-4); }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--accent); text-decoration: none; }
.breadcrumbs .sep { color: var(--text-faint); }
.breadcrumbs [aria-current="page"] { color: var(--text); }

/* Dropdown menu (avatar, New) */
.menu { position: relative; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  min-width: 190px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
  display: none;
}
.menu.is-open .menu__panel { display: block; }
.menu__panel a, .menu__panel button {
  display: flex; align-items: center; gap: var(--space-2); width: 100%;
  padding: 8px 10px; border-radius: var(--radius-sm); font-size: 14px;
  color: var(--text); background: none; border: none; cursor: pointer; text-align: left;
}
.menu__panel a:hover, .menu__panel button:hover { background: var(--surface-2); text-decoration: none; }
.menu__panel .menu__sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu__panel .menu__head { padding: 8px 10px 4px; font-size: 12px; color: var(--text-faint); }
.menu__panel svg { width: 16px; height: 16px; color: var(--text-muted); }
.menu__panel .danger { color: var(--danger); }
.menu__panel .danger svg { color: var(--danger); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 9px 12px; font-size: 14px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 550; }

/* Progress */
.progress { display: flex; flex-direction: column; gap: 6px; }
.progress__track { height: 8px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.progress__bar { height: 100%; background: var(--accent); border-radius: inherit; }
.progress__meta { display: flex; justify-content: space-between; font-size: 12px; font-family: var(--font-mono); color: var(--text-muted); }

/* Filter bar */
.filterbar {
  display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center;
  padding: var(--space-3); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filterbar .select, .filterbar .input { width: auto; min-width: 150px; padding: 7px 10px; font-size: 13px; }
.filterbar .filter-count { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }

/* Segmented control (e.g. difficulty quick filter) */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.segmented button { border: none; background: none; padding: 5px 11px; font-size: 13px; color: var(--text-muted); border-radius: calc(var(--radius-sm) - 1px); cursor: pointer; font-family: var(--font-mono); }
.segmented button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: var(--shadow-sm); }

/* Spoiler / reveal writeup */
.spoiler { border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.spoiler__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--surface-2); }
.spoiler__bar .warn-label { display: inline-flex; align-items: center; gap: 8px; color: var(--warn); font-size: 13px; font-weight: 550; }
.spoiler__content { padding: var(--space-5); border-top: 1px solid var(--border); display: none; }
.spoiler.is-open .spoiler__content { display: block; }
.spoiler.is-open .spoiler__reveal { display: none; }

/* File download row */
.file-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.file-row .file-icon { color: var(--text-muted); flex: none; }
.file-row .file-name { font-family: var(--font-mono); font-size: 13px; flex: 1 1 auto; word-break: break-all; }
.file-row .file-size { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); flex: none; }

/* ---- Challenge detail: hero, connect string, points, submit bar ---- */
.chero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: inset 0 1px 0 var(--hairline), var(--shadow-sm); overflow: hidden; }
.chero__grid { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: var(--space-5); padding: var(--space-5) var(--space-6); }
.chero__tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: var(--space-3); }
.chero h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); letter-spacing: -0.03em; margin: 0; }
.chero__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-3); font-family: var(--font-mono); font-size: 12.5px; color: var(--text-faint); }
.chero__meta a { color: var(--text-muted); }
.chero__meta .dot { color: var(--border-strong); }
.chero__aside { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; flex: none; }
.chero__points { font-family: var(--font-mono); font-size: 2.4rem; font-weight: 600; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.chero__points span { font-size: 0.9rem; color: var(--text-faint); font-weight: 500; margin-left: 4px; letter-spacing: 0; }
.chero__solves { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.chero__status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; padding: 3px 10px; border-radius: var(--radius-pill); }
.chero__status.is-solved { color: var(--ok); background: var(--ok-soft); }
.chero__status.is-unsolved { color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); }
@media (max-width: 640px) {
  .chero__grid { grid-template-columns: 1fr; }
  .chero__aside { align-items: flex-start; text-align: left; }
}

/* connection string — code-styled, with copy affordance */
.connect { display: flex; align-items: center; gap: 0; margin-top: var(--space-4); max-width: 420px; border: 1px solid var(--code-border); border-radius: var(--radius-sm); background: var(--code-bg); overflow: hidden; }
.connect__label { font-family: var(--font-mono); font-size: 11px; color: var(--code-comment); padding: 0 10px; border-right: 1px solid var(--code-border); align-self: stretch; display: flex; align-items: center; }
.connect__cmd { font-family: var(--font-mono); font-size: 13px; color: var(--code-string); padding: 9px 10px; flex: 1 1 auto; overflow-x: auto; white-space: nowrap; }
.connect__copy { flex: none; }

/* submit bar — the primary action, full width */
.submit-bar { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 1px 0 var(--hairline), var(--shadow-sm); }
.submit-bar__inner { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); }
.submit-bar__icon { flex: none; width: 40px; height: 40px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.submit-bar__form { display: flex; gap: var(--space-2); flex: 1 1 auto; align-items: stretch; min-width: 0; }
.submit-bar__form .input-group { flex: 1 1 auto; }
.submit-bar__hint { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); padding: 0 var(--space-4) var(--space-3); }
@media (max-width: 620px) {
  .submit-bar__inner { flex-wrap: wrap; }
  .submit-bar__form { flex-wrap: wrap; }
  .submit-bar__form .btn { width: 100%; }
}

/* spec sheet — key/value rows with hairlines (sidebar) */
.spec { display: flex; flex-direction: column; }
.spec__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 11px 0; border-top: 1px solid var(--border); }
.spec__row:first-child { border-top: none; }
.spec__k { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.spec__v { font-size: 14px; text-align: right; }

/* ---- Challenge detail rework: content tabs + sticky rail ---- */
.ctabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.ctabs button {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 11px 14px; font-size: 14px; font-weight: 550; letter-spacing: -0.01em;
  color: var(--text-muted); background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; cursor: pointer;
}
.ctabs button:hover { color: var(--text); }
.ctabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.ctabs .tab-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 1px 7px; }
.ctabs button[aria-selected="true"] .tab-count { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

.rail-sticky { position: sticky; top: calc(var(--nav-h) + var(--space-4)); }

/* ---- Slides carousel (workshops) ---- */
.carousel { position: relative; }
.carousel__track { display: flex; gap: var(--space-3); overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none; border-radius: var(--radius); }
.carousel__track::-webkit-scrollbar { display: none; }
.carousel__slide { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); position: relative; }
.carousel__slide image-slot { width: 100%; height: 100%; display: block; }
.carousel__num { position: absolute; top: 8px; left: 10px; z-index: 2; font-family: var(--font-mono); font-size: 11px; color: var(--text); background: color-mix(in srgb, var(--bg) 70%, transparent); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 2px 9px; backdrop-filter: blur(4px); pointer-events: none; }
.carousel__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-3); }
.carousel__dots { display: flex; gap: 6px; align-items: center; }
.carousel__dot { width: 7px; height: 7px; border-radius: 50%; border: none; padding: 0; background: var(--border-strong); cursor: pointer; transition: background .12s, width .12s; }
.carousel__dot[aria-current="true"] { background: var(--accent); width: 18px; border-radius: var(--radius-pill); }
.carousel__arrows { display: flex; align-items: center; gap: 8px; }
.carousel__counter { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); min-width: 46px; text-align: center; }
.carousel__arrows .icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.carousel__caption { margin-top: var(--space-2); font-size: 13px; color: var(--text-muted); }

/* ---- Difficulty rose (challenges) ---- */
.rose { display: grid; grid-template-columns: 260px 1fr; gap: var(--space-6); align-items: center; }
.rose__chart { display: flex; justify-content: center; }
.rose__legend { min-width: 0; }
.rose__row { display: grid; grid-template-columns: 12px 68px 1fr 34px; align-items: center; gap: var(--space-3); padding: 7px 8px; border-radius: var(--radius-sm); color: inherit; }
.rose__row:hover { background: var(--surface-2); text-decoration: none; }
.rose__swatch { width: 10px; height: 10px; border-radius: 3px; }
.rose__name { font-size: 14px; font-weight: 550; }
.rose__bar { height: 6px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.rose__bar > span { display: block; height: 100%; border-radius: inherit; }
/* Django integration: per-difficulty swatch/bar colour so templates only need
   an inline width, not an inline colour. */
.rose__row--easy   .rose__swatch, .rose__row--easy   .rose__bar > span { background: var(--diff-easy); }
.rose__row--medium .rose__swatch, .rose__row--medium .rose__bar > span { background: var(--diff-medium); }
.rose__row--hard   .rose__swatch, .rose__row--hard   .rose__bar > span { background: var(--diff-hard); }
.rose__row--insane .rose__swatch, .rose__row--insane .rose__bar > span { background: var(--diff-insane); }
.rose__count { text-align: right; font-size: 14px; color: var(--text-muted); }
.rose__solved { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border); font-size: 13px; color: var(--text-faint); font-family: var(--font-mono); }
@media (max-width: 720px) {
  .rose { grid-template-columns: 1fr; gap: var(--space-4); }
}

/* ---- Month calendar (events) ---- */
.cal { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: inset 0 1px 0 var(--hairline), var(--shadow-sm); }
.cal__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.cal__title { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.cal__title .yr { color: var(--text-faint); font-family: var(--font-mono); font-weight: 400; margin-left: 6px; }
.cal__nav { display: flex; align-items: center; gap: 4px; }
.cal__legend { display: flex; flex-wrap: wrap; gap: var(--space-3); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.cal__legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal__legend i { width: 8px; height: 8px; border-radius: 2px; }
.cal__dow { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal__dow span { padding: 7px 10px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal__cell { min-height: 104px; padding: 6px 7px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.cal__cell:nth-child(7n) { border-right: none; }
.cal__grid > .cal__cell:nth-last-child(-n+7) { border-bottom: none; }
.cal__cell.is-out { background: color-mix(in srgb, var(--surface-2) 40%, transparent); }
.cal__daynum { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); align-self: flex-start; }
.cal__cell.is-out .cal__daynum { color: var(--text-faint); }
.cal__cell.is-today .cal__daynum { background: var(--accent); color: var(--accent-contrast); border-radius: var(--radius-pill); width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.cal__event { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: var(--radius-sm); font-size: 11.5px; line-height: 1.3; color: var(--text); background: var(--surface-2); border-left: 3px solid var(--evt, var(--border-strong)); text-decoration: none; overflow: hidden; }
.cal__event:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--text) 8%); text-decoration: none; }
.cal__event .t { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); flex: none; }
.cal__event .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal__more { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); padding: 0 6px; }
@media (max-width: 700px) {
  .cal__cell { min-height: 74px; padding: 4px; }
  .cal__event .n { display: none; }
  .cal__event { justify-content: center; }
  .cal__event .t { display: none; }
  .cal__event { height: 8px; padding: 0; border-left: none; background: var(--evt, var(--border-strong)); }
}

/* Meta list (key/value) */
.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 8px var(--space-4); font-size: 14px; }
.meta-list dt { color: var(--text-faint); font-size: 13px; }
.meta-list dd { margin: 0; }

/* ---- Error pages (400/403/404/429/500) ---- */
.errpage { max-width: 460px; width: 100%; text-align: center; }
.errpage__code { font-family: var(--font-mono); font-size: clamp(3.5rem, 2rem + 8vw, 5.5rem); font-weight: 700; line-height: 1; letter-spacing: -0.04em; }
.errpage__icon { width: 44px; height: 44px; margin: var(--space-4) auto var(--space-3); }
.errpage__icon svg { width: 100%; height: 100%; }
.errpage__title { font-size: 1.5rem; font-weight: 640; margin-bottom: var(--space-3); }
.errpage__text { color: var(--text-muted); max-width: 42ch; margin: 0 auto; }
.errpage__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: var(--space-5); }

/* Role-gated affordance highlight (mockup annotation aid) */
[data-role-gate] { position: relative; }

/* 16. ------------------------------------------------------------ UTILITIES */
.hidden { display: none !important; }
.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; }
.mt-0 { margin-top: 0 !important; }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.divider { height: 1px; background: var(--border); }
.flex { display: flex; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.items-center { align-items: center; }
.w-full { width: 100%; }

/* ==========================================================================
   Django integration: components that were page-local in the source mockups
   ========================================================================== */
/* Compact date chip used in the events rail (dashboard + events list). */
.datechip { flex: none; width: 44px; text-align: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 0; line-height: 1; }
.datechip__mon { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; color: var(--accent); }
.datechip__day { display: block; font-family: var(--font-mono); font-size: 18px; font-weight: 600; }

/* ==========================================================================
   Django integration utilities — replace the source mockups' inline styles
   with classes so templates stay inline-style-free (djlint H021).
   ========================================================================== */
.fw-600 { font-weight: 600; }
.text-14 { font-size: 14px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-11 { font-size: 11px; }
.min-w-0 { min-width: 0; }
.min-w-160 { min-width: 160px; }
.max-w-60 { max-width: 60ch; }
.flex-1 { flex: 1; }
.flex-none { flex: none; }
.icon-col { flex: none; width: 18px; }
.items-start { align-items: flex-start; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-14 { gap: 14px; }
.m-0 { margin: 0; }
.my-1 { margin: 6px 0; }
.mb-1 { margin-bottom: 2px; }
.mb-3 { margin-bottom: 12px; }
.mb-5 { margin-bottom: var(--space-5); }
.mt-1 { margin-top: 2px; }
.py-2 { padding: 8px 0; }
.list-row { padding: 8px 20px; }
.list-row--me { background: var(--accent-soft); border-radius: 6px; margin: 0 8px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.color-text { color: var(--text); }
.color-accent { color: var(--accent); }
.color-inherit { color: inherit; }
.opacity-82 { opacity: .82; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.chip--plain { text-transform: none; }
.filterbar__search { width: 220px; background: var(--bg); }
.rose__svg { max-width: 240px; display: block; margin: 0 auto; }
.cal__event--crypto    { --evt: var(--cat-crypto); }
.cal__event--forensics { --evt: var(--cat-forensics); }
.cal__event--pwn       { --evt: var(--cat-pwn); }
.cal__event--misc      { --evt: var(--cat-misc); }
.dot-forensics { background: var(--cat-forensics); }
.dot-crypto    { background: var(--cat-crypto); }
.dot-pwn       { background: var(--cat-pwn); }
.self-center { align-self: center; }
.h-full { height: 100%; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.link-plain { color: inherit; text-decoration: none; }

/* Rose legend bar widths (stepped, avoids inline width). */
.w-0 { width: 0%; }
.w-5 { width: 5%; }
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-50 { width: 50%; }
.w-55 { width: 55%; }
.w-60 { width: 60%; }
.w-65 { width: 65%; }
.w-70 { width: 70%; }
.w-75 { width: 75%; }
.w-80 { width: 80%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }
.text-lead { font-size: 1.02rem; }
.mt-2 { margin-top: 6px; }

/* Profile header (banner + overlapping avatar). */
.card--clip { overflow: hidden; }
.profile-cover { height: 96px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.profile-head { padding-top: 0; }
.profile-head__row { align-items: flex-end; gap: var(--space-4); margin-top: -40px; }
.avatar--ring { box-shadow: 0 0 0 4px var(--surface); background: var(--surface-2); }
.profile-id { flex: 1 1 auto; min-width: 0; padding-bottom: 4px; }
.profile-bio { margin-top: var(--space-4); max-width: 70ch; }
.stat-lg { font-size: 1.4rem; }

/* Workshop slide carousel image. */
.carousel__img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); }

/* Sign-in page layout. */
.auth-main { min-height: calc(100vh - var(--nav-h) - 120px); display: grid; place-items: center; padding-block: var(--space-8); }
.auth-card { max-width: 400px; width: 100%; }
.auth-card__body { padding: var(--space-6); text-align: center; }
.auth-logo { height: 64px; margin: 0 auto var(--space-4); }

/* Auth / status page extras (error pages). */
.auth-icon { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto; border-radius: 50%; background: var(--surface-2); color: var(--accent); }
.auth-card--alert { border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.row--center { justify-content: center; }

/* ==========================================================================
   Django form styling: `{{ form.as_p }}` renders bare <input>/<select>/
   <textarea> (no .input class), so mirror the design's field styling here.
   ========================================================================== */
.djform p { margin: 0; }
.djform p + p { margin-top: var(--space-4); }
.djform label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 6px; }
.djform input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.djform select,
.djform textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 14px; line-height: 1.4;
  transition: border-color .12s, box-shadow .12s;
}
.djform input::placeholder, .djform textarea::placeholder { color: var(--text-faint); }
.djform input:not([type="checkbox"]):not([type="radio"]):focus,
.djform select:focus,
.djform textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
.djform textarea { resize: vertical; min-height: 120px; font-family: var(--font-mono); font-size: 13px; }
.djform select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.djform select[multiple] { min-height: 120px; background-image: none; padding-right: 11px; }
.djform input[type="checkbox"], .djform input[type="radio"] { width: auto; margin-right: 6px; accent-color: var(--accent); vertical-align: middle; }
.djform input[type="file"] { width: 100%; font-size: 13px; color: var(--text-muted); }
.djform .helptext { display: block; font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.djform ul.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--danger); font-size: 12px; }

/* Formset rows render bare fields (see _formset_row.html) — style + lay out. */
.formset-field { flex: 1 1 auto; min-width: 0; }
.formset-field input:not([type="checkbox"]):not([type="file"]),
.formset-field select,
.formset-field textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 14px; line-height: 1.4;
}
.formset-field input:focus, .formset-field select:focus, .formset-field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
.formset-field textarea { min-height: 60px; resize: vertical; font-family: var(--font-mono); font-size: 13px; }
.formset-field input[type="file"] { width: 100%; font-size: 12px; color: var(--text-muted); }
.formset-field label { display: none; }
.formset-field .helptext { display: none; }
.formset-field ul.errorlist { list-style: none; padding: 0; margin: 3px 0 0; color: var(--danger); font-size: 11px; }

/* Boolean fields (e.g. "Published") as a clean toggle switch instead of a
   bare native checkbox stacked under its label. */
.djform p:has(> input[type="checkbox"]) { display: flex; align-items: center; gap: 10px; }
.djform p:has(> input[type="checkbox"]) label { margin-bottom: 0; }
.djform input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 38px; height: 22px; margin: 0;
  border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface-2); position: relative; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.djform input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-muted); transition: transform .15s, background .15s;
}
.djform input[type="checkbox"]:checked { background: var(--accent-soft); border-color: var(--accent); }
.djform input[type="checkbox"]:checked::after { transform: translateX(16px); background: var(--accent); }
.djform input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.role--guest { color: var(--text-faint); background: var(--surface-2); }
