/* harsh source tour — styles. Dark by default, with a light variant via the
   [data-theme] attribute toggled in app.js. */
:root {
  --bg:        #0e1116;
  --bg-soft:   #151a21;
  --bg-inset:  #1b212b;
  --panel:     #11151b;
  --border:    #232b36;
  --border-2:  #2d3744;
  --fg:        #c9d4e0;
  --fg-dim:    #8893a3;
  --fg-faint:  #5a6573;
  --accent:    #7fd1c4;   /* the harsh teal */
  --accent-2:  #6aa8ff;
  --link:      #79c0ff;
  --link-path: #f0b072;
  --marker:    #4b5a6b;
  --note-bg:   #131922;
  --flash:     rgba(127, 209, 196, 0.16);

  /* syntax */
  --s-comment: #6b7a8d;
  --s-string:  #9ecea8;
  --s-keyword: #d2a8ff;
  --s-builtin: #79c0ff;
  --s-var:     #f0b072;
  --s-number:  #ffab70;
  --s-func:    #7fd1c4;
  --s-punct:   #8893a3;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --rail-w: 340px;

  /* the content column: max width + side padding. The full-bleed top bar and
     console use --content-gutter so their inner content lines up with .doc. */
  --content-max: 1180px;
  --content-pad: 28px;
  --content-gutter: max(var(--content-pad), calc((100% - var(--content-max)) / 2 + var(--content-pad)));
}
[data-theme="light"] {
  --bg:#fbfcfd; --bg-soft:#f1f4f8; --bg-inset:#eef2f6; --panel:#ffffff;
  --border:#e2e8f0; --border-2:#d3dbe6; --fg:#222b36; --fg-dim:#5a6573;
  --fg-faint:#8893a3; --accent:#0f9d8f; --accent-2:#2563eb; --link:#0b62d6;
  --link-path:#b9651b; --marker:#b7c2d0; --note-bg:#f5f8fb; --flash:rgba(15,157,143,.12);
  --s-comment:#7a8694; --s-string:#1a7f4b; --s-keyword:#8250df; --s-builtin:#0b62d6;
  --s-var:#b9651b; --s-number:#b9651b; --s-func:#0f9d8f; --s-punct:#5a6573;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- top bar ---------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: 52px; padding: 0 var(--content-gutter);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .2px; }
.brand .glyph { color: var(--accent); font-family: var(--mono); font-size: 18px; }
.brand a { color: var(--fg); }
.crumbs { color: var(--fg-dim); font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs b { color: var(--fg); font-weight: 600; }
.spacer { flex: 1; }
.btn {
  font: inherit; font-size: 13px; color: var(--fg-dim);
  background: var(--bg-soft); border: 1px solid var(--border-2);
  border-radius: 7px; padding: 0 10px; cursor: pointer; display: inline-flex; gap: 7px; align-items: center;
  /* Fixed height + border-box so every top-bar control lines up the same
     regardless of font size or whether it carries a kbd chip / icon. */
  height: 32px; box-sizing: border-box; flex: none;
}
.btn:hover { color: var(--fg); border-color: var(--accent); }
.btn kbd {
  font-family: var(--mono); font-size: 11px; color: var(--fg-faint);
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}
.mode-badge {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; text-transform: lowercase;
  color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border-2));
  min-width: 3.6em; justify-content: center;
}
.mode-badge::before { content: "⌨ "; opacity: .6; }
.mode-badge:hover { color: var(--fg); border-color: var(--accent); }
.iconlink {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg-dim); border-radius: 7px;
  height: 32px; box-sizing: border-box; padding: 0 7px; flex: none;
}
.iconlink:hover { color: var(--fg); background: var(--bg-soft); text-decoration: none; }

/* ---- pop-down terminal ------------------------------------------------ */
.console {
  position: sticky; top: 52px; z-index: 25;
  background: var(--panel); border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 13px;
}
.con-scroll {
  max-height: 0; overflow-y: auto; padding: 0 var(--content-gutter);
  transition: max-height .2s ease, padding .2s ease;
}
.console.open .con-scroll {
  max-height: min(48vh, 440px); padding: 12px var(--content-gutter) 14px;
  border-bottom: 1px solid var(--border);
}
.con-line { display: flex; align-items: center; gap: 9px; padding: 8px var(--content-gutter); cursor: text; }
.con-prompt { color: var(--accent); white-space: nowrap; cursor: pointer; user-select: none; }
.con-input {
  flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  color: var(--fg); font: inherit; caret-color: var(--accent);
}
.con-input::placeholder { color: var(--fg-faint); }
/* vi command (normal) mode: a steady block-ish caret cue + faint tint */
.con-input.vi-normal { caret-color: transparent; background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 4px; }
.con-toggle { background: transparent; border: none; color: var(--fg-faint); cursor: pointer; font-size: 13px; padding: 2px 6px; }
.con-toggle:hover { color: var(--accent); }
.con-out { line-height: 1.55; white-space: pre-wrap; word-break: break-word; margin: 1px 0; }
.con-out b { color: var(--fg); font-weight: 600; }
.con-out.err { color: #f0907a; }
.con-out.con-cmd { color: var(--fg-dim); margin-top: 7px; }
.con-out .con-p { color: var(--accent); }
.con-dim { color: var(--fg-faint); }
.con-out .e { display: grid; grid-template-columns: minmax(150px, max-content) 1fr; gap: 16px; align-items: baseline; }
.con-out a.e-dir { color: var(--accent-2); }
.con-out a.e-file { color: var(--s-func); }
.con-out .blurb { color: var(--fg-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* copy mode (tmux/vi keyboard layer over the scrollback) */
.copybuf { margin: 0; font: inherit; white-space: pre; tab-size: 4; }
.copybuf .sel { background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 2px; }
.copybuf .cur { background: var(--accent); color: var(--bg); border-radius: 2px; }
.con-status {
  font-family: var(--mono); font-size: 11.5px; color: var(--accent);
  padding: 0 var(--content-gutter); height: 0; overflow: hidden; transition: height .12s ease;
  white-space: nowrap; text-overflow: ellipsis; border-top: 1px solid transparent;
}
.con-status:not(:empty) { height: 22px; line-height: 22px; border-top: 1px solid var(--border); background: var(--bg-soft); }
.con-status.flash { color: var(--bg); background: var(--accent); font-weight: 600; }

.main { min-width: 0; padding: 0 0 120px; }
.doc { position: relative; max-width: var(--content-max); margin: 0 auto; padding: 26px var(--content-pad) 0; }

/* footer */
.site-footer {
  max-width: var(--content-max); margin: 56px auto 0; padding: 20px var(--content-pad) 36px;
  border-top: 1px solid var(--border);
  color: var(--fg-faint); font-size: 12.5px; text-align: center;
}
.site-footer a { color: var(--fg-dim); }
.site-footer a:hover { color: var(--accent); }

/* file header card */
.filehead { margin: 8px 0 22px; }
.filehead h1 {
  font-family: var(--mono); font-size: 22px; margin: 0 0 4px; color: var(--fg); font-weight: 600;
}
.filehead h1 .dir { color: var(--fg-faint); }
.filehead .grouptag { color: var(--accent); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.filehead .intro {
  margin-top: 10px; color: var(--fg-dim); font-size: 14.5px; max-width: 70ch;
  border-left: 2px solid var(--border-2); padding-left: 14px; white-space: pre-line;
}
.filehead .intro code { font-family: var(--mono); font-size: .92em; background: var(--bg-inset); padding: 1px 5px; border-radius: 4px; color: var(--fg); }

/* ---- code ------------------------------------------------------------- */
.code { font-family: var(--mono); font-size: 13px; line-height: 1.62; }
.row { display: grid; grid-template-columns: 3.4em 1fr; }
.row:target, .row.flash { background: var(--flash); }
.row .ln {
  color: var(--fg-faint); text-align: right; padding-right: 14px; user-select: none;
}
.row .cl { white-space: pre-wrap; word-break: break-word; padding-left: 10px; }
.code .row:hover { background: color-mix(in srgb, var(--bg-soft) 60%, transparent); }

/* Full-line comments get woven-in "annotation" styling: a faint accent tint and
   a left spine. Consecutive comment lines share the spine, so a comment block
   reads as one unit — perfectly aligned, since it stays in the code flow. */
.row.cmt { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.row.cmt .cl {
  border-left: 2px solid color-mix(in srgb, var(--accent) 38%, transparent);
  padding-left: 8px;
}
.row.cmt:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.row.cmt .cl .t-comment { color: color-mix(in srgb, var(--s-comment) 45%, var(--fg)); font-style: normal; }
.t-hash { opacity: .45; font-weight: 600; }

/* syntax token colours */
.t-comment { color: var(--s-comment); font-style: italic; }
.t-string  { color: var(--s-string); }
.t-keyword { color: var(--s-keyword); }
.t-builtin { color: var(--s-builtin); }
.t-var     { color: var(--s-var); }
.t-number  { color: var(--s-number); }
.t-punct   { color: var(--s-punct); }
a.t-func   { color: var(--s-func); border-bottom: 1px dotted color-mix(in srgb, var(--s-func) 55%, transparent); }
a.t-func:hover { text-decoration: none; border-bottom-color: var(--s-func); }
a.path     { color: var(--link-path); border-bottom: 1px dotted color-mix(in srgb, var(--link-path) 50%, transparent); }
a.path:hover { text-decoration: none; }

/* ---- markdown --------------------------------------------------------- */
.md { max-width: 78ch; font-size: 15.5px; line-height: 1.7; color: var(--fg); }
.md h1, .md h2, .md h3 { color: var(--fg); line-height: 1.3; margin: 1.6em 0 .5em; }
.md h1 { font-size: 26px; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.md h2 { font-size: 21px; border-bottom: 1px solid var(--border); padding-bottom: .25em; }
.md h3 { font-size: 17px; }
.md p { margin: .8em 0; color: var(--fg-dim); }
.md a.path { color: var(--link-path); }
.md ul, .md ol { color: var(--fg-dim); padding-left: 1.4em; }
.md li { margin: .25em 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--bg-inset); padding: 2px 6px; border-radius: 5px; color: var(--fg); }
.md pre { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; }
.md pre code { background: none; padding: 0; font-size: 13px; line-height: 1.6; display: block; }
.md blockquote { border-left: 3px solid var(--border-2); margin: 1em 0; padding: .2em 0 .2em 16px; color: var(--fg-faint); }
.md table { border-collapse: collapse; margin: 1.2em 0; font-size: 14px; width: 100%; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.md th { background: var(--bg-soft); color: var(--fg); }
.md td { color: var(--fg-dim); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

/* ---- command palette -------------------------------------------------- */
.palette-bg {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5);
  display: none; align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.palette-bg.open { display: flex; }
.palette {
  width: min(640px, 92vw); background: var(--panel); border: 1px solid var(--border-2);
  border-radius: 12px; box-shadow: 0 24px 70px rgba(0,0,0,.5); overflow: hidden;
}
.palette input {
  width: 100%; border: none; background: transparent; color: var(--fg);
  font: inherit; font-size: 16px; padding: 16px 18px; outline: none;
  border-bottom: 1px solid var(--border);
}
.palette .results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette .res {
  display: flex; align-items: baseline; gap: 10px; padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
.palette .res.sel { background: var(--bg-inset); }
.palette .res .kind { font-family: var(--mono); font-size: 10px; color: var(--bg); background: var(--fg-faint); border-radius: 4px; padding: 1px 5px; text-transform: uppercase; }
.palette .res .kind.fn { background: var(--s-func); }
.palette .res .kind.file { background: var(--accent-2); }
.palette .res .label { font-family: var(--mono); font-size: 13.5px; color: var(--fg); }
.palette .res .blurb { color: var(--fg-faint); font-size: 12.5px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.palette .empty { padding: 18px; color: var(--fg-faint); text-align: center; }

/* ---- responsive ------------------------------------------------------- */
@media (max-width: 760px) {
  .crumbs { display: none; }
  .con-out .e { grid-template-columns: 1fr; gap: 0; }
  /* Keyboard-shortcut chips are meaningless on touch — drop them so the buttons
     are compact and uniform, and tighten the bar's gap to fit a small screen. */
  .topbar { gap: 10px; }
  .btn kbd { display: none; }
  .btn { gap: 0; }
}

/* scrollbars */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; border: 3px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }
