:root {
  --bg-primary: #0a0a0c;
  --bg-panel: rgba(18, 18, 20, 0.85);
  --bg-secondary: rgba(30, 30, 35, 0.6);
  --border: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.3);
  --text-primary: #ffffff;
  --text-muted: #8e8e93;
  --grid-color: rgba(255, 255, 255, 0.02);
  --status-color: #ffffff;
  --vignette-opacity: 0.8;
  --hover-line-color: #8e8e93;
}

body.light-theme {
  --bg-primary: #f3f3f2;
  --bg-panel: rgba(255, 255, 255, 0.85);
  --bg-secondary: rgba(0, 0, 0, 0.04);
  --border: rgba(0, 0, 0, 0.08);
  --border-bright: rgba(0, 0, 0, 0.3);
  --text-primary: #000000;
  --text-muted: #575757;
  --grid-color: rgba(0, 0, 0, 0.03);
  --status-color: #000000;
  --vignette-opacity: 0.2;
  --hover-line-color: #ffffff;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
      linear-gradient(var(--grid-color) 1px, transparent 1px),
      linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 40px 40px;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s, color 0.2s, background-image 0.2s;
}

@keyframes flickerIgnite {
  0% { opacity: 0; filter: brightness(0.2); }
  5% { opacity: 0.1; }
  10% { opacity: 0; }
  15% { opacity: 0.35; }
  20% { opacity: 0.1; }
  30% { opacity: 0.55; filter: brightness(1.4); }
  35% { opacity: 0.15; }
  50% { opacity: 0.8; }
  55% { opacity: 0.35; }
  70% { opacity: 0.9; }
  75% { opacity: 0.55; }
  90% { opacity: 1; filter: brightness(1.1); }
  100% { opacity: 1; filter: brightness(1); }
}

.vignette {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0, var(--vignette-opacity)) 100%);
  pointer-events: none;
  z-index: 10;
  transition: background 0.2s;
}

.scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.008) 3px,
    rgba(255, 255, 255, 0.008) 4px
  );
  pointer-events: none;
  z-index: 11;
}

body.light-theme .scanlines {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.004) 3px,
    rgba(0, 0, 0, 0.004) 4px
  );
}

.site-header {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 95%;
  max-width: 1400px;
  height: 64px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  transition: background-color 0.2s, border-color 0.2s;
  opacity: 0;
  animation: flickerIgnite 0.6s cubic-bezier(0.25, 1, 0.5, 1) 0.1s forwards;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cross-icon {
  width: 18px;
  height: 18px;
  position: relative;
  flex-shrink: 0;
}

.cross-icon::before, .cross-icon::after {
  content: '';
  position: absolute;
  background: var(--text-primary);
  transition: background-color 0.2s;
}

.cross-icon::before {
  width: 2px;
  height: 100%;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

.cross-icon::after {
  height: 2px;
  width: 100%;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.brand h1 {
  font-family: 'Share Tech Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--text-primary);
  line-height: 1;
  transition: color 0.2s;
}

.brand h1 span { color: var(--text-muted); }

.brand .sub {
  font-size: 7px;
  color: var(--text-muted);
  letter-spacing: 0.25em;
  margin-top: 3px;
  display: block;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.categories-nav {
  display: flex;
  background: rgba(0,0,0,0.1);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}

body.light-theme .categories-nav {
  background: rgba(0,0,0,0.03);
}

.category-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.1em;
}

.category-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.03);
}

body.light-theme .category-btn:hover {
  background: rgba(0,0,0,0.02);
}

.category-btn.active {
  background: var(--text-primary);
  color: var(--bg-primary);
  font-weight: bold;
}

.system-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: var(--status-color);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--status-color);
  animation: blink 2.5s infinite ease-in-out;
  transition: background-color 0.2s;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

body.light-theme .theme-toggle:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.app-container {
  margin-top: 110px;
  width: 100%;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 24px 60px 24px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  flex: 1;
  position: relative;
}

.center-feed {
  position: relative;
  border-top: 1px solid var(--border);
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  counter-reset: post-counter;
}

.post-card {
  position: relative;
  padding: 40px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: transparent;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 280px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.2s ease, border-color 0.2s;
  counter-increment: post-counter;
  opacity: 0;
}

.post-card:nth-child(1) {
  animation: flickerIgnite 0.7s cubic-bezier(0.25, 1, 0.5, 1) 0.3s forwards;
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 4px; height: 0;
  background: var(--hover-line-color);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.08);
  transition: height 0.2s ease;
}

.post-card:hover {
  background-color: rgba(255, 255, 255, 0.015);
}

body.light-theme .post-card:hover {
  background-color: rgba(0, 0, 0, 0.015);
}

.post-card:hover::before {
  height: 100%;
}

.post-card.hidden {
  display: none;
}

.post-card:nth-child(2n) {
  border-right: none;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.card-number::before {
  content: "LOG // 0" counter(post-counter);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.card-plus {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--text-muted);
}

.post-card:hover .card-plus {
  color: var(--text-primary);
  animation: blink-fast 0.4s infinite steps(2, start);
}

@keyframes blink-fast {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.card-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.post-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.3px;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.post-excerpt {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 300;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.right-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  animation: flickerIgnite 0.8s cubic-bezier(0.25, 1, 0.5, 1) 0.75s forwards;
}

.sidebar-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-primary);
}

.badge {
  background: var(--border-bright);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 8px;
  color: var(--text-primary);
}

.sidebar-list {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 500px;
  overflow-y: auto;
}

.sidebar-item {
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 2px solid var(--text-muted);
}

.sidebar-item:hover {
  border-color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

body.light-theme .sidebar-item:hover {
  background: rgba(0, 0, 0, 0.02);
}

.item-meta {
  display: flex;
  justify-content: space-between;
  font-family: 'Share Tech Mono', monospace;
  font-size: 7.5px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.item-title {
  font-size: 11px;
  line-height: 1.3;
  font-weight: 500;
  color: var(--text-primary);
}

.post-reader {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  width: 90%;
  max-width: 800px;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  backdrop-filter: blur(20px);
  padding: 40px;
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.post-reader.active {
  opacity: 1;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

.reader-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.reader-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.reader-close:hover {
  border-color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

body.light-theme .reader-close:hover {
  background: rgba(0,0,0,0.05);
}

.reader-nav-buttons {
  display: flex;
  gap: 8px;
}

.nav-arrow-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-arrow-btn:hover:not(:disabled) {
  border-color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

body.light-theme .nav-arrow-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
}

.nav-arrow-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.reader-meta {
  display: flex;
  gap: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.reader-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.reader-content {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.reader-content p {
  margin-bottom: 16px;
}

.reader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1090;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.reader-overlay.active {
  opacity: 1;
  pointer-events: all;
}

@media (max-width: 1000px) {
  .app-container {
    grid-template-columns: 1fr;
  }
  .categories-nav {
    display: none;
  }
}

@media (max-width: 680px) {
  .blog-grid {
    grid-template-columns: 1fr;
  }
  .post-card {
    border-right: none !important;
    padding: 30px 16px;
  }
  .reader-nav-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}