/* nvim.css — the editor chrome.
 *
 * All borders, separators, tree guides and bullets are drawn in CSS rather
 * than with box-drawing characters: the webfont's latin subset has no glyphs
 * above U+2500, so `╭─╮` would fall back to a different font and break the
 * monospace grid. CSS also stays crisp at 13px.
 *
 * Colours all come from custom properties set by colorschemes.js.
 */

@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/JetBrainsMono/JetBrainsMono-latin.woff2') format('woff2');
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/JetBrainsMono/JetBrainsMono-latin-italic.woff2') format('woff2');
  font-weight: 100 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs: 13.5px;
  --lh: 1.62;
  --sidebar-w: 260px;
  --tabline-h: 36px;
  --statusline-h: 26px;
  --radius: 6px;

  /* Fallback palette so the page is never unstyled before JS runs. Keep this
   * in step with DEFAULT_SCHEME in colorschemes.js (gruvbox-dark), or the
   * first paint flashes the wrong colours. */
  --bg: #282828; --bg-dark: #1d2021; --bg-float: #1d2021; --bg-alt: #32302f;
  --bg-hl: #3c3836; --bg-sel: #504945;
  --fg: #ebdbb2; --fg-dim: #d5c4a1; --fg-gutter: #504945; --fg-num: #7c6f64;
  --border: #504945; --comment: #928374;
  --blue: #83a598; --cyan: #8ec07c; --green: #b8bb26; --yellow: #fabd2f;
  --orange: #fe8019; --red: #fb4934; --purple: #d3869b; --pink: #d3869b;
  --teal: #689d6a; --accent: #83a598;
  --shadow: rgba(0, 0, 0, 0.45); --overlay: rgba(0, 0, 0, 0.45);
}

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

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg-dark);
  color: var(--fg);
  font-family: var(--mono);
  font-size: var(--fs);
  line-height: var(--lh);
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

::selection { background: var(--bg-sel); color: var(--fg); }

.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.14em;
  flex: none;
}
.icon-inline { width: 1.05em; height: 1.05em; margin-right: 0.4em; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Frame ─────────────────────────────────────────────────────────────── */

#app {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: 1fr auto;
  height: 100dvh;
  background: var(--bg);
}

/* ── Explorer (snacks.nvim sidebar) ────────────────────────────────────── */

.explorer {
  grid-row: 1;
  grid-column: 1;
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#app.no-explorer .explorer { display: none; }

.explorer-title {
  display: flex;
  align-items: center;
  gap: 7px;
  height: var(--tabline-h);
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  flex: none;
}
.explorer-title .cwd { color: var(--fg-dim); font-weight: 400; }

.explorer-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-gutter) transparent;
}
.explorer-tree::-webkit-scrollbar { width: 8px; }
.explorer-tree::-webkit-scrollbar-thumb {
  background: var(--fg-gutter);
  border-radius: 4px;
}
.explorer-tree::-webkit-scrollbar-track { background: transparent; }

.tree-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 0;
  cursor: pointer;
  white-space: nowrap;
  color: var(--fg-dim);
  border: 0;
  background: none;
  font: inherit;
  width: 100%;
  text-align: left;
  border-left: 2px solid transparent;
}
.tree-row:hover { background: var(--bg-hl); color: var(--fg); }
.tree-row.cursor { background: var(--bg-hl); }
.tree-row.active {
  background: var(--bg-sel);
  color: var(--fg);
  border-left-color: var(--accent);
}
.tree-row.active .tree-name { font-weight: 700; }
.tree-row:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }

/* Indent guides: one hairline per level, drawn rather than typed. */
.tree-indent {
  flex: none;
  align-self: stretch;
  position: relative;
  width: calc(var(--depth) * 14px);
}
.tree-indent::before {
  content: '';
  position: absolute;
  inset-block: -2px;
  right: 7px;
  border-left: 1px solid var(--indent-guide, var(--fg-gutter));
  opacity: 0.55;
}
.tree-row[data-depth='0'] .tree-indent::before { display: none; }

.tree-chevron {
  flex: none;
  width: 13px;
  color: var(--fg-num);
  transition: transform 0.12s ease;
}
.tree-chevron .icon { width: 0.78em; height: 0.78em; }
.tree-row[aria-expanded='true'] .tree-chevron { transform: rotate(90deg); }
.tree-row.is-file .tree-chevron { visibility: hidden; }

.tree-icon { flex: none; display: flex; }
.tree-icon .icon { width: 1.02em; height: 1.02em; }
.tree-name { overflow: hidden; text-overflow: ellipsis; }
.tree-git {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  padding-left: 6px;
}
.tree-git[data-status='M'] { color: var(--yellow); }
.tree-git[data-status='A'] { color: var(--green); }

.explorer-hint {
  flex: none;
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  color: var(--comment);
  font-size: 11px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.explorer-hint kbd { color: var(--fg-num); }

/* ── Main column ───────────────────────────────────────────────────────── */

.main {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ── Bufferline ────────────────────────────────────────────────────────── */

.tabline {
  flex: none;
  height: var(--tabline-h);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.tabline::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px 0 12px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--fg-num);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
  max-width: 220px;
}
.tab:hover { background: var(--bg-hl); color: var(--fg-dim); }
.tab.active {
  background: var(--bg);
  color: var(--fg);
}
/* The accent bar lualine/bufferline puts above the current buffer. */
.tab.active::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--accent);
}
.tab:focus-visible { outline: 1px solid var(--accent); outline-offset: -3px; }

.tab-index { color: var(--fg-gutter); font-size: 11px; }
.tab.active .tab-index { color: var(--accent); }
.tab-name { overflow: hidden; text-overflow: ellipsis; }
.tab-close {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.55;
  padding: 0;
}
.tab-close .icon { width: 0.72em; height: 0.72em; }
.tab-close:hover { background: var(--red); color: var(--bg); opacity: 1; }

.tabline-spacer { flex: 1; min-width: 12px; }
.tabline-actions { display: flex; align-items: center; gap: 2px; padding-right: 6px; flex: none; }
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-num);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: var(--bg-hl); color: var(--accent); }
.icon-btn .icon { width: 0.98em; height: 0.98em; }

/* ── Buffer / editor area ──────────────────────────────────────────────── */

.editor {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.gutter {
  flex: none;
  padding: 14px 0 60vh;
  text-align: right;
  color: var(--fg-gutter);
  background: var(--bg);
  user-select: none;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  line-height: var(--lh);
  overflow: hidden;
  position: relative;
}
.gutter-num { padding: 0 12px 0 14px; height: calc(var(--fs) * var(--lh)); }
.gutter-num.current {
  color: var(--fg-num);
  font-weight: 700;
  background: var(--bg-hl);
}

.buffer {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 0 60vh;
  scroll-behavior: smooth;
  outline: none;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-gutter) transparent;
}
.buffer::-webkit-scrollbar { width: 10px; }
.buffer::-webkit-scrollbar-thumb { background: var(--fg-gutter); border-radius: 5px; }
.buffer::-webkit-scrollbar-track { background: transparent; }

.buffer-inner {
  max-width: 78ch;
  padding: 0 28px;
}

/* The dashboard fills the viewport instead of sitting inside the buffer's
 * scroll padding — a percentage height would otherwise resolve against the
 * content box that `padding-bottom: 60vh` has already shrunk. */
.buffer.is-dashboard { padding: 0; }

@media (prefers-reduced-motion: reduce) {
  .buffer { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Statusline (lualine) ──────────────────────────────────────────────── */

.statusline {
  grid-row: 2;
  grid-column: 1 / -1;
  height: var(--statusline-h);
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  font-size: 12px;
  overflow: hidden;
  flex: none;
}

.sl {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  color: var(--fg-dim);
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
}
button.sl { cursor: pointer; }
button.sl:hover { background: var(--bg-hl); color: var(--fg); }
.sl .icon { width: 0.95em; height: 0.95em; }

.sl-mode {
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--bg);
  background: var(--mode-normal);
  padding: 0 12px;
  position: relative;
}
/* Powerline arrow, drawn as a triangle instead of a  glyph. */
.sl-mode::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 0;
  border-style: solid;
  border-width: calc(var(--statusline-h) / 2) 0 calc(var(--statusline-h) / 2) 9px;
  border-color: transparent transparent transparent var(--mode-normal);
}
body[data-mode='INSERT'] .sl-mode { background: var(--mode-insert); }
body[data-mode='INSERT'] .sl-mode::after { border-left-color: var(--mode-insert); }
body[data-mode='VISUAL'] .sl-mode { background: var(--mode-visual); }
body[data-mode='VISUAL'] .sl-mode::after { border-left-color: var(--mode-visual); }
body[data-mode='COMMAND'] .sl-mode { background: var(--mode-command); }
body[data-mode='COMMAND'] .sl-mode::after { border-left-color: var(--mode-command); }

.sl-branch { color: var(--purple); padding-left: 18px; }
.sl-diag-e { color: var(--red); }
.sl-diag-w { color: var(--yellow); }
.sl-file { color: var(--fg); font-weight: 600; }
.sl-spacer { flex: 1; }
.sl-scheme { color: var(--accent); }
.sl-pos { color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.sl-pct {
  background: var(--bg-hl);
  color: var(--accent);
  font-weight: 700;
  min-width: 52px;
  justify-content: center;
}

/* ── Command line ──────────────────────────────────────────────────────── */

.cmdline {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--statusline-h);
  height: 28px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  display: none;
  align-items: center;
  padding: 0 10px;
  gap: 2px;
  z-index: 60;
  font-size: 13px;
}
.cmdline.open { display: flex; }
.cmdline-prompt { color: var(--accent); font-weight: 700; }
.cmdline-input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  outline: none;
  caret-color: var(--accent);
}
.cmdline-ghost { color: var(--comment); pointer-events: none; }

.message {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--statusline-h);
  padding: 4px 12px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  color: var(--fg-dim);
  font-size: 12.5px;
  z-index: 55;
  display: none;
}
.message.open { display: block; }
.message.error { color: var(--red); }

/* ── Floating windows: picker + which-key ──────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 90;
  display: none;
}
.overlay.open { display: block; }

/* overflow stays visible so the title can straddle the top border the way a
 * Neovim float's title does; children clip themselves instead. */
.float {
  position: fixed;
  background: var(--bg-float);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px var(--shadow);
  z-index: 100;
  overflow: visible;
  display: none;
  flex-direction: column;
}
.float.open { display: flex; }

.float-title {
  position: absolute;
  top: -1px;
  left: 14px;
  transform: translateY(-50%);
  background: var(--bg-float);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  padding: 0 7px;
  letter-spacing: 0.04em;
  z-index: 2;
}

/* Picker */
#picker {
  top: 8vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(940px, 94vw);
  height: min(620px, 74vh);
}
.picker-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.picker-prompt { color: var(--accent); font-weight: 700; }
.picker-input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  caret-color: var(--accent);
}
.picker-count { color: var(--comment); font-size: 11.5px; flex: none; }

.picker-body {
  flex: 1;
  display: flex;
  min-height: 0;
  /* Clips here rather than on .float, which must stay overflow:visible. */
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.picker-list {
  width: 42%;
  min-width: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 5px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-gutter) transparent;
}
.picker-list::-webkit-scrollbar { width: 8px; }
.picker-list::-webkit-scrollbar-thumb { background: var(--fg-gutter); border-radius: 4px; }

.picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  cursor: pointer;
  color: var(--fg-dim);
  white-space: nowrap;
  border-left: 2px solid transparent;
  overflow: hidden;
}
.picker-item:hover { background: var(--bg-hl); }
.picker-item.sel {
  background: var(--bg-sel);
  color: var(--fg);
  border-left-color: var(--accent);
}
.picker-item .m { color: var(--accent); font-weight: 700; }
.picker-item .picker-sub {
  color: var(--comment);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.picker-item .icon { width: 1em; height: 1em; }

.picker-preview {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-gutter) transparent;
}
.picker-preview::-webkit-scrollbar { width: 8px; }
.picker-preview::-webkit-scrollbar-thumb { background: var(--fg-gutter); border-radius: 4px; }
.picker-preview-head {
  color: var(--comment);
  font-size: 11.5px;
  margin-bottom: 9px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}
.picker-empty { color: var(--comment); padding: 22px 14px; }

/* Which-key */
#whichkey {
  left: 50%;
  bottom: calc(var(--statusline-h) + 12px);
  transform: translateX(-50%);
  width: min(760px, 94vw);
  max-height: 56vh;
  padding: 16px 18px 14px;
}
.wk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 3px 20px;
  overflow-y: auto;
}
.wk-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 5px;
  border-radius: 3px;
  cursor: pointer;
  color: var(--fg-dim);
  border: 0;
  background: none;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  width: 100%;
}
.wk-item:hover { background: var(--bg-hl); color: var(--fg); }
.wk-key {
  color: var(--accent);
  font-weight: 700;
  min-width: 2.4em;
  flex: none;
}
.wk-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  color: var(--comment);
  font-size: 11.5px;
}
.wk-sep { color: var(--fg-gutter); flex: none; }
.wk-group { color: var(--purple); font-weight: 600; }

kbd {
  font-family: inherit;
  background: var(--bg-hl);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  font-size: 0.88em;
  color: var(--fg-dim);
  white-space: nowrap;
}

/* ── Search highlighting ───────────────────────────────────────────────── */

mark.search-hit {
  background: var(--search-bg);
  color: inherit;
  border-radius: 2px;
}
mark.search-hit.current {
  background: var(--search-cur-bg);
  color: var(--bg);
  font-weight: 700;
}

/* ── Dashboard (snacks.nvim) ───────────────────────────────────────────── */

.dashboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  gap: 26px;
  padding: 28px 20px;
  overflow-y: auto;
}
/* figlet art only reads correctly when the rows touch — the vertical strokes
 * of one line have to meet the underscores of the next. */
.dash-art {
  color: var(--accent);
  font-size: clamp(6px, 1.7vw, 15px);
  line-height: 1.02;
  white-space: pre;
  margin: 0;
  font-weight: 700;
  text-align: center;
  overflow-x: auto;
  max-width: 100%;
}
.dash-sub { color: var(--comment); font-size: 12.5px; text-align: center; }
.dash-keys { display: flex; flex-direction: column; gap: 2px; min-width: 270px; }
.dash-key {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--fg-dim);
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  width: 100%;
}
.dash-key:hover { background: var(--bg-hl); color: var(--fg); }
.dash-key .icon { color: var(--accent); width: 1.05em; height: 1.05em; }
.dash-key .k { margin-left: auto; color: var(--fg-gutter); font-size: 11.5px; }
.dash-foot { color: var(--fg-gutter); font-size: 11.5px; text-align: center; }

/* ── Rendered markdown ─────────────────────────────────────────────────── */

.md-h {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  margin: 1.5em 0 0.62em;
  font-weight: 700;
  line-height: 1.35;
  scroll-margin-top: 20px;
}
.buffer-inner > .md-h:first-child { margin-top: 0.2em; }
.md-h-hash { flex: none; opacity: 0.55; font-weight: 400; }
.md-h-text { min-width: 0; }

/* render-markdown.nvim's full-width tinted heading bars */
.md-h1, .md-h2, .md-h3 {
  border-radius: 4px;
  padding: 0.24em 0.6em;
  margin-left: -0.6em;
  margin-right: -0.6em;
}
.md-h1 { font-size: 1.62em; color: var(--h1); background: var(--h1-bg); }
.md-h2 { font-size: 1.3em; color: var(--h2); background: var(--h2-bg); }
.md-h3 { font-size: 1.12em; color: var(--h3); background: var(--h3-bg); }
.md-h4 { font-size: 1.02em; color: var(--h4); }
.md-h5 { font-size: 0.97em; color: var(--h5); }
.md-h6 { font-size: 0.93em; color: var(--h6); }

.md-h1 .md-h-hash { color: var(--h1); }
.md-h2 .md-h-hash { color: var(--h2); }
.md-h3 .md-h-hash { color: var(--h3); }

.md-p { margin: 0.72em 0; }
.md-strong { color: var(--fg); font-weight: 700; }
.md-em { font-style: italic; color: var(--fg-dim); }
.md-del { color: var(--comment); text-decoration-color: var(--red); }

.md-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
}
.md-link:hover {
  border-bottom-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.md-link:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

.md-code {
  background: var(--bg-hl);
  color: var(--orange);
  padding: 0.08em 0.4em;
  border-radius: 3px;
  font-size: 0.94em;
}

.md-codeblock {
  margin: 1.05em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-alt);
}
.md-codeblock-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  background: var(--bg-hl);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--lang-color, var(--fg-dim));
}
.md-lang-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lang-color, var(--fg-dim));
  flex: none;
}
.md-lang { font-weight: 600; letter-spacing: 0.03em; }
.md-pre {
  margin: 0;
  padding: 11px 13px;
  overflow-x: auto;
  font-size: 12.6px;
  line-height: 1.62;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-gutter) transparent;
}
.md-pre::-webkit-scrollbar { height: 8px; }
.md-pre::-webkit-scrollbar-thumb { background: var(--fg-gutter); border-radius: 4px; }
.md-pre code { font-family: inherit; }

.tok-comment { color: var(--syn-comment); font-style: italic; }
.tok-string { color: var(--syn-string); }
.tok-number { color: var(--syn-number); }
.tok-keyword { color: var(--syn-keyword); }
.tok-function { color: var(--syn-function); }
.tok-type { color: var(--syn-type); }
.tok-constant { color: var(--syn-constant); }
.tok-operator { color: var(--syn-operator); }
.tok-property { color: var(--syn-property); }
.tok-punct { color: var(--syn-punct); }
.tok-added { color: var(--green); }
.tok-deleted { color: var(--red); }

.md-list { margin: 0.6em 0; padding: 0; list-style: none; }
.md-list .md-list { margin: 0.14em 0 0.14em 1.35em; }
.md-li {
  display: flex;
  align-items: baseline;
  gap: 0.62em;
  margin: 0.18em 0;
  flex-wrap: wrap;
}
.md-li-text { flex: 1; min-width: 0; }
.md-li > .md-list { flex-basis: 100%; margin-left: 1.35em; }

/* Bullets drawn as shapes, so they need no glyph coverage. */
.md-bullet {
  flex: none;
  width: 0.44em;
  height: 0.44em;
  margin-top: 0.1em;
  align-self: center;
  background: var(--accent);
}
.md-bullet.b-disc { border-radius: 50%; }
.md-bullet.b-circle {
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--purple);
}
.md-bullet.b-diamond { transform: rotate(45deg); background: var(--cyan); }
.md-bullet.b-square { background: var(--green); }
.md-num { flex: none; color: var(--accent); font-weight: 700; }

.md-task .md-check { flex: none; display: flex; align-self: center; }
.md-task .md-check .icon { width: 0.95em; height: 0.95em; margin: 0; color: var(--fg-gutter); }
.md-task.done .md-check .icon { color: var(--green); }
.md-task.done .md-li-text { color: var(--comment); text-decoration: line-through; }

.md-quote {
  margin: 1em 0;
  padding: 0.1em 0 0.1em 1.05em;
  border-left: 3px solid var(--fg-gutter);
  color: var(--fg-dim);
  font-style: italic;
}
.md-quote .md-p { margin: 0.35em 0; }

.md-callout {
  margin: 1.05em 0;
  border: 1px solid color-mix(in srgb, var(--callout) 40%, transparent);
  border-left: 3px solid var(--callout);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--callout) 8%, transparent);
  padding: 9px 13px;
}
.md-callout-head {
  display: flex;
  align-items: center;
  color: var(--callout);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  margin-bottom: 3px;
}
.md-callout-body .md-p { margin: 0.28em 0; }
.md-callout-body > :first-child { margin-top: 0; }
.md-callout-body > :last-child { margin-bottom: 0; }

.md-table-wrap {
  margin: 1.05em 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scrollbar-width: thin;
  scrollbar-color: var(--fg-gutter) transparent;
}
.md-table-wrap::-webkit-scrollbar { height: 8px; }
.md-table-wrap::-webkit-scrollbar-thumb { background: var(--fg-gutter); border-radius: 4px; }
.md-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.8px;
}
.md-table th, .md-table td {
  padding: 5px 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.md-table th {
  background: var(--bg-hl);
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}
.md-table tr:last-child td { border-bottom: 0; }
.md-table th:last-child, .md-table td:last-child { border-right: 0; }
.md-table tbody tr:hover { background: var(--bg-hl); }

.md-hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.6em 0;
}
.md-img { max-width: 100%; border-radius: var(--radius); }

/* ── Mobile ────────────────────────────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 40;
  display: none;
}
.scrim.open { display: block; }

@media (max-width: 820px) {
  :root { --fs: 14px; --sidebar-w: 78vw; }

  /* The explorer becomes a drawer rather than a column. */
  #app { grid-template-columns: 1fr; }
  .explorer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    max-width: 320px;
    transform: translateX(-101%);
    transition: transform 0.18s ease;
    box-shadow: 0 0 40px var(--shadow);
  }
  .explorer.open { transform: none; }
  #app.no-explorer .explorer { display: flex; }
  .main { grid-column: 1; }

  .buffer-inner { padding: 0 15px; }
  .gutter { display: none; }
  .md-h1 { font-size: 1.42em; }
  .md-h2 { font-size: 1.2em; }

  #picker { top: 0; left: 0; transform: none; width: 100vw; height: 100dvh; border-radius: 0; }
  .picker-body { flex-direction: column; }
  .picker-list { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); flex: 1; }
  .picker-preview { display: none; }

  .sl-branch, .sl-diag, .sl-filetype, .sl-scheme, .sl-enc { display: none; }
  .explorer-hint { display: none; }
}

@media (min-width: 821px) {
  .mobile-only { display: none !important; }
}
