* { box-sizing: border-box; }

:root {
  --bg: #ffffff;
  --text: #111827;
  --border-color: #e6e9ee;
  --text-muted: #6b7280;
  --accent-color: #0a84ff;
  --shadow: 0 2px 4px rgba(0,0,0,0.12);
  --border-radius: 10px;
  --gap: 0.9rem;
  --container-padding: 0.75rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --text: #e6edf3;
    --border-color: #24303a;
    --text-muted: #9aa4ae;
    --accent-color: #3aa0ff;
    --shadow: 0 2px 4px rgba(0,0,0,0.22);
  }
}

/* Base layout */
html, body {
  height: 100%;
}
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.site-main {
  flex: 1;
}
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--container-padding);
}

/* Ensure responsive container padding */
@media (max-width: 1024px) {
  .container {
    padding: max(0.5rem, 5vw);
  }
}

/* Links */
a {
  color: var(--accent-color);
  text-decoration: none;
}
a:hover {
  opacity: 0.9;
}

/* Header */
header {
  background: var(--bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 0;
}
header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.15rem;
}
.logo img {
  width: 44px;
  height: 44px;
  border-radius: calc(var(--border-radius) - 4px);
}
.nav-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.25rem;
}
.nav-menu a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.nav-menu a:hover {
  color: var(--accent-color);
}
#nav-toggle {
  display: none;
}
.hamburger {
  display: none;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  padding: 0.25rem;
}
.hamburger span {
  display: block;
  width: 26px;
  height: 3px;
  background: var(--text);
  border-radius: 3px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Articles Grid */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--gap);
  margin-top: 0.5rem;
}
@media (min-width: 768px) {
  .articles-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 1024px) {
  .articles-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Cards */
.card {
  padding: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255,255,255,0.01), transparent);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 18px rgba(10, 36, 99, 0.08);
}
.card-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: calc(var(--border-radius) - 2px);
  margin-bottom: 0.75rem;
}

/* Featured Image */
.featured-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem auto;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

/* Article Meta */
.article-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.95rem;
}
.article-meta .author {
  font-weight: 600;
}

/* Article Content Images */
[itemprop="articleBody"] img {
  max-width: 45%;
  height: auto;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin: 0.5rem 1.5rem 1rem 0;
}
[itemprop="articleBody"] img:nth-of-type(odd) {
  float: left;
  margin: 0.5rem 1.5rem 1rem 0;
}
[itemprop="articleBody"] img:nth-of-type(even) {
  float: right;
  margin: 0.5rem 0 1rem 1.5rem;
}
[itemprop="articleBody"]::after {
  content: "";
  display: table;
  clear: both;
}

/* Article Tables */
[itemprop="articleBody"] table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}
[itemprop="articleBody"] table thead,
[itemprop="articleBody"] table tbody,
[itemprop="articleBody"] table tfoot {
  display: table;
  width: 100%;
  table-layout: fixed;
}
[itemprop="articleBody"] table thead {
  background: var(--accent-color);
  color: #fff;
}
[itemprop="articleBody"] table th,
[itemprop="articleBody"] table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid var(--border-color);
  white-space: normal;
  word-break: break-word;
}
[itemprop="articleBody"] table th {
  font-weight: 700;
  text-align: center;
}
[itemprop="articleBody"] table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}
@media (prefers-color-scheme: dark) {
  [itemprop="articleBody"] table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
  }
}
[itemprop="articleBody"] table tbody tr:hover {
  background: rgba(10, 132, 255, 0.06);
}
@media (max-width: 768px) {
  [itemprop="articleBody"] table {
    font-size: 0.85rem;
  }
  [itemprop="articleBody"] table th,
  [itemprop="articleBody"] table td {
    padding: 0.5rem;
  }
}

/* Breadcrumb */
.breadcrumb {
  list-style: none;
  display: flex;
  gap: 0.5rem;
  padding: 0;
}
.breadcrumb li:last-child {
  font-weight: 700;
}

/* Search Form */
.search-form {
  max-width: 600px;
  margin: 0 auto 1.25rem;
  display: flex;
  gap: 0.5rem;
}
.search-form input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg);
  color: var(--text);
}
.search-form input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(10,132,255,0.06);
}
.search-form button {
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: opacity 0.25s ease, transform 0.15s ease;
}
.search-form button:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 40;
  }
  .nav-menu ul {
    flex-direction: column;
    padding: 1rem;
  }
  #nav-toggle:checked ~ .nav-menu {
    display: block;
  }
  [itemprop="articleBody"] img {
    float: none !important;
    max-width: 100%;
    margin: 1rem 0 !important;
  }
  .search-form {
    flex-direction: column;
  }
  .search-form button {
    width: 100%;
  }
}
@media (max-width: 480px) {
  .article-meta {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
}