:root {
  --bg: #f6f6f6;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --text: #111111;
  --muted: #5f5f5f;
  --border: #dddddd;
  --primary: #111111;
  --primary-hover: #2b2b2b;
  --accent: #ededed;
  --warning: #f4f4f4;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.06);
  --radius: 18px;
  --header-bg: rgba(255, 255, 255, 0.9);
}

:root[data-theme="dark"] {
  --bg: #0c0c0c;
  --surface: #151515;
  --surface-soft: #1c1c1c;
  --text: #f5f5f5;
  --muted: #b8b8b8;
  --border: #2d2d2d;
  --primary: #ffffff;
  --primary-hover: #d6d6d6;
  --accent: #202020;
  --warning: #171717;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  --header-bg: rgba(12, 12, 12, 0.9);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  transition: background-color 160ms ease, color 160ms ease;
}

a { color: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
}

.nav {
  width: min(1120px, calc(100% - 24px));
  min-height: 54px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
}

.brand {
  flex: 0 0 auto;
  text-decoration: none;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.92rem;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--primary);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.theme-toggle:hover { background: var(--accent); }

.hero {
  padding: 88px 20px 72px;
  background:
    radial-gradient(circle at 14% 12%, color-mix(in srgb, var(--accent) 100%, transparent) 0, transparent 27%),
    radial-gradient(circle at 88% 18%, color-mix(in srgb, var(--accent) 78%, transparent) 0, transparent 22%),
    linear-gradient(180deg, var(--surface-soft) 0%, var(--bg) 100%);
}

.hero-inner, .container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.hero p, .page-hero p {
  max-width: 760px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--primary);
  color: var(--bg);
  text-decoration: none;
  font-weight: 750;
}

.button:hover { background: var(--primary-hover); }

.button.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--primary);
}

.section { padding: 72px 0; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.2rem);
  line-height: 1.25;
}

.section-heading p {
  max-width: 600px;
  margin: 0;
  color: var(--muted);
}

.tool-grid, .article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 22px;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card:hover {
  transform: translateY(-3px);
  transition: transform 0.18s ease;
}

.card-badge {
  width: fit-content;
  margin-bottom: 18px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 800;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 1.3rem;
}

.card p {
  margin: 0 0 22px;
  color: var(--muted);
  flex: 1;
}

.card-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 800;
}

.flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.flow-step {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-align: center;
}

.flow-step strong {
  display: block;
  margin-bottom: 6px;
  color: var(--primary);
}

.profile-panel {
  max-width: 760px;
  padding: 24px 26px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-panel p {
  margin: 0;
  color: var(--muted);
}

.profile-panel p + p { margin-top: 12px; }

.profile-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.profile-section h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.notice {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--warning);
}

.page-hero { padding: 64px 0 24px; }
.page-hero h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.1rem); }

.article-card {
  display: block;
  min-height: 230px;
  text-decoration: none;
}

.article-card small {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
}

.article {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 0 80px;
}

.article-wide { max-width: 960px; }
.article h1 { margin-bottom: 10px; line-height: 1.25; }
.article h2 { margin-top: 42px; }
.article h3 { margin-top: 28px; }
.article .lead { font-size: 1.1rem; color: var(--muted); }
.checklist { padding-left: 22px; }
.checklist li + li { margin-top: 8px; }

.resource-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0;
}

.learning-map {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 32px 0 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.learning-map a {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 800;
}

.learning-map a:hover { background: var(--accent); }

.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.topic-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.topic-card h3 {
  margin: 0 0 12px;
  font-size: 1.08rem;
}

.step-list { padding-left: 24px; }
.step-list li + li { margin-top: 8px; }

.data-table {
  width: 100%;
  margin: 20px 0;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.data-table th,
.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: var(--surface-soft);
  color: var(--primary);
}

.data-table tr:last-child td { border-bottom: 0; }

.competition-section {
  margin-top: 48px;
}

.competition-section > h2 {
  margin-top: 0;
}

.competition-section > p {
  color: var(--muted);
}

.compact-map {
  margin-top: 22px;
}

.year-group {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.year-group h3 {
  margin: 0 0 12px;
  font-size: 1.12rem;
}

.year-group summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 1.02rem;
  font-weight: 800;
}

.year-group .file-list { margin-top: 0; }

.year-group summary + .file-list { margin-top: 14px; }

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.image-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--primary);
  text-decoration: none;
  font-weight: 800;
}

.image-card:hover { background: var(--accent); }

.image-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface-soft);
}

.image-card span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.88rem;
}

.asset-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.asset-block h4 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.asset-kind + .asset-kind {
  margin-top: 16px;
}

.asset-kind h5 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.asset-group {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.asset-group summary {
  cursor: pointer;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.asset-group .image-grid,
.asset-group .file-list {
  margin-top: 12px;
}

.file-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}

.file-list.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.file-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--primary);
  text-decoration: none;
  font-weight: 800;
}

.file-list a:hover { background: var(--accent); }

.file-list span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.code-block {
  overflow-x: auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 88%, var(--primary) 12%);
  color: var(--text);
  font-family: Consolas, monospace;
  white-space: pre-wrap;
}

.site-footer {
  padding: 28px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
  background: var(--surface);
}

@media (max-width: 880px) {
  .tool-grid, .article-grid, .flow, .topic-grid, .file-list.two-column, .image-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .nav {
    min-height: 52px;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
  }

  .nav-actions {
    min-width: 0;
    margin-left: auto;
    justify-content: space-between;
    gap: 8px;
  }

  .nav-links {
    min-width: 0;
    gap: 10px;
    overflow-x: auto;
    white-space: nowrap;
  }

  .theme-toggle {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 0 9px;
  }

  .hero {
    padding-top: 72px;
  }
}
