:root {
  color-scheme: light dark;
  --bg: #fbfdf7;
  --surface: #fbfdf7;
  --surface-dim: #dbe5dc;
  --surface-bright: #fbfdf7;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f2f6ef;
  --surface-container: #edf2ea;
  --surface-container-high: #e7ece4;
  --surface-container-highest: #e1e7de;
  --on-surface: #191d1a;
  --on-surface-variant: #424940;
  --outline: #727970;
  --outline-variant: #c2c9bf;
  --primary: #006b5f;
  --on-primary: #ffffff;
  --primary-container: #9ef2e3;
  --on-primary-container: #00201c;
  --secondary: #4a635e;
  --on-secondary: #ffffff;
  --secondary-container: #cce8e0;
  --on-secondary-container: #06201b;
  --tertiary: #456179;
  --tertiary-container: #cce5ff;
  --error: #ba1a1a;
  --focus: rgba(0, 107, 95, .24);
  --shadow-color: 30, 42, 36;
  --elevation-1: 0 1px 2px rgba(var(--shadow-color), .18), 0 1px 3px 1px rgba(var(--shadow-color), .10);
  --elevation-2: 0 2px 6px 2px rgba(var(--shadow-color), .12), 0 1px 2px rgba(var(--shadow-color), .18);
  --elevation-3: 0 4px 8px 3px rgba(var(--shadow-color), .13), 0 1px 3px rgba(var(--shadow-color), .18);
  --shape-xs: 8px;
  --shape-sm: 12px;
  --shape-md: 16px;
  --shape-lg: 24px;
  --shape-xl: 28px;
  --shape-full: 999px;
  --content: min(1120px, calc(100% - 32px));
  --state-hover: color-mix(in srgb, var(--primary) 8%, transparent);
  --state-pressed: color-mix(in srgb, var(--primary) 12%, transparent);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101512;
  --surface: #101512;
  --surface-dim: #101512;
  --surface-bright: #363b37;
  --surface-container-lowest: #0b100d;
  --surface-container-low: #191d1a;
  --surface-container: #1d211e;
  --surface-container-high: #272b28;
  --surface-container-highest: #323633;
  --on-surface: #e1e7df;
  --on-surface-variant: #c2c9bf;
  --outline: #8c9389;
  --outline-variant: #424940;
  --primary: #82d5c7;
  --on-primary: #003731;
  --primary-container: #005047;
  --on-primary-container: #9ef2e3;
  --secondary: #b0ccc4;
  --on-secondary: #1c3530;
  --secondary-container: #334b46;
  --on-secondary-container: #cce8e0;
  --tertiary: #adc9e5;
  --tertiary-container: #2d4960;
  --error: #ffb4ab;
  --focus: rgba(130, 213, 199, .28);
  --shadow-color: 0, 0, 0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101512;
    --surface: #101512;
    --surface-dim: #101512;
    --surface-bright: #363b37;
    --surface-container-lowest: #0b100d;
    --surface-container-low: #191d1a;
    --surface-container: #1d211e;
    --surface-container-high: #272b28;
    --surface-container-highest: #323633;
    --on-surface: #e1e7df;
    --on-surface-variant: #c2c9bf;
    --outline: #8c9389;
    --outline-variant: #424940;
    --primary: #82d5c7;
    --on-primary: #003731;
    --primary-container: #005047;
    --on-primary-container: #9ef2e3;
    --secondary: #b0ccc4;
    --on-secondary: #1c3530;
    --secondary-container: #334b46;
    --on-secondary-container: #cce8e0;
    --tertiary: #adc9e5;
    --tertiary-container: #2d4960;
    --error: #ffb4ab;
    --focus: rgba(130, 213, 199, .28);
    --shadow-color: 0, 0, 0;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--on-surface);
  background:
    radial-gradient(circle at 8% -8%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 28rem),
    radial-gradient(circle at 100% 0, color-mix(in srgb, var(--tertiary) 12%, transparent), transparent 26rem),
    var(--bg);
  font: 400 16px/1.65 "Noto Sans SC", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  text-rendering: optimizeLegibility;
  transition: background-color .22s ease, color .22s ease;
}

a {
  color: var(--primary);
  text-decoration-color: color-mix(in srgb, var(--primary) 45%, transparent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration-color: currentColor; }

.shell { width: var(--content); margin: 0 auto; padding: 18px 0 48px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  margin: 0 0 18px;
  padding: 8px 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  color: var(--on-surface);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -.01em;
}
.brand::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--tertiary));
  box-shadow: var(--elevation-1);
}
.topnav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--shape-full);
  color: var(--on-surface-variant);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.topnav a:hover { color: var(--on-surface); background: var(--state-hover); }

.theme-toggle,
.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-height: 40px;
  padding: 2px;
  border: 1px solid var(--outline);
  border-radius: var(--shape-full);
  background: transparent;
}
.theme-toggle button,
.view-switch button,
.deck-nav button {
  appearance: none;
  border: 0;
  min-height: 34px;
  border-radius: var(--shape-full);
  padding: 0 13px;
  color: var(--on-surface-variant);
  background: transparent;
  font: 700 13px/1 "Noto Sans SC", "PingFang SC", sans-serif;
  cursor: pointer;
}
.theme-toggle button:hover,
.view-switch button:hover,
.deck-nav button:hover { background: var(--state-hover); color: var(--on-surface); }
.theme-toggle button[aria-pressed="true"],
.view-switch button[aria-pressed="true"] {
  color: var(--on-secondary-container);
  background: var(--secondary-container);
}

.hero {
  display: grid;
  gap: 18px;
  padding: clamp(28px, 6vw, 64px);
  border-radius: var(--shape-xl);
  background: linear-gradient(145deg, var(--primary-container), color-mix(in srgb, var(--surface-container-low) 76%, var(--primary-container)));
  color: var(--on-primary-container);
  box-shadow: var(--elevation-1);
}
.hero.compact { padding: clamp(24px, 4vw, 42px); }
.kicker {
  margin: 0;
  color: color-mix(in srgb, var(--on-primary-container) 74%, transparent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  max-width: 920px;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1.04;
  font-weight: 800;
  letter-spacing: -.045em;
}
h2 {
  margin: 0;
  font-size: clamp(21px, 3vw, 30px);
  line-height: 1.18;
  font-weight: 760;
  letter-spacing: -.025em;
}
h3 { margin: 0; font-size: 18px; line-height: 1.3; }
p { margin: 8px 0 0; line-height: 1.72; font-size: 16px; }
.hero p,
.hero-subtitle {
  max-width: 720px;
  margin: 0;
  color: color-mix(in srgb, var(--on-primary-container) 78%, transparent);
  font-size: clamp(16px, 2vw, 18px);
}
.meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--on-surface-variant); font-size: 14px; }
.hero .meta { color: color-mix(in srgb, var(--on-primary-container) 72%, transparent); }
.pill,
.facts span,
.badge-read {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: var(--shape-full);
  padding: 0 10px;
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
  font-size: 13px;
  font-weight: 650;
}
.hero .pill { background: color-mix(in srgb, var(--on-primary-container) 10%, transparent); color: var(--on-primary-container); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2px; }
.button,
.button-tonal,
.button-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 20px;
  border-radius: var(--shape-full);
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
}
.button { color: var(--on-primary); background: var(--primary); box-shadow: var(--elevation-1); }
.button:hover { color: var(--on-primary); box-shadow: var(--elevation-2); }
.button-tonal { color: var(--on-secondary-container); background: var(--secondary-container); }
.button-outline { color: var(--primary); border: 1px solid var(--outline); background: transparent; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 34px 0 14px;
  color: var(--on-surface);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.section-title::before {
  content: "";
  width: 6px;
  height: 22px;
  border-radius: var(--shape-full);
  background: var(--primary);
}

.news-grid,
.feature-grid { display: grid; gap: 16px; }
.feature-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card,
.project-card {
  position: relative;
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-lg);
  padding: clamp(18px, 3vw, 24px);
  background: var(--surface-container-low);
  box-shadow: none;
  overflow: hidden;
}
.card:hover,
.project-card:hover {
  background: var(--surface-container);
  box-shadow: var(--elevation-1);
}
.card-head,
.project-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.card-head h2,
.project-head h2 { min-width: 0; }
.card-head h2 a,
.project-head h2 a {
  color: var(--on-surface);
  text-decoration: none;
}
.card-head h2 a:hover,
.project-head h2 a:hover { color: var(--primary); text-decoration: underline; }
.num {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--shape-full);
  color: var(--on-secondary-container);
  background: var(--secondary-container);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
}
.facts { margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.label {
  margin-top: 18px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .02em;
}
code {
  border-radius: var(--shape-xs);
  padding: 2px 6px;
  background: var(--surface-container-highest);
  color: var(--primary);
}

.card-figure {
  margin: 14px 0 0;
  border-radius: var(--shape-md);
  overflow: hidden;
  background: var(--surface-container-high);
}
.card-figure img { display: block; width: 100%; height: auto; object-fit: cover; }
.card-figure figcaption { padding: 8px 12px; color: var(--on-surface-variant); font-size: 12px; }
.video-link,
.recent-source-link a { font-weight: 760; }

.project-picks {
  margin-top: 28px;
  padding: clamp(18px, 3vw, 28px);
  border-radius: var(--shape-xl);
  background: var(--surface-container);
  box-shadow: var(--elevation-1);
}
.project-picks-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.project-kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.project-picks-head h2 { margin-top: 4px; }
.project-picks-head p {
  max-width: 520px;
  margin: 0;
  color: var(--on-surface-variant);
  font-size: 14px;
}
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.project-card { background: var(--surface-container-lowest); }
.project-source {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 13px;
  border-radius: var(--shape-full);
  color: var(--primary);
  border: 1px solid var(--outline);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.project-source:hover { background: var(--state-hover); }
.project-body { margin-top: 4px; }

.news-view-head {
  position: sticky;
  top: 72px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 28px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-lg);
  background: color-mix(in srgb, var(--surface-container-low) 88%, transparent);
  backdrop-filter: blur(16px);
}
.news-view-head .section-title { margin: 0; font-size: 18px; }
.news-view-head .section-title::before { height: 18px; }
.view-hint { margin: 4px 0 0; color: var(--on-surface-variant); font-size: 13px; line-height: 1.45; }
.deck-nav {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--on-surface-variant);
  font-weight: 800;
}
.deck-nav button { border: 1px solid var(--outline-variant); background: var(--surface-container-low); }
.deck-nav button:disabled { opacity: .42; cursor: default; }

.event-timeline {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.event-timeline li {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: var(--shape-md);
  background: var(--surface-container);
}
.event-timeline li.current-event { outline: 2px solid color-mix(in srgb, var(--primary) 36%, transparent); }
.event-timeline time {
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}
.event-timeline a { color: var(--on-surface); font-weight: 800; text-decoration: none; }
.event-timeline p { margin: 4px 0 0; color: var(--on-surface-variant); font-size: 13px; line-height: 1.45; }

.reading-progress { position: fixed; top: 0; left: 0; width: 100%; height: 3px; z-index: 999; pointer-events: none; }
.reading-progress-fill { height: 100%; width: 0; background: var(--primary); transition: width .12s linear; }
.reading-progress-fill.reading-progress-done { background: var(--secondary); }
.continue-hint {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 998;
  cursor: pointer;
  color: var(--on-secondary-container);
  background: var(--secondary-container);
  border-radius: var(--shape-full);
  padding: 8px 16px;
  box-shadow: var(--elevation-2);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.continue-section { margin: 24px 0 0; }
.continue-progress { display: inline-block; margin-left: 6px; color: var(--primary); font-weight: 800; }
.badge-read.status-unread { color: var(--error); background: color-mix(in srgb, var(--error) 12%, transparent); }
.badge-read.status-reading { color: var(--on-tertiary-container, var(--on-surface)); background: var(--tertiary-container); }
.badge-read.status-read { color: var(--on-secondary-container); background: var(--secondary-container); }
.card.card-read::after { content: none; }

.footer { margin: 34px 0 0; color: var(--on-surface-variant); text-align: center; font-size: 14px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

body.news-view-deck { overflow-x: hidden; }
body.news-view-deck .reading-progress { display: none; }
body.news-view-deck .project-picks,
body.news-view-deck .continue-section,
body.news-view-deck .continue-section-title,
body.news-view-deck .hero { display: none; }
body.news-view-deck .shell { width: min(780px, 100% - 20px); min-height: 100dvh; padding-top: 8px; }
body.news-view-deck .topbar { min-height: 50px; margin-bottom: 8px; }
body.news-view-deck .topnav,
body.news-view-deck .theme-toggle { display: none; }
body.news-view-deck .news-view-head { top: 58px; margin: 0 0 10px; }
body.news-view-deck .view-hint { display: none; }
body.news-view-deck .deck-nav { display: flex; }
body.news-view-deck .home-news-grid {
  position: relative;
  display: block;
  min-height: clamp(520px, calc(100dvh - 132px), 780px);
  overflow: visible;
  touch-action: pan-y pinch-zoom;
}
body.news-view-deck .home-news-grid::before,
body.news-view-deck .home-news-grid::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  height: 40px;
  border-radius: 0 0 var(--shape-lg) var(--shape-lg);
  background: var(--surface-container-high);
  box-shadow: var(--elevation-1);
  pointer-events: none;
}
body.news-view-deck .home-news-grid::before { bottom: -10px; transform: scale(.95); opacity: .58; }
body.news-view-deck .home-news-grid::after { bottom: -22px; left: 36px; right: 36px; transform: scale(.9); opacity: .34; }
body.news-view-deck .home-news-grid .card {
  display: none;
  border-radius: var(--shape-xl);
  padding: clamp(20px, 4vw, 30px);
  box-shadow: var(--elevation-2);
  z-index: 3;
}
body.news-view-deck .home-news-grid .card.is-active-card {
  display: block;
  position: relative;
  min-height: clamp(520px, calc(100dvh - 132px), 780px);
}
body.news-view-deck .home-news-grid .card.is-leaving-left { animation: deckLeaveLeft .18s ease both; }
body.news-view-deck .home-news-grid .card.is-leaving-right { animation: deckLeaveRight .18s ease both; }
body.news-view-deck .home-news-grid .card.is-entering-left { animation: deckEnterLeft .18s ease both; }
body.news-view-deck .home-news-grid .card.is-entering-right { animation: deckEnterRight .18s ease both; }
body.news-view-grid .home-news-grid .card { display: block; }

@keyframes deckLeaveLeft { to { transform: translateX(-34px) rotate(-1deg); opacity: 0; } }
@keyframes deckLeaveRight { to { transform: translateX(34px) rotate(1deg); opacity: 0; } }
@keyframes deckEnterLeft { from { transform: translateX(-28px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes deckEnterRight { from { transform: translateX(28px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (max-width: 760px) {
  :root { --content: min(100% - 20px, 1120px); }
  .shell { padding-top: 10px; }
  .topbar { flex-wrap: wrap; min-height: auto; gap: 10px; }
  .brand { flex: 1 1 auto; }
  .topnav { order: 3; width: 100%; overflow-x: auto; margin-left: 0; padding-bottom: 2px; }
  .topnav a { flex: 0 0 auto; }
  .theme-toggle { margin-left: auto; }
  .hero { border-radius: var(--shape-lg); padding: 24px; }
  .hero-actions .button,
  .hero-actions .button-tonal,
  .hero-actions .button-outline { flex: 1 1 160px; }
  .project-picks-head,
  .news-view-head,
  .card-head,
  .project-head { align-items: flex-start; flex-direction: column; }
  .news-view-head { top: 0; }
  .view-switch { width: 100%; }
  .view-switch button { flex: 1; }
  .project-grid,
  .feature-grid { grid-template-columns: 1fr; }
  .event-timeline li { grid-template-columns: 64px minmax(0, 1fr); }
  body.news-view-deck .shell { width: min(100% - 16px, 780px); }
  body.news-view-deck .brand { min-height: 36px; font-size: 16px; }
  body.news-view-deck .news-view-head { top: 52px; flex-direction: row; align-items: center; }
  body.news-view-deck .news-view-head .section-title { font-size: 16px; }
  body.news-view-deck .view-switch { width: auto; }
  body.news-view-deck .view-switch button { flex: none; padding: 0 11px; }
  body.news-view-deck .home-news-grid,
  body.news-view-deck .home-news-grid .card.is-active-card { min-height: calc(100dvh - 128px); }
}
