:root {
  color-scheme: dark;

  /* Surfaces */
  --bg:        #060b17;
  --surface:   #0d1829;
  --surface-2: #121f38;

  /* Text */
  --text:   #deeaff;
  --text-2: #8ba5c8;
  --muted:  #4d6882;

  /* Borders */
  --line:   #182c46;
  --line-2: #1e3552;

  /* Accent colours */
  --green:  #22c55e;
  --blue:   #38bdf8;
  --violet: #a78bfa;
  --amber:  #fbbf24;
  --red:    #f87171;

  /* Semantic aliases kept for any future JS usage */
  --accent:   var(--green);
  --accent-2: var(--blue);
  --danger:   var(--red);
  --warn:     var(--amber);

  /* Elevation */
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 4px 24px rgba(0,0,0,.28);
  --shadow-lg: 0 4px 8px rgba(0,0,0,.5), 0 16px 48px rgba(0,0,0,.4);

  /* Radii */
  --r-sm: 8px;
  --r:    14px;
  --r-lg: 20px;

  font-size: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0; min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 50% at 12% -8%,  rgba(56,189,248,.07)  0%, transparent 60%),
    radial-gradient(ellipse 55% 40% at 90%  4%,  rgba(34,197,94,.05)   0%, transparent 55%),
    radial-gradient(ellipse 60% 30% at 50% 105%, rgba(167,139,250,.04) 0%, transparent 60%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, textarea, input { font: inherit; }
h1, h2, h3, h4 { margin-top: 0; }
p { margin-top: 0; }

/* ─── Typography ────────────────────────────────── */
h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.02; letter-spacing: -.04em; font-weight: 800; margin-bottom: 16px; }
h2 { font-size: clamp(1.15rem, 2.4vw, 1.5rem); font-weight: 700; letter-spacing: -.02em; margin-bottom: 10px; }
h3 { font-size: 1rem; font-weight: 700; color: var(--text); margin: 28px 0 12px; letter-spacing: -.01em; }

code, pre, textarea, .mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
}

/* ─── Utilities ─────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.muted { color: var(--text-2); }

/* ─── Skip link ─────────────────────────────────── */
.skip-link {
  position: absolute; left: -999px; top: 12px; z-index: 200;
  background: var(--green); color: #011a06;
  padding: 10px 18px; border-radius: var(--r); font-weight: 700; font-size: .875rem;
}
.skip-link:focus { left: 12px; }

/* ─── Top bar ───────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 60px;
  padding: 0 max(20px, calc((100vw - 1200px) / 2));
  background: rgba(6,11,23,.9);
  backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(140deg, var(--green) 0%, var(--blue) 100%);
  color: #031b08; font-size: 1.1rem; font-weight: 900;
  box-shadow: 0 2px 14px rgba(34,197,94,.22); flex-shrink: 0;
}
.brand-text strong { display: block; font-size: .88rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.brand-text small, .brand small {
  display: block; font-size: .68rem; color: var(--muted);
  letter-spacing: .07em; text-transform: uppercase; line-height: 1;
}

nav { display: flex; align-items: center; gap: 8px; }

.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-links a, nav a {
  display: inline-flex; align-items: center;
  padding: 7px 12px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: .85rem; font-weight: 500;
  transition: color .15s, background .15s;
  white-space: nowrap; border: 1px solid transparent;
}
.nav-links a:hover, nav a:hover { color: var(--text); background: rgba(255,255,255,.05); filter: none; }
.nav-links a[aria-current], nav a[aria-current] {
  color: var(--text); background: rgba(56,189,248,.1); border-color: rgba(56,189,248,.2);
}

.nav-hamburger {
  display: none; background: none; border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--text-2);
  padding: 7px 10px; cursor: pointer; font-size: 1rem; line-height: 1;
  transition: color .15s, border-color .15s;
}
.nav-hamburger:hover { color: var(--text); border-color: var(--line-2); filter: none; }

/* ─── App shell ─────────────────────────────────── */
.app-shell { width: min(1200px, calc(100% - 40px)); margin: 0 auto; padding: 40px 0 96px; }

/* ─── Footer ────────────────────────────────────── */
.footer {
  color: var(--muted); text-align: center; padding: 28px 20px;
  font-size: .78rem; letter-spacing: .03em; border-top: 1px solid var(--line);
}

/* ─── Cards ─────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 28px;
}

/* ─── Hero grid ─────────────────────────────────── */
.hero-grid {
  display: grid; grid-template-columns: minmax(0,1fr) 280px;
  gap: 20px; margin-bottom: 24px; align-items: stretch;
}

.hero-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 36px 40px; position: relative; overflow: hidden;
}
.hero-panel::after {
  content: ''; position: absolute; top: 0; left: 0; width: 50%; height: 50%;
  background: radial-gradient(ellipse at top left, rgba(56,189,248,.05), transparent);
  pointer-events: none;
}

.daily-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 28px; display: flex; flex-direction: column; gap: 14px;
}

/* ─── Eyebrow ───────────────────────────────────── */
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--green); font-size: .7rem; font-weight: 800;
  letter-spacing: .13em; text-transform: uppercase; margin-bottom: 14px;
}
.eyebrow::before {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px var(--green); flex-shrink: 0;
}

.label {
  display: inline-block; color: var(--blue);
  font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}

/* ─── Lede ──────────────────────────────────────── */
.lede { color: var(--text-2); font-size: 1.05rem; line-height: 1.7; max-width: 72ch; margin-bottom: 20px; }

/* ─── Meta row ──────────────────────────────────── */
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.meta-row span {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-2); background: rgba(255,255,255,.04);
  border-radius: var(--r); padding: 6px 12px;
  color: var(--text-2); font-size: .78rem; font-weight: 600;
}

/* ─── Difficulty badges ─────────────────────────── */
.badge-easy   { color: #4ade80 !important; border-color: rgba(74,222,128,.3)  !important; background: rgba(74,222,128,.07) !important; }
.badge-medium { color: #fbbf24 !important; border-color: rgba(251,191,36,.3)  !important; background: rgba(251,191,36,.07) !important; }
.badge-hard   { color: #f87171 !important; border-color: rgba(248,113,113,.3) !important; background: rgba(248,113,113,.07) !important; }

/* ─── Date display ──────────────────────────────── */
.date-display { font-size: 1.05rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }

/* ─── Countdown row ─────────────────────────────── */
.countdown-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: rgba(56,189,248,.05); border: 1px solid rgba(56,189,248,.15);
  border-radius: var(--r); font-size: .8rem; color: var(--text-2);
}
.countdown-row .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--blue);
  box-shadow: 0 0 6px var(--blue); flex-shrink: 0;
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }

/* ─── Mini stats ────────────────────────────────── */
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }
.mini-stat {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 12px; text-align: center;
}
.mini-stat b {
  display: block; font-size: 1.6rem; font-weight: 800;
  color: var(--green); line-height: 1; margin-bottom: 4px;
}
.mini-stat span { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ─── Challenge layout ──────────────────────────── */
.layout {
  display: grid; grid-template-columns: minmax(0,1.2fr) minmax(360px,.8fr);
  gap: 20px; align-items: start;
}
.solve-card { position: sticky; top: 76px; }

/* ─── Section title ─────────────────────────────── */
.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 18px; margin-bottom: 22px; border-bottom: 1px solid var(--line);
}
.section-title .eyebrow { margin-bottom: 0; }
.section-title h2 { margin-bottom: 0; }

/* ─── Tag cloud ─────────────────────────────────── */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud span {
  display: inline-flex; align-items: center;
  border: 1px solid rgba(167,139,250,.28); background: rgba(167,139,250,.07);
  border-radius: var(--r); padding: 5px 10px;
  color: #c4b5fd; font-size: .78rem; font-weight: 600;
}
.tag-cloud.small span { font-size: .72rem; padding: 4px 8px; }

/* ─── Sample logs ───────────────────────────────── */
.samples { display: grid; gap: 12px; }

.sample-wrap { border: 1px solid #162035; border-radius: var(--r); overflow: hidden; background: #030812; }
.sample-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 6px 14px;
  background: #050d1e; border-bottom: 1px solid #162035;
}
.sample-label {
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: .65rem; font-weight: 700; letter-spacing: .12em; color: #3d5a7a;
}
.sample-wrap pre.sample { margin: 0; padding: 16px; border: none; border-radius: 0; background: transparent; }

/* Standalone sample (no wrapper) */
pre.sample {
  position: relative; white-space: pre-wrap; overflow-x: auto;
  background: #030812; border: 1px solid #162035; border-radius: var(--r);
  padding: 16px; color: #8fb8e8; line-height: 1.65; font-size: .8rem; margin: 0;
}
.sample { color: #8fb8e8; line-height: 1.65; font-size: .8rem; white-space: pre-wrap; overflow-x: auto; }

.copy-sample {
  background: rgba(255,255,255,.06); color: var(--text-2);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 4px 9px; font-size: .7rem; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s;
}
.copy-sample:hover { background: rgba(255,255,255,.12); color: var(--text); filter: none; }

/* ─── Required fields ───────────────────────────── */
.fields { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.fields li {
  display: inline-flex; align-items: center;
  border: 1px solid rgba(56,189,248,.2); background: rgba(56,189,248,.05);
  border-radius: var(--r); padding: 5px 11px;
  color: var(--blue); font-size: .78rem; font-weight: 600;
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ─── Textarea / regex workspace ────────────────── */
textarea {
  width: 100%; min-height: 168px; resize: vertical;
  background: #03090f; color: #7dd3a8;
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; outline: none; line-height: 1.7; font-size: .85rem;
  transition: border-color .2s, box-shadow .2s;
}
textarea:focus { border-color: rgba(56,189,248,.55); box-shadow: 0 0 0 3px rgba(56,189,248,.07); }
textarea::placeholder { color: #1e3452; }

/* ─── Buttons ───────────────────────────────────── */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; border-radius: var(--r); cursor: pointer;
  font-weight: 700; font-size: .85rem; padding: 11px 18px;
  transition: filter .15s, transform .1s, box-shadow .15s; line-height: 1;
}
button:active { transform: translateY(1px); }

button:not(.secondary):not(.ghost):not(.copy-sample):not(.nav-hamburger) {
  background: var(--green); color: #031405;
  box-shadow: 0 2px 16px rgba(34,197,94,.18);
}
button:not(.secondary):not(.ghost):not(.copy-sample):not(.nav-hamburger):hover {
  filter: brightness(1.1); box-shadow: 0 4px 24px rgba(34,197,94,.3);
}
button.secondary {
  background: transparent; color: var(--text-2); border: 1px solid var(--line-2);
}
button.secondary:hover { background: rgba(255,255,255,.05); color: var(--text); border-color: rgba(255,255,255,.15); filter: none; }
button.ghost { background: rgba(255,255,255,.04); color: var(--muted); border: 1px solid transparent; }
button.ghost:hover { background: rgba(255,255,255,.08); color: var(--text-2); filter: none; }

a:hover { filter: none; }

/* ─── Actions ───────────────────────────────────── */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ─── Score model / info box ────────────────────── */
.score-model {
  margin: 16px 0 8px; padding: 12px 14px;
  border-radius: var(--r); border: 1px solid var(--line);
  background: rgba(255,255,255,.025); color: var(--muted); font-size: .8rem; line-height: 1.6;
}

/* ─── Hint ──────────────────────────────────────── */
.hint {
  margin: 14px 0; padding: 14px 16px; border-radius: var(--r);
  border: 1px solid rgba(251,191,36,.25); border-left: 3px solid var(--amber);
  background: rgba(251,191,36,.05); color: var(--text-2); font-size: .9rem; line-height: 1.6;
}

/* ─── Solution ──────────────────────────────────── */
.solution {
  margin: 14px 0; padding: 18px; border-radius: var(--r);
  border: 1px solid rgba(167,139,250,.22); background: rgba(167,139,250,.05); color: var(--text-2);
}
.solution pre, .case pre {
  white-space: pre-wrap; overflow-x: auto;
  background: #030812; border-radius: var(--r-sm);
  padding: 14px; color: #8fb8e8; margin-top: 8px;
}

/* ─── Solved banner ─────────────────────────────── */
.solved-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0; padding: 14px 18px; border-radius: var(--r);
  border: 1px solid rgba(34,197,94,.3); background: rgba(34,197,94,.06);
  color: #86efac; font-weight: 800; font-size: .9rem;
}
.solved-banner::before {
  content: '✓'; flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(34,197,94,.18); display: grid; place-items: center;
  color: var(--green); font-size: .75rem;
}

/* ─── Warnings ──────────────────────────────────── */
.warnings {
  margin: 10px 0; padding: 12px 14px; border-radius: var(--r);
  border: 1px solid rgba(251,191,36,.2); background: rgba(251,191,36,.04);
  color: #fde68a; font-size: .85rem;
}
.warnings ul { margin: 6px 0 0; padding-left: 18px; }

/* ─── Results ───────────────────────────────────── */
.result { display: grid; gap: 10px; margin-top: 16px; }
.result-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-radius: var(--r); border: 1px solid var(--line); font-weight: 700;
}
.result-summary.pass { border-color: rgba(34,197,94,.4);    background: rgba(34,197,94,.06);    color: #86efac; }
.result-summary.fail { border-color: rgba(248,113,113,.4);  background: rgba(248,113,113,.06);  color: #fca5a5; }

.case {
  padding: 14px; border-radius: var(--r); border: 1px solid var(--line);
  background: rgba(255,255,255,.02); font-size: .875rem;
}
.case.pass { border-color: rgba(34,197,94,.25); }
.case.fail { border-color: rgba(248,113,113,.25); }
.case strong { display: block; margin-bottom: 8px; }

/* ─── Admin check rows ──────────────────────────── */
.check-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px; border-radius: var(--r); border: 1px solid var(--line);
  background: rgba(255,255,255,.02); margin-bottom: 8px; font-size: .875rem;
}
.check-row strong { flex-shrink: 0; min-width: 180px; }
.check-row span { color: var(--text-2); }
.check-row.pass { border-color: rgba(34,197,94,.25); }
.check-row.fail { border-color: rgba(248,113,113,.25); }

/* ─── Page head ─────────────────────────────────── */
.page-head { margin-bottom: 32px; }
.page-head h1 { margin-bottom: 12px; }

/* ─── Challenge grid ────────────────────────────── */
.challenge-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }

.archive-card {
  display: flex; flex-direction: column; gap: 12px;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.archive-card:hover {
  transform: translateY(-4px);
  border-color: rgba(56,189,248,.4);
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.archive-card h2 { font-size: 1rem; margin-bottom: 0; line-height: 1.35; }
.archive-card .card-meta { color: var(--muted); font-size: .78rem; margin: 0; }
.archive-card .card-score { margin-top: auto; font-weight: 700; font-size: .82rem; color: var(--text-2); }
.archive-card .card-score.solved { color: var(--green); }

/* ─── Pill ──────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-2); background: rgba(255,255,255,.04);
  border-radius: var(--r); padding: 4px 10px;
  font-size: .72rem; font-weight: 700; color: var(--text-2);
}

/* ─── Profile stats grid ────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; text-align: center; padding: 30px 20px;
}
.stat b { font-size: 2.8rem; font-weight: 800; color: var(--green); line-height: 1; }
.stat span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 6px; }

/* ─── Table ─────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead tr { border-bottom: 1px solid var(--line-2); }
th { padding: 12px 14px; text-align: left; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); color: var(--text-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ─── Prose ─────────────────────────────────────── */
.prose { line-height: 1.75; color: var(--text-2); }
.prose h2 { color: var(--text); margin-top: 28px; }

/* ─── Loading / error ───────────────────────────── */
.loading { color: var(--muted); font-size: .9rem; margin-top: 40px; }
.error { color: var(--red); margin-top: 40px; }

/* ─── Responsive ────────────────────────────────── */
@media (max-width: 1020px) {
  .hero-grid { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .solve-card { position: static; }
  .challenge-grid { grid-template-columns: repeat(2, 1fr); }
  .daily-card { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .mini-stats { flex: 1; min-width: 180px; margin-top: 0; }
}

@media (max-width: 640px) {
  :root { font-size: 15px; }
  .topbar { padding: 0 16px; }
  .app-shell { width: calc(100% - 24px); padding: 28px 0 72px; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column;
    position: fixed; top: 60px; left: 0; right: 0;
    background: rgba(6,11,23,.97); backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--line);
    padding: 12px 16px; z-index: 99; gap: 4px;
  }
  .nav-links.open a { width: 100%; }
  .nav-hamburger { display: flex; }
  .challenge-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .hero-panel { padding: 24px; }
  .card { padding: 20px; }
}
