:root {
  --bg-primary: #0a0c10;
  --bg-sidebar: #0f1219;
  --bg-card: #151a24;
  --border: #232a3b;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #545d68;
  --accent-cyan: #38bdf8;
  --accent-cyan-glow: rgba(56, 189, 248, 0.15);
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --font-sans: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

/* CUSTOM SCROLLBAR (MATCH DARK THEME) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: #232a3b;
  border-radius: 999px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: #38bdf8;
}

/* Firefox scrollbar support */
* {
  scrollbar-width: thin;
  scrollbar-color: #232a3b var(--bg-primary);
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow: hidden;
  height: 100vh;
}

.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr 340px;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge-img {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-badge-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}

.logo-badge {
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  color: #050811;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.25);
}

.brand-text h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
}

.subdomain {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-secondary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan-glow);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 13px;
  font-family: var(--font-sans);
  width: 100%;
}

.search-kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 4px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.topic-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topic-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.topic-list li:hover {
  background: var(--bg-card);
  color: #fff;
}

.topic-list li.active {
  background: var(--accent-cyan-glow);
  color: var(--accent-cyan);
  font-weight: 600;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot.all { background: var(--accent-cyan); }
.dot.edge-systems { background: #38bdf8; }
.dot.stream-thoughts { background: #a855f7; }
.dot.tools { background: #10b981; }

.count {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--font-mono);
  opacity: 0.6;
}

.status-legend {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-block;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.badge.seedling { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.badge.budding { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge.evergreen { background: rgba(16, 185, 129, 0.15); color: #10b981; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.bio-snippet {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bio-name {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
}

.bio-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.portfolio-link {
  font-size: 11.5px;
}

.portfolio-link a {
  color: var(--accent-cyan);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 11px;
}

.portfolio-link a:hover {
  text-decoration: underline;
}

/* READING PANE */
.reading-pane {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-primary);
}

.top-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 48px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 12, 16, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.breadcrumbs {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.theme-switch {
  cursor: pointer;
  font-size: 16px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.theme-switch:hover {
  opacity: 1;
}

.article-content {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px 80px 24px;
  animation: articleFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes articleFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.article-header {
  margin-bottom: 32px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 24px;
}

.article-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.reading-time {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.share-article-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.share-article-btn:hover {
  background: var(--accent-cyan-glow);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.article-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.article-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.25;
  color: #fff;
  margin-bottom: 12px;
}

.article-tags {
  display: flex;
  gap: 6px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.article-body {
  line-height: 1.8;
  font-size: 15.5px;
  color: #c9d1d9;
}

.article-body p {
  margin-bottom: 18px;
}

.article-body h2 {
  font-size: 20px;
  color: #fff;
  margin: 32px 0 14px 0;
  letter-spacing: -0.3px;
}

.article-body blockquote {
  border-left: 3px solid var(--accent-cyan);
  background: rgba(56, 189, 248, 0.05);
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: #93c5fd;
}

.article-body code {
  font-family: var(--font-mono);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13.5px;
  color: #38bdf8;
}

.article-body pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 20px 0;
  position: relative;
}

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-code-btn:hover {
  background: var(--accent-cyan-glow);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e2e8f0;
}

.connected-notes {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.connected-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.connected-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.connected-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.connected-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
}

.connected-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.connected-card-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* RIGHT GRAPH PANE */
.graph-pane {
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 16px;
  overflow: hidden;
}

.graph-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.graph-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.graph-hint {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.graph-container {
  height: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

/* GRAPH TOOLTIP OVERLAY */
.graph-tooltip {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  background: rgba(10, 12, 16, 0.92);
  border: 1px solid var(--accent-cyan);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #fff;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.graph-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.recent-thoughts {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.recent-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.recent-item:hover {
  background: var(--bg-card);
  border-color: rgba(56, 189, 248, 0.4);
}

.recent-item.active {
  background: var(--accent-cyan-glow);
  border-color: var(--accent-cyan);
}

.recent-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent-cyan);
  border-radius: 0 2px 2px 0;
}

.recent-item-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}

.recent-item-date {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* MOBILE TOGGLE BUTTONS & ACTIONS */
.mobile-toggle-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
}

.mobile-toggle-btn:hover {
  background: var(--bg-card);
}

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

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 40;
}

/* RESPONSIVE BREAKPOINTS */
@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 260px 1fr;
  }
  .graph-pane {
    position: fixed;
    top: 0;
    right: -340px;
    width: 320px;
    height: 100vh;
    z-index: 50;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  }
  .graph-pane.open {
    right: 0;
  }
  .mobile-toggle-btn#graphToggle {
    display: flex;
  }
}

@media (max-width: 768px) {
  .app-layout {
    display: block;
    height: 100vh;
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -290px;
    width: 280px;
    height: 100vh;
    z-index: 50;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    left: 0;
  }

  .mobile-toggle-btn {
    display: flex;
  }

  .backdrop.open {
    display: block;
  }

  .top-nav-bar {
    padding: 14px 18px;
    gap: 12px;
  }

  .breadcrumbs {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .article-content {
    padding: 24px 18px 80px 18px;
  }

  .article-title {
    font-size: 24px;
    letter-spacing: -0.5px;
  }

  .connected-grid {
    grid-template-columns: 1fr;
  }

  .graph-pane {
    right: -100%;
    width: 85%;
    max-width: 340px;
  }
}

/* ===================================================
   HOME / DASHBOARD VIEW STYLING (ANTI-SLOP ARCHITECTURE)
   =================================================== */

.home-dashboard {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 80px 24px;
  animation: articleFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.home-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px dashed var(--border);
}

.home-badge-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.home-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent-cyan);
  background: var(--accent-cyan-glow);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

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

.home-hero h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  color: #fff;
  line-height: 1.2;
}

.home-tagline {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent-cyan);
  letter-spacing: -0.2px;
}

.home-bio {
  font-size: 15.5px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 680px;
}

/* TELEMETRY STATS */
.home-telemetry {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 36px;
}

.telemetry-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s ease;
}

.telemetry-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-2px);
}

.telemetry-val {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: #fff;
}

.telemetry-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

/* SECTION HEADINGS IN HOME */
.home-section-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* BENTO CATEGORY PORTALS */
.bento-portals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 40px;
}

.bento-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.bento-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.2s ease;
}

.bento-card[data-cat="edge-systems"]::before { background: #38bdf8; }
.bento-card[data-cat="stream-thoughts"]::before { background: #a855f7; }
.bento-card[data-cat="tools"]::before { background: #10b981; }

.bento-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.bento-icon {
  font-size: 22px;
}

.bento-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
}

.bento-card p {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.bento-footer {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* RECENT DISPATCHES LIST */
.recent-dispatches {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dispatch-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dispatch-card:hover {
  border-color: var(--accent-cyan);
  background: rgba(21, 26, 36, 0.8);
  transform: translateX(4px);
}

.dispatch-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dispatch-title {
  font-size: 14.5px;
  font-weight: 600;
  color: #fff;
}

.dispatch-summary {
  font-size: 12.5px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dispatch-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .home-telemetry {
    grid-template-columns: 1fr;
  }
  .bento-portals {
    grid-template-columns: 1fr;
  }
  .dispatch-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .home-hero h1 {
    font-size: 28px;
  }
}

/* READING PANE FOOTER / COLOPHON */
.reading-footer {
  margin-top: 60px;
  padding: 28px 48px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.reading-footer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 12px;
}

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

.footer-sep {
  color: var(--text-muted);
}

.footer-motto {
  color: var(--text-secondary);
  font-style: italic;
  font-family: var(--font-sans);
  font-size: 12px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.footer-links a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.reading-footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 10.5px;
  color: var(--text-muted);
}

.footer-tech {
  letter-spacing: 0.3px;
}

@media (max-width: 900px) {
  .reading-footer {
    padding: 24px 20px;
  }
  .reading-footer-top, .reading-footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}
