/* ========== Design tokens ========== */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6b6760;
  --border: #e3e0d8;
  --accent: #1f6f5c;
  --accent-soft: #dcefe8;
  --live: #1f7a4d;
  --wip: #a15c07;
  --archived: #6b6760;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 8px 24px rgb(0 0 0 / .06);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181a;
    --surface: #1f2224;
    --text: #ecebe7;
    --muted: #a19d95;
    --border: #2e3235;
    --accent: #5cc2a5;
    --accent-soft: #1d3a33;
    --live: #5cc28c;
    --wip: #e0a24f;
    --archived: #8d8a84;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16181a;
  --surface: #1f2224;
  --text: #ecebe7;
  --muted: #a19d95;
  --border: #2e3235;
  --accent: #5cc2a5;
  --accent-soft: #1d3a33;
  --live: #5cc28c;
  --wip: #e0a24f;
  --archived: #8d8a84;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
  color-scheme: dark;
}

/* ========== Base ========== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
.container { width: min(1120px, 100% - 32px); margin-inline: auto; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 16px; top: -48px; padding: 8px 12px;
  background: var(--accent); color: #fff; border-radius: 8px; z-index: 10;
}
.skip-link:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ========== Header ========== */
.site-header { border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.theme-toggle {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); cursor: pointer;
}
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ========== Hero ========== */
.hero { display: flex; gap: 20px; align-items: flex-start; padding-block: 56px 32px; }
.avatar { width: 72px; height: 72px; border-radius: 50%; flex: none; }
.hero h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.4rem); line-height: 1.2; }
.tagline { display: block; font-size: 1rem; font-weight: 500; color: var(--muted); margin-top: 6px; }
.intro { margin: 14px 0 0; max-width: 60ch; color: var(--muted); }
.social { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.social a {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); text-decoration: none; font-size: .9rem;
}
.social a:hover { border-color: var(--accent); color: var(--accent); }
.social svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ========== Toolbar & filters ========== */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar h2 { margin: 0; font-size: 1.3rem; }
.count { color: var(--muted); font-weight: 500; font-size: .95rem; }
.search input {
  width: 100%; padding: 8px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.search { flex: 0 1 260px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 24px; }
.chip {
  padding: 5px 12px; font: inherit; font-size: .88rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }

/* ========== Grid & cards ========== */
.grid {
  list-style: none; padding: 0; margin: 0 0 64px;
  display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-link { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.thumb { aspect-ratio: 16 / 9; background: var(--border); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-meta { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status[data-status="live"] { color: var(--live); }
.status[data-status="wip"] { color: var(--wip); }
.status[data-status="archived"] { color: var(--archived); }
.card-title { margin: 0; font-size: 1.1rem; }
.card-title .star { color: var(--wip); margin-left: 4px; font-size: .9em; }
.card-desc { margin: 0; color: var(--muted); font-size: .92rem; flex: 1; }
.tags { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-size: .75rem; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.repo-link {
  position: absolute; top: 10px; right: 10px; padding: 3px 10px; font-size: .78rem;
  border-radius: 999px; background: rgb(0 0 0 / .6); color: #fff; text-decoration: none;
}
.repo-link:hover { background: rgb(0 0 0 / .8); }

.skeleton { min-height: 320px; background: linear-gradient(90deg, var(--surface), var(--border), var(--surface)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* ========== Footer ========== */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0; font-size: .85rem; color: var(--muted); }

/* ========== Responsive ========== */
@media (max-width: 560px) {
  .hero { flex-direction: column; gap: 14px; padding-block: 36px 24px; }
  .search { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ========== 404 ========== */
.not-found { text-align: center; padding-block: 96px; }
.not-found .intro { margin-inline: auto; }
