/* Dark is the default. An inline script in every page's head stamps
   data-theme on <html> before first paint, so there is no flash. */
:root {
  --bg: #0b0c0e;
  --surface: #141619;
  --surface-2: #1b1e23;
  --surface-3: #22262c;
  --border: #262a30;
  --border-strong: #363c45;
  --text: #eceef1;
  --text-soft: #cfd3d9;
  --muted: #8b929c;
  --accent: #5b8cff;
  --accent-hover: #4a7bf0;
  --accent-soft: rgba(91, 140, 255, .12);
  --nav-bg: rgba(11, 12, 14, .82);
  --overlay-bg: rgba(11, 12, 14, .92);
  --radius: 16px;
  --max: 940px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --surface-2: #eef0f4;
  --surface-3: #e3e7ed;
  --border: #dfe3e9;
  --border-strong: #c3cad4;
  --text: #14161a;
  --text-soft: #3d434c;
  --muted: #5f6773;
  --accent: #2f5fd0;
  --accent-hover: #244cae;
  --accent-soft: rgba(47, 95, 208, .10);
  --nav-bg: rgba(255, 255, 255, .82);
  --overlay-bg: rgba(255, 255, 255, .92);
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 22px; }

/* ── nav ── */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--max); margin: 0 auto; padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.nav-name {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 800; letter-spacing: -.3px; color: var(--text);
}
.nav-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--border); flex: 0 0 auto;
}
/* Hidden on desktop; the mobile query turns it on. */
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; cursor: pointer;
  background: transparent; border: 1px solid var(--border);
  border-radius: 9px; color: var(--text);
}
.nav-toggle:hover { background: var(--surface-2); }
.nav-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.nav-toggle .close, .nav-toggle[aria-expanded="true"] .open { display: none; }
.nav-toggle[aria-expanded="true"] .close { display: block; }
.nav-name:hover { text-decoration: none; }
/* The buttons sit after the links in the bar but before them in the markup,
   so the hamburger stays next to the panel it opens. */
.nav-links { display: flex; gap: 20px; font-size: 14px; margin-left: auto; order: 2; }
.nav-links a { color: var(--muted); }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; order: 3; margin-left: 18px; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; cursor: pointer;
  background: transparent; border: 1px solid var(--border);
  border-radius: 9px; color: var(--muted);
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
/* Show the icon for the theme the button switches you to. */
.theme-toggle .to-dark { display: none; }
:root[data-theme="light"] .theme-toggle .to-dark { display: block; }
:root[data-theme="light"] .theme-toggle .to-light { display: none; }

/* ── hero ── */
.hero { padding-top: 84px; padding-bottom: 56px; }
.avatar {
  width: 80px; height: 80px; border-radius: 50%;
  border: 1px solid var(--border); display: block; margin: 0 0 22px;
}
.hero h1 {
  font-size: clamp(34px, 6vw, 52px); line-height: 1.1;
  letter-spacing: -1.4px; margin: 0 0 18px; font-weight: 800;
}
.hero .lead { font-size: 18px; color: var(--muted); max-width: 620px; margin: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

/* ── buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  transition: border-color .15s, background .15s;
}
.btn:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn svg { width: 15px; height: 15px; fill: currentColor; }

/* ── sections ── */
.section { padding-top: 56px; padding-bottom: 56px; border-top: 1px solid var(--border); }
.section h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--muted); font-weight: 700; margin: 0 0 6px;
}
.section .section-sub { color: var(--muted); font-size: 15px; margin: 0 0 28px; }

/* ── tabs ── */
.tabs {
  display: inline-flex; gap: 4px; margin: 14px 0 24px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.tab {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 8px 18px; border-radius: 8px; border: 0;
  background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface-2); color: var(--text); }
.tab-panel[hidden] { display: none; }

/* ── grouped work ── */
.group-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted); font-weight: 700; margin: 32px 0 14px;
}
.apps + .group-title { margin-top: 36px; }
.sites { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.site-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; color: var(--text);
  transition: border-color .15s, transform .15s;
}
.site-card:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-2px); }
.site-logo {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 9px;
  background: #fff; padding: 4px; border: 1px solid var(--border); object-fit: contain;
}
.site-name { display: block; font-size: 14.5px; font-weight: 700; letter-spacing: -.1px; }
.site-desc { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ── app cards ── */
.apps { display: grid; gap: 16px; }
.app-card {
  display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  transition: border-color .15s, transform .15s;
}
.app-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.app-logo {
  flex: 0 0 auto; width: 56px; height: 56px; border-radius: 13px;
  background: #fff; padding: 6px; border: 1px solid var(--border); object-fit: contain;
}
.app-body { flex: 1 1 340px; min-width: 0; }
.app-name { font-size: 18px; font-weight: 700; letter-spacing: -.2px; margin: 0 0 4px; }
.app-tag {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 3px 10px; margin-left: 8px; vertical-align: 2px;
}
.app-desc { color: var(--muted); font-size: 14.5px; margin: 0 0 16px; }
.app-links { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── about ── */
.about { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.about-photo {
  flex: 0 0 auto; width: 180px; height: 180px; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border);
}
.about > div { flex: 1 1 320px; min-width: 0; }
.about .prose:last-child { margin-bottom: 0; }

/* ── reading ── */
.books { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 8px; }
.book {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; color: var(--text);
  transition: border-color .15s, transform .15s;
}
.book:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-2px); }
.book.is-current { border-left: 3px solid var(--accent); }
.book-cover {
  flex: 0 0 auto; width: 54px; aspect-ratio: 2 / 3; object-fit: cover;
  border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2);
}
.book-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.book-title {
  font-size: 13.5px; font-weight: 700; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.book-author { font-size: 12px; color: var(--muted); }
.book-stars { font-size: 12px; color: var(--accent); letter-spacing: 1px; margin-top: 2px; }
@media (max-width: 900px) { .books { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .books { grid-template-columns: 1fr; } }

/* ── cycling ── */
.prose { color: var(--muted); font-size: 15px; max-width: 620px; margin: 0 0 16px; }
.photos {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0 24px;
}
.photos img {
  width: 100%; height: 100%; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border); display: block;
}

/* ── terms page ── */
.doc { padding-top: 48px; padding-bottom: 80px; }
.doc h1 { font-size: 30px; letter-spacing: -.8px; margin: 0 0 6px; }
.doc .meta { color: var(--muted); font-size: 13px; margin: 0 0 26px; }
.doc h2 {
  font-size: 19px; margin: 40px 0 12px; padding-top: 26px;
  border-top: 1px solid var(--border); letter-spacing: -.3px;
}
.doc h3 { font-size: 15px; margin: 24px 0 8px; }
.doc p, .doc li { font-size: 14.5px; color: var(--text-soft); }
.doc ul { padding-left: 20px; }
.callout {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 16px 18px; margin: 20px 0;
}
.callout p { margin: 0; font-size: 14px; color: var(--muted); }
.callout strong { color: var(--text); }

/* ── blog ── */
.posts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.post-card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  color: var(--text); transition: border-color .15s, transform .15s;
}
.post-card:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-2px); }
/* The grid needs every card the same height, so covers crop to a uniform 3:2.
   `cover` crops but never stretches, so proportions stay true. */
.post-cover {
  width: 100%; aspect-ratio: 3 / 2; object-fit: cover; object-position: center;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.post-card-text { padding: 18px 20px 22px; }
.post-card h3 { margin: 0 0 4px; font-size: 17px; line-height: 1.35; letter-spacing: -.2px; }
@media (max-width: 900px) { .posts-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .posts-grid { grid-template-columns: 1fr; } }
.post-date { margin: 0; color: var(--muted); font-size: 13px; }
.post-excerpt { margin: 10px 0 0; color: var(--muted); font-size: 14.5px; }

/* Covers range from portrait ride photos to a very wide dashboard crop, so cap
   both axes and letterbox rather than crop a photo's subject out of frame. */
.post-hero {
  display: block; width: 100%; max-width: 680px; max-height: 440px;
  object-fit: contain; object-position: center;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); margin: 24px auto 32px 0;
}

.post-body { font-size: 17px; line-height: 1.75; color: var(--text-soft); max-width: 680px; }
.post-body > :first-child { margin-top: 0; }
.post-body p { margin: 0 0 20px; }
.post-body h2 { font-size: 22px; border: 0; padding-top: 0; margin: 40px 0 12px; color: var(--text); }
.post-body h3 { font-size: 17px; margin: 28px 0 8px; color: var(--text); }
.post-body h4 { font-size: 15px; margin: 24px 0 8px; color: var(--text); }
.post-body figure { margin: 28px 0; }
/* Drop cap on the opening paragraph. :first-of-type rather than :first-child so
   a post that opens with an image still gets it on the first real paragraph. */
.post-body > p:first-of-type::first-letter {
  float: left; font-size: 3.4em; line-height: 0.82; font-weight: 800;
  color: var(--text); padding: 4px 10px 0 0; margin-top: 2px;
}
/* Safari lifts the glyph slightly higher than the others do. */
@supports (-webkit-hyphens: none) {
  .post-body > p:first-of-type::first-letter { margin-top: 6px; }
}
.post-body figcaption { font-size: 13px; color: var(--muted); text-align: center; margin-top: 8px; }
.post-body hr { border: 0; border-top: 1px solid var(--border); margin: 36px 0; }
.post-body li { margin-bottom: 6px; }

.post-origin, .post-note {
  max-width: 680px; margin: 40px 0 0; padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 14px; color: var(--muted);
}
.post-origin + .post-note { margin-top: 12px; padding-top: 0; border-top: 0; }
/* ── admin views ── */
.views-range { margin: 0 0 18px; }
.views-range select {
  font: inherit; font-size: 14px; margin-left: 8px; padding: 7px 10px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
}
.views-table { width: 100%; border-collapse: collapse; margin-top: 22px; font-size: 14.5px; }
.views-table th, .views-table td {
  padding: 10px 12px 10px 0; text-align: left; border-bottom: 1px solid var(--border);
}
.views-table th {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); font-weight: 700;
}
.views-table td:nth-child(2), .views-table th:nth-child(2) { text-align: right; white-space: nowrap; }
.views-table td:last-child, .views-table th:last-child { text-align: right; white-space: nowrap; padding-right: 0; }

.post-recs { margin-top: 52px; padding-top: 28px; border-top: 1px solid var(--border); }
/* .doc h2 carries its own rule, which would sit directly under this section's. */
.post-recs h2 { margin: 0 0 18px; font-size: 18px; letter-spacing: -.2px; border-top: 0; padding-top: 0; }
.post-body img { max-width: 100%; border-radius: 10px; }
.post-body pre {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; overflow-x: auto;
}
.post-body code { font-size: 13.5px; }
.post-body blockquote {
  margin: 20px 0; padding-left: 16px; border-left: 3px solid var(--border); color: var(--muted);
}

/* ── admin ── */
.admin-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 8px;
}
.admin-head h1 { margin: 0 0 4px; }
.admin-head .meta { margin: 0; }
.admin-head .btn { flex: 0 0 auto; }

.editing-flag {
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 10px; padding: 10px 14px;
  font-size: 13px; font-weight: 600; color: var(--text);
}

.more { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.more summary {
  cursor: pointer; padding: 12px 16px; font-size: 13px; font-weight: 700;
  color: var(--muted); list-style: none;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: '▸ '; }
.more[open] summary::before { content: '▾ '; }
.more summary:hover { color: var(--text); }
.more-body { display: grid; gap: 14px; padding: 4px 16px 16px; }

/* The social links are a wall of self-promotion if you lead with them. Fold them
   away so the contact form is what people see first. */
.elsewhere { max-width: 720px; }
.elsewhere .more-body { display: flex; flex-wrap: wrap; gap: 10px; }

.save-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--overlay-bg); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 12px 0; margin-top: 4px;
}
.save-bar .form-msg { flex: 1 1 auto; min-height: 0; }
.save-bar .btn { cursor: pointer; }

.form { display: grid; gap: 16px; max-width: 720px; margin: 20px 0 40px; }
.form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form input:not([type=checkbox]):not([type=hidden]), .form textarea {
  font: inherit; font-size: 14.5px; font-weight: 400;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  width: 100%;
}
.form input::placeholder, .form textarea::placeholder { color: var(--muted); opacity: .7; }
.form textarea { resize: vertical; line-height: 1.6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--accent); }
.form .hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.form .check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.form button { justify-self: start; cursor: pointer; }
.form-msg { margin: 0; font-size: 13px; color: var(--muted); min-height: 18px; }

.post-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 10px;
}
.post-row-title { flex: 1 1 200px; font-size: 14.5px; font-weight: 600; }
.post-row .btn { padding: 6px 12px; cursor: pointer; }

/* EasyMDE ships a light theme; pull it into ours. */
.EasyMDEContainer .CodeMirror {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 10px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px;
}
.EasyMDEContainer .CodeMirror-cursor { border-left-color: var(--text); }
.EasyMDEContainer .CodeMirror-selected { background: var(--surface-2); }
.EasyMDEContainer .editor-toolbar {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px 10px 0 0; opacity: 1;
}
.EasyMDEContainer .editor-toolbar button { color: var(--muted); }
.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
  background: var(--surface); border-color: var(--border); color: var(--text);
}
.EasyMDEContainer .editor-toolbar i.separator { border-color: var(--border); }
.EasyMDEContainer .editor-statusbar { color: var(--muted); font-size: 12px; }
.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
  background: var(--bg); color: var(--text-soft); border-color: var(--border);
}
.EasyMDEContainer .editor-preview img,
.EasyMDEContainer .editor-preview-side img { max-width: 100%; border-radius: 8px; }
.EasyMDEContainer .CodeMirror-fullscreen,
.EasyMDEContainer .editor-toolbar.fullscreen { z-index: 20; }

/* honeypot: real people never see it, bots fill it in */
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.contact { margin: 0 0 28px; }

.bulk {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 16px 0; font-size: 13px;
}
.bulk .btn { padding: 6px 12px; cursor: pointer; }
.bulk .btn:disabled { opacity: .45; cursor: not-allowed; }
.post-pick { flex: 0 0 auto; width: 15px; height: 15px; }

.msg {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
}
.msg.is-unread { border-left: 3px solid var(--accent); }
.msg-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 13px; margin-bottom: 8px;
}
.msg-who { font-weight: 700; font-size: 14px; }
.msg-mail { color: var(--accent); }
.msg-when { color: var(--muted); margin-left: auto; }
.msg-head .btn { padding: 5px 10px; cursor: pointer; }
.msg-body { margin: 0; font-size: 14.5px; color: var(--text-soft); white-space: pre-wrap; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 24px 0 8px; }
.stats[hidden] { display: none; }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
}
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr 1fr; } }

/* ── footer ── */
.footer {
  border-top: 1px solid var(--border); padding-top: 32px; padding-bottom: 48px;
  color: var(--muted); font-size: 13.5px;
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--text); text-decoration: none; }

/* ── mobile ── */

/* Nothing should ever push the page sideways. */
img, svg, video { max-width: 100%; }
.post-body pre, .post-body table { max-width: 100%; overflow-x: auto; }
/* Tables carry real content in the build-cost posts. A rule under every row
   turns a long table into a ladder, so the banding does the separating and only
   the header keeps a line. display:block is what lets a wide one scroll. */
.post-body table {
  display: block; width: max-content; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; margin: 28px 0; font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.post-body th, .post-body td { padding: 10px 18px; text-align: left; }
.post-body thead th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--muted); font-weight: 700; white-space: nowrap;
  border-bottom: 1px solid var(--border); padding-bottom: 9px;
}
.post-body tbody tr:nth-child(odd) { background: var(--surface); }
.post-body tbody tr:hover { background: var(--surface-2); }
.post-body tbody td:first-child { border-radius: 8px 0 0 8px; }
.post-body tbody td:last-child { border-radius: 0 8px 8px 0; }
/* Markdown's `---:` alignment lands here; money reads better right-aligned. */
.post-body th[align="right"], .post-body td[align="right"] { text-align: right; }

/* ── enhanced tables: toolbar, chart, sorting ── */
.table-wrap { margin: 28px 0; }
.table-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.table-search {
  font: inherit; font-size: 14px; padding: 7px 12px; min-width: 180px; flex: 0 1 240px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
}
.table-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.table-count { font-size: 12.5px; color: var(--muted); margin-right: auto; }
.table-views { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.view-btn, .table-copy {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 5px 12px; border-radius: 7px; border: 0;
  background: transparent; color: var(--muted);
}
.view-btn.is-active { background: var(--surface-2); color: var(--text); }
.view-btn:hover, .table-copy:hover { color: var(--text); }
.table-copy { border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; }
.table-scroll { overflow-x: auto; }
.post-body tfoot td {
  padding-top: 12px; font-weight: 700; color: var(--text);
  border-top: 1px solid var(--border);
}

/* One measure, one hue — bar length already encodes the size, so tinting by
   value would spend the colour channel on information twice. */
.chart { --chart-name: 215px; }
.chart-plot { display: grid; gap: 4px; }
.chart-row {
  position: relative; display: grid; align-items: center; gap: 14px;
  grid-template-columns: var(--chart-name) 1fr;
  padding: 3px 0; border-radius: 8px;
}
.chart-row:hover, .chart-row:focus-visible { background: var(--surface); outline: none; }
.chart-row:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
/* Component names wrap rather than truncate — an ellipsis hides exactly the
   detail that tells two similar parts apart. */
.chart-name {
  font-size: 13px; color: var(--muted); text-align: right;
  line-height: 1.35; overflow-wrap: break-word;
}
.chart-track { position: relative; display: flex; align-items: center; gap: 10px; min-height: 24px; }
.chart-fill {
  height: 16px; background: var(--accent);
  border-radius: 0 4px 4px 0; min-width: 2px;
}
.chart-value { font-size: 12.5px; color: var(--text-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-tip {
  position: absolute; right: 0; top: -2px; z-index: 2;
  padding: 5px 10px; border-radius: 8px; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-size: 12.5px; font-variant-numeric: tabular-nums;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.chart-row:hover .chart-tip, .chart-row:focus-visible .chart-tip { opacity: 1; }
.chart-note { margin: 16px 0 0; font-size: 12.5px; color: var(--muted); }

@media (max-width: 620px) {
  /* Long component names have nowhere to go beside the bar on a phone. */
  .chart-row { grid-template-columns: 1fr; gap: 2px; padding: 6px 0; }
  .chart-name { text-align: left; white-space: normal; }
  .chart-tip { right: auto; left: 0; top: -4px; }
}

/* Click a header to sort. The button is the whole header so the hit area
   matches what it looks like. */
.post-body th.sortable { padding: 0; }
.post-body th.sortable .sort-btn {
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
  display: inline-flex; align-items: center; gap: 6px; width: 100%;
  padding: 10px 18px 9px; background: none; border: 0; cursor: pointer;
}
.post-body th[align="right"].sortable .sort-btn { justify-content: flex-end; }
.post-body th.sortable .sort-btn:hover { color: var(--text); }
.post-body .sort-caret { opacity: .45; font-size: 11px; }
.post-body th.is-sorted .sort-btn { color: var(--accent); }
.post-body th.is-sorted .sort-caret { opacity: 1; }

@media (max-width: 760px) {
  .wrap, .nav-inner { padding-left: 24px; padding-right: 24px; }

  /* Six links never fit on a phone. Collapse them behind a hamburger. */
  .nav-inner { position: relative; gap: 12px; }
  .nav-toggle { display: inline-flex; }
  .nav-name { flex: 0 0 auto; font-size: 15px; }

  .nav-links {
    display: none;
    position: absolute; top: calc(100% + 1px); left: 0; right: 0;
    flex-direction: column; gap: 0; align-items: stretch;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 6px 24px 14px;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a {
    padding: 14px 0; font-size: 15px;
    border-bottom: 1px solid var(--border);
  }
  .nav-links a:last-child { border-bottom: 0; }

  .hero { padding-top: 48px; padding-bottom: 36px; }
  .hero .lead { font-size: 16.5px; }
  .hero-actions { gap: 10px; margin-top: 22px; }

  .section { padding-top: 40px; padding-bottom: 40px; }
  .section .section-sub { margin-bottom: 22px; }

  .app-card { padding: 18px; gap: 14px; }
  .app-logo { width: 46px; height: 46px; }
  .app-body { flex-basis: 100%; }
  .app-name { font-size: 17px; }
  .sites { grid-template-columns: 1fr; }

  .tabs { display: flex; width: 100%; }
  .tab { flex: 1 1 0; text-align: center; padding: 9px 10px; }

  .about { gap: 18px; }
  .about-photo { width: 100%; max-width: 240px; height: auto; aspect-ratio: 1; }

  .photos { gap: 8px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 19px; }

  /* Buttons get thumb-sized and stop crowding each other. */
  .btn { padding: 10px 16px; }
  .app-links { gap: 8px; }

  .doc { padding-top: 36px; padding-bottom: 56px; }
  .doc h1 { font-size: 26px; }
  .doc h2 { font-size: 18px; margin-top: 32px; padding-top: 22px; }

  .post-body { font-size: 16px; }
  .post-hero { max-height: 300px; margin: 20px 0 26px; }
  .post-card-text { padding: 16px 18px 20px; }

  /* Footer reads better stacked than squeezed onto one line. */
  .footer {
    flex-direction: column; align-items: flex-start; gap: 16px;
    padding-top: 28px; padding-bottom: 40px;
  }
  .footer-links { gap: 14px 18px; }

  /* Admin */
  .form { gap: 14px; }
  .post-row { gap: 8px; padding: 12px 14px; }
  .post-row-title { flex: 1 1 100%; }
  .bulk { gap: 8px; }
  .msg-head { gap: 8px; }
  .msg-when { margin-left: 0; flex: 1 1 100%; order: 3; }
  .EasyMDEContainer .editor-toolbar { flex-wrap: wrap; }
}

@media (max-width: 400px) {
  .wrap, .nav-inner { padding-left: 20px; padding-right: 20px; }
  .stats { grid-template-columns: 1fr; }
  .hero-actions .btn, .contact button { width: 100%; justify-content: center; }
}
