html, body {
  scrollbar-gutter: stable;
}

#header {
  will-change: transform;
  transform: translateZ(0);
}

::selection {
  background: #1d4ed8;
  color: #fff;
}

::-moz-selection {
  background: #1d4ed8;
  color: #fff;
}

.article-page {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #000;
  padding: 8.5rem 1.5rem 12rem;
}

.article-page > * {
  max-width: 720px;
  width: 100%;
}

.article-hero {
  position: relative;
  margin-bottom: 1rem;
}

.article-hero.no-hero-image {
  margin-bottom: 1rem;
}

.article-hero .article-options-wrapper {
  position: absolute;
  top: 0;
  right: 0;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.8125rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.article-category {
  color: #60a5fa;
  text-decoration: none;
  transition: color 0.2s ease;
}

.article-category:hover {
  color: #93c5fd;
}

.article-meta-sep {
  color: rgba(255, 255, 255, 0.25);
  font-weight: 400;
}

.article-date {
  color: rgba(255, 255, 255, 0.4);
  font-weight: 500;
}

.article-title {
  font-size: 3rem;
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: #fff;
  margin: 0 0 1rem 0;
}

.article-excerpt {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 450;
  line-height: 1.65;
  margin: -0.25rem 0 0 0;
  max-width: 620px;
}

.article-toolbar {
  padding: 0.75rem 0 1.25rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.article-toolbar .read-aloud-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0;
  margin: 0;
  border: none;
}

.article-toolbar .read-aloud-label {
  font-weight: 600;
  color: #fff;
  font-size: 0.875rem;
}

.article-toolbar .read-aloud-player-left {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.article-toolbar .read-aloud-duration {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
  font-size: 0.875rem;
}

.article-toolbar .copy-link-text {
  margin-left: auto;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.2s ease;
  font-size: 0.875rem;
}

.article-toolbar .copy-link-text:hover {
  color: #fff;
}

.article-hero-image {
  margin: 0 0 2.5rem 0;
  padding: 0;
}

.article-featured-image {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 16px;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.article-content {
  font-size: 1.125rem;
  line-height: 1.85;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 1.5rem;
}

.article-content p {
  margin-bottom: 1.25rem;
}

.article-content p:last-child {
  margin-bottom: 0;
}

.article-content strong,
.article-content b {
  color: #fff;
  font-weight: 700;
}

.article-content a strong,
.article-content a b,
.article-content strong a,
.article-content b a {
  color: #7ab8ff;
}

.article-content em,
.article-content i {
  color: rgba(255, 255, 255, 0.8);
}

.article-content a {
  color: #7ab8ff;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-weight: 600;
  transition: all 0.25s ease;
}

.article-content a:hover {
  border-bottom-color: #7ab8ff;
}

.article-content a:visited {
  color: #7ab8ff;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
  color: #fff;
  font-weight: 750;
  line-height: 1.25;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  letter-spacing: -0.015em;
  cursor: pointer;
}

.heading-anchor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0);
  cursor: pointer;
  padding: 0;
  margin: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.2s ease;
  user-select: none;
  transform: translateX(-8px);
  width: 24px;
  height: 24px;
  opacity: 0;
  will-change: transform, opacity;
}

.heading-anchor svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}

.article-content h1:hover .heading-anchor,
.article-content h2:hover .heading-anchor,
.article-content h3:hover .heading-anchor,
.article-content h4:hover .heading-anchor,
.article-content h5:hover .heading-anchor,
.article-content h6:hover .heading-anchor {
  color: rgba(255, 255, 255, 0.4);
  transform: translateX(0);
  opacity: 1;
}

.heading-anchor.copied {
  color: #4ade80 !important;
  transform: scale(1.1);
  pointer-events: none;
  opacity: 1 !important;
}

.article-content h1 { font-size: 2.25rem; }
.article-content h2 { font-size: 1.85rem; }
.article-content h3 { font-size: 1.5rem; }
.article-content h4 { font-size: 1.25rem; }

.article-content img {
  max-width: 100%;
  border-radius: 12px;
  margin: 2rem 0;
  display: block;
}

.article-content ul {
  margin: 1.25rem 0 1.5rem 0;
  padding-left: 1.5rem;
  list-style-type: disc;
}

.article-content ol {
  margin: 1.25rem 0 1.5rem 0;
  padding-left: 1.5rem;
  list-style-type: decimal;
}

.article-content li {
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
  color: rgba(255, 255, 255, 0.7);
}

.article-content li::marker {
  color: rgba(255, 255, 255, 0.3);
}

.article-content blockquote {
  margin: 2rem 0;
  padding: 0 0 0 1.5rem;
  border-left: 3px solid rgba(96, 165, 250, 0.4);
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.75;
}

.article-content code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.875em;
  color: #e2e8f0;
}

.article-content pre {
  background: rgba(255, 255, 255, 0.04);
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin: 2rem 0;
}

.article-content pre code {
  background: transparent;
  padding: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  line-height: 1.7;
}

.article-related {
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}

.article-related-header {
  margin-bottom: 2rem;
}

.article-related-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.article-related-viewall {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
  transition: color 0.2s ease;
}

.article-related-viewall:hover {
  color: #fff;
}

.article-related-viewall svg {
  transition: transform 0.2s ease;
}

.article-related-viewall:hover svg {
  transform: translateX(3px);
}

.article-related-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.article-related-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  user-select: none;
  border-radius: 14px;
}

.article-related-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  background: #000;
}

.article-related-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, #000 100%);
  opacity: 0;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  z-index: 1;
}

.article-related-card:hover .article-related-image::after {
  opacity: 1;
}

.article-related-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-related-info {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.article-related-meta {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.article-related-category {
  color: #60a5fa;
}

.article-related-dot {
  color: rgba(255, 255, 255, 0.25);
  font-weight: 400;
  font-size: 0.75rem;
}

.article-related-date {
  color: rgba(255, 255, 255, 0.35);
}

.article-related-title {
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
  color: #fff;
  transition: color 0.2s ease;
}


.article-related-excerpt {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.875rem;
  line-height: 1.55;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-options-wrapper {
  position: relative;
}

.article-options-btn {
  border-radius: 8px;
  padding: 0.5rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
}

.article-options-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.article-options-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.375rem;
  min-width: 140px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.95) translateY(-4px);
  transform-origin: top right;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.15s ease, transform 0.15s ease;
  user-select: none;
}

.article-options-menu.active {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.article-option-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  color: #d4d4d4;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.15s ease;
  font-size: 0.8125rem;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  font-weight: 500;
}

.article-option-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.article-option-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.article-option-delete {
  color: #ef4444;
}

.article-option-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

.read-aloud-play-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  color: #fff;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.read-aloud-play-btn:hover { background: rgba(255, 255, 255, 0.12); }
.read-aloud-play-btn:active { transform: scale(0.95); }

.read-aloud-play-btn svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.read-aloud-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.875rem;
}

.read-aloud-separator {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
}

.copy-link-text {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 0;
  font-size: 0.875rem;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
  font-family: inherit;
  user-select: none;
  font-weight: 500;
}

.copy-link-text:hover { color: #fff; }
.copy-link-text:active { opacity: 0.7; }
.copy-link-text svg { width: 15px; height: 15px; pointer-events: none; }
.copy-link-text.copied, .copy-link-text.copied:hover { color: #4ade80; }
.copy-link-text.copied svg { color: #4ade80; animation: copyPulse 0.3s ease; }

@keyframes copyPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.reading-highlight {
  background-color: rgba(96, 165, 250, 0.2);
  padding: 2px 0;
  border-radius: 3px;
  transition: background-color 0.2s ease;
  color: #93c5fd;
}

.article-featured-image, .article-content img {
  cursor: zoom-in;
  transition: opacity 0.3s ease;
}

.image-lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  visibility: hidden;
  transition: visibility 0.2s, background-color 0.2s ease;
  user-select: none;
}

.image-lightbox-overlay.active {
  background: rgb(0, 0, 0);
  visibility: visible;
}

.image-lightbox-img {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate3d(-50%, -50%, 0);
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  z-index: 10001;
  cursor: zoom-out;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  will-change: transform, opacity;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
  transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1), 
              opacity 0.25s ease,
              border-radius 0.25s ease;
  border-radius: 12px;
  user-select: none;
  -webkit-user-drag: none;
}

.image-lightbox-img.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.db-error-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.db-error-content {
  text-align: center;
  padding: 6rem 2rem;
  max-width: 500px;
  margin: 0 auto;
}

.db-error-icon {
  font-size: 3.5rem !important;
  color: #ef4444;
  margin-bottom: 1.5rem;
  display: block;
  user-select: none;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 48;
}

.db-error-title {
  color: #fff;
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.db-error-message {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9375rem;
  line-height: 1.7;
  margin-bottom: 2rem;
}

.db-error-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  text-decoration: none;
  padding: 0.625rem 1.25rem;
  background: rgba(255, 255, 255, 0.08);
  user-select: none;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.875rem;
  transition: background-color 0.2s;
}

.db-error-back-link:hover {
  background-color: rgba(255, 255, 255, 0.12);
}

.db-error-back-link .material-symbols-rounded {
  font-size: 1.125rem;
}

@media (max-width: 768px) {
  .article-page {
    padding: 6.5rem 1.25rem 5rem;
  }

  .article-topbar {
    margin-bottom: 2rem;
  }

  .article-excerpt {
    font-size: 1.05rem;
  }

  .article-meta {
    margin-bottom: 0.85rem;
  }

  .article-title {
    font-size: 2rem;
    margin-bottom: 0.85rem;
  }

  .article-content {
    font-size: 1.0625rem;
    line-height: 1.8;
  }

  .article-featured-image {
    border-radius: 12px;
  }

  .article-related-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .article-hero-image {
    margin-bottom: 2rem;
  }
}

@media (max-width: 480px) {
  .article-page {
    padding: 5.75rem 1rem 4rem;
  }

  .article-title {
    font-size: 1.75rem;
    margin-bottom: 0.65rem;
  }

  .article-excerpt {
    font-size: 1rem;
  }

  .article-meta {
    margin-bottom: 0.65rem;
    font-size: 0.75rem;
  }
  .article-related-header h2 {
    font-size: 1rem;
  }
}