:root {
  --bg: #0b0f14;
  --bg-alt: #10161e;
  --surface: #151d27;
  --surface-hover: #1b2532;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8edf4;
  --text-muted: #98a6b8;
  --accent: #f5b942;        /* refined nod to classic ksh yellow */
  --accent-2: #38bdf8;      /* refined nod to classic #99CCCC teal */
  --accent-bg: rgba(245, 185, 66, 0.12);
  --code-bg: #0a0e13;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-alt: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #c27803;
  --accent-2: #0284c7;
  --accent-bg: rgba(217, 119, 6, 0.1);
  --code-bg: #0f172a;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--accent-bg);
  color: var(--accent);
  padding: 0.12em 0.4em;
  border-radius: 5px;
}

.container {
  width: min(1160px, calc(100% - 2rem));
  margin-inline: auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 66px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.brand-prompt {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 7px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.92rem;
}

.nav-links a {
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
}
.icon-btn:hover { border-color: var(--border-strong); background: var(--surface-hover); }

.mobile-only { display: none; }

.mobile-nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.mobile-nav[hidden] { display: none; }
.mobile-nav a {
  padding: 0.6rem 0.5rem;
  color: var(--text);
  font-weight: 500;
  border-radius: 8px;
}
.mobile-nav a:hover { background: var(--surface); text-decoration: none; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.7rem 1.15rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.94rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.85rem; }

.btn-primary {
  background: var(--accent);
  color: #0b0f14;
}
[data-theme="light"] .btn-primary { color: #ffffff; }
.btn-primary:hover { filter: brightness(1.06); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-hover); }

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

/* Hero */
.hero {
  position: relative;
  overflow: hidden;
  padding: 4.5rem 0 4rem;
}

.hero-glow {
  position: absolute;
  inset: -120px 0 auto;
  height: 460px;
  background:
    radial-gradient(600px 260px at 20% 20%, rgba(245, 185, 66, 0.15), transparent 70%),
    radial-gradient(620px 280px at 80% 30%, rgba(56, 189, 248, 0.14), transparent 70%);
  pointer-events: none;
}

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 2.5rem;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 1.25rem;
}

.eyebrow .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.hero-title {
  margin: 0 0 1.1rem;
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.hero-logo {
  display: block;
  width: min(100%, 490px);
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 0.9rem;
}

.logo-light { display: none; }
[data-theme="light"] .logo-dark { display: none; }
[data-theme="light"] .logo-light { display: block; }

.hero-subtitle {
  display: block;
  font-size: clamp(1.35rem, 2.6vw, 1.95rem);
  font-weight: 800;
}

.book-card h4 a { color: var(--text); }
.book-card h4 a:hover { color: var(--accent-2); }

.accent-gradient {
  background: linear-gradient(95deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-lead {
  font-size: 1.08rem;
  color: var(--text-muted);
  margin: 0 0 1.75rem;
  max-width: 56ch;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2.25rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.stat-val {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Interactive Terminal */
.terminal-card {
  background: #0a0e13;
  color: #e6edf3;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.terminal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  background: #131a23;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.terminal-dots { display: flex; gap: 6px; }
.t-dot { width: 11px; height: 11px; border-radius: 50%; }
.t-dot.red { background: #ef4444; }
.t-dot.yellow { background: #f59e0b; }
.t-dot.green { background: #22c55e; }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #94a3b8;
}

.term-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #94a3b8;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
}
.term-btn:hover { color: #fff; border-color: rgba(255, 255, 255, 0.3); }

.terminal-body {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 1rem;
  height: 290px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.t-line { margin-bottom: 0.45rem; }
.t-prompt { color: #f5b942; font-weight: 600; }
.t-cmd { color: #f8fafc; }
.t-out { color: #cbd5e1; }
.t-dim { color: #64748b; }
.t-accent { color: #38bdf8; }

.terminal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: #0e141c;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 0.22rem 0.55rem;
  cursor: pointer;
}
.chip:hover { background: rgba(245, 185, 66, 0.18); color: #f5b942; border-color: rgba(245, 185, 66, 0.4); }

.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.9rem;
  background: #111822;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.prompt-label {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 600;
  color: #f5b942;
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* Timeline */
.timeline-band {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 2rem 0;
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.25rem;
}

.t-item { position: relative; }
.t-year {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.t-item h3 { margin: 0 0 0.3rem; font-size: 0.96rem; }
.t-item p { margin: 0; font-size: 0.84rem; color: var(--text-muted); }

/* Sections */
.section { padding: 4.5rem 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section-head { margin-bottom: 2.25rem; max-width: 66ch; }
.section-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.45rem;
}
.section-head h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  letter-spacing: -0.02em;
}
.section-sub { margin: 0; color: var(--text-muted); font-size: 1.02rem; }

.sub-heading {
  margin: 2.5rem 0 1rem;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

/* Overview */
.overview-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 1.75rem;
  align-items: start;
}

.prose-card, .highlight-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}
.prose-card p:first-child { margin-top: 0; }
.prose-card p:last-child { margin-bottom: 0; }

.highlight-panel h3 { margin: 0 0 1rem; font-size: 1.1rem; }

.check-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}
.check-list li {
  padding-left: 1.35rem;
  position: relative;
}
.check-list li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}
.check-list strong { display: block; font-size: 0.95rem; }
.check-list span { display: block; font-size: 0.87rem; color: var(--text-muted); }

/* Cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}
.cards-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 700;
  margin-bottom: 0.9rem;
}
.card h3 { margin: 0 0 0.45rem; font-size: 1.05rem; }
.card p { margin: 0; font-size: 0.92rem; color: var(--text-muted); }

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

/* Code Showcase */
.code-showcase {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.code-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.65rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.code-tab {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  padding: 0.48rem 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.code-tab:hover { color: var(--text); }
.code-tab.active {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border-strong);
}

.code-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.15rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-muted);
}

.code-panel pre {
  margin: 0;
  padding: 1.25rem;
  background: var(--code-bg);
  color: #e6edf3;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.65;
}
.code-panel pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* Docs & Books */
.quick-docs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.doc-pill {
  display: block;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.doc-pill:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.doc-pill strong { display: block; margin-bottom: 0.25rem; font-size: 0.98rem; }
.doc-pill span { display: block; font-size: 0.84rem; color: var(--text-muted); }

.books-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.15rem;
}

.book-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.book-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
}
.book-card.featured {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, var(--surface)), var(--surface));
}
.book-card.featured:hover {
  border-color: var(--accent);
}
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.6rem;
}
.book-card h4 { margin: 0 0 0.3rem; font-size: 1rem; }
.book-meta { margin: 0 0 0.55rem; font-size: 0.82rem; color: var(--accent-2); font-weight: 500; }
.book-card p:last-child { margin: 0; font-size: 0.88rem; color: var(--text-muted); }

.papers-list {
  display: grid;
  gap: 0.75rem;
}
.paper-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.95rem 1.15rem;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.paper-year {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}
.paper-authors {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Bio */
.bio-card {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2.25rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2rem;
}

.bio-photo {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  display: block;
}

.bio-content h2 { margin: 0 0 0.75rem; font-size: 1.85rem; }
.bio-content p { margin: 0 0 0.9rem; color: var(--text-muted); }
.bio-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1rem 0 1.25rem;
}
.bio-tags span {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
}
.bio-links { display: flex; flex-wrap: wrap; gap: 0.65rem; }

/* Fun Gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.gallery-card {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  transition: transform 0.15s, border-color 0.15s;
}
.gallery-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.gallery-card img {
  width: 100%;
  height: 280px;
  object-fit: cover;
  object-position: center top;
  display: block;
  background: #0a0e13;
}
.gallery-card figcaption { padding: 1rem 1.15rem; }
.gallery-card figcaption strong { display: block; margin-bottom: 0.25rem; }
.gallery-card figcaption span { font-size: 0.88rem; color: var(--text-muted); }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 8, 12, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  gap: 1rem;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: min(900px, 92vw);
  max-height: 75vh;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.lightbox p { color: #e2e8f0; max-width: 64ch; text-align: center; margin: 0; }
.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 2.5rem 0;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.classic-logo {
  height: 44px;
  width: auto;
  border-radius: 6px;
  background: #fff;
  padding: 4px 8px;
  margin-bottom: 0.45rem;
  display: block;
}
.footer-brand p { margin: 0; font-size: 0.86rem; color: var(--text-muted); }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.9rem;
}
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--text); }

/* Responsive */
@media (max-width: 980px) {
  .nav-links { display: none; }
  .mobile-only { display: inline-flex; }
  .hero-grid, .overview-grid, .bio-card { grid-template-columns: 1fr; }
  .timeline-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-grid, .books-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-docs { grid-template-columns: repeat(2, 1fr); }
  .bio-photo { max-width: 240px; }
}

@media (max-width: 620px) {
  .hero { padding: 3rem 0 2.5rem; }
  .hero-stats, .timeline-grid, .cards-grid, .cards-grid.cols-2, .books-grid, .quick-docs, .gallery-grid {
    grid-template-columns: 1fr;
  }
}
