/* ── self-hosted fonts (was Google Fonts - saves 2 origins + a render-blocking request) ── */

@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/instrument-serif-italic-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/instrument-serif-normal-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/jetbrains-mono-italic-400-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/jetbrains-mono-italic-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/assets/fonts/jetbrains-mono-normal-400-500-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/assets/fonts/jetbrains-mono-normal-400-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ──────────────────────────────────────────────
   solarpunk pond palette (inspired by chinmaykarkar.com)
   #0A3323 dark green · #105666 midnight · #839958 moss
   #D3968C rosy · #F7F4D5 beige
   ────────────────────────────────────────────── */

:root {
  --dark-green: #0A3323;
  --midnight:   #105666;
  --moss:       #839958;
  --rosy:       #D3968C;
  --beige:      #F7F4D5;

  --bg:     var(--beige);
  --ink:    #082818;
  --soft:   #0f2e20;
  --muted:  #1e4535;
  --line:   rgba(10, 51, 35, 0.14);
  --accent: var(--midnight);
  --card-bg: rgba(255, 255, 255, 0.35);
  --vignette-top: rgba(247, 244, 213, 0.85);
  --vignette-mid: rgba(247, 244, 213, 0.55);

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;

  --page-width: 720px;
  --radius: 6px;

  --lorenz-1: #4338ca;
  --lorenz-2: #6366f1;
  --lorenz-3: #818cf8;
  --lorenz-4: #4f46e5;
  --lorenz-5: #7c3aed;
  --lorenz-6: #a78bfa;

  --torus-1: #f43f5e;
  --torus-2: #fb7185;
  --torus-3: #e879f9;
  --torus-4: #f472b6;
}

[data-theme="dark"] {
  /* Catppuccin Mocha */
  --ctp-crust:    #11111b;
  --ctp-mantle:   #181825;
  --ctp-base:     #1e1e2e;
  --ctp-surface0: #313244;
  --ctp-surface1: #45475a;
  --ctp-text:     #cdd6f4;
  --ctp-subtext1: #bac2de;
  --ctp-subtext0: #a6adc8;
  --ctp-overlay0: #6c7086;
  --ctp-mauve:    #cba6f7;
  --ctp-pink:     #f5c2e7;
  --ctp-blue:     #89b4fa;
  --ctp-lavender: #b4befe;
  --ctp-sapphire: #74c7ec;
  --ctp-sky:      #89dceb;
  --ctp-teal:     #94e2d5;
  --ctp-green:    #a6e3a1;
  --ctp-peach:    #fab387;
  --ctp-red:      #f38ba8;

  --bg:           var(--ctp-base);
  --line:         rgba(205, 214, 244, 0.1);
  --accent:       var(--ctp-blue);
  --card-bg:      rgba(49, 50, 68, 0.5);
  --ink:          #e8edf8;
  --soft:         #e2e8f8;
  --muted:        #c8d0e8;

  --dark-green:   var(--ctp-text);
  --midnight:     var(--ctp-blue);
  --moss:         var(--ctp-teal);
  --rosy:         var(--ctp-pink);

  --lorenz-1: #89b4fa;
  --lorenz-2: #74c7ec;
  --lorenz-3: #b4befe;
  --lorenz-4: #cba6f7;
  --lorenz-5: #89dceb;
  --lorenz-6: #a6e3a1;

  --torus-1: #f5c2e7;
  --torus-2: #f38ba8;
  --torus-3: #cba6f7;
  --torus-4: #fab387;
}

[data-theme="dark"] body {
  background: var(--ctp-crust);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  letter-spacing: -0.015em;
  font-variant-ligatures: contextual common-ligatures;
  font-feature-settings: "liga" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--bg);
  position: relative;
}

#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  display: block;
  pointer-events: none;
}

[data-bg="cosmos"] #bg {
  display: none;
}

.sketch-canvas,
.cosmos-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

html:not([data-bg="sketch"]) .sketch-canvas {
  display: none;
}

html:not([data-bg="cosmos"]) .cosmos-canvas {
  display: none;
}

[data-bg="none"] .vignette,
[data-bg="cosmos"] .vignette {
  opacity: 0;
}

[data-bg="none"] .page {
  text-shadow: none;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(247, 244, 213, 0.08) 0%, rgba(247, 244, 213, 0.58) 55%, rgba(247, 244, 213, 0.88) 100%),
    radial-gradient(ellipse at 50% 100%, rgba(247, 244, 213, 0) 0%, rgba(247, 244, 213, 0.45) 60%, rgba(247, 244, 213, 0.86) 100%);
}

[data-theme="dark"] .vignette {
  background:
    radial-gradient(ellipse at 50% 18%, rgba(30, 30, 46, 0.05) 0%, rgba(24, 24, 37, 0.52) 55%, rgba(17, 17, 27, 0.9) 100%),
    radial-gradient(ellipse at 50% 100%, rgba(30, 30, 46, 0) 0%, rgba(24, 24, 37, 0.42) 60%, rgba(17, 17, 27, 0.88) 100%);
}

[data-theme="dark"] ::selection {
  background: var(--ctp-mauve);
  color: var(--ctp-crust);
}

::selection {
  background: var(--moss);
  color: var(--beige);
}

a {
  color: var(--midnight);
  text-decoration: none;
  border-bottom: 1px solid rgba(16, 86, 102, 0.35);
  transition: color 0.15s ease, border-color 0.15s ease;
}

a:hover {
  color: var(--rosy);
  border-bottom-color: var(--rosy);
}

/* ── chrome controls ── */
.chrome-controls {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.site-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.2rem;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.site-nav__link {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  padding: 0.38rem 0.55rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.site-nav__sep {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  opacity: 0.4;
  user-select: none;
}

.site-nav__link:hover {
  color: var(--ink);
  border-bottom: none;
}

.site-nav__link[aria-current="page"] {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
}

[data-theme="dark"] .site-nav {
  background: rgba(49, 50, 68, 0.65);
  border-color: rgba(108, 112, 134, 0.45);
}

[data-theme="dark"] .site-nav__link[aria-current="page"] {
  background: rgba(69, 71, 90, 0.85);
  color: var(--ctp-text);
}

[data-theme="dark"] a.site-nav__link {
  color: var(--muted);
  border-bottom: none;
}

[data-theme="dark"] a.site-nav__link:hover {
  color: var(--ctp-text);
  border-bottom: none;
}

.bg-mode-toggle {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.65rem;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  text-transform: lowercase;
  color: var(--muted);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.bg-mode-toggle:hover {
  color: var(--ink);
  border-color: var(--moss);
}

[data-theme="dark"] .bg-mode-toggle {
  background: rgba(49, 50, 68, 0.65);
  border-color: rgba(108, 112, 134, 0.45);
}

[data-theme="dark"] .bg-mode-toggle:hover {
  border-color: var(--ctp-teal);
  color: var(--ctp-teal);
}

/* ── theme toggle ── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--rosy);
}

[data-theme="dark"] .theme-toggle {
  background: rgba(49, 50, 68, 0.65);
  border-color: rgba(108, 112, 134, 0.45);
}

[data-theme="dark"] .theme-toggle:hover {
  border-color: var(--ctp-pink);
  color: var(--ctp-pink);
}

/* ── layout ── */
.page {
  position: relative;
  z-index: 3;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 5rem 1.5rem 4rem;
  text-shadow: 0 0 18px rgba(247, 244, 213, 0.95), 0 1px 2px rgba(247, 244, 213, 0.85);
}

[data-theme="dark"] .page {
  text-shadow: 0 0 20px rgba(17, 17, 27, 0.95), 0 0 8px rgba(17, 17, 27, 0.85), 0 1px 3px rgba(0, 0, 0, 0.6);
}

.page--narrow {
  max-width: 820px;
}

/* ── hero ── */
.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.section-rule {
  border: 0;
  height: 0;
  margin: 0 0 1.25rem;
  border-top: 1px solid var(--line);
}

.section-rule + .block {
  margin-top: 0;
}

.hero-brand {
  display: block;
  width: 100%;
  margin-bottom: 0.4rem;
}

.hero-brand h1 {
  margin: 0;
}

.lorenz-wrap,
.torus-wrap {
  width: 152px;
  height: 96px;
  flex-shrink: 0;
  pointer-events: none;
}

.hero-name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 2.75rem);
  margin: 0;
  color: var(--dark-green);
  letter-spacing: -0.01em;
  text-align: center;
  white-space: nowrap;
}

.attractors-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: clamp(10px, 2.5vw, 18px);
  width: min(100%, 760px);
  margin-inline: auto;
}

.lorenz-wrap {
  justify-self: end;
}

.torus-wrap {
  justify-self: start;
  width: 168px;
}

.lorenz,
.torus {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}

h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 2.75rem);
  margin: 0 0 0.4rem;
  color: var(--dark-green);
  letter-spacing: -0.01em;
}

.tagline {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--soft);
  margin: 0 0 0.6rem;
}

.sub {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.affil { color: var(--midnight); font-weight: 500; }
.prev  { color: var(--muted); }
.dot   { margin: 0 0.5rem; opacity: 0.5; }

/* ── sections ── */
.block { margin: 1.5rem 0; }

h2 {
  font-family: var(--mono);
  font-style: normal;
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 1.25rem;
  padding-left: 0;
}

h2::before {
  content: "// ";
  color: var(--moss);
  font-weight: 400;
  letter-spacing: 0;
}

.block p {
  margin: 0 0 1rem;
  color: var(--soft);
  font-size: 14px;
}

.block p:last-child { margin-bottom: 0; }

.block em {
  color: var(--midnight);
  font-style: normal;
  font-weight: 500;
}

/* ── timeline items ── */
.item {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1rem 1.5rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--line);
}

.item:last-child { border-bottom: 1px solid var(--line); }

#work .item:first-of-type {
  border-top: none;
  padding-top: 0;
}

#work h2 {
  margin-bottom: 1rem;
}

.when {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--moss);
  padding-top: 0.15rem;
  letter-spacing: 0.02em;
}

.body h3 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--dark-green);
  letter-spacing: -0.01em;
}

.role {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

.body p {
  margin: 0;
  font-size: 14px;
  color: var(--soft);
}

/* ── project cards ── */
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.view-toggle__btn {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0.2rem 0.1rem;
  cursor: pointer;
  opacity: 0.6;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.view-toggle__btn:hover {
  color: var(--ink);
  opacity: 1;
}

.view-toggle__btn[aria-pressed="true"] {
  color: var(--moss);
  opacity: 1;
}

[data-theme="dark"] .view-toggle__btn[aria-pressed="true"] {
  color: var(--ctp-teal);
}

.view-toggle__sep {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  opacity: 0.35;
  user-select: none;
}

.cards {
  display: grid;
  gap: 1rem;
}

.cards--cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 640px) {
  .cards--cols {
    grid-template-columns: 1fr;
  }
}

.card {
  display: block;
  padding: 1.1rem 1.2rem;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  color: var(--ink);
}

.card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(211, 150, 140, 0.6);
  color: var(--ink);
}

[data-theme="dark"] a {
  color: var(--midnight);
  border-bottom-color: rgba(137, 180, 250, 0.35);
}

[data-theme="dark"] a:hover {
  color: var(--rosy);
  border-bottom-color: var(--rosy);
}

[data-theme="dark"] h1,
[data-theme="dark"] .body h3 {
  color: var(--ink);
}

[data-theme="dark"] h2 {
  color: var(--ctp-subtext0);
}

[data-theme="dark"] h2::before {
  color: var(--ctp-teal);
}

[data-theme="dark"] .when {
  color: var(--moss);
}

[data-theme="dark"] .affil {
  color: var(--midnight);
}

[data-theme="dark"] .card {
  background: var(--card-bg);
  border-color: var(--line);
  color: var(--ink);
}

[data-theme="dark"] .card:hover {
  background: rgba(49, 50, 68, 0.72);
  border-color: rgba(203, 166, 247, 0.45);
}

.card h3 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.card p {
  margin: 0 0 0.75rem;
  font-size: 14px;
  color: var(--soft);
  line-height: 1.65;
}

.card .meta {
  font-size: 11.5px;
  color: var(--moss);
  letter-spacing: 0.02em;
}

/* ── links list ── */
.links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.links li { margin: 0; }

.links a {
  font-size: 14px;
  border-bottom-width: 1px;
}

/* ── footer ── */
.foot {
  text-align: center;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.foot-wave {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--moss);
  opacity: 0.6;
  margin: 0 0 0.75rem;
  white-space: pre;
}

[data-theme="dark"] .foot-wave {
  color: var(--ctp-subtext1);
  opacity: 0.85;
}

.foot p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* ── blog ── */
.back-link {
  display: inline-block;
  font-size: 13px;
  margin-bottom: 2rem;
  color: var(--muted);
}

.back-link:hover { color: var(--ink); }

.blog-header {
  margin-bottom: 2.5rem;
}

.blog-header h1 {
  text-align: left;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  margin-bottom: 0.5rem;
}

.blog-header p {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

.blog-support__link {
  color: var(--soft);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.blog-support__link:hover {
  color: var(--ink);
  border-bottom-color: var(--moss);
}

[data-theme="dark"] .blog-support__link {
  color: var(--soft);
  border-bottom-color: rgba(108, 112, 134, 0.45);
}

[data-theme="dark"] .blog-support__link:hover {
  color: var(--ink);
  border-bottom-color: var(--ctp-teal);
}

.blog-support__tea {
  display: inline-block;
  margin-left: 0.2rem;
  font-size: 2.15em;
  line-height: 1;
  vertical-align: -0.12em;
  color: inherit;
  border: 0;
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-list li {
  border-top: 1px solid var(--line);
}

.post-list li:last-child {
  border-bottom: 1px solid var(--line);
}

.post-list a {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1rem 1.5rem;
  padding: 1.1rem 0;
  border-bottom: none;
  color: inherit;
  transition: opacity 0.15s ease;
}

.post-list a:hover {
  opacity: 0.75;
  color: inherit;
  border-bottom: none;
}

.post-date {
  font-size: 12px;
  color: var(--muted);
}

.post-title {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.post-excerpt {
  grid-column: 2;
  font-size: 13px;
  color: var(--soft);
  margin-top: -0.25rem;
}

/* ── vault sidebar (blog section content tree) ── */
.vault {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 248px;
  z-index: 4;
  padding: 1.6rem 1.3rem 1.4rem 1.6rem;
  border-right: 1px solid var(--line);
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow-y: auto;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

/* toggle handle for the vault (created by vault.js) - an edge tab that rides
   the sidebar's right border when open and the screen's left edge when closed */
.vault-toggle {
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  z-index: 6;
  width: 24px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 9px 9px 0;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: left 0.25s ease, color 0.15s ease, border-color 0.15s ease;
}

.vault-toggle:hover {
  color: var(--ink);
  border-color: var(--moss);
}

[data-theme="dark"] .vault-toggle:hover {
  border-color: var(--ctp-teal);
  color: var(--ctp-teal);
}

.vault__title {
  font-family: var(--serif);
  font-size: 1.45rem;
  color: var(--dark-green);
  border-bottom: none;
  display: inline-block;
}

.vault__title:hover {
  color: var(--rosy);
  border-bottom: none;
}

.vault__sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin: 0.1rem 0 1.6rem;
}

.vault__head {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 0.7rem;
}

.vault__head::before {
  content: "// ";
  color: var(--moss);
  font-weight: 400;
  letter-spacing: 0;
}

.vault__tree {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 13px;
}

.vault__about {
  display: block;
  padding: 0.32rem 0.5rem;
  border-radius: 6px;
  border-bottom: none;
  color: var(--soft);
}

.vault__about:hover {
  background: rgba(255, 255, 255, 0.35);
  border-bottom: none;
}

.vault__about[aria-current="page"],
.vault__post-link[aria-current="page"] {
  color: var(--midnight);
  background: rgba(131, 153, 88, 0.16);
}

[data-theme="dark"] .vault__about:hover,
[data-theme="dark"] .vault__post-link:hover {
  background: rgba(69, 71, 90, 0.55);
}

[data-theme="dark"] .vault__about[aria-current="page"],
[data-theme="dark"] .vault__post-link[aria-current="page"] {
  color: var(--ctp-teal);
  background: rgba(148, 226, 213, 0.1);
}

.vault__folder {
  margin-top: 0.1rem;
}

.vault__folder-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.32rem 0.5rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--soft);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.vault__folder-btn:hover {
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
}

[data-theme="dark"] .vault__folder-btn:hover {
  background: rgba(69, 71, 90, 0.55);
}

.vault__chev {
  display: inline-block;
  color: var(--moss);
  font-size: 11px;
  transition: transform 0.15s ease;
}

.vault__folder-btn[aria-expanded="true"] .vault__chev {
  transform: rotate(90deg);
}

.vault__name {
  flex: 1;
}

.vault__count {
  font-size: 10px;
  color: var(--moss);
}

.vault__posts {
  list-style: none;
  margin: 0.1rem 0 0.3rem;
  padding: 0 0 0 1.15rem;
  border-left: 1px solid var(--line);
  margin-left: 0.85rem;
}

.vault__post-link {
  display: block;
  padding: 0.26rem 0.5rem;
  border-radius: 6px;
  border-bottom: none;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vault__post-link:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.35);
  border-bottom: none;
}

.vault__empty {
  font-size: 11.5px;
  font-style: italic;
  color: var(--muted);
  opacity: 0.75;
  padding: 0.26rem 0.5rem;
}

.vault__home {
  margin-top: auto;
  padding-top: 1.5rem;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  border-bottom: none;
}

.vault__home:hover {
  color: var(--rosy);
  border-bottom: none;
}

/* open state (explicit, set by vault.js) */
.vault-open .vault {
  transform: none;
}

.vault-collapsed .vault {
  transform: translateX(-100%);
}

/* when open, the handle rides the sidebar's right border */
.vault-open .vault-toggle {
  left: 248px;
}

@media (min-width: 1020px) {
  /* default to open on desktop (no flash before vault.js runs) */
  .vault {
    transform: none;
  }

  .vault-toggle {
    left: 248px;
  }

  .vault-collapsed .vault {
    transform: translateX(-100%);
  }

  .vault-collapsed .vault-toggle {
    left: 0;
  }

  .has-vault .page {
    margin-left: 300px;
    margin-right: auto;
  }

  /* leave room on the right so the floating TOC never overlaps text */
  .has-toc .page {
    margin-right: 7rem;
  }

  /* collapsed: re-center the content, drop the sidebar gutter */
  .has-vault.vault-collapsed .page {
    margin-left: auto;
    margin-right: auto;
  }

  /* the tree replaces the chip row + back link on desktop while open */
  .has-vault:not(.vault-collapsed) .topic-nav,
  .has-vault:not(.vault-collapsed) .back-link {
    display: none;
  }
}

/* ── topic index ── */
.topic-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.75rem;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: var(--card-bg);
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.topic-chip:hover {
  color: var(--ink);
  border-color: var(--rosy);
}

.topic-chip[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--moss);
  background: rgba(131, 153, 88, 0.14);
}

[data-theme="dark"] .topic-chip[aria-pressed="true"] {
  border-color: var(--ctp-teal);
  background: rgba(148, 226, 213, 0.1);
}

.topic-count {
  font-size: 10px;
  color: var(--moss);
}

.post-topic {
  display: block;
  margin-top: 0.2rem;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--moss);
}

.topic-empty {
  font-family: var(--mono);
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
  text-align: center;
  padding: 2.5rem 1rem;
  margin: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* ── blog post ── */
.post-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2rem;
}

.post-meta a {
  color: var(--moss);
  border-bottom-color: transparent;
}

.post-meta a:hover {
  color: var(--rosy);
}

.post-content h2 {
  scroll-margin-top: 2rem;
  font-family: var(--mono);
  font-style: normal;
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--ink);
  margin-top: 2.5rem;
  padding-left: 0;
}

.post-content h2::before { display: none; }

.post-content h3 {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  margin: 2rem 0 0.75rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.post-content p,
.post-content li {
  color: var(--soft);
  font-size: 14px;
}

.post-content ul,
.post-content ol {
  padding-left: 1.25rem;
  margin: 0 0 1rem;
}

.post-content li { margin-bottom: 0.35rem; }

.post-content code {
  font-family: var(--mono);
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.post-content pre {
  position: relative;
  overflow-x: auto;
  padding: 1rem 1.15rem;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
}

.post-content pre code {
  padding: 0;
  background: none;
  border: none;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  padding: 0.35em 0.6em;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.post-content pre:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--ink);
  border-color: var(--moss);
}

.copy-btn.is-copied {
  color: var(--accent);
  border-color: var(--accent);
  opacity: 1;
}

[data-theme="dark"] .copy-btn.is-copied {
  color: var(--ctp-green);
  border-color: var(--ctp-green);
}

@media (hover: none) {
  .copy-btn {
    opacity: 0.85;
  }
}

.post-content blockquote {
  margin: 1.5rem 0;
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.post-source {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: 13px !important;
  color: var(--muted) !important;
}

/* ── media: images, gifs, video, embeds ── */
.post-content figure {
  margin: 2.25rem 0;
}

.post-content img,
.post-content video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card-bg);
}

.post-content figcaption {
  margin-top: 0.65rem;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

/* responsive 16:9 wrapper for iframe embeds (youtube, vimeo, ...) */
.post-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--card-bg);
}

.post-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* inline svg diagrams adapt to the theme via currentColor */
.post-diagram {
  color: var(--soft);
}

.post-diagram svg {
  display: block;
  width: 100%;
  height: auto;
}

[data-theme="dark"] .post-diagram {
  color: var(--ctp-subtext1);
}

/* let media break out wider than the text column for emphasis */
.post-media--wide {
  width: min(94vw, 1080px);
  margin-left: 50%;
  transform: translateX(-50%);
}

@media (max-width: 880px) {
  .post-media--wide {
    width: 100%;
    margin-left: 0;
    transform: none;
  }
}

/* ── floating "on this page" navigator ── */
.toc {
  position: fixed;
  top: 50%;
  right: 1.75rem;
  transform: translateY(-50%);
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  max-width: 18rem;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  transition: background 0.2s ease, border-color 0.2s ease, backdrop-filter 0.2s ease;
}

.toc:hover,
.toc:focus-within {
  background: var(--card-bg);
  border-color: var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.toc__title {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  white-space: nowrap;
  color: var(--muted);
  opacity: 0;
  max-width: 0;
  max-height: 0;
  overflow: hidden;
  transform: translateX(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, max-width 0.2s ease, max-height 0.2s ease;
  pointer-events: none;
}

.toc:hover .toc__title,
.toc:focus-within .toc__title {
  opacity: 0.8;
  max-width: 16rem;
  max-height: 2rem;
  transform: none;
}

.toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.toc__link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  border-bottom: none;
  color: var(--muted);
}

.toc__dash {
  flex: none;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--muted);
  opacity: 0.5;
  transition: width 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.toc__label {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, max-width 0.2s ease, color 0.2s ease;
  color: var(--soft);
}

.toc:hover .toc__label,
.toc:focus-within .toc__label {
  max-width: 14rem;
  opacity: 1;
  transform: none;
}

.toc__link:hover .toc__dash {
  width: 24px;
  opacity: 1;
  background: var(--ink);
}

.toc__link:hover .toc__label {
  color: var(--ink);
}

.toc__link[aria-current="true"] .toc__dash {
  width: 28px;
  opacity: 1;
  background: var(--accent);
}

.toc__link[aria-current="true"] .toc__label {
  color: var(--ink);
}

[data-theme="dark"] .toc__link[aria-current="true"] .toc__dash {
  background: var(--ctp-mauve);
}

/* inline "on this page" (mobile only; hidden on desktop) */
.toc-inline {
  display: none;
}

@media (max-width: 1019px) {
  .toc {
    display: none;
  }

  .toc-inline {
    display: block;
    margin: 0 0 1.85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card-bg);
    overflow: hidden;
  }
}

.toc-inline > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.95rem;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.toc-inline > summary::-webkit-details-marker {
  display: none;
}

.toc-inline__chev {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.2s ease;
}

.toc-inline[open] .toc-inline__chev {
  transform: rotate(90deg);
}

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

.toc-inline a {
  display: block;
  padding: 0.4rem 0.95rem 0.4rem 1.55rem;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--soft);
  border-bottom: none;
}

.toc-inline a:hover {
  color: var(--ink);
}

.toc-inline a[aria-current="true"] {
  color: var(--accent);
}

[data-theme="dark"] .toc-inline a[aria-current="true"] {
  color: var(--ctp-mauve);
}

/* ── 404 ── */
.page-404 {
  text-align: center;
  padding-top: 6.5rem;
}

.eyebrow-404 {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--moss);
  margin: 0 0 0.5rem;
}

.page-404 h1 {
  font-size: clamp(4.5rem, 18vw, 7.5rem);
  line-height: 1;
  margin: 0 0 0.75rem;
}

.quip-404 {
  max-width: 34rem;
  margin: 0 auto;
}

.quote-404 {
  max-width: 28rem;
  margin: 1.75rem auto 0;
  padding: 0;
  border: none;
  text-align: center;
}

.quote-404__greek {
  font-family: var(--serif);
  font-size: clamp(1.05rem, 3.2vw, 1.25rem);
  font-style: italic;
  line-height: 1.5;
  color: var(--ink);
  margin: 0 0 0.45rem;
  letter-spacing: 0.01em;
}

.quote-404__latin {
  font-family: var(--serif);
  font-size: clamp(0.95rem, 2.8vw, 1.1rem);
  font-style: italic;
  line-height: 1.5;
  color: var(--soft);
  margin: 0 0 0.65rem;
}

.quote-404__gloss {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.quote-404__cite {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--moss);
}

.quote-404__cite cite {
  font-style: normal;
}

.quote-404__cite .dot {
  margin: 0 0.4rem;
  opacity: 0.55;
}

/* the fake transcript reuses the live terminal's styling, embedded in-page */
.term-static {
  margin: 2.25rem auto 2rem;
  width: min(520px, 100%);
  text-align: left;
  transform: none;
  transition: none;
}

.term-static .term-output {
  min-height: 0;
}

.links-404 {
  margin: 0 0 1rem;
}

.page-404 .foot {
  margin-top: 3rem;
}

/* ── responsive ── */
/* stack the name above the attractor canvases before the row can force
   the mobile layout viewport wider than the screen */
@media (max-width: 640px) {
  .attractors-wrap {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "title title"
      "lorenz torus";
    row-gap: 0.35rem;
    column-gap: 12px;
    width: 100%;
  }

  .hero-name {
    grid-area: title;
    justify-self: center;
  }

  .lorenz-wrap {
    grid-area: lorenz;
    justify-self: center;
    width: 140px;
    height: 85px;
  }

  .torus-wrap {
    grid-area: torus;
    justify-self: center;
    width: 152px;
    height: 85px;
  }
}

@media (max-width: 540px) {
  .page { padding: 4.5rem 1.15rem 3rem; }

  .item,
  .post-list a {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .when,
  .post-date { font-size: 11px; }

  .post-excerpt { grid-column: 1; margin-top: 0; }

  .chrome-controls {
    top: 0.85rem;
    right: 0.85rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: calc(100vw - 1.7rem);
  }

  .site-nav__link,
  .bg-mode-toggle {
    font-size: 10px;
    padding: 0.35rem 0.45rem;
  }

  .hero-brand {
    width: 100%;
  }

  .attractors-wrap {
    width: 100%;
  }

  .lorenz-wrap {
    width: 132px;
    height: 82px;
  }

  .torus-wrap {
    width: 140px;
    height: 82px;
  }
}

/* ── scroll reveal (only when fx.js is running) ── */
.fx .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.fx .reveal.is-visible {
  opacity: 1;
  transform: none;
}

.fx .card.tiltable {
  transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease,
              opacity 0.6s ease;
  will-change: transform;
}

/* ── hidden terminal ── */
.term {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh 1rem 0;
  padding: 9dvh 1rem 0;
  background: rgba(8, 40, 24, 0.25);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  /* visibility flips after the fade-out on close, but instantly on open -
     focus() needs the input visible in the same tick as the opening tap */
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

[data-theme="dark"] .term {
  background: rgba(17, 17, 27, 0.5);
}

.term.term-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0s;
}

.term-window {
  width: min(640px, 100%);
  max-height: 70vh;
  max-height: 70dvh;
  display: flex;
  flex-direction: column;
  background: rgba(247, 244, 213, 0.96);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(8, 40, 24, 0.35);
  overflow: hidden;
  transform: translateY(-12px) scale(0.985);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.term-open .term-window {
  transform: none;
}

[data-theme="dark"] .term-window {
  background: rgba(24, 24, 37, 0.97);
  border-color: rgba(108, 112, 134, 0.45);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--line);
}

.term-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rosy);
  opacity: 0.85;
}

.term-dot:nth-child(2) { background: var(--moss); }
.term-dot:nth-child(3) { background: var(--midnight); }

.term-title {
  margin-left: 0.5rem;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.term-output {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.9rem 1rem 0.4rem;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  min-height: 8rem;
}

.term-line {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

.term-dim    { color: var(--muted); }
.term-err    { color: var(--rosy); }
.term-accent { color: var(--midnight); font-weight: 500; }

[data-theme="dark"] .term-err    { color: var(--ctp-red); }
[data-theme="dark"] .term-accent { color: var(--ctp-green); }

.term-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem 0.9rem;
}

.term-prompt {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--moss);
  white-space: nowrap;
}

[data-theme="dark"] .term-prompt {
  color: var(--ctp-teal);
}

.term-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  caret-color: var(--rosy);
}

/* ── terminal hint in footer ── */
.term-hint {
  display: inline-block;
  border: none;
  background: transparent;
  padding: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  cursor: pointer;
  margin: 0 0 0.5rem;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.term-hint:hover {
  opacity: 1;
  color: var(--midnight);
}

.term-hint kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 0.1em 0.45em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--card-bg);
}

/* ── matrix rain ── */
.matrix {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0.55;
}

/* ── responsive: terminal ── */
@media (max-width: 540px) {
  .term {
    padding-top: 4vh;
    padding-top: 4dvh;
  }
  .term-window {
    max-height: 78vh;
    max-height: 78dvh;
  }
  .term-output, .term-prompt { font-size: 12px; }
  .term-output { min-height: 4rem; }
  /* 16px minimum stops iOS from auto-zooming the page on focus */
  .term-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .fx .reveal {
    opacity: 1;
    transform: none;
  }
}

/* ── guided tour ── */
.tour-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tour-btn:hover {
  color: var(--ink);
  border-color: var(--rosy);
}

[data-theme="dark"] .tour-btn {
  background: rgba(49, 50, 68, 0.65);
  border-color: rgba(108, 112, 134, 0.45);
}

[data-theme="dark"] .tour-btn:hover {
  color: var(--ctp-mauve);
  border-color: var(--ctp-mauve);
}

.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  cursor: default;
}

.tour-spotlight {
  position: fixed;
  z-index: 51;
  border-radius: 10px;
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(12, 14, 22, 0.6);
  pointer-events: none;
  transition: all 0.25s ease;
}

[data-theme="dark"] .tour-spotlight {
  border-color: var(--ctp-mauve);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.72);
}

.tour-tooltip {
  position: fixed;
  z-index: 52;
  width: max-content;
  max-width: min(310px, calc(100vw - 28px));
  padding: 1rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.28);
}

.tour-tooltip h4 {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  margin: 0 0 0.45rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.tour-tooltip p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--soft);
  margin: 0;
}

.tour-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-top: 0.95rem;
}

.tour-progress {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.tour-actions {
  display: flex;
  gap: 0.4rem;
}

.tour-action {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.tour-action:hover {
  color: var(--ink);
  border-color: var(--moss);
}

.tour-action--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tour-action--primary:hover {
  color: #fff;
  filter: brightness(1.08);
}

.tour-action:disabled {
  opacity: 0.4;
  cursor: default;
}

.tour-skip {
  border-color: transparent;
  margin-right: auto;
}

/* the highlighted target stays *below* the click-blocking overlay (so it
   can't be operated mid-tour) but shows through the spotlight's clear hole.
   forced visible for hover-only controls like the copy button. */
.tour-active {
  opacity: 1 !important;
}

/* expand the floating TOC while it's the active step */
.toc.tour-active .toc__title {
  opacity: 0.8;
  max-width: 16rem;
  max-height: 2rem;
  transform: none;
}

.toc.tour-active .toc__label {
  max-width: 14rem;
  opacity: 1;
  transform: none;
}

.toc.tour-active {
  background: var(--card-bg);
  border-color: var(--line);
}

/* ── mood RGB aura (music.js) ── */
:root {
  --mood-r: 178;
  --mood-g: 128;
  --mood-b: 255;
  --mood-ar: 118;
  --mood-ag: 205;
  --mood-ab: 225;
  --mood-i: 0.72;
}

.mood-aura {
  position: fixed;
  inset: 0;
  z-index: 2; /* above the vignette + bg canvas, below .page content (z-index 3) */
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease;
  background:
    radial-gradient(ellipse 85% 65% at 18% 28%, rgb(var(--mood-r) var(--mood-g) var(--mood-b) / calc(0.42 * var(--mood-i))), transparent 68%),
    radial-gradient(ellipse 75% 55% at 82% 72%, rgb(var(--mood-ar) var(--mood-ag) var(--mood-ab) / calc(0.36 * var(--mood-i))), transparent 62%),
    radial-gradient(ellipse 120% 90% at 50% 100%, rgb(var(--mood-r) var(--mood-g) var(--mood-b) / calc(0.20 * var(--mood-i))), transparent 55%);
  mix-blend-mode: multiply; /* light theme: colored-gel look that reads on cream bg */
}

[data-theme="dark"] .mood-aura {
  mix-blend-mode: screen; /* dark theme: glow that lifts off the dark bg */
}

.mood-aura.is-live {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .mood-aura {
    transition: none;
  }
}

/* ── music dock (lazy YouTube embed - free, no login, right-aligned) ── */
.music-dock {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  max-width: min(360px, calc(100vw - 2.2rem));
}

.music-dock__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  text-transform: lowercase;
  color: var(--muted);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
}

.music-dock__toggle:hover {
  color: var(--ink);
  border-color: var(--moss);
}

.music-dock--open .music-dock__toggle {
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: 0 0 18px rgb(var(--mood-r) var(--mood-g) var(--mood-b) / 0.35);
}

[data-theme="dark"] .music-dock__toggle {
  background: rgba(49, 50, 68, 0.65);
  border-color: rgba(108, 112, 134, 0.45);
}

[data-theme="dark"] .music-dock--open .music-dock__toggle {
  border-color: var(--ctp-mauve);
  box-shadow: 0 0 20px rgb(var(--mood-r) var(--mood-g) var(--mood-b) / 0.4);
}

.music-dock__icon {
  display: inline-block;
  font-size: 13px;
  transform-origin: center center;
}

@keyframes music-dock-icon-dance {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.music-dock--playing .music-dock__icon {
  animation: music-dock-icon-dance 2s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .music-dock--playing .music-dock__icon {
    animation: none;
  }
}

.music-dock__label {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-dock__panel {
  position: absolute; /* out of flow so the closed toggle rests at bottom-right */
  right: 0;
  bottom: calc(100% + 0.5rem); /* float above the toggle */
  width: min(360px, calc(100vw - 2.2rem));
  padding: 0.75rem 0.85rem 0.85rem;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  /* user-resizable width only; height follows content */
  resize: horizontal;
  overflow: hidden;
  direction: rtl;
  min-width: 230px;
  min-height: 0;
  max-width: min(92vw, 560px);
  transform-origin: bottom right;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0.28s;
}

.music-dock__panel > * {
  direction: ltr;
}

.music-dock--open .music-dock__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s;
}

@media (prefers-reduced-motion: reduce) {
  .music-dock__panel,
  .music-dock--open .music-dock__panel {
    transition: opacity 0.12s ease, visibility 0s;
    transform: none;
  }
}

[data-theme="dark"] .music-dock__panel {
  background: rgba(49, 50, 68, 0.88);
  border-color: rgba(108, 112, 134, 0.45);
}

.music-dock__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.music-dock__title {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--soft);
}

.music-dock__mood,
.music-dock__link,
.music-dock__qbtn,
.music-dock__shuffle {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  text-transform: lowercase;
  padding: 0.3rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
}

.music-dock__mood[aria-pressed="true"],
.music-dock__qbtn[aria-pressed="true"],
.music-dock__shuffle[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

[data-theme="dark"] .music-dock__mood[aria-pressed="true"],
[data-theme="dark"] .music-dock__qbtn[aria-pressed="true"],
[data-theme="dark"] .music-dock__shuffle[aria-pressed="true"] {
  color: var(--ctp-mauve);
  border-color: var(--ctp-mauve);
}

.music-dock__mood:hover,
.music-dock__link:hover,
.music-dock__qbtn:hover,
.music-dock__shuffle:hover {
  color: var(--ink);
  border-color: var(--moss);
}

/* ── playlist / queue panel (slides out to the left of the dock panel) ── */
.music-dock__queue,
.music-dock__playlists {
  position: absolute;
  right: 0; /* JS shifts these left of the panel on wide screens */
  bottom: calc(100% + 0.5rem);
  z-index: 4;
  display: flex;
  flex-direction: column;
  width: min(300px, calc(100vw - 2.2rem));
  max-height: 56vh;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0.28s;
}

.music-dock__playlists {
  width: min(190px, calc(100vw - 2.2rem));
  z-index: 3; /* sits under the songs column when they overlap (mobile) */
}

.music-dock--open.music-dock--queue .music-dock__queue,
.music-dock--open.music-dock--playlists .music-dock__playlists {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s;
}

[data-theme="dark"] .music-dock__queue,
[data-theme="dark"] .music-dock__playlists {
  background: rgba(49, 50, 68, 0.92);
  border-color: rgba(108, 112, 134, 0.45);
}

.music-dock__pl-list {
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  overflow-y: auto;
}

.music-dock__pl-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.music-dock__pl-row:hover { background: rgba(0, 0, 0, 0.05); }
[data-theme="dark"] .music-dock__pl-row:hover { background: rgba(255, 255, 255, 0.06); }

.music-dock__pl-row.is-active {
  background: rgb(var(--mood-r) var(--mood-g) var(--mood-b) / 0.14);
  color: var(--accent);
}

[data-theme="dark"] .music-dock__pl-row.is-active { color: var(--ctp-mauve); }

.music-dock__pl-row::before {
  content: "♫";
  font-size: 11px;
  opacity: 0.7;
}

.music-dock__queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--soft);
}

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

.music-dock__search-wrap {
  display: flex;
  align-items: center;
  padding: 0.45rem 0.75rem 0.35rem;
  border-bottom: 1px solid var(--line);
}

.music-dock__search {
  width: 100%;
  padding: 0.35rem 0.45rem;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.music-dock__search::placeholder {
  color: var(--muted);
}

.music-dock__search:focus {
  border-color: var(--accent);
}

[data-theme="dark"] .music-dock__search {
  color: var(--ctp-text);
  border-color: rgba(108, 112, 134, 0.45);
}

[data-theme="dark"] .music-dock__search:focus {
  border-color: var(--ctp-mauve);
}

.music-dock__queue-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
}

.music-dock__queue-close:hover { color: var(--ink); }

.music-dock__queue-list {
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  overflow-y: auto;
}

.music-dock__queue-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
  cursor: pointer;
}

.music-dock__queue-row:hover { background: rgba(0, 0, 0, 0.05); }
[data-theme="dark"] .music-dock__queue-row:hover { background: rgba(255, 255, 255, 0.06); }

.music-dock__queue-row.is-current {
  background: rgb(var(--mood-r) var(--mood-g) var(--mood-b) / 0.14);
}

.music-dock__queue-row.is-current .music-dock__queue-title { color: var(--accent); }
[data-theme="dark"] .music-dock__queue-row.is-current .music-dock__queue-title { color: var(--ctp-mauve); }

.music-dock__queue-thumb {
  width: 44px;
  height: 33px;
  flex: none;
  object-fit: cover;
  border-radius: 4px;
  background: var(--line);
}

.music-dock__queue-title {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-dock__queue-empty {
  list-style: none;
  padding: 0.7rem;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

/* off-screen player: video stays hidden, audio keeps streaming */
.music-dock__audio {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 300px;
  height: 170px;
  opacity: 0;
  pointer-events: none;
}

.music-dock__nowplaying {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.music-dock__art {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid var(--line);
}

[data-theme="dark"] .music-dock__art {
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(108, 112, 134, 0.45);
}

.music-dock__now {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-dock__footer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.music-dock__shuffle {
  flex-shrink: 0;
  padding: 0.28rem 0.45rem;
}

.music-dock__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.music-dock__volume {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
  margin: 0;
  cursor: pointer;
}

.music-dock__vol-label {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  text-transform: lowercase;
  color: var(--muted);
}

.music-dock__vol {
  flex: 1;
  min-width: 0;
  height: 4px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

[data-theme="dark"] .music-dock__vol {
  accent-color: var(--ctp-mauve);
}

.music-dock__ctrl {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 0;
  line-height: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.music-dock__ctrl[data-act="prev"],
.music-dock__ctrl[data-act="next"] {
  font-size: 0;
}

.music-dock__skip {
  display: block;
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.music-dock__ctrl--play::before,
.music-dock__ctrl--play::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}

.music-dock__ctrl--play::before {
  left: calc(50% + 1px);
  transform: translate(-50%, -50%);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid currentColor;
}

.music-dock__ctrl--play.is-playing::before,
.music-dock__ctrl--play.is-playing::after {
  width: 2.5px;
  height: 12px;
  background: currentColor;
  border: 0;
  border-radius: 1px;
  transform: translateY(-50%);
}

.music-dock__ctrl--play.is-playing::before { left: calc(50% - 4px); }
.music-dock__ctrl--play.is-playing::after { left: calc(50% + 2px); }

.music-dock__ctrl:hover {
  color: var(--ink);
  border-color: var(--moss);
}

.music-dock__ctrl--play:hover {
  color: var(--accent);
  border-color: transparent;
}

[data-theme="dark"] .music-dock__ctrl--play:hover {
  color: var(--ctp-mauve);
}

.music-dock__ctrl--play {
  width: 42px;
  height: 42px;
  color: var(--accent);
  border: 0;
  background: transparent;
}

.music-dock__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}

.music-dock__ring-track,
.music-dock__ring-prog {
  fill: none;
  stroke-width: 2;
}

.music-dock__ring-track {
  stroke: var(--line);
}

.music-dock__ring-prog {
  stroke: var(--accent);
  stroke-linecap: round;
}

[data-theme="dark"] .music-dock__ctrl--play {
  color: var(--ctp-mauve);
}

[data-theme="dark"] .music-dock__ring-track {
  stroke: rgba(166, 173, 200, 0.35);
}

[data-theme="dark"] .music-dock__ring-prog {
  stroke: var(--ctp-mauve);
}

.music-dock__ctrl--play:hover .music-dock__ring-track {
  stroke: var(--moss);
}

/* ── narrow screens (phones, iPad portrait): the 3 columns can't sit side by
   side, so each panel becomes a full-width cover that stacks over the previous
   (songs > playlists > dock panel). close × on each drills back out. ── */
@media (max-width: 899px) {
  .music-dock__panel,
  .music-dock__queue,
  .music-dock__playlists {
    width: calc(100vw - 1.7rem) !important; /* beats inline resize width */
    max-width: calc(100vw - 1.7rem) !important;
    height: auto !important;
    right: 0;
  }

  .music-dock__panel {
    resize: none; /* drag-resize is awkward on touch */
  }

  .music-dock__queue,
  .music-dock__playlists {
    max-height: 70vh;
    max-height: 70dvh;
  }
}

@media (max-width: 640px) {
  .music-dock {
    right: 0.85rem;
    bottom: 0.85rem;
  }

  .music-dock__label {
    max-width: 7.5rem;
  }

  .music-dock__controls {
    gap: 0.5rem;
  }

  .music-dock__ctrl {
    width: 44px;
    height: 44px;
  }

  .music-dock__ctrl--play {
    width: 52px;
    height: 52px;
  }

  [data-theme="dark"] .music-dock__ctrl:not(.music-dock__ctrl--play) {
    border-color: rgba(166, 173, 200, 0.38);
  }
}

/* ── pjax soft-navigation loading cue (thin top bar) ── */
.pjax-loading::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  z-index: 9999;
  background: var(--accent);
  transform-origin: left;
  animation: pjax-bar 0.9s ease-in-out infinite;
}

[data-theme="dark"] .pjax-loading::after {
  background: var(--ctp-mauve);
}

@keyframes pjax-bar {
  0% { transform: scaleX(0); opacity: 0.7; }
  60% { transform: scaleX(0.75); opacity: 0.7; }
  100% { transform: scaleX(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pjax-loading::after { animation: none; opacity: 0.6; }
}
