:root {
  --bg: #fdfdfc;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #2b5cff;
  --border: #e6e6e3;
  --maxw: 640px;
  --grid: rgba(0, 0, 0, 0.015);
}

/* dark values, shared by auto + manual override */
:root[data-theme="dark"],
:root.dark {
  --bg: #111110;
  --fg: #e8e8e6;
  --muted: #9a9a96;
  --accent: #7aa2ff;
  --border: #2a2a28;
  --grid: rgba(255, 255, 255, 0.018);
}

/* follow OS only when user hasn't picked a theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --fg: #e8e8e6;
    --muted: #9a9a96;
    --accent: #7aa2ff;
    --border: #2a2a28;
    --grid: rgba(255, 255, 255, 0.018);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    system-ui, Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: -0.011em;
  margin: 0;
  padding: 0 20px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* square grid overlay (sits above the bg, below content) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 64px 0 96px;
}

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 0.5px;
  text-decoration-color: var(--muted);
}
a:hover { color: var(--muted); }

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.3;
}
h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 40px 0 12px; }
[data-panel] > :first-child { margin-top: 0; }

.tagline { color: var(--muted); margin: 0 0 28px; }

/* nav */
nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
nav a {
  color: var(--fg);
  text-decoration: none;
}
nav a.active { text-decoration: underline; text-underline-offset: 3px; }
nav a:hover { color: var(--muted); }

.theme-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease;
}
.theme-toggle:hover { color: var(--fg); }
.theme-toggle svg { width: 17px; height: 17px; display: block; }
/* show the right icon for the active theme */
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .moon,
:root.dark .theme-toggle .moon { display: block; }
:root[data-theme="dark"] .theme-toggle .sun,
:root.dark .theme-toggle .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
}

/* socials */
.socials {
  display: flex;
  gap: 16px;
  margin: 24px 0 0;
}
.socials a {
  color: var(--muted);
  display: inline-flex;
  text-decoration: none;
}
.socials a:hover { color: var(--accent); }
.socials svg { width: 20px; height: 20px; display: block; }

/* lists */
.list { list-style: none; padding: 0; margin: 0; }

[data-panel] > .list { margin-top: -28px; margin-bottom: -28px; }
.list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: none; }
.list .date { color: var(--muted); white-space: nowrap; font-size: 0.85rem; }

/* blog post */
.post .back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.post .back:hover { color: var(--fg); }
.post h2 { margin-top: 12px; }
.post-date { color: var(--muted); font-size: 0.85rem; margin: 0 0 24px; }

.project { padding: 14px 0; border-bottom: 1px solid var(--border); }
.project:last-child { border-bottom: none; }
.project .desc { color: var(--muted); margin: 2px 0 0; }

.ama-item { margin: 0 0 24px; }
.ama-item .q { font-weight: 600; margin: 0 0 4px; }
.ama-item .a { color: var(--muted); margin: 0; }

p { margin: 0 0 16px; }

.muted { color: var(--muted); }

.name-zh {
  font-size: 0.85em;
  font-weight: 400;
  margin-left: 4px;
}

.bullets {
  margin: 4px 0 16px;
  padding-left: 1.2em;
  list-style: none;
}
.bullets li {
  position: relative;
  padding: 2px 0;
}
.bullets li::before {
  content: "–";
  position: absolute;
  left: -1.2em;
  color: var(--muted);
}

.inline-icon {
  height: 1em;
  width: 1em;
  vertical-align: -0.15em;
  margin-right: 0.3em;
  border-radius: 3px;
}

/* footer / webring */
footer {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
footer .socials { margin: 0 0 12px; }
.email { margin: 0 0 20px; }
.copyright { text-align: right; }
.webring {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.webring .label { color: var(--fg); }
