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

/* Base */
:root {
  --bg: #fefefe;
  --text: #2c2c2c;
  --accent: #b04632;
  --border: #e0e0e0;
  --code-bg: #f5f5f5;
  --muted: #666;
  --font-body: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --font-heading: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1a1a;
    --text: #d4d4d4;
    --accent: #e07a5f;
    --border: #333;
    --code-bg: #252525;
    --muted: #999;
  }
}

:root[data-theme="dark"] {
  --bg: #1a1a1a;
  --text: #d4d4d4;
  --accent: #e07a5f;
  --border: #333;
  --code-bg: #252525;
  --muted: #999;
}

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

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Header */
.site-header {
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.site-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}

.site-name:hover {
  text-decoration: none;
  color: var(--accent);
}

.site-tagline {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.site-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 0.85rem;
}

.site-nav a {
  color: var(--text);
}

.site-nav a:hover {
  color: var(--accent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.4rem;
  line-height: 1;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding: 1.5rem 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
}

.site-footer a:hover {
  color: var(--accent);
}

/* Main */
main {
  min-height: 60vh;
}

/* Index */
.intro {
  color: var(--muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.post-list {
  display: flex;
  flex-direction: column;
}

.post-item {
  display: flex;
  gap: 1.2rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}

.post-item time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.post-item a {
  font-weight: 600;
  font-family: var(--font-heading);
  color: var(--text);
  font-size: 0.95rem;
}

.post-item a:hover {
  color: var(--accent);
}

.post-desc {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* Post */
.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.8rem;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.post-meta {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.post-meta time {
  font-family: var(--font-mono);
}

.post-tags {
  font-size: 0.78rem;
}

.post-body h2 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 2rem 0 0.8rem;
}

.post-body h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.1rem;
  margin: 1.8rem 0 0.6rem;
}

.post-body h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
}

.post-body p {
  margin-bottom: 1.5em;
}

.post-body strong {
  font-weight: 600;
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
}

.post-body pre {
  background: var(--code-bg);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin-bottom: 1.5em;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.5;
}

.post-body pre code {
  background: none;
  padding: 0;
}

.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: 1.5em 0;
  color: var(--muted);
  font-style: italic;
}

.post-body blockquote p {
  margin-bottom: 0.5em;
}

.post-body ul,
.post-body ol {
  margin: 0 0 1.5em 1.5rem;
}

.post-body li {
  margin-bottom: 0.3em;
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.post-body img {
  max-width: 100%;
  height: auto;
}

.post-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.post-nav-next {
  margin-left: auto;
}

/* Archive */
.archive-year h2 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.2rem;
  margin: 2rem 0 0.5rem;
  color: var(--muted);
}

.archive-list {
  list-style: none;
}

.archive-list li {
  display: flex;
  gap: 1rem;
  padding: 0.4rem 0;
  align-items: baseline;
}

.archive-list time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.archive-list a {
  color: var(--text);
}

.archive-list a:hover {
  color: var(--accent);
}

/* About */
.about h1 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
}

.about-body p {
  margin-bottom: 1.5em;
}

.about-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* 404 */
.not-found {
  text-align: center;
  padding: 4rem 0;
}

.not-found h1 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* Reading progress bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  z-index: 100;
  transition: width 50ms linear;
}

/* Utilities */
@media (max-width: 600px) {
  html {
    font-size: 17px;
  }

  body {
    padding: 0 1rem;
  }

  .header-inner {
    flex-direction: column;
    gap: 0.3rem;
  }

  .post-item {
    flex-direction: column;
    gap: 0.2rem;
  }

  .post-header h1 {
    font-size: 1.5rem;
  }
}
