:root {
  color-scheme: dark;
  --hue: 280;
  --accent: hsl(var(--hue), 65%, 68%);
  --accent-dim: hsl(var(--hue), 35%, 45%);
  --accent-bg: hsl(var(--hue), 65%, 68%, .14);
  --accent-fg: hsl(var(--hue), 18%, 8%);
  --bg: hsl(var(--hue), 22%, 7%);
  --bg-elev: hsl(var(--hue), 20%, 11%);
  --bg-elev-2: hsl(var(--hue), 18%, 14%);
  --border: hsl(var(--hue), 16%, 22%);
  --border-dim: hsl(var(--hue), 16%, 17%);
  --fg: #e6e8eb;
  --fg-dim: #a8abb0;
  --fg-mute: #7e8186;
  --ok: hsl(140, 50%, 60%);
  --warn: hsl(35, 80%, 62%);
  --err: hsl(0, 70%, 65%);
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: var(--mono);
  --radius: 4px;
  --ch: 0.6em;
  --avatar-size: 520px;
  --avatar-gap: 2.5rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.mono { font-family: var(--mono); }
.dim { color: var(--fg-dim); }
.mute { color: var(--fg-mute); }
.hl { color: var(--accent); }
.hl-bg { background: var(--accent-bg); color: var(--accent); padding: 0 4px; border-radius: 2px; }

/* ========== intro (homepage lede) ========== */
.intro { display: grid; grid-template-columns: var(--avatar-size) 1fr; gap: var(--avatar-gap); align-items: start; padding: .5rem 0 1rem; }
.intro .avatar { width: var(--avatar-size); height: var(--avatar-size); border-radius: 12px; background: transparent; object-fit: cover; display: block; }
.intro p { margin: 0 0 1.25rem; font-size: 28px; line-height: 1.6; font-weight: 500; }
.intro p:last-child { margin-bottom: 0; }
.intro .who { color: var(--accent); font-weight: 700; }
.hl { font-weight: 700; }
.intro p.dim { color: var(--fg-dim); font-size: 22px; }
@media (max-width: 900px) {
  :root { --avatar-size: 280px; --avatar-gap: 1.5rem; }
}
@media (max-width: 640px) {
  .intro { grid-template-columns: 1fr; gap: 1rem; justify-items: center; text-align: left; }
  .intro > div { width: 100%; }
  .intro .avatar { width: 240px; height: 240px; margin: 0 auto; }
  .intro p { font-size: 22px; }
  .intro p.dim { font-size: 18px; }
}

/* ========== top status bar ========== */
.statusbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: .55rem 1.25rem;
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}
.statusbar .sb-host::before { content: "▌ "; opacity: .6; }
.statusbar .sb-sep { opacity: .45; }
.statusbar .sb-right { margin-left: auto; display: flex; gap: 1rem; }
.statusbar .sb-blink::after { content: "█"; animation: blink 1.1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* ========== nav ========== */
nav.tabs {
  display: flex;
  gap: 0;
  align-items: stretch;
  padding: 0 1.25rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  overflow-x: auto;
  text-transform: uppercase;
  letter-spacing: .04em;
}
nav.tabs .host {
  display: inline-flex;
  align-items: center;
  padding: .85rem 1.4rem .85rem 0;
  margin-right: 0;
  color: var(--accent);
  text-transform: lowercase;
  letter-spacing: 0;
  font-weight: 700;
  white-space: nowrap;
  border-right: none;
  text-decoration: none;
}
nav.tabs a.host:hover { background: transparent; color: var(--accent); text-decoration: none; }
nav.tabs .host::before { content: "▌ "; opacity: .8; }
nav.tabs a {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem 1.1rem;
  color: var(--fg);
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  text-decoration: none;
}
nav.tabs a:hover { color: var(--accent); text-decoration: none; background: var(--bg-elev-2); }
nav.tabs a.on {
  color: var(--accent-fg);
  background: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}
nav.tabs a.on::before { content: "› "; opacity: .7; }
nav.tabs a .key { color: var(--fg-mute); font-size: 11px; }
nav.tabs .right { margin-left: auto; display: flex; align-items: center; gap: .75rem; padding: .35rem 0; }

/* hue slider in nav */
.hue-control {
  display: flex; align-items: center; gap: .65rem;
  font-family: var(--mono); font-size: 16px; font-weight: 500; color: var(--fg-dim);
  text-transform: lowercase; letter-spacing: 0;
}
.hue-control b { font-weight: 700; }
.hue-control input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 140px; height: 8px;
  background: linear-gradient(to right,
    hsl(0,70%,55%), hsl(60,70%,55%), hsl(120,70%,55%),
    hsl(180,70%,55%), hsl(240,70%,55%), hsl(300,70%,55%), hsl(360,70%,55%));
  border-radius: 999px; outline: none; cursor: pointer;
}
.hue-control input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}
.hue-control input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
}
.hue-control b { color: var(--accent); font-weight: 500; min-width: 3.2ch; text-align:right; }

/* ========== main layout ========== */
main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
/* let flex/grid children shrink below their content's intrinsic width, so
   wide code blocks scroll internally instead of widening the whole page */
main > * { min-width: 0; }

/* section spacing */
.panel { margin-top: 4rem; }
.panel:first-of-type { margin-top: 3rem; }
@media (max-width: 640px) { .panel, .panel:first-of-type { margin-top: 2.5rem; } }

/* ========== section (bare TUI rule, no box) ========== */
.panel { background: transparent; border: none; border-radius: 0; position: relative; margin: 1.25rem 0 0; }
.panel:first-child { margin-top: 0; }
.panel > .panel-title {
  position: static;
  display: flex;
  align-items: center;
  gap: .65rem;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--fg-dim);
  white-space: nowrap;
  padding: 0;
  background: transparent;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.panel > .panel-title::before { content: "──"; color: var(--border); }
.panel > .panel-title::after {
  content: "";
  flex: 1;
  border-top: 2px solid var(--border);
  margin-left: .4rem;
}
.panel > .panel-title .acc { color: var(--accent); }
.panel > .panel-body { padding: 1rem 0 0; }

/* ========== hero (avatar + bio) ========== */
.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .85rem;
  align-items: center;
  padding: .35rem 0 .25rem;
}
.hero .avatar {
  width: 64px; height: 64px;
  border-radius: 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  padding: 4px;
  flex-shrink: 0;
}
.hero h1 {
  margin: 0 0 .15rem;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}
.hero h1::before { content: "▌ "; color: var(--accent); }
.hero h1 .at { color: var(--accent); font-weight: 500; }
.hero .tagline { margin: 0; color: var(--fg-dim); font-size: 13px; }
.hero .tagline::before { content: "# "; color: var(--fg-mute); }
.hero .meta-row {
  margin-top: .5rem;
  font-size: 12px;
  color: var(--fg-mute);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.hero .meta-row .ok { color: var(--ok); }
.hero .meta-row b { color: var(--fg-dim); font-weight: 500; }

/* ========== filters ========== */
.filters {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  padding: .5rem 0;
}
.filters .group { display: flex; align-items: center; gap: .75rem; }
.filters label { color: var(--fg-dim); font-size: 18px; font-weight: 500; }
.filters input[type=range] { width: 160px; height: 8px; accent-color: var(--accent); }
.filters .val { color: var(--accent); min-width: 4ch; font-weight: 700; }
.chip {
  display: inline-block;
  padding: .15rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--fg);
  cursor: pointer;
  user-select: none;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { color: var(--fg); border-color: var(--accent-dim); }
.chip.on {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 700;
}
.chip .hash { opacity: .55; margin-right: 2px; }

/* ========== post list ========== */
.posts { display: flex; flex-direction: column; }
.post-row {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  gap: 1.25rem;
  padding: .25rem .35rem;
  border-bottom: none;
  align-items: baseline;
  transition: background .15s;
  animation: fadeUp .25s ease-out both;
}
.post-row:last-child { border-bottom: none; }
.post-row:hover { background: var(--accent-bg); }
.post-row.hidden { display: none; }
.post-row .date { font-family: var(--mono); font-size: 22px; color: var(--fg-dim); font-weight: 500; }
.post-row .body { display: flex; align-items: baseline; gap: .85rem; flex-wrap: wrap; }
.post-row .body h3 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: 0; display: inline; }
.post-row .body h3::before { content: "› "; color: var(--accent); font-weight: 600; }
.post-row .body h3 a { color: var(--fg); }
.post-row .body h3 a:hover { color: var(--accent); text-decoration: none; }
.post-row:hover .body h3::before { content: "» "; }
.post-row .body .sum { display: none; }
.post-row .tags-inline { display: none; }
.post-row .body .tags { display: none; }
.post-row .body .tags a { color: var(--accent-dim); }
.post-row .body .tags a::before { content: "#"; opacity: .6; }
.post-row .body .tags a:hover { color: var(--accent); }
.post-row .read { font-family: var(--mono); font-size: 22px; color: var(--accent); font-weight: 600; white-space: nowrap; }

/* ========== rows (projects, elsewhere) ========== */
.row {
  display: grid;
  grid-template-columns: 320px 1fr auto;
  gap: 1.25rem;
  padding: .2rem .35rem;
  align-items: baseline;
  border-bottom: none;
  font-size: 22px;
}
.row.project .val { white-space: nowrap; overflow: visible; }
@media (max-width: 900px) { .row.project .val { white-space: normal; } }
.row:hover { background: var(--accent-bg); }
.row .key { color: var(--accent); font-weight: 700; }
.row .val { color: var(--fg); font-weight: 500; }
.row .val.mono { font-family: var(--mono); font-size: 18px; word-break: break-all; }
.row .ext { color: var(--fg-dim); font-size: 18px; font-weight: 500; white-space: nowrap; }
.row, .row a { color: var(--fg); text-decoration: none; }
.row:hover, .row:hover *, .row a:hover { text-decoration: none; }
.row:hover .key, .row a:hover { color: var(--accent); }
.row .copy {
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg-dim);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
  padding: .15rem .65rem;
  margin-left: .5rem;
}
.row .copy:hover { border-color: var(--accent); color: var(--accent); }
.row .copy.ok { color: var(--accent); border-color: var(--accent); }

@media (max-width: 640px) {
  .row { grid-template-columns: 120px 1fr; font-size: 18px; }
  .row .ext { grid-column: 1 / -1; }
  .row .val.mono { font-size: 16px; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ========== cast / asciinema-style player ========== */
.cast {
  background: #000;
  border-radius: var(--radius);
  padding: .65rem .85rem .85rem;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: #cfd2d6;
  min-height: 200px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
.cast .cast-header {
  display: flex; align-items: center; gap: .5rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid #1a1c1f;
  margin-bottom: .55rem;
  font-size: 11px;
  color: var(--fg-mute);
}
.cast .cast-header .dots { display: flex; gap: 4px; }
.cast .cast-header .dot { width: 10px; height: 10px; border-radius: 50%; background: #2a2c30; }
.cast .cast-header .dot.r { background: hsl(0, 60%, 55%); }
.cast .cast-header .dot.y { background: hsl(40, 70%, 55%); }
.cast .cast-header .dot.g { background: hsl(140, 50%, 55%); }
.cast .cast-header .name { margin-left: .25rem; }
.cast .cast-header .right { margin-left: auto; display: flex; gap: .55rem; }
.cast .cast-header button {
  font-family: var(--mono); font-size: 11px;
  background: transparent; color: var(--fg-dim);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 1px 7px; cursor: pointer;
}
.cast .cast-header button:hover { color: var(--accent); border-color: var(--accent-dim); }
.cast .cast-body { white-space: pre-wrap; word-break: break-word; }
.cast .prompt { color: var(--accent); }
.cast .ok { color: var(--ok); }
.cast .warn { color: var(--warn); }
.cast .com { color: var(--fg-mute); }
.cast .cursor { display: inline-block; width: 8px; height: 1em; background: var(--accent); vertical-align: text-bottom; animation: blink 1.1s steps(1) infinite; }

/* ========== modeline (footer) ========== */
.modeline {
  display: flex; gap: 1rem; align-items: center;
  padding: .35rem 1rem;
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
.modeline .mode {
  background: var(--accent-fg);
  color: var(--accent);
  padding: 0 .55rem;
  border-radius: 2px;
  letter-spacing: .04em;
}
.modeline .right { margin-left: auto; display: flex; gap: 1rem; opacity: .85; }

/* ========== post page ========== */
article.post {
  max-width: 820px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  font-size: 22px;
  line-height: 1.65;
}
article.post header.post-head {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
article.post header.post-head h1 {
  font-size: 40px; font-weight: 700; letter-spacing: 0;
  margin: 0 0 .65rem; line-height: 1.2;
  color: var(--fg);
}
article.post header.post-head .meta {
  font-family: var(--mono); font-size: 18px; color: var(--fg-dim);
  display: flex; gap: 1.25rem; flex-wrap: wrap;
}
article.post header.post-head .meta b { color: var(--accent); font-weight: 600; margin-right: .35rem; }
article.post p { margin: 0 0 1.25rem; }
article.post h2 { font-size: 30px; margin: 2.75rem 0 1rem; font-weight: 700; letter-spacing: 0; line-height: 1.25; color: var(--accent); }
article.post h3 { font-size: 24px; margin: 2rem 0 .65rem; font-weight: 600; letter-spacing: 0; color: var(--accent-dim); }
article.post pre {
  background: #000;
  border-left: 2px solid var(--accent);
  border-radius: 3px;
  padding: .85rem 1.1rem;
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1.5;
  overflow-x: auto;
  margin: 0 0 1.25rem;
}
article.post code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--bg-elev-2);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--accent);
}
article.post pre code { background: transparent; padding: 0; color: inherit; font-size: inherit; }

/* images scale to the column / viewport */
article.post img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
article.post p > img { margin: .25rem 0; }
/* prevent long inline code / URLs from forcing horizontal scroll */
article.post p, article.post li { overflow-wrap: break-word; }

/* syntax tokens (pre-rendered by build script) */
article.post pre .tok-kw  { color: hsl(var(--hue), 60%, 75%); font-weight: 700; }
article.post pre .tok-str { color: hsl(140, 45%, 65%); }
article.post pre .tok-cm  { color: var(--fg-mute); font-style: italic; }
article.post pre .tok-num { color: hsl(30, 65%, 65%); }
article.post pre .tok-prompt { color: var(--accent); }
article.post blockquote {
  border-left: 2px solid var(--accent-dim);
  margin: 1.25rem 0; padding: 0 1.25rem;
  color: var(--fg-dim);
}
article.post ul, article.post ol { list-style: none; padding-left: 0; margin: 0 0 1.25rem; }
article.post ul > li, article.post ol > li {
  padding-left: 2.5rem;
  position: relative;
  margin-bottom: .35rem;
}
article.post ul > li::before {
  content: "›";
  position: absolute;
  left: .25rem;
  color: var(--accent);
  font-weight: 700;
}
article.post ol { counter-reset: poly-ol; }
article.post ol > li {
  counter-increment: poly-ol;
}
article.post ol > li::before {
  content: counter(poly-ol) ".";
  position: absolute;
  left: 0;
  width: 2rem;
  text-align: right;
  color: var(--accent);
  font-weight: 700;
}

/* tables */
article.post table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.5rem;
  font-size: 18px;
  display: block;
  overflow-x: auto;
}
article.post thead { background: var(--bg-elev); }
article.post th {
  text-align: left;
  padding: .55rem .85rem;
  border-bottom: 2px solid var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-size: 15px;
  white-space: nowrap;
}
article.post td {
  padding: .5rem .85rem;
  border-bottom: 1px solid var(--border-dim);
  vertical-align: top;
}
article.post tbody tr:last-child td { border-bottom: none; }
article.post tbody tr:hover { background: var(--accent-bg); }
article.post .post-foot {
  margin-top: 3rem; padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 18px;
  gap: 1rem; flex-wrap: wrap;
}
article.post .post-foot .tags { display: flex; gap: .65rem; flex-wrap: wrap; }
article.post .post-foot .tags a { color: var(--accent); opacity: .7; }

@media (max-width: 640px) {
  article.post { font-size: 18px; }
  article.post header.post-head h1 { font-size: 28px; }
  article.post h2 { font-size: 22px; }
  article.post h3 { font-size: 19px; }
  article.post header.post-head .meta { font-size: 14px; gap: .85rem; }
  article.post pre { font-size: 15px; }
  article.post .post-foot { font-size: 14px; }
}

/* ========== tags page ========== */
.tag-cloud { display: flex; gap: .6rem; flex-wrap: wrap; }
.tag-cloud a {
  font-family: var(--mono);
  padding: .3rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  color: var(--fg);
  font-size: 13px;
}
.tag-cloud a::before { content: "#"; color: var(--accent); margin-right: 2px; }
.tag-cloud a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.tag-cloud a .count { color: var(--fg-mute); margin-left: .35rem; font-size: 11px; }

/* ========== about page ========== */
.about-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.about-grid .about-avatar {
  width: 160px; height: 160px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}
.about-grid h1 { margin: 0 0 .5rem; font-size: 20px; font-weight: 700; }
.about-grid h1::before { content: "# "; color: var(--accent); font-weight: 400; }
.about-grid .id-card {
  font-family: var(--mono); font-size: 13px;
  background: var(--bg-elev-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: .75rem 1rem;
  margin: 1rem 0;
}
.about-grid .id-card div { display: flex; gap: .65rem; }
.about-grid .id-card .k { color: var(--fg-mute); min-width: 8ch; }
.about-grid .id-card .v { color: var(--fg); }
.about-grid .id-card .v.acc { color: var(--accent); }

/* ========== responsive ========== */
@media (max-width: 640px) {
  .statusbar { font-size: 11px; gap: .55rem; }
  .statusbar .sb-right { gap: .55rem; }
  nav.tabs { font-size: 12px; padding: 0 .5rem; }
  nav.tabs a { padding: .5rem .55rem; }
  .hue-control input[type=range] { width: 80px; }
  main { padding: 1rem .65rem 1.5rem; }
  .post-row { grid-template-columns: 1fr; gap: .15rem; }
  .post-row .date { font-size: 11px; }
  .post-row .read { display: none; }
  .hero { grid-template-columns: 1fr; text-align: left; }
  .hero .avatar { width: 64px; height: 64px; }
  .about-grid { grid-template-columns: 1fr; }
  .about-grid .about-avatar { width: 120px; height: 120px; }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .post-row, .cast .cursor, .statusbar .sb-blink::after { animation: none !important; }
}

/* mobile: drop the date + inline tags, keep title + duration */
@media (max-width: 640px) {
  .post-row { grid-template-columns: 1fr auto; gap: .85rem; }
  .post-row .date { display: none; }
  .post-row .tags-inline { display: none; }
  .post-row .body h3 { font-size: 20px; }
  .post-row .read { font-size: 18px; }
}
