:root {
  /* Default (neutral blue-gray) */
  --accent-color: #2563eb;
  --bg-color: #ffffff;
  --text-color: #0f172a;
  --muted-color: #6b7280;
  --border-color: #e6edf8;
  --border-radius: 6px;
  --shadow: 0 6px 18px rgba(15,23,42,0.06);
  --container-max: 1100px;
  --transition: 200ms ease;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0b1220;
    --text-color: #e6eef8;
    --muted-color: #9aa6b2;
    --border-color: rgba(255,255,255,0.06);
    --shadow: 0 6px 18px rgba(2,6,23,0.6);
  }
}

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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: var(--text-color);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--bg-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  transition: background var(--transition), color var(--transition);
}

/* Layout containers */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
header {
  background: var(--bg-color);
  box-shadow: 0 2px 4px rgba(2,6,23,0.06);
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--border-color);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 1rem;
}

/* Logo */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-color);
  font-weight: 600;
}
.logo img {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius);
  object-fit: cover;
  display: block;
  box-shadow: var(--shadow);
}

/* Main nav - desktop */
.main-nav ul {
  list-style: none;
  display: flex;
  gap: 1.25rem;
  align-items: center;
}
.main-nav a {
  color: var(--text-color);
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: calc(var(--border-radius) - 2px);
  transition: background var(--transition), color var(--transition);
  font-weight: 500;
}
.main-nav a:hover {
  background: rgba(37,99,235,0.08);
}

/* Hamburger (checkbox hack) */
.nav-toggle {
  display: none;
}
.hamburger {
  display: none;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-color);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
@media (max-width: 767px) {
  .hamburger { display: flex; }
  .main-nav {
    position: absolute;
    right: 1rem;
    top: 64px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: calc(var(--border-radius) - 2px);
    box-shadow: var(--shadow);
    padding: 0.5rem;
    display: none;
    min-width: 160px;
  }
  .main-nav ul {
    flex-direction: column;
    gap: 0;
  }
  .main-nav a {
    display: block;
    padding: 0.5rem 0.75rem;
  }

  /* When checked, show menu */
  .nav-toggle:checked + .hamburger + .main-nav {
    display: block;
  }

  /* Ensure clickable area is limited */
  .hamburger {
    max-width: 24px;
    max-height: 24px;
  }
}

/* Main area */
main {
  flex: 1 0 auto;
  width: 100%;
  padding-top: 3rem;
  padding-bottom: 3rem;
}

/* Footer */
footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: 2rem 0;
  text-align: center;
  border-top: 1px solid var(--border-color);
  background: transparent;
}

/* Articles grid */
.articles-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 768px) {
  .articles-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }
}

/* Cards */
.card {
  background: linear-gradient(180deg, rgba(0,0,0,0.01), transparent);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: var(--border-radius);
  transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: calc(var(--border-radius) - 2px);
  display: block;
  margin-bottom: 0.75rem;
}

/* Card body in index list */
.card .card-body h2 {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
}
.card .card-body p {
  color: var(--muted-color);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

/* Article page specific */
.article {
  max-width: 880px;
  margin: 0 auto;
  padding: 1rem 0;
}
.featured-image {
  width: 100% !important;
  max-width: 100% !important;
  height: auto;
  margin-bottom: 2rem;
  border-radius: var(--border-radius);
}

/* Article content and alternating images behavior */
.article-content {
  max-width: 100% !important;
  overflow-x: hidden;
  line-height: 1.7;
  font-size: 1rem;
  color: var(--text-color);
}

/* Tables inside article */
.article-content table {
  display: block;
  width: 100% !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5rem 0;
  border-collapse: collapse;
}

/* All media responsiveness */
.article-content img,
.article-content iframe,
.article-content video {
  max-width: 100% !important;
  height: auto;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

/* Desktop alternating images with max 450px */
@media (min-width: 768px) {
  .article-content img {
    max-width: 450px !important;
    margin: 1rem;
  }
  .article-content img:nth-of-type(odd) {
    float: left;
    margin-left: 0;
    margin-right: 2rem;
  }
  .article-content img:nth-of-type(even) {
    float: right;
    margin-right: 0;
    margin-left: 2rem;
  }
}

/* Mobile centered images */
@media (max-width: 767px) {
  .article-content img {
    float: none;
    max-width: 100% !important;
    margin: 1.5rem auto;
    display: block;
  }
}

/* Clear floats */
.article-content::after {
  content: "";
  display: table;
  clear: both;
}

/* Ensure text flows properly */
.article-content p,
.article-content h2,
.article-content h3,
.article-content ul,
.article-content ol {
  overflow-y: auto;
}

/* Breadcrumbs */
.breadcrumbs ul {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  font-size: 0.9rem;
  color: var(--muted-color);
  margin: 0.75rem 0 1.25rem 0;
}
.breadcrumbs a {
  color: var(--muted-color);
  text-decoration: none;
}

/* Recommended section */
.recommended {
  margin-top: 3rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}
.recommended h2 {
  margin-bottom: 1rem;
}

/* Search form styles */
#search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
#search-input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: calc(var(--border-radius) - 2px);
  background: transparent;
  color: var(--text-color);
}
#search-form button {
  padding: 0.6rem 0.9rem;
  border: none;
  background: var(--accent-color);
  color: #fff;
  border-radius: calc(var(--border-radius) - 2px);
  cursor: pointer;
}
#search-form button:hover {
  opacity: 0.95;
}

/* Not-found styles */
.not-found {
  text-align: center;
  padding: 3rem 1rem;
}

/* Small helpers */
.no-results {
  color: var(--muted-color);
  padding: 1rem 0;
}

/* Accessibility focus */
a:focus, button:focus, input:focus {
  outline: 3px solid rgba(37,99,235,0.12);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Responsive adjustments */
@media (min-width: 1200px) {
  :root { --container-max: 1200px; }
}