@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&display=swap');

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

:root {
  --text: #222;
  --muted: #999;
  --link: #0055aa;
  --bg: #fff;
  --border: #e8e8e8;
  --serif: 'Google Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --sans: 'Google Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 18px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  max-width: 660px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ── */
.site-header {
  padding: 56px 0 40px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 56px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
}

.site-name {
  font-size: 17px;
  font-weight: normal;
  font-family: var(--sans);
}

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

.site-nav {
  font-family: var(--sans);
  font-size: 14px;
  display: flex;
  gap: 18px;
  flex-shrink: 0;
}

.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--text); }

/* ── History nav buttons ── */
.nav-history {
  display: flex;
  gap: 2px;
}

.nav-history button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  line-height: 1;
}

.nav-history button:hover:not(:disabled) { background: #f0f0f0; color: var(--text); }
.nav-history button:disabled { opacity: 0.3; cursor: default; }

/* ── Post list ── */
.posts { list-style: none; padding: 0; }

.posts li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.posts li:first-child { border-top: 1px solid var(--border); }

.post-link {
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  font-family: var(--sans);
  flex: 1;
}

.post-link:hover { text-decoration: underline; }

.post-date {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Empty / loading ── */
.empty {
  padding: 64px 0;
  text-align: center;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--muted);
}

/* ── Single post ── */
.back {
  display: inline-block;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 48px;
}

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

.post-title {
  font-size: 36px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 12px;
}

.post-meta {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 48px;
}

/* ── Prose ── */
.prose p { margin-bottom: 1.25em; }

.prose h1 { font-size: 1.55em; font-weight: 700; letter-spacing: -0.3px; margin: 1.8em 0 0.6em; line-height: 1.2; }
.prose h2 { font-size: 1.3em; font-weight: 700; letter-spacing: -0.2px; margin: 1.8em 0 0.6em; line-height: 1.25; }
.prose h3 { font-size: 1.1em; font-weight: 500; margin: 1.6em 0 0.5em; line-height: 1.3; }

.prose a { color: var(--link); }
.prose a:hover { text-decoration: none; }

.prose ul, .prose ol { margin: 0 0 1.25em 1.5em; }
.prose li { margin-bottom: 0.3em; }

.prose blockquote {
  border-left: 3px solid var(--border);
  margin: 1.5em 0;
  padding: 0.1em 1.2em;
  color: #666;
  font-style: italic;
}

.prose code {
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 0.83em;
  background: #f5f5f5;
  padding: 2px 5px;
  border-radius: 3px;
}

.prose pre {
  background: #f5f5f5;
  padding: 1.2em 1.4em;
  overflow-x: auto;
  border-radius: 5px;
  margin-bottom: 1.4em;
  line-height: 1.55;
}

.prose pre code { background: none; padding: 0; font-size: 0.88em; }

.prose img { max-width: 100%; height: auto; margin: 1em 0; display: block; }

.prose iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  margin: 1em 0 0;
  display: block;
}

/* italic immediately after image or iframe = caption */
.prose img + em,
.prose p:has(> img) + p > em:only-child,
.prose iframe + p > em:only-child {
  display: block;
  text-align: center;
  font-size: 0.8em;
  font-style: normal;
  color: var(--muted);
  margin-top: -0.5em;
  margin-bottom: 1.25em;
}

.prose iframe + p > em:only-child { margin-top: 0.4em; }

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

.prose strong { font-weight: 600; }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: 1.25em; font-size: 0.95em; }
.prose th, .prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.prose th { font-family: var(--sans); font-size: 0.85em; font-weight: 600; color: var(--muted); }

/* ── About page ── */
.page-title {
  font-size: 30px;
  font-weight: normal;
  letter-spacing: -0.4px;
  margin-bottom: 40px;
}

/* ── Footer ── */
.site-footer {
  margin-top: 80px;
  padding: 24px 0 48px;
  border-top: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

@media (max-width: 520px) {
  body { font-size: 17px; padding: 0 18px; }
  .site-header { padding: 36px 0 28px; margin-bottom: 36px; flex-wrap: wrap; }
  .post-title { font-size: 28px; }
  .site-footer { flex-direction: column; align-items: flex-start; }
}

/* ── Theme toggle button ── */
.theme-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 0;
  transition: background .15s;
}
.theme-btn:hover { background: #f0f0f0; color: var(--text); }

.icon-light { display: inline; }
.icon-dark  { display: none; }

/* ── Dark mode ── */
html.dark {
  --text: #e2e2e2;
  --muted: #777;
  --link: #6eaaef;
  --bg: #111;
  --border: #2a2a2a;
}

html.dark body { background: #111; color: var(--text); }
html.dark .theme-btn:hover { background: #222; }
html.dark .icon-light { display: none; }
html.dark .icon-dark  { display: inline; }

html.dark .prose blockquote { color: #aaa; }
html.dark .prose code,
html.dark .prose pre { background: #1e1e1e; }

html.dark .nav-history button { background: transparent; color: var(--muted); }
html.dark .nav-history button:hover:not(:disabled) { background: #222; color: var(--text); }
