/* ============================================================
   bloggen — Neovim Buffer Theme (Tokyo Night)
   ============================================================ */

/* Self-host JetBrains Mono so the ASCII-art header (and code blocks)
   render with proper box-drawing-char widths on every device — Android's
   system monospace doesn't always advance ╗ ║ ═ at the same width as
   ASCII, which makes the banner look "wavy". */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/static/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:           #1a1b26;
  --bg-dark:      #16161e;
  --bg-highlight: #292e42;
  --bg-float:     #1f2335;
  --fg:           #c0caf5;
  --fg-dark:      #565f89;
  --fg-gutter:    #3b4261;
  --blue:         #7aa2f7;
  --cyan:         #7dcfff;
  --green:        #9ece6a;
  --magenta:      #bb9af7;
  --orange:       #ff9e64;
  --red:          #f7768e;
  --teal:         #2ac3de;
  --yellow:       #e0af68;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', ui-monospace, monospace;
  --font-size: 15px;
  --line-height: 1.7;
  --tabline-h: 38px;
  --statusline-h: 28px;
  --content-max: 72rem;
  --gutter-w: 3.5rem;
}

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

html {
  font-size: var(--font-size);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  line-height: var(--line-height);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* === Tabline === */
#tabline {
  display: flex;
  align-items: stretch;
  height: var(--tabline-h);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--fg-gutter);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

#tabline::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 1rem;
  font-size: 0.85rem;
  color: var(--fg-dark);
  text-decoration: none;
  border-right: 1px solid var(--fg-gutter);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
  position: relative;
}

.tab:hover {
  color: var(--fg);
  background: var(--bg-highlight);
}

.tab.active {
  color: var(--fg);
  background: var(--bg);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--blue);
}

.tab-mod {
  color: var(--green);
  font-size: 0.6rem;
}

.tab-icon {
  font-size: 0.85rem;
}

.tab-fill {
  flex: 1;
  background: var(--bg-dark);
  border-bottom: none;
}

#theme-toggle {
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-left: 1px solid var(--fg-gutter);
  color: var(--fg-dark);
  cursor: pointer;
  padding: 0 0.9rem;
  font-size: 0.95rem;
  line-height: 1;
  display: flex;
  align-items: center;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
}
#theme-toggle:hover {
  color: var(--fg);
  background: var(--bg-highlight);
}

/* === Editor === */
#editor {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-gutter) var(--bg);
}

#editor::-webkit-scrollbar { width: 8px; }
#editor::-webkit-scrollbar-track { background: var(--bg); }
#editor::-webkit-scrollbar-thumb { background: var(--fg-gutter); border-radius: 4px; }

#content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.5rem 2rem;
  min-height: 100%;
}

/* Post list / tag pages / about: wider on desktop so long titles don't cram */
#content.netrw,
#content.about {
  max-width: 96rem;
}

/* === Statusline (lualine-inspired) === */
#statusline {
  display: flex;
  align-items: center;
  height: var(--statusline-h);
  background: var(--bg-dark);
  border-top: 1px solid var(--fg-gutter);
  flex-shrink: 0;
  font-size: 0.78rem;
  overflow: hidden;
}

.stl-section {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  height: 100%;
  white-space: nowrap;
}

.stl-mode {
  background: var(--blue);
  color: var(--bg-dark);
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0 1rem;
}

.stl-branch {
  background: var(--bg-highlight);
  color: var(--magenta);
}

.stl-icon {
  margin-right: 0.3rem;
}

.stl-file {
  background: var(--bg-highlight);
  color: var(--fg);
}

.stl-spacer {
  flex: 1;
  background: var(--bg-dark);
}

.stl-encoding {
  color: var(--fg-dark);
}

.stl-filetype {
  color: var(--cyan);
}

.stl-pos {
  background: var(--blue);
  color: var(--bg-dark);
  font-weight: 700;
  padding: 0 1rem;
}

/* === Netrw (Index Page) === */
.netrw {
  padding-top: 2rem;
}

.netrw-header {
  margin-bottom: 1.5rem;
}

.ascii-art {
  color: var(--magenta);
  font-family: 'JetBrains Mono', var(--font-mono);
  font-size: 1rem;
  line-height: 1.15;
  margin-bottom: 1rem;
  user-select: none;
  overflow: hidden;
  text-align: center;
}

.netrw-comment {
  color: var(--fg-dark);
  font-style: italic;
  padding: 0.1rem 0;
  font-size: 0.9rem;
  text-align: center;
}

.netrw-comment kbd {
  display: inline-block;
  background: var(--bg-highlight);
  color: var(--yellow);
  border: 1px solid var(--fg-gutter);
  border-radius: 3px;
  padding: 0 0.35rem;
  font-size: 0.75rem;
  font-style: normal;
  font-family: var(--font-mono);
}

.netrw-separator {
  border-bottom: 1px solid var(--fg-gutter);
  margin: 0.25rem 0;
}

.netrw-entries {
  margin: 0.5rem 0;
}

.netrw-section {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  margin-top: 1.5rem;
  border-bottom: 1px solid var(--fg-gutter);
}
.netrw-section:first-child { margin-top: 0.5rem; }
.netrw-section-icon { font-size: 0.95rem; }
.netrw-section-name {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
  color: var(--cyan);
}
.netrw-section-series .netrw-section-name { color: var(--magenta); }
.netrw-section-meta {
  color: var(--fg-dark);
  font-size: 0.78rem;
  font-style: italic;
}
.netrw-section-count {
  margin-left: auto;
  color: var(--fg-dark);
  font-size: 0.78rem;
}

.netrw-entry {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 0.5rem;
  text-decoration: none;
  color: var(--fg);
  border-radius: 4px;
  transition: background 0.12s;
}

.netrw-entry:hover {
  background: var(--bg-highlight);
}

.netrw-icon {
  flex-shrink: 0;
  width: 1.5rem;
  text-align: center;
}

.netrw-date {
  color: var(--fg-dark);
  flex-shrink: 0;
  font-size: 0.88rem;
}

.netrw-title {
  color: var(--blue);
  flex: 1;
  font-size: 0.95rem;
  min-width: 0;
}

.netrw-entry:hover .netrw-title {
  color: var(--cyan);
}

.netrw-meta {
  color: var(--fg-dark);
  font-size: 0.8rem;
  flex-shrink: 0;
}


/* === Post === */
.post {
  padding-bottom: 3rem;
}

.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--fg-gutter);
}

.post-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--magenta);
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.meta-item {
  color: var(--fg-dark);
}

.meta-date { color: var(--green); }
.meta-sep { color: var(--fg-gutter); }

/* === Tags === */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
}

.post-tags-label {
  color: var(--fg-gutter);
  font-style: italic;
  margin-right: 0.25rem;
}

.tag-pill {
  display: inline-block;
  background: var(--bg-highlight);
  color: var(--cyan);
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  text-decoration: none;
  border: 1px solid var(--fg-gutter);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  cursor: pointer;
  white-space: nowrap;
}

.tag-pill:hover {
  background: var(--bg-float);
  color: var(--blue);
  border-color: var(--blue);
}

.tag-pill.tag-series {
  color: var(--magenta);
  border-color: rgba(187, 154, 247, 0.4);
}

.tag-pill.tag-series:hover {
  color: var(--magenta);
  border-color: var(--magenta);
}

.tag-pill.tag-active {
  background: var(--blue);
  color: var(--bg-dark);
  border-color: var(--blue);
}

.tag-pill.tag-active.tag-series {
  background: var(--magenta);
  border-color: var(--magenta);
}

/* === Tag pills as LSP diagnostics (left-bar accent only) === */
.tag-pill.tag-diag {
  border-radius: 2px;
  border-left: 3px solid;
}
/* Severity colors map to vim-style diagnostic signs */
.tag-pill.tag-diag-e             { border-left-color: var(--red);       color: var(--red); }
.tag-pill.tag-diag-w             { border-left-color: var(--yellow);    color: var(--yellow); }
.tag-pill.tag-diag-i             { border-left-color: var(--blue);      color: var(--cyan); }
.tag-pill.tag-diag-h             { border-left-color: var(--fg-gutter); color: var(--fg-dark); }
.tag-pill.tag-diag:hover         { background: var(--bg-float); }
.tag-pill.tag-diag.tag-active    { background: var(--bg-highlight); }

.netrw-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex-shrink: 1;
  min-width: 0;
}

.netrw-entry .tag-pill {
  font-size: 0.68rem;
  padding: 0 0.35rem;
}

.netrw-entry .tag-label {
  color: var(--cyan);
  font-weight: 700;
  flex: 1;
}

.netrw-entry .tag-label.tag-series {
  color: var(--magenta);
}

/* === Series Navigation (quickfix-style) === */
.series-nav {
  background: var(--bg-dark);
  border: 1px solid var(--fg-gutter);
  border-radius: 6px;
  margin-top: 0.75rem;
  overflow: hidden;
}

.series-header {
  padding: 0.4rem 0.75rem;
  background: var(--bg-highlight);
  color: var(--magenta);
  font-size: 0.82rem;
  font-weight: 700;
  border-bottom: 1px solid var(--fg-gutter);
}

.series-entries {
  padding: 0.25rem 0;
}

.series-entry {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  text-decoration: none;
  color: var(--fg-dark);
  font-size: 0.82rem;
  transition: background 0.12s;
}

.series-entry:hover {
  background: var(--bg-highlight);
}

.series-entry.series-current {
  color: var(--fg);
  background: var(--bg-highlight);
}

.series-marker {
  color: var(--magenta);
  font-weight: 700;
  width: 1ch;
  flex-shrink: 0;
}

.series-part {
  color: var(--fg-gutter);
  width: 2ch;
  text-align: right;
  flex-shrink: 0;
}

.series-current .series-part {
  color: var(--magenta);
}

.series-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.series-current .series-title {
  color: var(--blue);
}

.series-date {
  color: var(--fg-gutter);
  flex-shrink: 0;
  font-size: 0.78rem;
}

.series-current .series-date {
  color: var(--fg-dark);
}

/* Series part numbers on tag pages */
.series-part-num {
  color: var(--magenta);
  font-weight: 700;
  flex-shrink: 0;
  width: 2ch;
  text-align: right;
}

/* === TOC (vim fold style) === */
.toc {
  margin: 0.5rem 0 0.5rem 0;
  font-size: 0.85rem;
}

.toc details summary {
  cursor: pointer;
  color: var(--fg-gutter);
  font-family: inherit;
  list-style: none;
}

.toc details summary::before {
  content: '▸ ';
  color: var(--yellow);
}

.toc details[open] summary::before {
  content: '▾ ';
  color: var(--yellow);
}

.toc details summary:hover {
  color: var(--fg-dark);
}

.toc ul {
  list-style: none;
  padding: 0.3rem 0 0 0;
  margin: 0;
}

.toc li {
  padding: 0.15rem 0;
}

.toc li::before {
  content: '· ';
  color: var(--fg-gutter);
}

.toc li.toc-h3 {
  padding-left: 1.2rem;
}

.toc li.toc-h3::before {
  content: '└ ';
  color: var(--fg-gutter);
}

.toc a {
  color: var(--blue);
  text-decoration: none;
}

.toc a:hover {
  color: var(--cyan);
  text-decoration: underline;
}

/* === Post Body === */
.post-body > * {
  margin-bottom: 1rem;
}

/* Colored left accent for headings */
.post-body > h2 {
  color: var(--blue);
  font-size: 1.3rem;
  margin-top: 2rem;
  padding: 1rem 0 0 0.75rem;
  border-top: 1px solid var(--fg-gutter);
  border-left: 3px solid var(--blue);
}

.post-body > h3 {
  color: var(--cyan);
  font-size: 1.1rem;
  margin-top: 1.5rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--magenta);
}

.post-body > h4 {
  color: var(--green);
  font-size: 1rem;
  margin-top: 1rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--green);
}

/* Links */
.post-body a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.post-body a:hover {
  border-bottom-color: var(--cyan);
}

/* Bold / italic */
.post-body strong { color: var(--fg); font-weight: 700; }
.post-body em { color: var(--fg-dark); font-style: italic; }

/* Images */
.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--fg-gutter);
  margin: 0.5rem 0;
  transition: border-color 0.2s;
}

.post-body img:hover {
  border-color: var(--blue);
}

/* Lists */
.post-body ul, .post-body ol {
  padding-left: 1.5rem;
}

.post-body ul { list-style-type: '❯ '; }
.post-body li { margin-bottom: 0.3rem; }
.post-body li::marker { color: var(--magenta); }

/* Blockquotes */
.post-body blockquote {
  border-left: 3px solid var(--blue);
  background: var(--bg-dark);
  padding: 0.75rem 1rem 0.75rem 1rem;
  border-radius: 0 4px 4px 0;
  color: var(--fg-dark);
  font-style: italic;
}

/* Inline code */
.post-body code {
  background: var(--bg-highlight);
  color: var(--teal);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Tables */
.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.post-body th {
  background: var(--bg-highlight);
  color: var(--blue);
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--fg-gutter);
}

.post-body td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--fg-gutter);
}

/* Horizontal rules */
.post-body hr {
  border: none;
  border-top: 1px solid var(--fg-gutter);
  margin: 2rem 0;
}

/* === Code Blocks === */
.code-block {
  background: var(--bg-dark);
  border: 1px solid var(--fg-gutter);
  border-radius: 6px;
  overflow: hidden;
  margin: 1rem 0;
}

/* === Code-block winbar (Neovim-style) === */
.code-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: linear-gradient(to bottom, var(--bg-highlight), var(--bg-dark));
  border-bottom: 1px solid var(--fg-gutter);
  font-size: 0.78rem;
}

.code-icon {
  color: var(--orange, var(--yellow));
  font-size: 0.85rem;
  flex-shrink: 0;
}

.code-lang {
  color: var(--yellow);
  font-weight: 700;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.code-sep {
  color: var(--fg-gutter);
  flex-shrink: 0;
  user-select: none;
}

.code-context {
  color: var(--fg-dark);
  font-size: 0.72rem;
  flex-shrink: 0;
}

.code-spacer {
  flex: 1;
}

.code-yank {
  background: none;
  border: 1px solid var(--fg-gutter);
  color: var(--fg-dark);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.code-yank:hover {
  color: var(--green);
  border-color: var(--green);
}

.code-yank-done {
  color: var(--green) !important;
  border-color: var(--green) !important;
}

.code-block pre {
  margin: 0;
  padding: 0.5rem 0;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-gutter) var(--bg-dark);
}

.code-block code {
  background: none;
  color: var(--fg);
  padding: 0;
  border-radius: 0;
  font-size: 0.88rem;
  line-height: 1.6;
}

.code-line {
  display: flex;
  padding: 0 0.75rem 0 0;
  min-height: 1.6em;
}

.code-line:hover {
  background: var(--bg-highlight);
}

.code-ln {
  flex-shrink: 0;
  width: 3rem;
  text-align: right;
  padding-right: 0.75rem;
  margin-right: 0.75rem;
  color: var(--fg-gutter);
  border-right: 1px solid var(--fg-gutter);
  user-select: none;
  font-size: 0.8rem;
}

/* === Syntax Highlighting (Tokyo Night) === */
/* All classes appear on the same span (e.g. "hl-string hl-quoted hl-rust"),
   so we use compound selectors (no spaces) to target combinations. */

/* Comments */
.hl-comment { color: var(--fg-dark); font-style: italic; }
.hl-punctuation.hl-definition.hl-comment { color: var(--fg-dark); font-style: italic; }

/* Strings */
.hl-string { color: var(--green); }
.hl-string.hl-regexp { color: var(--cyan); }
.hl-punctuation.hl-definition.hl-string { color: var(--green); }
.hl-string.hl-template { color: var(--green); }
.hl-constant.hl-character.hl-escape { color: var(--magenta); }

/* Constants (numbers, true/false/null, language constants) */
.hl-constant { color: var(--orange); }
.hl-constant.hl-numeric { color: var(--orange); }
.hl-constant.hl-language { color: var(--orange); font-weight: 600; }
.hl-constant.hl-other { color: var(--orange); }

/* Keywords */
.hl-keyword { color: var(--magenta); }
.hl-keyword.hl-control { color: var(--magenta); }
.hl-keyword.hl-other { color: var(--magenta); }
.hl-keyword.hl-operator { color: var(--cyan); }
.hl-keyword.hl-operator.hl-assignment { color: var(--cyan); }
.hl-keyword.hl-operator.hl-comparison { color: var(--cyan); }
.hl-keyword.hl-operator.hl-arithmetic { color: var(--cyan); }
.hl-keyword.hl-operator.hl-logical { color: var(--cyan); }

/* Storage (let/const/var/type modifiers like pub/static/mut) */
.hl-storage { color: var(--magenta); }
.hl-storage.hl-type { color: var(--cyan); }
.hl-storage.hl-modifier { color: var(--magenta); }
.hl-storage.hl-class { color: var(--magenta); }

/* Entity names (functions, types, classes) */
.hl-entity.hl-name.hl-function { color: var(--blue); }
.hl-entity.hl-name.hl-type,
.hl-entity.hl-name.hl-class,
.hl-entity.hl-name.hl-struct,
.hl-entity.hl-name.hl-trait,
.hl-entity.hl-name.hl-enum,
.hl-entity.hl-name.hl-namespace,
.hl-entity.hl-name.hl-module { color: var(--yellow); }
.hl-entity.hl-name.hl-tag { color: var(--magenta); }
.hl-entity.hl-name.hl-macro { color: var(--cyan); }
.hl-entity.hl-name.hl-label { color: var(--orange); }
.hl-entity.hl-other.hl-attribute-name { color: var(--green); }
.hl-entity.hl-other.hl-inherited-class { color: var(--yellow); }

/* Variables */
.hl-variable { color: var(--fg); }
.hl-variable.hl-parameter { color: var(--orange); }
.hl-variable.hl-function { color: var(--blue); }
.hl-variable.hl-language { color: var(--magenta); }
.hl-variable.hl-other.hl-member { color: var(--fg); }

/* Support (builtins, std types/functions) */
.hl-support { color: var(--cyan); }
.hl-support.hl-function { color: var(--cyan); }
.hl-support.hl-type,
.hl-support.hl-class { color: var(--yellow); }
.hl-support.hl-constant { color: var(--orange); }
.hl-support.hl-macro { color: var(--cyan); font-weight: 600; }

/* Punctuation — mostly default, but accents on string delimiters */
.hl-punctuation { color: var(--fg); }
.hl-punctuation.hl-section.hl-block,
.hl-punctuation.hl-section.hl-group,
.hl-punctuation.hl-section.hl-brackets { color: var(--fg-dark); }
.hl-punctuation.hl-separator { color: var(--fg-dark); }
.hl-punctuation.hl-terminator { color: var(--fg-dark); }
.hl-punctuation.hl-accessor { color: var(--cyan); }

/* Meta (annotations, attributes, decorators) */
.hl-meta.hl-attribute { color: var(--yellow); }
.hl-meta.hl-annotation { color: var(--yellow); }
.hl-meta.hl-decorator { color: var(--yellow); }

/* Markdown */
.hl-markup.hl-bold { color: var(--orange); font-weight: 700; }
.hl-markup.hl-italic { color: var(--orange); font-style: italic; }
.hl-markup.hl-heading { color: var(--magenta); font-weight: 700; }
.hl-markup.hl-list { color: var(--blue); }
.hl-markup.hl-quote { color: var(--fg-dark); font-style: italic; }
.hl-markup.hl-raw { color: var(--green); }
.hl-markup.hl-underline.hl-link { color: var(--cyan); text-decoration: underline; }

/* Shell-specific — keep mostly default fg; the ❯❯❯ prompt is the visual
   anchor for "this is a command" so we don't need to colour the command
   name itself (the bash parser also tags every line's first word as a
   command, including output lines). */
.hl-variable.hl-function.hl-shell { color: inherit; }
.hl-meta.hl-function-call.hl-shell { color: inherit; }
.hl-meta.hl-function-call.hl-arguments.hl-shell { color: inherit; }
.hl-variable.hl-parameter.hl-option { color: var(--orange); }
.hl-keyword.hl-operator.hl-assignment.hl-redirection { color: var(--red); }
.hl-keyword.hl-operator.hl-end-of-options { color: var(--red); }
.hl-string.hl-unquoted.hl-shell { color: inherit; }

/* YAML / TOML */
.hl-entity.hl-name.hl-tag.hl-yaml { color: var(--cyan); }
.hl-entity.hl-name.hl-tag.hl-toml { color: var(--cyan); }
.hl-meta.hl-tag.hl-table.hl-toml { color: var(--magenta); }
.hl-punctuation.hl-separator.hl-key-value { color: var(--fg-dark); }

/* Diff / patch */
.hl-markup.hl-inserted { color: var(--green); }
.hl-markup.hl-deleted { color: var(--red); }
.hl-markup.hl-changed { color: var(--yellow); }
.hl-string.hl-unquoted.hl-plain.hl-out.hl-yaml { color: var(--green); }
.hl-punctuation.hl-definition.hl-block.hl-sequence { color: var(--magenta); }
.hl-constant.hl-language.hl-boolean { color: var(--orange); }

/* Shell prompt ❯❯❯ */
.prompt-red    { color: var(--red);    font-weight: bold; }
.prompt-yellow { color: var(--yellow); font-weight: bold; }
.prompt-green  { color: var(--green);  font-weight: bold; }

/* === Discuss on Mastodon === */
.post-discuss {
  margin: 2.5rem 0 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--fg-gutter);
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.95rem;
  font-family: var(--font-mono);
}
.discuss-prefix {
  color: var(--cyan);
  font-weight: 600;
}
.discuss-mastodon {
  color: var(--magenta);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s;
}
.discuss-mastodon:hover {
  color: var(--cyan);
  text-decoration: underline;
}

/* === Post Navigation === */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--fg-gutter);
}

.post-nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg-dark);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  transition: background 0.12s, color 0.12s;
  max-width: 45%;
}

.post-nav-link:hover {
  background: var(--bg-highlight);
  color: var(--blue);
}

.nav-arrow {
  color: var(--magenta);
  font-weight: 700;
  flex-shrink: 0;
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-series-badge {
  font-size: 0.68rem;
  color: var(--magenta);
  border: 1px solid rgba(187, 154, 247, 0.4);
  border-radius: 3px;
  padding: 0 0.35rem;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Cursor blink */
.cursor-blink {
  color: var(--fg);
  animation: blink 1s step-end infinite;
  margin-top: 1rem;
  font-size: 1.1rem;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* === Boot Sequence (first load per session) === */
.booting #tabline {
  animation: boot-tabline 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
  transform-origin: top;
}
.booting #editor {
  animation: boot-editor 720ms cubic-bezier(0.22, 1, 0.36, 1) 220ms both;
}
.booting #statusline {
  animation: boot-statusline 520ms cubic-bezier(0.16, 1, 0.3, 1) 180ms both;
}
.booting #cmdline-msg.boot {
  font-size: 1rem;
}
.booting #cmdline-msg.boot::after {
  content: '█';
  margin-left: 1px;
  color: var(--blue);
  animation: blink 0.55s step-end infinite;
}
.booting #cmdline-msg.boot.fadeout {
  animation: boot-cmdline-out 280ms ease-in forwards;
}
.booting #cmdline-msg.boot.fadeout::after { display: none; }

@keyframes boot-tabline {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes boot-statusline {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes boot-editor {
  0%   { opacity: 0; transform: translateY(18px); filter: blur(6px); }
  60%  { opacity: 1; transform: translateY(0); filter: blur(0.5px); }
  100% { opacity: 1; transform: translateY(0); filter: blur(0); }
}
@keyframes boot-cmdline-out {
  to { opacity: 0; transform: translateY(-3px); }
}

/* === About Page === */
.about {
  padding-top: 1rem;
}

.about .ascii-art {
  text-align: center;
}

.about-body {
  margin: 2rem auto;
  line-height: 1.8;
  text-align: center;
}

.about-body p {
  margin-bottom: 1rem;
}

.about-body a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.about-body a:hover {
  border-bottom-color: var(--cyan);
}

.about-body img {
  display: block;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 3px solid var(--magenta);
  margin: 1.5rem auto;
  transition: border-color 0.3s;
}

.about-body img:hover {
  border-color: var(--blue);
}

.about-body h3 {
  color: var(--blue);
  font-size: 1.1rem;
  margin: 2.5rem auto 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--fg-gutter);
  max-width: 64rem;
}

.about-body ul {
  list-style: none;
  padding: 0;
  margin: 1rem auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 64rem;
  text-align: left;
}

.about-body li {
  font-size: 0.95rem;
}

/* === Responsive === */
@media (max-width: 768px) {
  :root {
    --font-size: 14px;
    --line-height: 1.7;
    --tabline-h: 32px;
    --gutter-w: 2.5rem;
    --content-max: 100%;
  }

  #content {
    padding: 1.25rem 1rem;
  }

  /* Strip keyboard-only chrome — useless without a physical keyboard,
     and the JS that drives them is also conditionally skipped on phones. */
  #cmdline, #cmdline-msg, #wildmenu,
  #telescope-modal, #term-modal, #lazy-modal, #checkhealth-modal,
  #neofetch-modal, #cowsay-modal, #help-modal, #ghost-cursor,
  #matrix-canvas, #ambient-matrix, #noice-container, #which-key {
    display: none !important;
  }

  /* Subtle scanline texture — fine on a panel, just noise on a 6" screen. */
  body::before { display: none; }

  /* Statusline: dense vim chrome, hides too much screen real estate on phones.
     The reading progress bar (re-pinned to viewport bottom) is the only
     chrome that earns its keep on mobile. */
  #statusline { display: none; }
  #read-progress {
    bottom: env(safe-area-inset-bottom, 0px);
    height: 3px;
  }

  /* Tabline: keep the brand, but pin the theme toggle so it stays reachable
     even when the tabs scroll horizontally. */
  .tab { padding: 0 0.7rem; font-size: 0.78rem; gap: 0.3rem; }
  #theme-toggle {
    position: sticky;
    right: 0;
    background: var(--bg-dark);
    z-index: 1;
    padding: 0 1rem;
    font-size: 1.05rem;
  }

  /* Index header: ASCII art stays as a brand cue; the keyboard-hints
     comment line ("? help · : commands · …") is dead weight on touch. */
  /* The CRISIDEV BLOG banner is ~92 chars wide. Scale font-size with the
     viewport so it grows to fill the screen without ever overflowing the
     `overflow: hidden` clip on the .ascii-art container. */
  .ascii-art { font-size: clamp(0.4rem, 1.65vw, 0.6rem); }
  .netrw-comment { display: none; }
  .netrw { padding-top: 1rem; }
  .netrw-header { margin-bottom: 0.75rem; }

  /* Each post entry becomes a 2-row grid:
     row 1 — emoji + post title (the hero, big, readable)
     row 2 — date · reading time (small, dim, indented under the title)
     row 3 — series badge (only when the post is part of a series)
     Keeps the netrw aesthetic but stops squeezing the title into a thin
     middle column with date pushing in from the left. */
  .netrw-entry {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 0.6rem;
    row-gap: 0.15rem;
    align-items: baseline;
    padding: 0.85rem 0.4rem;
    border-bottom: 1px solid var(--fg-gutter);
    border-radius: 0;
  }
  .netrw-entry:last-child { border-bottom: none; }
  .netrw-icon  { grid-row: 1; grid-column: 1; width: auto; }
  .netrw-title {
    grid-row: 1; grid-column: 2;
    font-size: 0.95rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  .netrw-meta  {
    grid-row: 1; grid-column: 3;
    display: inline;
    font-size: 0.78rem;
    color: var(--fg-dark);
    align-self: start;
    padding-top: 0.2rem;
    white-space: nowrap;
  }
  .netrw-date  {
    grid-row: 2; grid-column: 2 / span 2;
    font-size: 0.78rem;
    color: var(--fg-dark);
  }
  .netrw-tags  { display: none; }
  .netrw-tags:has(.tag-series) {
    grid-row: 3; grid-column: 2 / span 2;
    display: flex;
    margin-top: 0.15rem;
  }
  .netrw-tags .tag-pill:not(.tag-series) { display: none; }

  /* Tag pills: bigger tap target. */
  .tag-pill {
    min-height: 30px;
    padding: 0.35rem 0.7rem;
    line-height: 1.3;
    display: inline-flex;
    align-items: center;
  }
  .post-tags { font-size: 0.78rem; gap: 0.4rem; flex-wrap: wrap; }

  /* Post header: tighter typography, wraps cleanly. */
  .post-title { font-size: 1.3rem; line-height: 1.25; }
  .post-meta { font-size: 0.78rem; flex-wrap: wrap; gap: 0.4rem; }
  .meta-sep { display: none; }

  /* Post body: reading-first. */
  .post-body { font-size: 0.95rem; }
  .post-body > h2 { font-size: 1.15rem; margin-top: 1.5rem; }
  .post-body > h3 { font-size: 1rem; margin-top: 1.15rem; }
  .post-body > * + * { margin-top: 1rem; }

  /* Code blocks: trim the gutter so code has more horizontal room. */
  .code-ln {
    width: 2rem;
    padding-right: 0.4rem;
    margin-right: 0.4rem;
  }

  /* Discuss-on-mastodon: stack vertically, generous tap target. */
  .post-discuss {
    flex-direction: column;
    gap: 0.5rem;
    margin: 2rem 0 1rem;
    padding: 1rem 0;
  }
  .discuss-mastodon {
    padding: 0.55rem 1rem;
    border: 1px solid var(--fg-gutter);
    border-radius: 6px;
    background: var(--bg-float);
  }

  /* Prev/next post nav: full-width stacked links. */
  .post-nav { flex-direction: column; gap: 0.6rem; margin-top: 1.5rem; }
  .post-nav-link { max-width: 100%; padding: 0.75rem 1rem; }

  /* Series nav inside post header: don't overflow. */
  .series-nav { font-size: 0.85rem; }
  .series-entry { padding: 0.35rem 0.5rem; }
}

/* === Selection === */
::selection {
  background: var(--blue);
  color: var(--bg-dark);
}

.code-block ::selection {
  background: var(--blue);
  color: var(--bg-dark);
}

/* === Command Line === */
#cmdline {
  display: flex;
  align-items: center;
  height: var(--statusline-h);
  background: var(--bg-dark);
  padding: 0 0.75rem;
  border-top: 1px solid var(--fg-gutter);
  flex-shrink: 0;
}

#cmdline.hidden { display: none; }

#cmdline-prefix {
  color: var(--fg);
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 0.25rem;
}

#cmdline-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
  caret-color: var(--green);
}

/* === Wildmenu (Tab Completion) === */
#wildmenu {
  display: flex;
  align-items: center;
  height: var(--statusline-h);
  background: var(--bg-highlight);
  border-top: 1px solid var(--fg-gutter);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
  font-size: 0.82rem;
  padding: 0 0.5rem;
  gap: 0.15rem;
}

#wildmenu::-webkit-scrollbar { display: none; }
#wildmenu.hidden { display: none; }

.wild-item {
  padding: 0.1rem 0.6rem;
  color: var(--fg-dark);
  white-space: nowrap;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.1s;
}

.wild-item:hover {
  background: var(--bg-float);
  color: var(--fg);
}

.wild-item.wild-active {
  background: var(--blue);
  color: var(--bg-dark);
  font-weight: 700;
}

.cmdline-msg {
  display: flex;
  align-items: center;
  height: var(--statusline-h);
  background: var(--bg-dark);
  padding: 0 0.75rem;
  border-top: 1px solid var(--fg-gutter);
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--fg);
}

.cmdline-msg.hidden { display: none; }
.cmdline-error { color: var(--red) !important; }

/* === Search Highlights === */
.search-hl {
  background: var(--yellow);
  color: var(--bg-dark);
  border-radius: 2px;
  padding: 0 2px;
}

.search-hl.search-current {
  background: var(--orange);
  outline: 2px solid var(--orange);
}

/* === Visual / Command Mode Statusline === */
.stl-mode-visual {
  background: var(--magenta) !important;
}

.stl-mode-command {
  background: var(--green) !important;
}

/* === Cross-document View Transitions ===
   Opt-in fade-and-lift between same-origin navigations. Browsers without
   support (Firefox today) ignore this entirely; nav still works. */
@view-transition {
  navigation: auto;
}
::view-transition-old(root) {
  animation: 180ms cubic-bezier(0.4, 0, 0.2, 1) both vt-fade-out;
}
::view-transition-new(root) {
  animation: 240ms cubic-bezier(0.4, 0, 0.2, 1) both vt-fade-in;
}
@keyframes vt-fade-out {
  to { opacity: 0; transform: translateY(-6px); }
}
@keyframes vt-fade-in {
  from { opacity: 0; transform: translateY(6px); }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}

/* === Reading Progress Bar (post pages only) === */
#read-progress {
  position: fixed;
  bottom: var(--statusline-h);
  left: 0;
  height: 2px;
  width: 0;
  background: var(--blue);
  z-index: 200;
  pointer-events: none;
  transition: width 0.08s linear;
}
@media (prefers-reduced-motion: reduce) {
  #read-progress { transition: none; }
}

/* === Ghost Cursor === */
#ghost-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 8px;
  height: 1.2em;
  background: var(--fg);
  opacity: 0;
  pointer-events: none;
  z-index: 300;
  transition: opacity 0.2s;
  mix-blend-mode: difference;
  border-radius: 1px;
  will-change: transform;
}

/* === Ambient Matrix Rain (index only) === */
#ambient-matrix {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
}

/* === Matrix Rain Canvas (Konami) === */
#matrix-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
}

#matrix-canvas.hidden { display: none; }

.matrix-fade {
  animation: fadeOut 1s forwards;
}

@keyframes fadeOut {
  to { opacity: 0; }
}

/* === Cowsay Modal === */
#cowsay-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 22, 30, 0.85);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

#cowsay-modal.hidden { display: none; }

#cowsay-text {
  color: var(--green);
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre;
  padding: 2rem;
  background: var(--bg-dark);
  border: 1px solid var(--fg-gutter);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-width: 90vw;
  overflow-x: auto;
}

/* === Help Modal === */
#help-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 22, 30, 0.85);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

#help-modal.hidden { display: none; }

.help-content {
  background: var(--bg-float);
  border: 1px solid var(--fg-gutter);
  border-radius: 8px;
  padding: 2rem 2.5rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-width: 64rem;
  width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
}

.help-header {
  color: var(--magenta);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--fg-gutter);
}

.help-columns {
  display: flex;
  gap: 3rem;
}

.help-col {
  flex: 1;
}

.help-section {
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.75rem;
  margin-bottom: 0.4rem;
}

.help-section:first-child {
  margin-top: 0;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.help-table td {
  padding: 0.3rem 0.6rem;
  color: var(--fg-dark);
  vertical-align: top;
}

.help-key {
  color: var(--yellow) !important;
  font-weight: 700;
  white-space: nowrap;
  width: 11rem;
}

.help-footer {
  color: var(--fg-dark);
  font-size: 0.75rem;
  text-align: center;
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--fg-gutter);
}

/* === Relative Line Numbers === */
.rnu .code-ln-current {
  color: var(--fg) !important;
  font-weight: 700;
}

/* === Telescope Modal === */
#telescope-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 600;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  background: rgba(22, 22, 30, 0.85);
  backdrop-filter: blur(4px);
}
#telescope-modal.hidden { display: none; }

.telescope-content {
  background: var(--bg-float);
  border: 1px solid var(--blue);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  width: 90vw;
  max-width: 72rem;
  overflow: hidden;
}

.telescope-header {
  padding: 0.5rem 0.75rem;
  color: var(--blue);
  font-weight: 700;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--fg-gutter);
}

.telescope-input-row {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--fg-gutter);
}

.telescope-prompt {
  color: var(--magenta);
  font-weight: 700;
  margin-right: 0.5rem;
}

#telescope-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  outline: none;
}

#telescope-results {
  max-height: 55vh;
  overflow-y: auto;
}

.telescope-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.82rem;
}
.telescope-item:hover { background: var(--bg-highlight); }
.telescope-active { background: var(--bg-highlight); }
.telescope-slug { color: var(--fg-dark); flex-shrink: 0; }
.telescope-title { color: var(--fg); }

.telescope-footer {
  padding: 0.35rem 0.75rem;
  font-size: 0.72rem;
  color: var(--fg-dark);
  border-top: 1px solid var(--fg-gutter);
}

/* === Lazy Modal === */
#lazy-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 22, 30, 0.85);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
#lazy-modal.hidden { display: none; }

.lazy-content {
  background: var(--bg-float);
  border: 1px solid var(--fg-gutter);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  width: 90vw;
  max-width: 36rem;
  padding: 1rem 0;
}

.lazy-header {
  color: var(--magenta);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0 1rem 0.75rem;
  border-bottom: 1px solid var(--fg-gutter);
}

#lazy-list {
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.lazy-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.2rem 1rem;
  font-size: 0.82rem;
}

.lazy-loaded { color: var(--green); }
.lazy-not-loaded { color: var(--fg-dark); }
.lazy-name { color: var(--blue); font-weight: 700; min-width: 8rem; }
.lazy-ver { color: var(--fg-dark); min-width: 3rem; }
.lazy-desc { color: var(--fg); flex: 1; }
.lazy-time { color: var(--fg-dark); font-size: 0.75rem; text-align: right; min-width: 4rem; }

.lazy-footer {
  padding: 0.5rem 1rem 0;
  font-size: 0.75rem;
  color: var(--fg-dark);
  border-top: 1px solid var(--fg-gutter);
}

/* === Checkhealth Modal === */
#checkhealth-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 22, 30, 0.85);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
#checkhealth-modal.hidden { display: none; }

.checkhealth-content {
  background: var(--bg-float);
  border: 1px solid var(--fg-gutter);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  padding: 1.5rem 2rem;
  max-width: 42rem;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

#checkhealth-text {
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--fg);
}

/* === Which-Key Popup === */
#which-key {
  position: fixed;
  bottom: calc(var(--statusline-h) + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--bg-float);
  border: 1px solid var(--fg-gutter);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  font-size: 0.82rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  animation: wkFadeIn 0.1s ease-out;
}

#which-key.hidden { display: none; }

@keyframes wkFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.wk-header {
  color: var(--magenta);
  font-weight: 700;
  padding-right: 0.5rem;
  border-right: 1px solid var(--fg-gutter);
}

.wk-row { display: flex; gap: 0.4rem; }
.wk-key { color: var(--yellow); font-weight: 700; }
.wk-desc { color: var(--fg-dark); }

/* === Cursorline === */
.cursorline {
  background: rgba(41, 46, 66, 0.6) !important;
  border-radius: 2px;
}

.cursorline::before {
  color: var(--fg) !important;
  font-weight: 700;
}

/* Day theme cursorline */
.theme-day .cursorline {
  background: rgba(180, 185, 210, 0.5) !important;
}

/* === Noice Notifications === */
#noice-container {
  position: fixed;
  top: calc(var(--tabline-h) + 8px);
  right: 12px;
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: 420px;
}

.noice-toast {
  background: var(--bg-float);
  border: 1px solid var(--fg-gutter);
  border-left: 3px solid var(--blue);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.45);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
  pointer-events: auto;
  cursor: pointer;
}

.noice-toast.noice-show {
  transform: translateX(0);
  opacity: 1;
}

.noice-toast.noice-hide {
  transform: translateX(120%);
  opacity: 0;
}

.noice-error { border-left-color: var(--red); }
.noice-error .noice-icon { color: var(--red); }
.noice-info .noice-icon { color: var(--blue); }

.noice-icon { font-weight: 700; flex-shrink: 0; }
.noice-text { color: var(--fg); word-break: break-word; }

/* === Visual Line Selection === */
.visual-selected {
  background: rgba(122, 162, 247, 0.18) !important;
  border-radius: 2px;
}

.theme-day .visual-selected {
  background: rgba(46, 125, 233, 0.15) !important;
}

@media (max-width: 768px) {
  #noice-container { max-width: 85vw; right: 8px; }
}

/* === Image Lightbox === */
#lightbox-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 22, 30, 0.92);
  backdrop-filter: blur(6px);
  cursor: pointer;
  padding: 2rem;
}

#lightbox-modal.hidden { display: none; }

#lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  border: 1px solid var(--fg-gutter);
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
  object-fit: contain;
}

/* Make post images show pointer cursor for lightbox */
.post-body img {
  cursor: zoom-in;
}

/* === Neofetch Modal === */
#neofetch-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 22, 30, 0.85);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
#neofetch-modal.hidden { display: none; }

#neofetch-text {
  color: var(--fg);
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre;
  padding: 2rem;
  background: var(--bg-dark);
  border: 1px solid var(--fg-gutter);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.neofetch-label { color: var(--blue); font-weight: 700; }

/* === Terminal modal (:term) === */
#term-modal {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: rgba(22, 22, 30, 0.85);
  backdrop-filter: blur(4px);
}
#term-modal.hidden { display: none; }

.term-content {
  position: absolute;
  inset: 1.5rem;
  background: var(--bg-dark);
  border: 1px solid var(--cyan);
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.term-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  background: var(--bg-highlight);
  border-bottom: 1px solid var(--fg-gutter);
  font-size: 0.78rem;
}
.term-traffic { display: inline-flex; gap: 0.35rem; align-items: center; }
.term-light {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  user-select: none;
  background: currentColor;
  vertical-align: middle;
}
.term-light-r { color: #ff5f56; cursor: pointer; }
.term-light-y { color: #ffbd2e; }
.term-light-g { color: #3ddb53; }
.term-title { color: var(--cyan); font-weight: 700; flex: 1; text-align: center; }
.term-hint { color: var(--fg-dark); font-size: 0.72rem; }

.term-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.85rem;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.5;
  scrollbar-color: var(--fg-gutter) var(--bg-dark);
}

#term-output { flex: 0 0 auto; }
.term-line {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  min-height: 1.32em;
  margin: 0;
  padding: 0;
}
.term-rule {
  display: block;
  width: 100%;
  height: 0;
  border-bottom: 1px dashed var(--cyan);
  opacity: 0.5;
  margin: 0.3rem 0 0.6rem;
}
.term-err { color: var(--red); }
.term-info { color: var(--cyan); }
.term-dir { color: var(--blue); font-weight: 700; }
.term-md { color: var(--green); }
.term-prompt-echo { color: var(--green); font-weight: 700; }

.term-prompt-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex: 0 0 auto;
  line-height: 1.5;
}
.term-prompt {
  flex-shrink: 0;
  white-space: nowrap;
  line-height: 1.5;
}
.term-cwd {
  color: var(--cyan);
  margin-left: 0.25rem;
}
#term-input {
  flex: 1;
  min-width: 4rem;
  background: transparent;
  border: 0;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: inherit;
  outline: none;
  caret-color: var(--blue);
  padding: 0;
  margin: 0;
}

@media (max-width: 768px) {
  .term-content { inset: 0.5rem; }
  .term-body { font-size: 0.82rem; }
  #term-input { font-size: 0.82rem; }
}

/* === CRT scanlines (dark theme only) === */
:root {
  --scanline-opacity: 0.07;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, var(--scanline-opacity)) 2px,
    rgba(0, 0, 0, var(--scanline-opacity)) 3px
  );
}

/* === Tokyo Night Day (Light Theme) === */
.theme-day {
  --bg:           #e1e2e7;
  --bg-dark:      #d5d6db;
  --bg-highlight: #c4c8da;
  --bg-float:     #e1e2e7;
  --fg:           #3760bf;
  --fg-dark:      #6172b0;
  --fg-gutter:    #a8aecb;
  --blue:         #2e7de9;
  --cyan:         #007197;
  --green:        #587539;
  --magenta:      #9854f1;
  --orange:       #b15c00;
  --red:          #f52a65;
  --teal:         #118c74;
  --yellow:       #8c6c3e;
  --scanline-opacity: 0;
}

/* === Gruvbox Light (Hard) === */
.theme-gruvbox-day {
  --bg:           #f9f5d7;
  --bg-dark:      #f2e5bc;
  --bg-highlight: #d5c4a1;
  --bg-float:     #f9f5d7;
  --fg:           #3c3836;
  --fg-dark:      #7c6f64;
  --fg-gutter:    #bdae93;
  --blue:         #076678;
  --cyan:         #427b58;
  --green:        #79740e;
  --magenta:      #8f3f71;
  --orange:       #af3a03;
  --red:          #9d0006;
  --teal:         #689d6a;
  --yellow:       #b57614;
  --scanline-opacity: 0;
}

/* === Catppuccin Latte === */
.theme-catppuccin-day {
  --bg:           #eff1f5;
  --bg-dark:      #e6e9ef;
  --bg-highlight: #ccd0da;
  --bg-float:     #eff1f5;
  --fg:           #4c4f69;
  --fg-dark:      #6c6f85;
  --fg-gutter:    #acb0be;
  --blue:         #1e66f5;
  --cyan:         #04a5e5;
  --green:        #40a02b;
  --magenta:      #8839ef;
  --orange:       #fe640b;
  --red:          #d20f39;
  --teal:         #179299;
  --yellow:       #df8e1d;
  --scanline-opacity: 0;
}

/* === Nord Light (Snow Storm) === */
.theme-nord-day {
  --bg:           #eceff4;
  --bg-dark:      #e5e9f0;
  --bg-highlight: #d8dee9;
  --bg-float:     #e5e9f0;
  --fg:           #2e3440;
  --fg-dark:      #4c566a;
  --fg-gutter:    #b8becd;
  --blue:         #5e81ac;
  --cyan:         #88c0d0;
  --green:        #a3be8c;
  --magenta:      #b48ead;
  --orange:       #d08770;
  --red:          #bf616a;
  --teal:         #8fbcbb;
  --yellow:       #ebcb8b;
  --scanline-opacity: 0;
}

/* === Rosé Pine Dawn === */
.theme-rose-pine-day {
  --bg:           #faf4ed;
  --bg-dark:      #fffaf3;
  --bg-highlight: #f2e9e1;
  --bg-float:     #fffaf3;
  --fg:           #575279;
  --fg-dark:      #9893a5;
  --fg-gutter:    #cecacd;
  --blue:         #286983;
  --cyan:         #d7827e;
  --green:        #56949f;
  --magenta:      #907aa9;
  --orange:       #ea9d34;
  --red:          #b4637a;
  --teal:         #56949f;
  --yellow:       #ea9d34;
  --scanline-opacity: 0;
}

/* === Gruvbox (Dark Hard) === */
.theme-gruvbox {
  --bg:           #1d2021;
  --bg-dark:      #161718;
  --bg-highlight: #3c3836;
  --bg-float:     #282828;
  --fg:           #ebdbb2;
  --fg-dark:      #a89984;
  --fg-gutter:    #504945;
  --blue:         #83a598;
  --cyan:         #8ec07c;
  --green:        #b8bb26;
  --magenta:      #d3869b;
  --orange:       #fe8019;
  --red:          #fb4934;
  --teal:         #689d6a;
  --yellow:       #fabd2f;
}

/* === Catppuccin (Mocha) === */
.theme-catppuccin {
  --bg:           #1e1e2e;
  --bg-dark:      #181825;
  --bg-highlight: #313244;
  --bg-float:     #181825;
  --fg:           #cdd6f4;
  --fg-dark:      #a6adc8;
  --fg-gutter:    #45475a;
  --blue:         #89b4fa;
  --cyan:         #94e2d5;
  --green:        #a6e3a1;
  --magenta:      #cba6f7;
  --orange:       #fab387;
  --red:          #f38ba8;
  --teal:         #74c7ec;
  --yellow:       #f9e2af;
}

/* === Nord === */
.theme-nord {
  --bg:           #2e3440;
  --bg-dark:      #242933;
  --bg-highlight: #434c5e;
  --bg-float:     #3b4252;
  --fg:           #d8dee9;
  --fg-dark:      #81a1c1;
  --fg-gutter:    #4c566a;
  --blue:         #81a1c1;
  --cyan:         #88c0d0;
  --green:        #a3be8c;
  --magenta:      #b48ead;
  --orange:       #d08770;
  --red:          #bf616a;
  --teal:         #8fbcbb;
  --yellow:       #ebcb8b;
}

/* === Rosé Pine === */
.theme-rose-pine {
  --bg:           #191724;
  --bg-dark:      #1f1d2e;
  --bg-highlight: #26233a;
  --bg-float:     #1f1d2e;
  --fg:           #e0def4;
  --fg-dark:      #908caa;
  --fg-gutter:    #6e6a86;
  --blue:         #31748f;
  --cyan:         #9ccfd8;
  --green:        #9ccfd8;
  --magenta:      #c4a7e7;
  --orange:       #f6c177;
  --red:          #eb6f92;
  --teal:         #31748f;
  --yellow:       #f6c177;
}

/* === Responsive === */
@media (max-width: 768px) {
  .help-columns {
    flex-direction: column;
    gap: 0;
  }

  #ghost-cursor {
    display: none;
  }

  #cowsay-text {
    font-size: 0.7rem;
    padding: 1rem;
  }
}

/* === Print === */
@media print {
  #tabline, #statusline, .cursor-blink, .post-nav, #cmdline, #cmdline-msg, #ghost-cursor,
  #matrix-canvas, #ambient-matrix, #cowsay-modal, #help-modal { display: none; }
  body { height: auto; overflow: visible; }
  #editor { overflow: visible; }
  .post-body > * { padding-left: 0; }
}
