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

:root {
  --bg: #faf9f7;
  --bg-secondary: #f4f2ee;
  --text: #2a2a28;
  --text-muted: #888;
  --text-faint: #c0bdb8;
  --border: #e8e6e0;
  --border-light: #f0ede8;
  --accent: #3d7a56;
  --accent-light: #d0e8da;
}

[data-theme="dark"] {
  --bg: #1a1714;
  --bg-secondary: #231f1c;
  --text: #d4cfc8;
  --text-muted: #7a7068;
  --text-faint: #4a443e;
  --border: #302a26;
  --border-light: #261f1c;
  --accent: #7ab896;
  --accent-light: #1e3428;
}

[data-theme="paper"] {
  --bg: #f0e8d8;
  --bg-secondary: #e5dac8;
  --text: #2e2018;
  --text-muted: #7a6050;
  --text-faint: #a8957a;
  --border: #cec0a8;
  --border-light: #d8ccb8;
  --accent: #7a5830;
  --accent-light: #d4bfa0;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}

a { color: inherit; text-decoration: none; }

.container {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 80px;
}
.tag-f[data-active="true"] { border-color: var(--accent); color: var(--accent); }

.site-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 32px 0; border-bottom: 1px solid var(--border);
}
.nav-logo { font-size: 16px; color: var(--text-muted); letter-spacing: 0.12em; text-decoration: none; }
.nav-logo span { color: var(--accent); }
.nav-links { display: flex; gap: 40px; list-style: none; }
.nav-links a { font-size: 15px; color: var(--text-faint); letter-spacing: 0.08em; text-decoration: none; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }
.nav-active { color: var(--text) !important; }
.nav-right { display: flex; align-items: center; gap: 20px; }

.writing-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 32px 0 20px; border-bottom: 1px solid var(--border);
}
.writing-title { font-size: 13px; color: var(--text-faint); letter-spacing: 0.2em; text-transform: uppercase; }
.tag-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-f {
  font-size: 13px; color: var(--text-faint); letter-spacing: 0.08em;
  border: 1px solid var(--border); padding: 5px 12px; border-radius: 2px;
  cursor: pointer; transition: all 0.15s; background: none;
  font-family: inherit;
}
.tag-f:hover { border-color: var(--accent); color: var(--accent); }
.tag-f[data-active] { border-color: var(--accent); color: var(--accent); }

.writing-list { display: flex; flex-direction: column; }
.writing-row {
  display: grid; grid-template-columns: 100px 1fr 160px;
  align-items: baseline; gap: 32px; padding: 22px 0;
  border-bottom: 1px solid var(--border-light); text-decoration: none;
  transition: opacity 0.15s;
}
.writing-row:hover { opacity: 0.7; }
.writing-date { font-size: 15px; color: var(--text-faint); letter-spacing: 0.06em; }
.writing-center { display: flex; flex-direction: column; gap: 5px; }
.writing-post-title {
  font-family: 'LXGW WenKai', 'Noto Serif SC', serif;
  font-size: 22px; font-weight: 400; color: var(--text); line-height: 1.5;
}
.writing-subtitle { font-size: 15px; color: var(--text-muted); }
.writing-tag { font-size: 14px; color: var(--accent); letter-spacing: 0.1em; text-align: right; }


@media (max-width: 768px) {
  .container { padding: 0 18px; }

  .site-nav {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 12px;
    padding: 18px 0;
  }
  .nav-logo { font-size: 14px; grid-column: 1; grid-row: 1; }
  .nav-right { grid-column: 2; grid-row: 1; }
  .nav-links { grid-column: 1 / -1; grid-row: 2; display: flex; gap: 20px; }
  .nav-links a { font-size: 13px; }

  .writing-header { flex-direction: column; align-items: flex-start; gap: 14px; padding: 24px 0 16px; }
  .tag-filters { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .tag-f { white-space: nowrap; font-size: 12px; padding: 5px 10px; }

  .writing-row {
    grid-template-columns: 64px 1fr;
    gap: 10px;
    padding: 16px 0;
  }
  .writing-tag { display: none; }
  .writing-post-title { font-size: 16px; line-height: 1.6; }
  .writing-date { font-size: 12px; }
  .writing-subtitle { font-size: 13px; }

  .content-grid {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 32px 0;
  }
  .side-col {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-top: 28px;
    margin-top: 0;
    gap: 24px;
  }

  .post-row {
    grid-template-columns: 64px 1fr;
    gap: 10px;
    padding: 16px 0;
  }
  .post-arrow { display: none; }
  .post-title { font-size: 16px; line-height: 1.6; }
  .post-date { font-size: 12px; }
  .post-tag { font-size: 11px; }

  .post-header { padding: 28px 0 20px; max-width: 100%; }
  .post-title { font-size: 24px; }
  .post-body { padding: 0 0 40px; max-width: 100%; }
  .post-body :global(p) { font-size: 16px; line-height: 1.9; }
  .post-body :global(li) { font-size: 16px; }
  .post-body :global(pre) { padding: 12px 14px; font-size: 12px; overflow-x: auto; }
  .post-body :global(h1) { font-size: 22px; }
  .post-body :global(h2) { font-size: 19px; }
  .post-body :global(h3) { font-size: 17px; }
  .post-nav { max-width: 100%; }

  .hero { padding: 32px 0 24px; }
  .hero-title-line2 { font-size: 28px; padding-left: 14px; line-height: 1.4; margin-bottom: 0; }
  .hero-title-line1 { font-size: 11px; }
  .hero-eyebrow { font-size: 10px; margin-bottom: 18px; }
  .cursor { height: 26px; width: 2px; }

  .about-text { font-size: 15px; }
  .section-label { font-size: 10px; }

  .cat-chip { font-size: 12px; padding: 6px 10px; }

  .footer-bar {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    max-width: 100%;
    padding: 20px 0;
  }
  .footer-right { gap: 16px; }
  .footer-left { font-size: 11px; }
  .footer-link { font-size: 11px; }
}

@media (max-width: 480px) {
  .container { padding: 0 14px; }
  .hero-title-line2 { font-size: 24px; }
  .nav-links { gap: 14px; }
  .nav-links a { font-size: 12px; }
}

/* ── Paper theme overrides ─────────────────────────── */
[data-theme="paper"] img:not([src*=".svg"]) {
  filter: sepia(0.15) saturate(0.88) brightness(0.98);
}
[data-theme="paper"] body {
  letter-spacing: 0.005em;
}

/* ── Dark theme overrides ──────────────────────────── */
[data-theme="dark"] body {
  -webkit-font-smoothing: subpixel-antialiased;
}
