:root {
  --bg: #07090f;
  --bg-elevated: rgba(15, 20, 32, 0.72);
  --bg-card: rgba(17, 23, 38, 0.65);
  --bg-card-hover: rgba(24, 32, 52, 0.82);
  --bg-code: #0b0f1a;
  --border: rgba(148, 163, 184, 0.12);
  --border-hover: rgba(99, 102, 241, 0.45);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-cyan: #22d3ee;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --glow-1: rgba(99, 102, 241, 0.22);
  --glow-2: rgba(34, 211, 238, 0.15);
  --shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.65);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, monospace;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elevated: rgba(255, 255, 255, 0.82);
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-code: #0f172a;
  --border: rgba(15, 23, 42, 0.09);
  --border-hover: rgba(79, 70, 229, 0.4);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #4f46e5;
  --accent-cyan: #0891b2;
  --accent-emerald: #059669;
  --glow-1: rgba(99, 102, 241, 0.12);
  --glow-2: rgba(34, 211, 238, 0.10);
  --shadow: 0 18px 40px -15px rgba(15, 23, 42, 0.09);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.35s ease, color 0.35s ease;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Aurora & Subtle Grid */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
  overflow: hidden;
}

.ambient-bg::before {
  content: "";
  position: absolute;
  top: -22%;
  left: 50%;
  transform: translateX(-50%);
  width: 960px;
  height: 540px;
  background: radial-gradient(ellipse at center, var(--glow-1) 0%, var(--glow-2) 42%, transparent 72%);
  filter: blur(65px);
  animation: auroraFloat 14s ease-in-out infinite alternate;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 55% at 50% 15%, #000 25%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse 80% 55% at 50% 15%, #000 25%, transparent 85%);
  opacity: 0.45;
}

@keyframes auroraFloat {
  0% { transform: translateX(-52%) translateY(0) scale(1); }
  100% { transform: translateX(-48%) translateY(28px) scale(1.07); }
}

/* Reading Progress Bar */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2.5px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-cyan), var(--accent-emerald));
  z-index: 200;
  transition: width 0.1s linear;
}

/* Sticky Glass Header */
.site-header {
  position: sticky;
  top: 14px;
  z-index: 100;
  max-width: 1120px;
  margin: 14px auto 0;
  padding: 0 20px;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--text);
}

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

.cmd-btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cmd-btn:hover, .icon-btn:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: rgba(99, 102, 241, 0.1);
}

.kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text);
}

/* Main Container */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 24px 96px;
}

/* Hero Section */
.hero {
  padding: 36px 0 54px;
  text-align: left;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.28);
  color: var(--accent-emerald);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 24px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.65); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.hero h1 {
  font-size: clamp(2.25rem, 5vw, 3.65rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.035em;
  margin-bottom: 20px;
  max-width: 820px;
}

.gradient-text {
  background: linear-gradient(135deg, #818cf8 0%, #22d3ee 52%, #34d399 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  font-size: clamp(1rem, 2vw, 1.16rem);
  color: var(--text-secondary);
  max-width: 660px;
  margin-bottom: 32px;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 28px -6px rgba(99, 102, 241, 0.55);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px -6px rgba(99, 102, 241, 0.72);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text);
  font-weight: 500;
  font-size: 0.92rem;
  text-decoration: none;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

/* Section Headers */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 56px 0 22px;
  gap: 16px;
}

.section-head h2 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-head span {
  font-size: 0.86rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Bento Grid */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}

.bento-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: border-color 0.25s ease, transform 0.25s ease, background 0.25s ease;
  position: relative;
  overflow: hidden;
}

.bento-card:hover {
  border-color: var(--border-hover);
}

.col-5 { grid-column: span 5; }
.col-7 { grid-column: span 7; }
.col-12 { grid-column: span 12; }

.card-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-cyan);
  margin-bottom: 10px;
}

.bento-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.bento-card p.desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

/* Telemetry Widget */
.telemetry-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
}

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

.sparkline-wrap {
  height: 68px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  margin-bottom: 12px;
  position: relative;
}

[data-theme="light"] .sparkline-wrap {
  background: rgba(15, 23, 42, 0.04);
}

.sparkline-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.mini-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* BBR Simulator */
.sim-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.sim-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.bar-track {
  height: 10px;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.fill-brutal { background: linear-gradient(90deg, #10b981, #22d3ee); }
.fill-bbr { background: linear-gradient(90deg, #6366f1, #38bdf8); }
.fill-cubic { background: linear-gradient(90deg, #f59e0b, #ef4444); }

/* Articles Grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.post-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: all 0.25s ease;
  cursor: pointer;
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.14);
  color: #818cf8;
  font-weight: 600;
}

[data-theme="light"] .badge {
  color: #4f46e5;
}

.post-card h3 {
  font-size: 1.14rem;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.4;
}

.post-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

/* Stack Pills */
.stack-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.stack-pill {
  padding: 7px 14px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Modal / Reader Drawer & Command Palette */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay.open {
  display: flex;
}

.modal-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 760px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 34px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.75);
  position: relative;
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
}

.article-body h2 {
  font-size: 1.65rem;
  margin-bottom: 10px;
}

.article-body h4 {
  font-size: 1.1rem;
  margin: 24px 0 10px;
  color: var(--accent-cyan);
}

.article-body p {
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.code-block {
  position: relative;
  background: var(--bg-code);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.16);
  overflow-x: auto;
  margin: 14px 0 18px;
  line-height: 1.6;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #cbd5e1;
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
}

/* Command Palette */
.cmd-modal {
  max-width: 540px;
  padding: 0;
  overflow: hidden;
}

.cmd-input {
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.98rem;
  font-family: inherit;
  outline: none;
}

.cmd-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
}

.cmd-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.88rem;
}

.cmd-item:hover {
  background: rgba(99, 102, 241, 0.14);
  color: var(--text);
}

/* Footer */
.site-footer {
  margin-top: 72px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.footer-links {
  display: flex;
  gap: 18px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
}

@media (max-width: 820px) {
  .col-5, .col-7 { grid-column: span 12; }
  .nav-links { display: none; }
  .sim-controls { grid-template-columns: 1fr; }
}
