*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ---- Light Theme (Parchment) ---- */
[data-theme="light"] {
  --color-bg: #f5f4ed;
  --color-surface: #faf9f5;
  --color-surface-hover: #f0eee6;
  --color-text: #141413;
  --color-text-secondary: #5e5d59;
  --color-muted: #87867f;
  --color-border: #f0eee6;
  --color-border-strong: #e8e6dc;
  --color-accent: #c96442;
  --color-accent-hover: #d97757;
  --color-accent-soft: rgba(201, 100, 66, 0.08);
  --color-ring: #d1cfc5;
  --shadow-whisper: rgba(0, 0, 0, 0.05) 0px 4px 24px;
}

/* ---- Dark Theme (Near Black) ---- */
[data-theme="dark"] {
  --color-bg: #141413;
  --color-surface: #30302e;
  --color-surface-hover: #3d3d3a;
  --color-text: #faf9f5;
  --color-text-secondary: #b0aea5;
  --color-muted: #87867f;
  --color-border: #30302e;
  --color-border-strong: #4d4c48;
  --color-accent: #d97757;
  --color-accent-hover: #c96442;
  --color-accent-soft: rgba(217, 119, 87, 0.12);
  --color-ring: #4d4c48;
  --shadow-whisper: rgba(0, 0, 0, 0.2) 0px 4px 24px;
}

:root {
  --font-serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --max-width: 860px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */

header {
  padding: 24px 24px;
}

nav {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.nav-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-link {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 0 4px;
}

.nav-link:hover {
  color: var(--color-text);
}

.theme-toggle,
.lang-toggle {
  background: var(--color-surface);
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--color-surface) 0px 0px 0px 0px, var(--color-ring) 0px 0px 0px 1px;
}

.theme-toggle { width: 36px; }

.lang-toggle {
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
}

.theme-toggle:hover,
.lang-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* ---- Language Toggle ---- */
[data-lang="zh"] .lang-zh { display: inline; }
[data-lang="zh"] .lang-en { display: none; }
[data-lang="en"] .lang-zh { display: none; }
[data-lang="en"] .lang-en { display: inline; }

/* ---- Main ---- */

main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

/* ---- Hero ---- */

.hero {
  text-align: center;
  padding: 80px 0 60px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: 3.25rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.10;
  margin-bottom: 12px;
  color: var(--color-text);
}

.hero .subtitle {
  font-size: 1.25rem;
  color: var(--color-text-secondary);
  font-weight: 400;
  line-height: 1.6;
  margin-bottom: 24px;
}

.hero-links {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn {
  display: inline-block;
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  line-height: 1.25;
}

.btn-brand {
  background: var(--color-accent);
  color: #faf9f5;
  border: none;
  box-shadow: var(--color-accent) 0px 0px 0px 0px, var(--color-accent) 0px 0px 0px 1px;
}

.btn-brand:hover {
  background: var(--color-accent-hover);
}

.btn-surface {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: none;
  box-shadow: var(--color-surface) 0px 0px 0px 0px, var(--color-ring) 0px 0px 0px 1px;
}

.btn-surface:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

/* ---- Sections ---- */

.section {
  padding: 60px 0;
}

.section + .section {
  border-top: 1px solid var(--color-border);
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--color-text);
  margin-bottom: 24px;
  text-align: left;
}

/* ---- Featured Card ---- */

.featured-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  display: flex;
  gap: 20px;
  align-items: center;
  box-shadow: var(--shadow-whisper);
}

.featured-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--color-accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.featured-body {
  flex: 1;
  min-width: 0;
}

.featured-body h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: 4px;
}

.featured-body h3 a {
  color: var(--color-text);
  text-decoration: none;
}

.featured-body h3 a:hover {
  color: var(--color-accent);
}

.featured-body p {
  font-size: 0.875rem;
  color: var(--color-muted);
  line-height: 1.6;
}

/* ---- Project Grid ---- */

.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.project-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  padding: 20px 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.project-card:hover {
  background: var(--color-surface-hover);
  box-shadow: var(--color-surface) 0px 0px 0px 0px, var(--color-ring) 0px 0px 0px 1px;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--color-accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-body h3 {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.card-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tag-accent {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  padding: 2px 8px;
  border-radius: 24px;
  white-space: nowrap;
}

.tag-active {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: #5a8a5e;
  background: rgba(90, 138, 94, 0.1);
  padding: 2px 8px;
  border-radius: 24px;
  white-space: nowrap;
}

.tag-retired {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-muted);
  background: transparent;
  box-shadow: inset 0px 0px 0px 1px var(--color-ring);
  padding: 2px 8px;
  border-radius: 24px;
  border: none;
  white-space: nowrap;
}

.project-card p {
  font-size: 0.8125rem;
  color: var(--color-muted);
  line-height: 1.6;
}

/* ---- Footer ---- */

footer {
  padding: 60px 24px 32px;
  text-align: center;
  border-top: 1px solid var(--color-border);
}

footer p {
  font-size: 0.75rem;
  color: var(--color-muted);
  letter-spacing: 0.12px;
}

/* ---- Responsive ---- */

@media (min-width: 768px) {
  .project-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .hero h1 {
    font-size: 4rem;
  }
}

@media (max-width: 767px) and (min-width: 480px) {
  .project-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero h1 {
    font-size: 2.5rem;
  }
}

@media (max-width: 479px) {
  .project-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero {
    padding: 48px 0 40px;
  }

  .featured-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
