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

:root {
  --bg: #0A0F1E;
  --surface: #111827;
  --card: #1A2744;
  --accent: #3DFFC0;
  --accent-dim: rgba(61,255,192,0.10);
  --accent-mid: rgba(61,255,192,0.35);
  --text: #E8F4F0;
  --muted: #7BAFC4;
  --border: rgba(123,175,196,0.15);
  --sidebar-w: 220px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
aside {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: sticky;
  top: 0;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.2rem;
}

.logo-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  text-decoration: none;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-section-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.75rem 0.5rem 0.35rem;
  opacity: 0.6;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.tab-btn .tab-icon {
  font-size: 1rem;
  width: 20px;
  flex-shrink: 0;
  text-align: center;
}

.tab-btn:hover {
  background: var(--accent-dim);
  color: var(--text);
}

.tab-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-mid);
}

.tab-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-mid);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-footer a {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  text-decoration: none;
  display: block;
  margin-bottom: 0.3rem;
  transition: color 0.15s;
}

.sidebar-footer a:hover { color: var(--accent); }

/* ── MAIN CONTENT ── */
main {
  flex: 1;
  min-width: 0;
}

/* ── HERO (App page) ── */
.app-hero {
  position: relative;
  min-height: 100vh;
  height: 100vh;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

#hero-canvas {
  position: absolute; inset: 0;
  opacity: 0.3;
  pointer-events: none;
}

.app-hero-inner {
  position: relative;
  z-index: 2;
  padding: 0.75rem 1.5rem;
  width: 100%;
  height: 100%;
  display: flex;
}

/* Title overlay badge, top-left corner */
.hero-corner-badge {
  position: absolute;
  top: 1.25rem;
  left: 1.5rem;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: rgba(10,15,30,0.55);
  backdrop-filter: blur(6px);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
  white-space: nowrap;
}

h1 .accent { color: var(--accent); }

.hero-eyebrow-inline {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.2rem;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.hero-eyebrow::before {
  content: '';
  display: block;
  width: 24px;
  height: 1px;
  background: var(--accent);
}

/* ── INTRO ROW (below hero) ── */
.intro-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  padding: 1.25rem 5vw;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.hero-sub-compact {
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 440px;
  text-align: left;
  line-height: 1.6;
}

.hero-stats-compact {
  display: flex;
  gap: 1.5rem;
}

.hstat { display: flex; flex-direction: column; align-items: center; }

.hstat-n {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.hstat-l {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.2rem;
}

.cta-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  padding: 0.55rem 1.2rem;
  border-radius: 5px;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.15s;
}

.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.8rem;
  padding: 0.55rem 1.2rem;
  border-radius: 5px;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s, transform 0.15s;
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }

/* ── APP EMBED (live demo container, fills hero) ── */
.app-embed-container {
  display: flex;
  flex: 0 0 40%;
  width: 50%;
  height: 100%;
  margin: 0 auto;
}

.app-embed-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 0 60px rgba(61,255,192,0.06), 0 25px 80px rgba(0,0,0,0.3);
}

.embed-caption {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* ── GENERIC CONTENT SECTIONS ── */
.content-section {
  padding: 4rem 5vw;
  border-top: 1px solid var(--border);
}

.content-section:first-of-type { border-top: none; }

.section-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.section-intro {
  color: var(--muted);
  max-width: 620px;
  margin-bottom: 2.5rem;
  line-height: 1.8;
}

.body-text {
  color: var(--muted);
  max-width: 680px;
  line-height: 1.85;
  margin-bottom: 1.1rem;
  font-size: 0.94rem;
}

/* ── PAGE HEADER ── */
.page-header {
  padding: 4rem 5vw 2rem;
  border-bottom: 1px solid var(--border);
}

/* ── FEATURES GRID ── */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.feat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  transition: border-color 0.2s;
}

.feat-card:hover { border-color: var(--accent-mid); }

.feat-icon {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
}

.feat-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.feat-desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.65;
}

/* ── BOOKS PAGE ── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  padding: 3rem 5vw;
}

.book-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.book-card:hover {
  border-color: var(--accent-mid);
  transform: translateY(-3px);
}

.book-cover {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: linear-gradient(135deg, #0d1f35 0%, #0f2a1e 100%);
  position: relative;
  overflow: hidden;
}

.book-cover-2 { background: linear-gradient(135deg, #1a0d35 0%, #2a0f1e 100%); }

.book-cover-glow {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--accent-dim);
  filter: blur(30px);
}

.book-cover span { position: relative; z-index: 1; }

.book-body { padding: 1.5rem; }

.book-tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.book-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.65rem;
  line-height: 1.35;
}

.book-desc {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.book-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge.gold {
  border-color: rgba(255,210,80,0.4);
  color: #FFD250;
  background: rgba(255,210,80,0.07);
}

/* ── BOOK DETAIL PAGE ── */
.book-detail {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 3rem;
  padding: 3rem 5vw;
  align-items: start;
}

.book-detail-cover {
  height: 360px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  background: linear-gradient(135deg, #0d1f35 0%, #0f2a1e 100%);
  position: relative;
  overflow: hidden;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.toc-item {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.toc-item .toc-num {
  font-family: var(--font-mono);
  color: var(--accent);
  margin-right: 0.75rem;
}

.toc-item .toc-title { color: var(--text); flex: 1; }

/* ── RESEARCH PAGE ── */
.chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.35rem 0.8rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: default;
  transition: border-color 0.15s, color 0.15s;
}

.chip:hover { border-color: var(--accent-mid); color: var(--accent); }
.chip.hot { border-color: var(--accent-mid); color: var(--accent); background: var(--accent-dim); }

.pub-list { display: flex; flex-direction: column; gap: 0.75rem; }

.pub-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 1.1rem 1.25rem;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 1rem;
  align-items: start;
  transition: border-color 0.2s;
}

.pub-item:hover { border-color: var(--accent-mid); }

.pub-year {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  padding-top: 2px;
}

.pub-title {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  line-height: 1.4;
}

.pub-meta {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  color: var(--muted);
}

.pub-tag {
  display: inline;
  margin-left: 0.5rem;
  font-size: 0.6rem;
  padding: 0.1rem 0.45rem;
  border-radius: 2px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-mid);
}

/* ── TIMELINE (research) ── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 2px solid var(--border);
  margin-left: 0.5rem;
  padding-left: 1.5rem;
}

.timeline-item {
  position: relative;
  padding-bottom: 2rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.6rem;
  top: 0.3rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-year {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

/* ── ABOUT PAGE ── */
.about-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 3rem;
  align-items: start;
  padding: 3rem 5vw;
}

.portrait-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  aspect-ratio: 3/4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  position: relative;
  overflow: hidden;
}

.portrait-glow {
  position: absolute;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: var(--accent-dim);
  filter: blur(40px);
  top: 20%;
}

.portrait-box span { position: relative; z-index: 1; }

.portrait-emoji { font-size: 2.5rem; position: relative; z-index: 1; }

.about-tag {
  position: absolute;
  bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-mid);
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
  z-index: 2;
}

.about-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 1.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.astat { display: flex; flex-direction: column; }
.astat-n { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--accent); line-height: 1; }
.astat-l { font-family: var(--font-mono); font-size: 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 0.2rem; }

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.clink {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}

.clink:hover { border-color: var(--accent); color: var(--accent); }

/* ── MOBILE NAV ── */
.mobile-nav {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  gap: 0.5rem;
  overflow-x: auto;
}

.mobile-tab {
  white-space: nowrap;
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.mobile-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-mid);
}

/* ── FOOTER ── */
.page-footer {
  padding: 2.5rem 5vw;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 768px) {
  body { flex-direction: column; }
  aside { display: none; }
  .mobile-nav { display: flex; }
  /* Fill remaining viewport after the sticky nav bar (~52px) */
  .app-hero { height: calc(100vh - 52px - 55px); min-height: calc(100vh - 52px - 55px); }
  .app-hero-inner { padding: 0; }
  /* Hide the title badge — it overlaps the app on mobile */
  .hero-corner-badge { display: none; }
  h1 { font-size: 1.1rem; white-space: nowrap; }
  .intro-row { flex-direction: column; gap: 0.6rem; text-align: center; padding: 1.25rem 4vw; }
  .hero-sub-compact { text-align: center; max-width: 100%; }
  /* Iframe fills the full hero area edge-to-edge */
  .app-embed-container { width: 100%; flex: 1; margin: 0; height: 100%; }
  .app-embed-frame { border-radius: 0; border-left: none; border-right: none; }
  .about-grid { grid-template-columns: 1fr; }
  .book-detail { grid-template-columns: 1fr; }
}