/* ==========================================================================
   LOCAL FONT HOSTING
   ========================================================================== */

/* JetBrains Mono */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('assets/fonts/jetbrains-mono-v24-latin-300.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/jetbrains-mono-v24-latin-400.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('assets/fonts/jetbrains-mono-v24-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/jetbrains-mono-v24-latin-700.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/jetbrains-mono-v24-latin-italic.woff2') format('woff2');
}

/* Outfit */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('assets/fonts/outfit-v15-latin-300.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/outfit-v15-latin-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('assets/fonts/outfit-v15-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/outfit-v15-latin-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/outfit-v15-latin-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('assets/fonts/outfit-v15-latin-800.woff2') format('woff2');
}

/* ==========================================================================
   DESIGN SYSTEM & CSS VARIABLES
   ========================================================================== */
:root {
  /* Fonts */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  /* Theme: Dark Mode (Default) */
  --bg-app: hsl(222, 20%, 8%);
  --bg-sidebar: rgba(13, 16, 23, 0.75);
  --bg-card: rgba(22, 28, 41, 0.55);
  --bg-card-hover: rgba(30, 38, 56, 0.7);
  --bg-input: rgba(10, 12, 18, 0.6);
  --bg-modal: hsl(222, 24%, 10%);
  --bg-modal-header: rgba(13, 16, 23, 0.8);
  --bg-tag: rgba(99, 102, 241, 0.12);
  --bg-tag-hover: rgba(99, 102, 241, 0.25);
  
  --text-primary: hsl(210, 38%, 95%);
  --text-secondary: hsl(215, 20%, 68%);
  --text-muted: hsl(215, 12%, 50%);
  --text-accent: hsl(262, 89%, 68%); /* Neo-violet */
  --text-accent-secondary: hsl(142, 76%, 45%); /* Matrix green */
  
  --border-color: rgba(255, 255, 255, 0.07);
  --border-color-hover: rgba(255, 255, 255, 0.15);
  --border-accent: hsl(262, 89%, 68%);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
  
  --glass-blur: 16px;
  --glass-bg: radial-gradient(circle at 50% 0%, rgba(30, 38, 56, 0.15), rgba(13, 16, 23, 0.05));
}

[data-theme="light"] {
  /* Theme: Light Mode (IDE theme) */
  --bg-app: hsl(220, 20%, 96%);
  --bg-sidebar: rgba(255, 255, 255, 0.85);
  --bg-card: rgba(255, 255, 255, 0.65);
  --bg-card-hover: rgba(255, 255, 255, 0.9);
  --bg-input: rgba(240, 242, 246, 0.8);
  --bg-modal: hsl(0, 0%, 100%);
  --bg-modal-header: rgba(255, 255, 255, 0.9);
  --bg-tag: rgba(99, 102, 241, 0.08);
  --bg-tag-hover: rgba(99, 102, 241, 0.18);
  
  --text-primary: hsl(222, 28%, 15%);
  --text-secondary: hsl(220, 16%, 36%);
  --text-muted: hsl(220, 10%, 55%);
  --text-accent: hsl(262, 80%, 50%);
  --text-accent-secondary: hsl(142, 70%, 35%);
  
  --border-color: rgba(0, 0, 0, 0.06);
  --border-color-hover: rgba(0, 0, 0, 0.12);
  --border-accent: hsl(262, 80%, 50%);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  
  --scrollbar-thumb: rgba(0, 0, 0, 0.1);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.25);
  
  --glass-bg: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.6), rgba(240, 242, 246, 0.3));
}

/* ==========================================================================
   BASE STYLES & RESET
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  transition: background-color 0.4s ease, color 0.4s ease;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background 0.3s;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Typography elements */
a {
  color: var(--text-accent);
  text-decoration: none;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}
a:hover {
  text-shadow: 0 0 6px rgba(99, 102, 241, 0.2);
}

button {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

/* ==========================================================================
   APP SHELL LAYOUT
   ========================================================================== */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* 1. Sidebar Navigation Styles */
.app-sidebar {
  width: 320px;
  min-width: 320px;
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s, border-color 0.4s;
  overflow-y: auto;
}

.sidebar-header {
  padding: 32px 24px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.avatar-container {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--border-accent);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.25);
  transition: transform 0.3s ease;
}
.avatar-container:hover {
  transform: rotate(5deg) scale(1.05);
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

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

.brand-subtitle {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 4px;
}

.mobile-close-btn {
  display: none;
  font-size: 1.8rem;
  color: var(--text-secondary);
  position: absolute;
  top: 20px;
  right: 20px;
}

/* Sidebar Search Box */
.sidebar-search {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.search-box {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 14px;
  gap: 10px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.search-box:focus-within {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-icon {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  width: 100%;
}
.search-box input::placeholder {
  color: var(--text-muted);
}

.clear-search-btn {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: bold;
  padding: 0 4px;
  transition: color 0.2s;
}
.clear-search-btn:hover {
  color: var(--text-primary);
}

/* Sidebar Filter Sections */
.sidebar-nav {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  flex: 1;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-pill {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  background-color: var(--bg-tag);
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.tag-pill:hover {
  background-color: var(--bg-tag-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}
.tag-pill.active {
  background-color: var(--text-accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  transform: translateY(-1px);
}
.tag-pill .tag-count {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-left: 4px;
}

/* Tag Skeleton Loader */
.tag-skeleton {
  height: 28px;
  width: 80px;
  background: linear-gradient(90deg, var(--border-color) 25%, var(--bg-card) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
  border-radius: 8px;
}

.about-text {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Sidebar Footer / Toggle */
.sidebar-footer {
  padding: 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.theme-toggle-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.theme-toggle-btn {
  width: 48px;
  height: 24px;
  position: relative;
  background: none;
}

.toggle-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  transition: background-color 0.3s;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .toggle-track {
  background-color: var(--text-accent);
  border-color: transparent;
}
[data-theme="dark"] .toggle-thumb {
  transform: translateX(24px);
  background-color: #fff;
}

.copyright-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 2. Main content container layout */
.app-main {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--glass-bg);
}

.main-topbar {
  height: 64px;
  min-height: 64px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 5;
  transition: background-color 0.4s, border-color 0.4s;
}

.mobile-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 16px;
}
.hamburger-bar {
  height: 2px;
  width: 100%;
  background-color: var(--text-primary);
  border-radius: 1px;
}

.stats-counter {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Active filter bar inside topbar */
.active-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.filter-badge-val {
  font-weight: bold;
}
.filter-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background-color: var(--text-accent);
  color: #fff;
}
.remove-filter-btn {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: color 0.2s;
}
.remove-filter-btn:hover {
  color: var(--text-primary);
}

/* Main Content Scrollable Area */
.main-content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
}

.posts-section {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.section-header {
  border-left: 3px solid var(--border-accent);
  padding-left: 16px;
}

.section-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.8px;
}

.section-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ==========================================================================
   POSTS GRID & CARDS
   ========================================================================== */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

/* Year group header inside grid */
.year-group-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 36px;
  margin-bottom: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.year-group-header:first-of-type {
  margin-top: 0;
}

.year-text {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
  position: relative;
}

.year-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background-color: var(--bg-tag);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}


/* Card Skeleton loader */
.card-skeleton {
  height: 280px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(99, 102, 241, 0.05) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Sleek Interactive Blog Card */
.post-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  height: 290px;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* Card Hover micro-animations */
.post-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--text-accent), var(--text-accent-secondary));
  opacity: 0;
  transition: opacity 0.3s;
}

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

.post-card:hover::before {
  opacity: 1;
}

.post-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.post-card-date {
  font-weight: 500;
}

.post-card-readtime {
  font-weight: 500;
}

.post-card-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 12px;
  /* Multi-line truncation (3 lines) */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.2s;
}

.post-card:hover .post-card-title {
  color: var(--text-accent);
}

.post-card-excerpt {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: auto;
}

/* Card tags list inside card footer */
.post-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
}

.post-card-tags {
  display: flex;
  gap: 6px;
  overflow: hidden;
  mask-image: linear-gradient(to right, #000 75%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, #000 75%, transparent 100%);
}

.card-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background-color: var(--bg-tag);
  color: var(--text-secondary);
  white-space: nowrap;
}

.article-tags .card-tag {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.article-figure {
  text-align: center;
  margin: 32px 0;
}

.article-figure img {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.article-figure figcaption {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.article-notice {
  border-left: 3px solid var(--text-accent);
  background-color: var(--bg-tag);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 24px 0;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.post-card-arrow {
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: transform 0.2s, color 0.2s;
}
.post-card:hover .post-card-arrow {
  transform: translateX(4px);
  color: var(--text-accent);
}

/* No results / Search failed state */
.no-results {
  text-align: center;
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.no-results-icon {
  font-size: 3rem;
  color: var(--text-muted);
}
.no-results h3 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}
.no-results p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.5;
}

/* Button general style */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 10px;
  transition: all 0.2s;
}
.btn-primary {
  background-color: var(--text-accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.2);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

/* Pagination container */
.pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.load-more-btn {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 14px 28px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}
.load-more-btn:hover {
  border-color: var(--border-accent);
  background-color: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-secondary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   ARTICLE READER OVERLAY & MODAL
   ========================================================================== */
.reader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(6, 8, 12, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.reader-dialog {
  width: 820px;
  max-width: calc(100% - 48px);
  height: calc(100% - 80px);
  background-color: var(--bg-modal);
  box-shadow: var(--shadow-lg);
  border-radius: 20px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
  transform: scale(0.95) translateY(20px);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s;
  overflow: hidden;
}

.reader-overlay.active .reader-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Modal Header Bar Styles */
.reader-header {
  height: 64px;
  min-height: 64px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-modal-header);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 102;
}

.reader-close-btn {
  font-size: 1.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s;
}
.reader-close-btn:hover {
  color: var(--text-primary);
}

.kbd-hint {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.reader-actions {
  display: flex;
  gap: 12px;
}

.reader-action-btn {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.reader-action-btn:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
  background-color: var(--bg-card-hover);
}

/* Modal Main Scroll Container */
.reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 50px 32px 80px;
}

.reader-article {
  max-width: 680px;
  margin: 0 auto;
}

.article-header {
  margin-bottom: 30px;
}

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

.article-title {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-primary);
  letter-spacing: -1px;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.article-divider {
  height: 1px;
  background-color: var(--border-color);
  margin-bottom: 40px;
}

/* ==========================================================================
   TECHNICAL ARTICLE TYPOGRAPHY & CODE BLOCKS
   ========================================================================== */
.article-content {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-primary);
}

/* Paragraph spacing */
.article-content p {
  margin-bottom: 24px;
  letter-spacing: -0.1px;
}

/* Headers */
.article-content h1, 
.article-content h2, 
.article-content h3, 
.article-content h4 {
  color: var(--text-primary);
  font-weight: 700;
  margin-top: 40px;
  margin-bottom: 16px;
  letter-spacing: -0.5px;
  line-height: 1.3;
}
.article-content h1 { font-size: 1.6rem; }
.article-content h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
.article-content h3 { font-size: 1.2rem; }

/* Subtext/lists */
.article-content ul, 
.article-content ol {
  margin-left: 24px;
  margin-bottom: 24px;
}
.article-content li {
  margin-bottom: 8px;
}

/* Inline code markup */
.article-content code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 3px 6px;
  border-radius: 4px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-accent);
}

/* Large custom code block structure */
.bb-code-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  background-color: #121319;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: none;
  padding: 8px 16px;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
}
.bb-code-title::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-accent-secondary);
  box-shadow: 0 0 6px var(--text-accent-secondary);
}

.bb-code,
.article-content pre {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
  background-color: #0b0c10 !important;
  color: #c9d1d9;
  padding: 20px;
  border-radius: 12px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  white-space: pre;
}

/* If code title exists, adjust border-radius */
.bb-code-title + .bb-code,
.bb-code-title + .article-content pre {
  border-top-left-radius: 0;
  margin-top: 0;
}

/* Embedded Images Base Treatment */
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
}

/* Hover Zoom Micro-animation */
.article-content img:hover {
  transform: scale(1.015);
  box-shadow: var(--shadow-md);
}

/* Standard Centered Block Images (illustrations, covers, tables) */
.article-content img:not([style*="float"]) {
  display: block;
  margin: 36px auto !important;
  box-shadow: var(--shadow-md);
}

/* Left Floated Images (aligned with wrapped text) */
.article-content img[style*="float: left"],
.article-content img[style*="float:left"] {
  float: left !important;
  margin: 12px 24px 16px 0 !important;
  display: inline-block !important;
}

/* Right Floated Images (aligned with wrapped text) */
.article-content img[style*="float: right"],
.article-content img[style*="float:right"] {
  float: right !important;
  margin: 12px 0 16px 24px !important;
  display: inline-block !important;
}

/* Center tags and titles */
.article-content p[style*="text-align: center"],
.article-content p[style*="text-align:center"] {
  display: flex;
  justify-content: center;
}

/* Table styles */
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}
.article-content th, 
.article-content td {
  padding: 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}
.article-content th {
  background-color: var(--bg-input);
  font-weight: 600;
}

/* Blockquotes */
.article-content blockquote {
  border-left: 4px solid var(--text-accent);
  background-color: var(--bg-input);
  padding: 16px 20px;
  border-radius: 0 12px 12px 0;
  margin-bottom: 24px;
  font-style: italic;
  color: var(--text-secondary);
}

/* ==========================================================================
   SCROLL TO TOP IN MODAL
   ========================================================================== */
.scroll-to-top {
  position: absolute;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--text-accent);
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 105;
}
.scroll-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.scroll-to-top:hover {
  background-color: var(--text-accent-secondary);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   TOAST NOTIFICATION SYSTEM
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background-color: #121319;
  border: 1px solid var(--border-accent);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(15px);
  animation: toast-fade-in 0.3s forwards, toast-fade-out 0.3s 2.7s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

@keyframes toast-fade-in {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-fade-out {
  to { opacity: 0; transform: translateY(-15px); }
}

/* ==========================================================================
   RESPONSIVE DESIGN INTERFACES
   ========================================================================== */
@media (max-width: 1024px) {
  .app-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: none;
  }
  
  .app-sidebar.active {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  
  .mobile-close-btn {
    display: block;
  }
  
  .main-topbar {
    padding: 0 24px;
  }
  
  .mobile-menu-btn {
    display: flex;
  }
  
  .main-content-scroll {
    padding: 24px;
  }
  
  .reader-dialog {
    width: 820px;
    max-width: calc(100% - 32px);
    height: calc(100% - 48px);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s;
  }
  
  .reader-overlay.active .reader-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .posts-grid {
    grid-template-columns: 1fr;
  }
  
  .section-title {
    font-size: 1.6rem;
  }
  
  .article-title {
    font-size: 1.8rem;
  }
  
  .reader-dialog {
    max-width: calc(100% - 24px);
    height: calc(100% - 32px);
    border-radius: 12px;
  }
  
  .reader-header {
    padding: 0 16px;
  }
  
  .reader-body {
    padding: 30px 16px 60px;
  }
  
  .kbd-hint {
    display: none;
  }
}

/* ==========================================================================
   STANDALONE POST STYLES & LAYOUT OVERRIDES
   ========================================================================== */
html:has(body.standalone-body) {
  overflow-y: auto !important;
  height: auto !important;
}

body.standalone-body {
  overflow-y: auto !important;
  height: auto !important;
  min-height: 100vh;
  background-color: var(--bg-app);
}

.standalone-header {
  height: 64px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
}

.standalone-header-content {
  width: 820px;
  max-width: calc(100% - 48px);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.standalone-back-link {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s ease;
}

.standalone-back-link:hover {
  color: var(--text-accent);
}

.standalone-brand {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.5px;
}

.standalone-container {
  width: 820px;
  max-width: calc(100% - 48px);
  margin: 40px auto 80px;
  background-color: var(--bg-modal);
  box-shadow: var(--shadow-lg);
  border-radius: 20px;
  border: 1px solid var(--border-color);
  padding: 50px 32px 80px;
}

/* ==========================================================================
   SPLIT-PANE MASTER-DETAIL LAYOUT
   ========================================================================== */
.main-split-container {
  display: flex;
  flex: 1;
  width: 100%;
  height: calc(100% - 64px); /* Subtract topbar height */
  overflow: hidden;
  position: relative;
}

.app-main.split-active .main-split-container {
  flex-direction: row-reverse; /* Put reader on left, posts master list on right */
}

.app-main.split-active .main-content-scroll {
  width: 380px;
  min-width: 380px;
  max-width: 380px;
  flex: none;
  border-left: 1px solid var(--border-color); /* Separator on the left of list */
  padding: 24px;
  background-color: var(--bg-sidebar); /* Column sidebar style background */
}

/* Transform grid to single-column list when split-active */
.app-main.split-active .posts-grid {
  grid-template-columns: 1fr !important;
  gap: 16px;
}

/* Make year group header compact in split list */
.app-main.split-active .year-group-header {
  margin-top: 20px;
  margin-bottom: 4px;
  padding-bottom: 8px;
}
.app-main.split-active .year-text {
  font-size: 1.3rem;
}

/* Compact Card Styles in Split View */
.app-main.split-active .post-card {
  height: auto;
  min-height: 120px;
  padding: 16px;
  border-radius: 12px;
}

.app-main.split-active .post-card-excerpt {
  display: none; /* Hide excerpt inside the compact list for clean readability */
}

.app-main.split-active .post-card-footer {
  margin-top: 12px;
  padding-top: 8px;
}

/* Selected Card Highlight Styles */
.app-main.split-active .post-card.active {
  background-color: var(--bg-card-hover);
  border-color: var(--text-accent);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}
.app-main.split-active .post-card.active::before {
  opacity: 1;
}
.app-main.split-active .post-card.active .post-card-title {
  color: var(--text-accent);
}

/* Split Pane Reader Panel (replacing floating modal overlay) */
.app-main.split-active .reader-overlay {
  display: flex;
  position: relative; /* Flat in grid container */
  top: auto;
  left: auto;
  width: auto;
  height: 100%;
  flex: 1.6; /* Let detail grow bigger than sidebar list */
  min-width: 0; /* Prevent flex overflow and clipping from wide code blocks */
  background-color: var(--bg-modal);
  border-right: 1px solid var(--border-color); /* Separator on the right of reader */
  z-index: 5;
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  /* Premium left-aligned entry transition */
  animation: slideInLeft 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.app-main.split-active .reader-dialog {
  width: 100%;
  max-width: 100%;
  min-width: 0; /* Allow dialog to shrink safely inside flex wrapper */
  height: 100%;
  border: none;
  border-radius: 0;
  transform: none;
  box-shadow: none;
  opacity: 1;
  background-color: var(--bg-modal);
}

@keyframes slideInLeft {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Responsive Master-Detail Design under 900px */
@media (max-width: 900px) {
  .app-main.split-active .main-content-scroll {
    display: none; /* Hide master list in reading mode on smaller viewports */
  }
  .app-main.split-active .reader-overlay {
    width: 100%;
    flex: 1;
    border-right: none;
  }
}

/* On mobile, adjust margins and padding for standalone posts */
@media (max-width: 640px) {
  .standalone-header-content {
    max-width: calc(100% - 24px);
  }
  .standalone-container {
    max-width: calc(100% - 24px);
    margin: 20px auto 40px;
    padding: 30px 16px 60px;
    border-radius: 12px;
  }
}

/* ==========================================================================
   UNIFIED TECHNICAL CODE FRAMES & CLIPBOARD
   ========================================================================== */
.code-block-wrapper {
  position: relative;
  margin-bottom: 28px;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #161822;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: none;
  padding: 8px 16px;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.code-block-header .copy-code-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px 10px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
}

.code-block-header .copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.code-block-wrapper pre.bb-code {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* ==========================================================================
   POST NAVIGATION SIDEBARS (standalone article pages)
   ========================================================================== */

.post-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 820px) 220px;
  gap: 24px;
  max-width: 1316px;
  margin: 40px auto 80px;
  padding: 0 24px;
  box-sizing: border-box;
  align-items: start;
}

/* When the article is inside a post-layout, suppress its own margin/width */
.post-layout > .standalone-container {
  margin: 0;
  width: 100%;
  max-width: none;
}

.post-sidebar {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post-sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.post-sidebar-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 2px;
}

.post-nav-card {
  display: block;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s, border-color 0.15s;
}

.post-nav-card:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--text-accent);
}

.post-nav-card-dir {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-accent);
  margin-bottom: 5px;
}

.post-nav-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 5px;
}

.post-nav-card-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Collapse sidebars on viewports narrower than the 3-column layout */
@media (max-width: 1300px) {
  .post-layout {
    grid-template-columns: 1fr;
    max-width: 868px;
  }

  .post-sidebar {
    display: none;
  }

  .post-layout > .standalone-container {
    width: auto;
    max-width: 820px;
    margin: 0 auto;
  }
}

@media (max-width: 640px) {
  .post-layout {
    padding: 0 12px;
  }
}

