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

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --border: #e5e5e5;
  --link: #1a1a1a;
  --link-hover: #555555;
  --code-bg: #f5f5f5;
  --max-width: 640px;
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --text: #e5e5e5;
  --text-secondary: #999999;
  --border: #333333;
  --link: #e5e5e5;
  --link-hover: #aaaaaa;
  --code-bg: #2a2a2a;
}

html {
  font-size: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  padding: 0 1.5rem;
  transition: background 0.2s ease, color 0.2s ease;
}

/* ── Layout ── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

/* ── Header ── */
.site-header {
  margin-bottom: 3rem;
}

.site-title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.site-title a {
  color: var(--text);
  text-decoration: none;
}

.site-bio {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.site-bio a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
}

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

.site-blog-name {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 0.75rem;
}

/* ── Theme toggle ── */
.theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--bg);
  border: 1.5px solid var(--text-secondary);
  border-radius: 50%;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
}

.theme-toggle:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ── Post list (index) ── */
.post-list {
  list-style: none;
}

.post-list li {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.post-list a {
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.25;
}

.post-list a:hover {
  color: var(--link-hover);
}

.post-date {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

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

.post-title {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.post-meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.post-content h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  letter-spacing: -0.01em;
}

.post-content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.post-content p {
  margin-bottom: 1.2rem;
}

.post-content a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
}

.post-content a:hover {
  text-decoration-color: var(--text);
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

.post-content blockquote {
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  color: var(--text-secondary);
  margin: 1.5rem 0;
}

.post-content code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--code-bg);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.5;
}

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

.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
  margin: 1.5rem 0;
}

.post-content th, .post-content td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.post-content th {
  font-weight: 600;
  border-bottom: 2px solid var(--text);
}

.post-content tr:last-child td {
  border-bottom: none;
}

.post-content ul, .post-content ol {
  margin: 0 0 1.2rem 1.5rem;
}

.post-content li {
  margin-bottom: 0.3rem;
}

/* ── Back link ── */
.back-link {
  display: inline-block;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  color: var(--text);
}

.post-content ~ .back-link {
  margin-top: 3rem;
}

/* ── Post footer (permalink + share) ── */
.post-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.post-footer a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
}

.post-footer a:hover {
  color: var(--text);
}

/* ── Footer ── */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8rem;
}
