:root{
  --bg: #ffffff;
  --fg: #0b1220;
  --muted: #5b6475;
  --card: #f6f7f9;
  --border: rgba(10, 20, 40, .10);
  --accent: #3b5bff;
  --shadow: 0 10px 30px rgba(10, 20, 40, .08);
  --radius: 18px;
  --max: 980px;

  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg: #0b0f17;
    --fg: #eaf0ff;
    --muted: #a6b0c3;
    --card: #101828;
    --border: rgba(234,240,255,.12);
    --accent: #7aa2ff;
    --shadow: 0 14px 34px rgba(0,0,0,.35);
  }
}
[data-theme="light"]{
  --bg: #ffffff; --fg:#0b1220; --muted:#5b6475; --card:#f6f7f9; --border: rgba(10,20,40,.10);
  --accent:#3b5bff; --shadow: 0 10px 30px rgba(10,20,40,.08);
}
[data-theme="dark"]{
  --bg:#0b0f17; --fg:#eaf0ff; --muted:#a6b0c3; --card:#101828; --border: rgba(234,240,255,.12);
  --accent:#7aa2ff; --shadow: 0 14px 34px rgba(0,0,0,.35);
}

*{ box-sizing:border-box; }
html{ scroll-behavior:smooth; }
body{
  margin:0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  line-height:1.6;
}
a{ color:inherit; text-decoration:none; }
a:hover{ text-decoration:underline; text-decoration-thickness:2px; text-underline-offset:3px; }

.wrap{ max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* Subtle animated background blob */
.bg-blob{
  position: fixed;
  inset: -30vh -30vw;
  z-index:-1;
  pointer-events:none;
  opacity:.55;
  background:
    radial-gradient(500px 300px at 20% 20%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 65%),
    radial-gradient(520px 320px at 80% 10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(600px 380px at 50% 85%, rgba(255,255,255,.06), transparent 70%);
  filter: saturate(1.05);
  transform: translate3d(0,0,0);
  animation: floaty 14s ease-in-out infinite;
}
@keyframes floaty{
  0%,100%{ transform: translate3d(0,0,0); }
  50%{ transform: translate3d(12px,-10px,0); }
}

/* Header / Nav */
header{
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav{
  display:flex; align-items:center; justify-content:space-between;
  gap:14px; padding: 14px 0;
}
.brand{
  display:flex; flex-direction:column; gap:2px;
  min-width: 180px;
}
.brand b{ font-family: var(--serif); font-size: 16px; letter-spacing:.2px; }
.brand span{ font-size: 12px; color: var(--muted); }

.links{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; justify-content:flex-end; }
.links a{
  font-size: 13px;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background .15s ease, color .15s ease, transform .15s ease, border-color .15s ease;
}
.links a:hover{
  color: var(--fg);
  background: color-mix(in srgb, var(--card) 75%, transparent);
  border-color: var(--border);
  transform: translateY(-1px);
  text-decoration:none;
}
.links a.active{
  color: var(--fg);
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.btn{
  display:inline-flex; align-items:center; justify-content:center;
  gap:8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 65%, transparent);
  cursor:pointer;
  font: inherit;
  color: var(--fg);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
  user-select:none;
}
.btn:hover{
  background: color-mix(in srgb, var(--card) 90%, transparent);
  transform: translateY(-1px);
  text-decoration:none;
}
.btn.primary{
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 70%, var(--border));
  color: white;
  box-shadow: 0 18px 40px color-mix(in srgb, var(--accent) 18%, transparent);
}
.btn.primary:hover{ filter: brightness(1.03); }
.btn.small{ padding: 8px 10px; font-size: 13px; }

/* Sections */
main{ padding: 34px 0 80px; }
section{ padding: 44px 0; }
.kicker{ color: var(--muted); font-size: 13px; letter-spacing:.12em; text-transform: uppercase; }
h1{
  font-family: var(--serif);
  font-size: clamp(34px, 3.4vw, 48px);
  line-height:1.12;
  margin: 10px 0 14px;
  letter-spacing: .2px;
}
h2{
  font-family: var(--serif);
  font-size: 24px;
  margin: 0 0 14px;
}
p{ margin: 0 0 14px; color: color-mix(in srgb, var(--fg) 92%, var(--muted)); }

.hero{
  display:grid;
  grid-template-columns: 1.3fr .7fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 880px){ .hero{ grid-template-columns: 1fr; } }

.panel{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow:hidden;
}

/* subtle geek scanlines on image panel */
.panel.geek:before{
  content:"";
  position:absolute; inset:0;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 10px,
      rgba(0,0,0,.04) 11px
    );
  opacity: .35;
  pointer-events:none;
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark){
  .panel.geek:before{
    background:
      repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 10px,
        rgba(255,255,255,.05) 11px
      );
    mix-blend-mode: screen;
    opacity: .25;
  }
}

.cursorline{
  display:inline-block;
  position: relative;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}
.cursorline:after{
  content:"";
  display:inline-block;
  width: 10px;
  height: 1.1em;
  margin-left: 6px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 70%, transparent);
  vertical-align: -2px;
  animation: blink 1.1s steps(1,end) infinite;
}
@keyframes blink{ 50%{ opacity: 0; } }

.meta{ display:flex; flex-wrap:wrap; gap:8px; margin-top: 14px; }
.tag{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  color: var(--muted);
}

.cta-row{ display:flex; flex-wrap:wrap; gap:10px; margin-top: 16px; }

.heroimg{
  width: 100%;
  display:block;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
}
.imgcap{
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  line-height: 1.5;
}
.imgcap a{ color: color-mix(in srgb, var(--accent) 92%, white); }

.grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}
.card{
  grid-column: span 6;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  will-change: transform;
  position: relative;
}
.card:hover{
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  box-shadow: 0 18px 45px color-mix(in srgb, var(--accent) 10%, rgba(0,0,0,.18));
}
@media (max-width: 880px){ .card{ grid-column: span 12; } }

.card h3{ margin: 0 0 6px; font-size: 16px; letter-spacing:.2px; }
.card p{ margin: 0 0 12px; color: var(--muted); font-size: 14px; }

.row{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; justify-content:space-between; }
.rowlinks{ display:flex; flex-wrap:wrap; gap:10px; }
.pillrow{ display:flex; flex-wrap:wrap; gap:8px; margin: 10px 0 12px; }

.link{
  font-size: 13px;
  color: color-mix(in srgb, var(--accent) 92%, white);
  text-decoration:none;
}
.link:hover{ text-decoration:underline; }

.corner{
  position:absolute;
  top: 10px; right: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: color-mix(in srgb, var(--muted) 90%, transparent);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}

.list{ display:flex; flex-direction:column; gap:10px; }
.item{
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 70%, transparent);
}
.item b{ font-weight: 600; }
.sub{ color: var(--muted); font-size: 13px; margin-top: 4px; }

.reveal{
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .55s ease, transform .55s ease;
}
.reveal.in{ opacity: 1; transform: translateY(0); }

footer{
  border-top: 1px solid var(--border);
  padding: 26px 0;
  color: var(--muted);
  font-size: 13px;
}
.footer-row{ display:flex; flex-wrap:wrap; gap:10px; align-items:center; justify-content:space-between; }

.mono{ font-family: var(--mono); }
.tiny{ font-size:12px; }
.mb10{ margin-bottom:10px; }
.spacer12{ height:12px; }

@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior:auto; }
  .bg-blob{ animation:none !important; }
  .cursorline:after{ animation:none !important; opacity:1; }
  .reveal{ opacity:1 !important; transform:none !important; transition:none !important; }
  .links a, .btn, .card{ transition:none !important; }
}

.katex-display {
  margin: 1.2em 0;
}

.katex {
  font-size: 1.05em;
}

.katex-display {
  padding: 12px 0;
  border-left: 3px solid var(--accent);
}

.container {
  text-align: center;
}