:root {
  --fg: #1a1a1a;
  --fg-soft: #444;
  --fg-dim: #888;
  --bg: #fcfcfa;
  --bg-soft: #f3f2ee;
  --accent: #b8532c;
  --border: #e5e3dc;
  --code-bg: #f6f4ee;
  --max-width: 800px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e9e7e2;
    --fg-soft: #bcbab4;
    --fg-dim: #7a7770;
    --bg: #17171a;
    --bg-soft: #202024;
    --accent: #e88a56;
    --border: #2b2b30;
    --code-bg: #202024;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 1.25rem; }
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: var(--accent); }
h1, h2, h3, h4 { font-weight: 650; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.4rem; margin: 2rem 0 0.6rem; }
h3 { font-size: 1.15rem; margin: 1.4rem 0 0.4rem; }
p, ul, ol { margin: 0 0 1rem; }
img { max-width: 100%; height: auto; }
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-bottom: 2.5rem;
}
/* Header shares the global --max-width (800px). Nav has 10 items now
 * (Posts / Notes / Projects / Photos / Snippets / Casts / Archives /
 * Drive / Paste / About) — 0.85rem per-link margin + 0.95rem font size
 * fits in 800 with room to spare next to the title. */
.site-header .wrap {
  display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0.75rem;
}
.site-title {
  font-weight: 650; font-size: 1.2rem; color: var(--fg); border: none;
}
.site-nav a {
  margin-left: 0.85rem; font-size: 0.95rem; color: var(--fg-soft); border: none;
}
.site-nav a:hover, .site-nav a.active { color: var(--accent); }

/* On narrow screens (phones), the 9-item nav doesn't fit next to the
 * title. Instead of wrapping onto 2-3 rows (head-heavy, ugly), turn
 * the nav into a horizontally-scrollable strip with fade-out masks
 * on both edges as a visual hint that more items exist off-screen. */
@media (max-width: 560px) {
  .site-header .wrap { flex-wrap: nowrap; align-items: center; }
  .site-nav {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, transparent 0, black 1.5rem, black calc(100% - 1.5rem), transparent 100%);
            mask-image: linear-gradient(to right, transparent 0, black 1.5rem, black calc(100% - 1.5rem), transparent 100%);
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { margin-left: 0.9rem; flex-shrink: 0; }
  .site-nav a:first-child { margin-left: 1.5rem; }
  .site-nav a:last-child { padding-right: 1.5rem; }
}

.site-main { min-height: 60vh; padding-bottom: 4rem; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2rem;
  color: var(--fg-dim);
  font-size: 0.88rem;
}
.site-footer .fine { font-size: 0.8rem; margin-top: 0.35rem; color: var(--fg-dim); }

.home-intro { margin: 0 0 3rem; }
.home-intro h1 { font-size: 2rem; }
.home-intro p { font-size: 1.05rem; color: var(--fg-soft); }

.home-recent { margin: 2.5rem 0; }
.home-recent h2 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-dim); border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }

.home-secondary { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2rem; margin-top: 3rem; }
.home-secondary h3 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-dim); border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.mini-list { list-style: none; padding: 0; font-size: 0.95rem; }
.mini-list li { margin: 0.4rem 0; color: var(--fg-soft); }
.mini-list li a { font-weight: 500; }
.more-link { font-size: 0.88rem; color: var(--fg-dim); }

.post-list { list-style: none; padding: 0; }
.post-entry { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.75rem; padding: 0.35rem 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.post-entry time { color: var(--fg-dim); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.post-entry a { color: var(--fg); border: none; }
.post-entry a:hover .post-title { color: var(--accent); }
.post-entry .post-summary { grid-column: 2 / -1; font-size: 0.88rem; color: var(--fg-dim); margin: 0.15rem 0 0.3rem; }
.badge { display: inline-block; font-size: 0.7rem; background: var(--bg-soft); color: var(--fg-dim); padding: 0.05rem 0.4rem; border-radius: 3px; margin-left: 0.4rem; text-transform: uppercase; letter-spacing: 0.06em; }
@media (max-width: 560px) {
  .post-entry { grid-template-columns: 1fr; gap: 0.1rem; padding: 0.55rem 0; }
  .post-entry time { font-size: 0.8rem; }
}

.section-header { margin-bottom: 2rem; }
.section-header h1 { font-size: 1.6rem; }
.section-intro { color: var(--fg-soft); }

.post-header { margin-bottom: 1.5rem; }
.post-header h1 { font-size: 1.9rem; }
.post-meta { color: var(--fg-dim); font-size: 0.9rem; }
.post-meta a { color: var(--fg-dim); border: none; }
.post-meta a:hover { color: var(--accent); }
.post-tags a { margin-right: 0.3rem; }

.post-content h2 { margin-top: 2.2rem; }
.post-content blockquote {
  border-left: 3px solid var(--border);
  margin: 1rem 0;
  padding: 0.15rem 1rem;
  color: var(--fg-soft);
  font-style: italic;
}
.post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.post-content pre {
  background: var(--code-bg);
  padding: 0.85rem 1rem;
  overflow-x: auto;
  border-radius: 4px;
  font-size: 0.88rem;
  line-height: 1.5;
  border: 1px solid var(--border);
}
.post-content pre code { background: transparent; padding: 0; }
.post-content table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.92rem; }
.post-content th, .post-content td { border-bottom: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }
.post-content th { background: var(--bg-soft); font-weight: 650; }
.post-content img { border-radius: 3px; margin: 1rem 0; }
.post-content figure { margin: 1.5rem 0; }
.post-content figcaption { font-size: 0.85rem; color: var(--fg-dim); text-align: center; margin-top: 0.35rem; }

.post-footer { margin-top: 3rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.post-nav { display: flex; justify-content: space-between; font-size: 0.9rem; gap: 1rem; }
.post-nav .prev, .post-nav .next { max-width: 45%; color: var(--fg-soft); border: none; }
.post-nav .next { text-align: right; margin-left: auto; }
.post-nav a:hover { color: var(--accent); }

.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 3rem; font-size: 0.9rem; color: var(--fg-dim); }
.pagination a { color: var(--fg-soft); }

.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.6rem; margin: 1.5rem 0; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; height: auto; display: block; border-radius: 3px; }
.gallery figcaption { font-size: 0.8rem; color: var(--fg-dim); padding: 0.25rem 0.1rem; }

.tag-cloud { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; }
.tag-cloud li { font-size: 0.95rem; }
.tag-cloud .count { color: var(--fg-dim); font-size: 0.8rem; }

.archive-year { margin-top: 2.25rem; font-size: 1.25rem; color: var(--fg); border-bottom: 1px solid var(--border); padding-bottom: 0.2rem; }

.uses-section h2 { margin-top: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.2rem; }
.uses-section dt { font-weight: 650; margin-top: 0.6rem; }
.uses-section dd { margin: 0 0 0.2rem 1.5rem; color: var(--fg-soft); font-size: 0.95rem; }

.blogroll dt { font-weight: 650; margin-top: 0.6rem; }
.blogroll dd { margin: 0 0 0.4rem 1.5rem; color: var(--fg-soft); font-size: 0.92rem; }

/* src / code-browser pages */
.breadcrumb { font-size: 0.88rem; color: var(--fg-dim); margin-bottom: 0.6rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.breadcrumb a { color: var(--fg-soft); border: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb strong { color: var(--fg); font-weight: 650; }

.repo-table, .file-tree { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin: 1rem 0 2rem; font-variant-numeric: tabular-nums; }
.repo-table th, .repo-table td, .file-tree th, .file-tree td { text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--border); }
.repo-table th, .file-tree th { background: var(--bg-soft); font-weight: 650; color: var(--fg-dim); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
.repo-table td a, .file-tree td a { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92rem; }
.repo-table td.repo-desc { color: var(--fg-soft); font-size: 0.88rem; font-family: inherit; }
.file-tree td:first-child { width: 60%; }
.file-tree td:nth-child(2), .repo-table td:nth-child(2), .repo-table td:nth-child(3), .repo-table td:nth-child(4) { color: var(--fg-dim); font-size: 0.85rem; white-space: nowrap; }

.repo-summary { color: var(--fg-soft); font-size: 0.95rem; margin-top: 0.4rem; }
.repo-status { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.1rem 0.4rem; border-radius: 3px; background: var(--bg-soft); color: var(--fg-dim); }
.repo-status-active { background: #1f5f3a; color: #eaf7ef; }
.repo-status-archived { background: #5f1f1f; color: #f7eaea; }
.repo-status-maintained { background: #3a3f5f; color: #eaeef7; }

.src-tree, .src-readme, .src-commits { margin-top: 2.2rem; }
.src-tree h2, .src-readme h2, .src-commits h2 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-dim); border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }

.commit-list { list-style: none; padding: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88rem; }
.commit-list li { padding: 0.25rem 0; border-bottom: 1px dashed var(--border); display: grid; grid-template-columns: 6.5rem 6rem 1fr; gap: 0.6rem; align-items: baseline; }
.commit-sha { color: var(--accent); background: transparent; padding: 0; font-size: 0.88rem; }
.commit-list time { color: var(--fg-dim); font-size: 0.85rem; }
.commit-list .commit-subject { color: var(--fg-soft); font-family: inherit; }
@media (max-width: 620px) {
  .commit-list li { grid-template-columns: 1fr; gap: 0.1rem; }
}

.src-file .src-file-body pre { margin: 0; border-radius: 4px; }
.src-file .src-file-body { margin-top: 1rem; }
.back-to-repo { margin-top: 1rem; font-size: 0.88rem; }

/* cast-player (asciinema-style screencast viewer) */
.cast { display: block; margin: 1.5rem 0; background: #0e0e10; color: #e8e6e0; border-radius: 4px; overflow: hidden; border: 1px solid #222; }
.cast-screen { margin: 0; padding: 0.75rem 0.9rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; line-height: 1.35; max-height: 24em; min-height: 8em; overflow-y: auto; white-space: pre; color: inherit; background: transparent; border: none; }
.cast-hint { color: #7a7770; font-style: italic; }
.cast-controls { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.75rem; background: #16161a; border-top: 1px solid #222; }
.cast-play { background: #2a2a30; color: #e8e6e0; border: 1px solid #3a3a40; padding: 0.2rem 0.7rem; border-radius: 3px; font-family: inherit; font-size: 0.82rem; cursor: pointer; }
.cast-play:hover:not(:disabled) { background: #3a3a40; }
.cast-play:disabled { opacity: 0.5; cursor: not-allowed; }
.cast-progress { flex: 1; height: 6px; background: #2a2a30; border-radius: 3px; overflow: hidden; }
.cast-progress-bar { height: 100%; background: var(--accent); width: 0; transition: width 0.12s linear; }
.cast-time { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 0.78rem; color: #bcbab4; font-variant-numeric: tabular-nums; min-width: 5em; text-align: right; }

.cast-post-list .post-entry { grid-template-columns: 6.5rem 1fr auto; }
.cast-duration { color: var(--fg-dim); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* snippets */
.snippet-list { list-style: none; padding: 0; }
.snippet-list .snippet-card { padding: 0.6rem 0; border-bottom: 1px dashed var(--border); }
.snippet-list .snippet-card h3 { font-size: 1rem; margin: 0 0 0.15rem; }
.snippet-list .snippet-card h3 a { color: var(--fg); border: none; }
.snippet-list .snippet-card .snippet-meta { font-size: 0.82rem; color: var(--fg-dim); margin-bottom: 0.25rem; }
.snippet-list .snippet-card p { font-size: 0.9rem; color: var(--fg-soft); margin: 0; }

/* talks list */
.talk-entry { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.talk-entry h3 { margin: 0 0 0.2rem; font-size: 1.05rem; }
.talk-entry .talk-meta { font-size: 0.85rem; color: var(--fg-dim); margin-bottom: 0.3rem; }
.talk-entry .talk-meta a { color: var(--fg-soft); }
.talk-entry p { font-size: 0.92rem; color: var(--fg-soft); margin: 0.2rem 0; }

/* video embed */
.post-content video, .gallery video { max-width: 100%; display: block; margin: 1rem 0; border-radius: 3px; background: #000; }

/* reading list */
.reading-list { list-style: none; padding: 0; }
.reading-list li { padding: 0.35rem 0; border-bottom: 1px dashed var(--border); display: grid; grid-template-columns: 1fr auto; gap: 0.6rem; align-items: baseline; }
.reading-list .book-title { font-weight: 500; }
.reading-list .book-author { color: var(--fg-soft); }
.reading-list .book-status { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-dim); padding: 0.05rem 0.4rem; border-radius: 3px; background: var(--bg-soft); }

/* now page + colophon */
.now-updated { color: var(--fg-dim); font-size: 0.88rem; font-style: italic; }
.colophon dt { font-weight: 650; margin-top: 0.6rem; }
.colophon dd { margin: 0 0 0.3rem 1.5rem; color: var(--fg-soft); font-size: 0.95rem; }
