:root {
  --ink: #1C1A17;
  --muted: #6B6459;
  --accent: #2563EB;
  --accent-dark: #0B1E3D;
  --bg: #FFFFFF;
  --card-bg: #FFFFFF;
  --border: #E7E2D9;
  --tile-bg: #F3F0E9;
  --hero-bg: #FAF8F3;
  --hero-gradient-end: #142850;
  --shadow: rgba(28, 26, 23, 0.08);
  --max-width: 1200px;
  --font-headline: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  color-scheme: light;

  /* One color per category, consistent identity across both themes */
  --cat-ai-ml-news: #2563EB;
  --cat-ai-ml-news-tile: #EFF4FF;
  --cat-ai-tools-saas: #B45309;
  --cat-ai-tools-saas-tile: #FBF0E1;
  --cat-opinion: #15803D;
  --cat-opinion-tile: #EEF6EE;
  --cat-tech-news: #7C3AED;
  --cat-tech-news-tile: #F3EEFE;
}

[data-theme="dark"] {
  --ink: #EDE9E1;
  --muted: #9C9A88;
  --accent: #60A5FA;
  --accent-dark: #071019;
  --bg: #14120F;
  --card-bg: #1B1815;
  --border: #322D26;
  --tile-bg: #211E19;
  --hero-bg: #1A1712;
  --hero-gradient-end: #1E3A5F;
  --shadow: rgba(0, 0, 0, 0.4);
  color-scheme: dark;

  /* Same category identities, brightened for dark-background contrast */
  --cat-ai-ml-news: #60A5FA;
  --cat-ai-ml-news-tile: #132235;
  --cat-ai-tools-saas: #FBBF24;
  --cat-ai-tools-saas-tile: #2A2013;
  --cat-opinion: #4ADE80;
  --cat-opinion-tile: #10241A;
  --cat-tech-news: #A78BFA;
  --cat-tech-news-tile: #241C36;
}

body { transition: background-color 0.2s ease, color 0.2s ease; }
* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  margin: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { text-decoration: underline; }

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Header */
.site-header-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
}
.site-header-wrap.scrolled { box-shadow: 0 2px 12px var(--shadow); }
.site-header {
  position: relative;
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
}
.site-header .logo {
  font-family: var(--font-headline);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.header-nav-group { display: flex; align-items: center; gap: 32px; }
.site-header nav { display: flex; gap: 32px; }
.site-header nav a {
  color: var(--ink);
  font-weight: 500;
  font-size: 15px;
  padding: 8px 0;
}
.site-header nav a:hover { color: var(--accent); text-decoration: none; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  padding: 8px;
}

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

.search-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}
.search-toggle:hover { background: var(--tile-bg); border-color: var(--muted); }
.search-toggle svg { width: 16px; height: 16px; }

.search-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 12px 24px var(--shadow);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  z-index: 30;
}
.search-panel.open { max-height: 420px; opacity: 1; overflow-y: auto; }
.search-panel-inner { max-width: var(--max-width); margin: 0 auto; padding: 20px 32px; }
.search-input {
  width: 100%;
  font-size: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--ink);
  font-family: inherit;
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-results { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--ink);
}
.search-result:hover { background: var(--tile-bg); text-decoration: none; }
.search-result .sr-title { font-weight: 600; font-size: 15px; }
.search-result .sr-excerpt { color: var(--muted); font-size: 13px; margin-top: 2px; }
.search-empty { color: var(--muted); font-size: 14px; padding: 10px 12px; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--tile-bg); border-color: var(--muted); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* Hero slider — auto-advances through the latest 5 articles */
.hero-slider {
  position: relative;
  max-width: var(--max-width);
  margin: 32px auto;
  padding: 0 32px;
  animation: fade-up 0.5s ease both;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.hero-slides {
  position: relative;
  min-height: 380px;
  background: var(--hero-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: height 0.3s ease;
}
.hero-slide {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.hero-slide.active { opacity: 1; visibility: visible; pointer-events: auto; }
.hero-text { padding: 48px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.hero-visual {
  background: linear-gradient(135deg, var(--accent-dark), var(--hero-gradient-end));
  min-height: 380px;
}
.hero-visual.cat-ai-ml-news { background: linear-gradient(135deg, var(--accent-dark), var(--cat-ai-ml-news)); }
.hero-visual.cat-ai-tools-saas { background: linear-gradient(160deg, var(--accent-dark) 20%, var(--cat-ai-tools-saas)); }
.hero-visual.cat-opinion { background: linear-gradient(135deg, var(--accent-dark), var(--cat-opinion)); }
.hero-visual.cat-tech-news { background: linear-gradient(135deg, var(--accent-dark), var(--cat-tech-news)); }
/* object-fit:cover crops to fill the grid cell regardless of the image's own
   aspect ratio. Height must be explicit here: the <img> now carries width/
   height attributes (added for layout-shift prevention), and without an
   explicit CSS height, browsers derive an aspect-ratio from those attributes
   and size the element to the image's own proportions instead of stretching
   to fill its grid cell. */
.hero-visual.hero-image { display: block; object-fit: cover; width: 100%; height: 100%; }
.hero-slide .image-credit { position: absolute; bottom: 8px; right: 12px; margin: 0; padding: 0; max-width: none; }

.hero-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.hero-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: none;
  background: var(--border);
  cursor: pointer;
  padding: 0;
  transition: background 0.2s ease, transform 0.2s ease;
}
.hero-dot:hover { transform: scale(1.2); }
.hero-dot.active { background: var(--accent); }

/* Thin tabs on the exterior edge of the slider, not overlapping the
   content inside — sit in the slider's own side padding, not on top of
   the title/text like a floating overlay button would. */
.hero-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 20px;
  height: 64px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.9;
  padding: 0;
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease, width 0.2s ease;
}
.hero-arrow:hover { opacity: 1; background: var(--tile-bg); color: var(--ink); width: 24px; }
.hero-arrow svg { width: 14px; height: 14px; }
.hero-arrow-prev { left: 4px; border-radius: 6px 0 0 6px; border-right: none; }
.hero-arrow-next { right: 4px; border-radius: 0 6px 6px 0; border-left: none; }
@media (max-width: 640px) {
  .hero-arrow { height: 48px; }
  .hero-arrow-prev { left: 0; }
  .hero-arrow-next { right: 0; }
}

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; min-height: 20px; }
.tag {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag.cat-ai-ml-news { color: var(--cat-ai-ml-news); }
.tag.cat-ai-tools-saas { color: var(--cat-ai-tools-saas); }
.tag.cat-opinion { color: var(--cat-opinion); }
.tag.cat-tech-news { color: var(--cat-tech-news); }
.tag-row .tag:not(:last-child)::after { content: "\00b7"; margin-left: 6px; color: var(--muted); font-weight: 400; }

.hero-text h1 {
  font-family: var(--font-headline);
  font-size: 36px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 16px 0;
  /* No line-clamp here on purpose — the title must always show in full.
     The slider container height is set dynamically by JS to match
     whichever slide is active, so a longer title just makes that slide
     (briefly) taller instead of getting cut off. */
}
.hero-text p {
  color: var(--muted);
  font-size: 16px;
  margin: 0 0 20px 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.read-more { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.read-more .arrow { display: inline-block; transition: transform 0.2s ease; }
.read-more:hover .arrow { transform: translateX(4px); }

/* Article grid */
.grid {
  max-width: var(--max-width);
  margin: 40px auto;
  padding: 0 32px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  align-items: stretch;
}
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  opacity: 0;
  transform: translateY(12px);
}
.card.in-view {
  opacity: 1;
  transform: translateY(0);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px var(--shadow);
  border-color: var(--muted);
}
.card h3 a { color: var(--ink); }
.card:hover h3 a { color: var(--accent); }
.card-image {
  width: calc(100% + 40px);
  margin: -20px -20px 14px -20px;
  height: 160px;
  object-fit: cover;
  border-radius: 6px 6px 0 0;
}

/* Embedded images within article bodies */
.article-page img { max-width: 100%; height: auto; border-radius: 6px; margin: 24px 0; display: block; }
.article-page figure { margin: 24px 0; }
.article-page figcaption { color: var(--muted); font-size: 13px; margin-top: 8px; text-align: center; }

/* Image attribution — required for CC-licensed (non-CC0) sourced photos */
.image-credit {
  max-width: var(--max-width);
  margin: 8px auto 0;
  padding: 0 32px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.image-credit a { color: var(--muted); }
.article-page .image-credit { padding: 0; margin-top: -12px; margin-bottom: 24px; }

.card h3 {
  font-family: var(--font-headline);
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 8px 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card p {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 12px 0;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .date { color: var(--muted); font-size: 13px; }

/* Article page */
.article-page { max-width: 760px; margin: 40px auto; padding: 0 32px; }
.article-cover { width: 100%; border-radius: 6px; margin-bottom: 0; display: block; }
.article-page h1 {
  font-family: var(--font-headline);
  font-size: 38px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.article-meta { color: var(--muted); font-size: 14px; margin-bottom: 32px; }
.article-page table { border-collapse: collapse; width: 100%; margin: 24px 0; }
.article-page th, .article-page td { border: 1px solid var(--border); padding: 10px 14px; text-align: left; font-size: 14px; }
.article-page th { background: var(--tile-bg); }
.article-page p { font-size: 17px; margin-bottom: 20px; }
.article-page h2 { font-family: var(--font-headline); font-size: 24px; margin-top: 36px; }

.breadcrumb {
  max-width: 760px;
  margin: 24px auto 0;
  padding: 0 32px;
  font-size: 13px;
  color: var(--muted);
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span[aria-current] { color: var(--ink); }

.related-articles {
  max-width: 760px;
  margin: 8px auto 56px;
  padding: 24px 32px 0;
  border-top: 1px solid var(--border);
}
.related-articles h2 {
  font-family: var(--font-headline);
  font-size: 20px;
  margin-bottom: 14px;
}
.related-articles ul { list-style: none; margin: 0; padding: 0; }
.related-articles li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.related-articles li:last-child { border-bottom: none; }
.related-articles a { color: var(--ink); font-weight: 600; }
.related-articles a:hover { color: var(--accent); }
.related-articles .date { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* Simple pages (About, Privacy, Contact) */
.simple-page { max-width: 720px; margin: 48px auto; padding: 0 32px; }
.simple-page h1 { font-family: var(--font-headline); font-size: 32px; font-weight: 700; }
.simple-page p { font-size: 16px; color: var(--muted); }
.simple-page.section-header { max-width: var(--max-width); }
.empty-state { color: var(--muted); padding: 40px 0; }

/* Footer */
.site-footer {
  max-width: var(--max-width);
  margin: 60px auto 0;
  padding: 24px 32px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
}
.site-footer a { color: var(--muted); }

/* ============ RESPONSIVE ============ */

/* Tablet */
@media (max-width: 900px) {
  .hero-slide { grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .hero-slides { min-height: 560px; }
  .hero-visual { min-height: 220px; order: -1; }
  .hero-text { padding: 32px; }
  .hero-text h1 { font-size: 28px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile */
@media (max-width: 640px) {
  .site-header { padding: 18px 20px; }
  .site-header .logo { font-size: 20px; }
  .nav-toggle { display: block; }
  .site-header nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg);
    flex-direction: column;
    gap: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 16px var(--shadow);
    z-index: 20;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease;
    display: flex;
  }
  .site-header nav.open { max-height: 320px; opacity: 1; }
  .site-header nav a { padding: 16px 24px; border-top: 1px solid var(--border); font-size: 16px; }
  .site-header { position: relative; }

  .hero-slider { margin: 20px auto; padding: 0 20px; }
  .hero-slides { min-height: 440px; }
  .hero-text { padding: 24px; }
  .hero-text h1 { font-size: 26px; }
  .hero-text p { font-size: 15px; }
  .hero-visual { min-height: 180px; }

  .grid { grid-template-columns: 1fr; padding: 0 20px; gap: 16px; margin: 24px auto; }
  .card { padding: 16px; }

  .article-page, .simple-page { padding: 0 20px; }
  .article-page h1 { font-size: 27px; }
  .article-page p { font-size: 16px; }

  .site-footer { flex-direction: column; gap: 12px; padding: 20px; text-align: center; }
}

/* Baseline touch-target sizing across breakpoints */
a, button { min-height: 24px; }
