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

:root {
  --bg:        #faf8f5;
  --bg2:       #f3f0eb;
  --bg3:       #ede9e2;
  --border:    #ddd9d0;
  --text:      #2c2925;
  --text-dim:  #6b6662;
  --text-muted:#9b9790;
  --accent:    #c4832a;
  --accent2:   #5c8a4e;
  --accent3:   #3d7a8a;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-serif:'Fraunces', serif;
}

/* ink dark palette, near-black, high contrast */
:root[data-theme="dark"] {
  --bg:        #0f1012;
  --bg2:       #16181b;
  --bg3:       #1d2024;
  --border:    #2c3036;
  --text:      #ededec;
  --text-dim:  #a9aaa9;
  --text-muted:#76787a;
  --accent:    #e6a857;
  --accent2:   #8abb72;
  --accent3:   #69b1c2;
}

html { scroll-behavior: smooth; }

/* keep any deep-linked element clear of the sticky header when jumped to */
:target { scroll-margin-top: 72px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  min-height: 100vh;
}

/* smooth the light/dark swap */
body, header, aside, .card, .terminal, .note, .algo, .code-file, .code-body, .cmp-table {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* take the glare off light figures in dark mode */
:root[data-theme="dark"] .plot-figure img { filter: brightness(0.9); }

/* hand-made diagrams ship in two versions: a light one and a recolored dark one
   (dark background, light ink, same accent colors). Swap by theme. */
.fig-dark { display: none !important; }
:root[data-theme="dark"] .fig-light { display: none !important; }
:root[data-theme="dark"] .fig-dark { display: block !important; filter: none; }

/* in dark mode the portrait swaps to a _dark asset whose cream background is
   darkened toward the page (the face and shoulders are left intact); a soft
   border and shadow still frame it as a photo */
:root[data-theme="dark"] .hero-portrait {
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

/* theme toggle button */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  width: 30px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 13px; line-height: 1; padding: 0;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.theme-toggle svg { width: 14px; height: 14px; display: block; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Layout ── */
.site-wrapper {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ── Header ── */
header {
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 52px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}

.logo-icon { width: 28px; height: 28px; flex-shrink: 0; }

.logo-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text);
}
.logo-name span { color: var(--accent); }

nav { display: flex; align-items: center; gap: 24px; }

nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 0.15s;
}
nav a:hover { color: var(--accent); }

/* ── Sidebar ── */
aside {
  border-right: 1px solid var(--border);
  padding: 28px 0;
  overflow-y: auto;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
}

.sidebar-section { margin-bottom: 8px; }

.sidebar-category {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  cursor: pointer;
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  user-select: none;
  transition: color 0.15s;
}
.sidebar-category:hover { color: var(--accent); }

.sidebar-category .chevron {
  width: 10px; height: 10px;
  opacity: 0.4;
  transition: transform 0.2s, opacity 0.15s;
  flex-shrink: 0;
}
.sidebar-category:hover .chevron { opacity: 0.8; }
.sidebar-section.open .chevron { transform: rotate(90deg); }

.tree { display: none; padding: 2px 0 6px 20px; }
.sidebar-section.open .tree { display: block; }

.tree-item { display: flex; align-items: flex-start; position: relative; }

.tree-connector {
  display: flex; flex-direction: column; align-items: center;
  flex-shrink: 0; width: 16px; padding-top: 10px;
}
.tree-connector::before {
  content: ''; display: block; width: 1px; height: 8px; background: var(--border);
}
.tree-connector::after {
  content: ''; display: block; width: 8px; height: 1px; background: var(--border);
}

.tree-link {
  display: block;
  padding: 4px 8px 4px 0;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s;
  line-height: 1.4;
  flex: 1;
  cursor: pointer;
}
.tree-link:hover { color: var(--accent); }
.tree-link.active { color: var(--accent); }
.tree-sub { font-size: 10.5px; opacity: 0.6; }

.tree-body { flex: 1; display: flex; flex-direction: column; align-items: flex-start; }
.tree-play {
  -webkit-appearance: none; appearance: none;
  margin: 1px 0 6px;
  display: inline-flex; align-items: center;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 11px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 400; letter-spacing: 0.06em;
  cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.tree-play:hover { color: var(--accent); border-color: var(--accent); }
.tree-play:focus { outline: none; }
.tree-play:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

/* ── Page views ── */
.page { display: none; }
.page.active { display: block; }

/* ── Main ── */
main {
  overflow-y: auto;
  padding: 48px 56px;
  max-width: 900px;
}

/* ── Footer (shows under whichever page is active) ── */
.site-footer {
  margin-top: 64px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.site-footer a { color: var(--text-muted); text-decoration: none; transition: color .15s; }
.site-footer a:hover { color: var(--accent); }

/* ── Hero (home page) ── */
.hero {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: center;
  gap: 28px;
  max-width: 680px;
  margin: 12px auto 32px;
  text-align: right;
}
.hero-text { flex: 0 1 auto; }
.hero-portrait {
  position: relative;
  flex-shrink: 0;
  width: 152px;
  height: 152px;
  border-radius: 18px;
  overflow: hidden;
}
.hero-portrait-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: opacity 0.18s ease-out;
}
.hero-portrait .portrait-hover { opacity: 0; }
.hero-portrait:hover .portrait-default { opacity: 0; }
.hero-portrait:hover .portrait-hover  { opacity: 1; }
.hero-text h1 {
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 300;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.05;
  margin: 0;
}
.hero-text h1 em {
  font-style: italic;
  color: var(--accent);
}
.hero-sub {
  margin: 12px 0 0;
  max-width: 460px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-dim);
}
.hero-sub a {
  color: var(--accent); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  cursor: pointer; transition: border-color 0.15s;
}
.hero-sub a:hover { border-bottom-color: var(--accent); }

/* ── Section label ── */
.section-label {
  font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 12px;
}
.section-label::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.section-note {
  text-transform: none; letter-spacing: 0; font-size: 11px;
  color: var(--text-muted); font-style: italic; white-space: nowrap;
}

/* ── Cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px; margin-bottom: 64px;
}
.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 4px;
  padding: 20px; text-decoration: none; display: flex; flex-direction: column;
  gap: 10px; transition: border-color 0.15s, background 0.15s;
  animation: fadeUp 0.4s both; cursor: pointer;
}
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.10s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:hover { border-color: var(--accent); background: var(--bg3); }
.card-thumb {
  width: 40px; height: 40px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; background: var(--bg3); flex-shrink: 0;
}
.card-title { font-family: var(--font-serif); font-size: 16px; font-weight: 400; color: var(--text); line-height: 1.3; }
.card-desc { font-size: 11px; color: var(--text-dim); line-height: 1.7; flex: 1; }
.card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.card-category { font-size: 10px; letter-spacing: 0.1em; color: var(--text-muted); text-transform: uppercase; }

/* ── Terminal bar ── */
.terminal-bar {
  display: flex; flex-direction: column;
  margin-bottom: 8px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 4px;
  font-size: 12px; color: var(--text-muted);
  font-family: var(--font-mono);
  transition: border-color 0.2s;
}
.terminal-bar:focus-within {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent);
}
.terminal-titlebar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.terminal-bar:focus-within .terminal-titlebar {
  border-bottom-color: var(--border);
}
.terminal-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-red    { background: #e05252; }
.dot-yellow { background: #d4a853; }
.dot-green  { background: #5c8a4e; }
.terminal-path { margin-left: 8px; color: var(--text-dim); }
.terminal-path span { color: var(--accent); }
.terminal-label {
  margin-left: auto; font-size: 10px; letter-spacing: 0.08em;
  color: var(--text-muted); opacity: 0.6;
}
/* macOS-style centred title — sits in the middle of the titlebar */
.terminal-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--text-dim); letter-spacing: 0.04em;
  pointer-events: none;
}
.terminal-titlebar { position: relative; }
.terminal-tip {
  font-size: 10px; letter-spacing: 0.06em;
  color: var(--text-muted); opacity: 0.7;
  margin: 0 4px 6px;
}
.terminal-cwd {
  color: var(--accent); font-size: 12px;   /* orange, matches "Timo" in the hero */
  flex-shrink: 0; user-select: none;
}

.terminal-output {
  padding: 6px 16px 2px;
  display: none;
  max-height: 140px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.terminal-output.has-content { display: block; }
.terminal-out-line {
  padding: 2px 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-dim);
  white-space: pre;
}
.terminal-echo {
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 0;
}
.t-ok  { color: var(--accent2); }
.t-err { color: #c0392b; }
.t-dim { color: var(--text-muted); }
.t-page { color: var(--accent3); display: inline-block; min-width: 160px; }
.t-pagelabel { color: var(--text-dim); }
.t-cwd { color: var(--accent); }   /* echoed ~/timo/garden, orange like the hero "Timo" */
.t-cmd { color: var(--accent); display: inline-block; min-width: 140px; }
.t-desc { color: var(--text-dim); }

.terminal-input-line {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
}
.terminal-prompt { color: var(--accent2); user-select: none; flex-shrink: 0; }
.terminal-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}
#terminal-input {
  position: relative; z-index: 1;
  background: none; border: none; outline: none;
  color: var(--text); font-family: var(--font-mono); font-size: 12px;
  width: 100%; caret-color: var(--accent);
}
#terminal-input::placeholder { color: var(--text-muted); opacity: 0.5; }
#terminal-measure {
  position: absolute; visibility: hidden; pointer-events: none;
  white-space: pre; font-family: var(--font-mono); font-size: 12px;
  z-index: 0;
}
#terminal-ghost {
  position: absolute; pointer-events: none; z-index: 0;
  white-space: pre; font-family: var(--font-mono); font-size: 12px;
  color: var(--text-dim); opacity: 0.32;
  display: none;
}
.terminal-tab-badge {
  font-size: 9px; letter-spacing: 0.06em; padding: 1px 5px;
  border: 1px solid var(--border); border-radius: 2px;
  color: var(--text-muted); margin-left: 10px;
  flex-shrink: 0; opacity: 0; transition: opacity 0.15s;
  user-select: none;
}
.terminal-tab-badge.visible { opacity: 1; }

.terminal-hint {
  font-size: 10px; color: var(--text-muted); letter-spacing: 0.04em;
  margin-bottom: 40px;
  display: flex; gap: 16px; align-items: center;
  padding: 0 4px;
}
.terminal-hint code {
  background: none; color: var(--text-dim); padding: 0; font-size: 10px;
}
.terminal-hint-sep { opacity: 0.3; }

/* ── LaTeX / Cheat-sheet page ── */
.katex { color: var(--accent) !important; font-size: 1.05em; }
.katex .mord,
.katex .mbin,
.katex .mrel,
.katex .mopen,
.katex .mclose,
.katex .mpunct,
.katex .minner { color: var(--accent) !important; }
.katex .frac-line { border-color: var(--accent) !important; }
.katex svg { fill: var(--accent) !important; stroke: var(--accent) !important; }

.katex-display {
  background: color-mix(in srgb, var(--accent) 5%, var(--bg2));
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  padding: 16px 20px;
  margin: 16px 0 !important;
  overflow-x: auto;
}

.cs-header { margin-bottom: 48px; }
.cs-header .breadcrumb {
  font-size: 11px; color: var(--text-muted);
  letter-spacing: 0.1em; margin-bottom: 12px;
}
.cs-header .breadcrumb span { color: var(--text-dim); cursor: pointer; }
.cs-header .breadcrumb span:hover { color: var(--accent); }
.cs-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 300; color: var(--text); line-height: 1.15; margin-bottom: 12px;
}
.cs-header h1 em { font-style: italic; color: var(--accent); }
.cs-header .page-subtitle {
  font-family: var(--font-serif);
  font-size: 16px;
  font-style: italic;
  font-weight: 300;
  color: var(--accent);
  margin-top: -6px;
  margin-bottom: 16px;
}
.cs-header p { font-size: 13px; color: var(--text-dim); line-height: 1.8; max-width: 480px; }
.cs-header p em { font-style: italic; color: var(--accent); }
.cs-header p a {
  color: var(--accent); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color 0.15s;
}
.cs-header p a:hover { border-bottom-color: var(--accent); }

.cs-section { margin-bottom: 52px; scroll-margin-top: 72px; }
.cs-section h2 {
  font-family: var(--font-serif);
  font-size: 22px; font-weight: 400; letter-spacing: -0.01em;
  color: var(--text-dim); margin-bottom: 20px;
  display: flex; align-items: center; gap: 16px;
}
.cs-section h2::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.cs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.cs-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 20px;
}
.cs-card-label {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 10px;
}
.cs-card p {
  font-size: 12px; color: var(--text-dim); line-height: 1.9; margin-top: 8px;
}
.cs-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.cs-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim); vertical-align: middle;
}
.cs-table td:first-child { color: var(--text); min-width: 180px; }
.cs-table tr:last-child td { border-bottom: none; }

code {
  font-family: var(--font-mono);
  background: var(--bg3); color: var(--accent3);
  padding: 1px 6px; border-radius: 3px; font-size: 11px;
}

/* ── Article-style derivation pages ── */
.prose { font-size: 13px; color: var(--text); line-height: 1.85; }
.prose p { margin-bottom: 14px; }
.prose h3 {
  font-family: var(--font-serif); font-weight: 400;
  font-size: 15px; color: var(--text-dim);
  margin: 28px 0 10px; letter-spacing: 0.01em;
}
.prose h4 {
  font-family: var(--font-serif); font-weight: 400; font-style: italic;
  font-size: 14px; color: var(--accent);
  margin: 22px 0 8px; letter-spacing: 0.01em;
}
.prose ul, .prose ol { margin: 0 0 14px 22px; }
.prose li { margin-bottom: 6px; }

/* ── Resume / experience / education lists ── */
.resume-list { list-style: none; padding-left: 0; margin: 0; }
.resume-list li {
  position: relative;
  padding: 4px 0 4px 16px;
  margin-bottom: 14px;
  border-left: 2px solid var(--accent);
  line-height: 1.55;
}
.resume-list li:last-child { margin-bottom: 0; }
.resume-list.edu li { border-left-color: var(--accent3); }
.resume-list .rl-place {
  color: var(--accent);
  font-weight: 500;
}
.resume-list.edu .rl-place { color: var(--accent3); }
.resume-list .rl-date {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg2);
  border-radius: 10px;
  letter-spacing: 0.02em;
  vertical-align: 1px;
}
.resume-list .rl-desc {
  display: block;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 13.5px;
}
.resume-list .rl-note {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-style: italic;
}
.prose strong { color: var(--text); font-weight: 500; }
.prose em { color: var(--accent); font-style: italic; }
.prose a {
  color: var(--accent); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color 0.15s;
}
.prose a:hover { border-bottom-color: var(--accent); }

.note {
  background: var(--bg2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent2); border-radius: 0 4px 4px 0;
  padding: 14px 18px; margin: 18px 0;
  font-size: 12px; color: var(--text-dim); line-height: 1.8;
}
.note strong { color: var(--text); font-weight: 500; }
.note.warn { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg2)); }
.note.plain { border: 1px solid var(--border); border-radius: 4px; }
.note.plain p { margin: 0 0 12px; }
.note.plain p:last-child { margin-bottom: 0; }

/* comparison table (e.g. bias/variance of advantage estimators) */
.cmp-table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 2px;
  font-size: 12px;
}
.cmp-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: 5px 10px 5px 0;
}
.cmp-table td {
  color: var(--text-dim);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  padding: 5px 10px 5px 0;
  vertical-align: top;
}
.cmp-table tr:last-child td { border-bottom: none; }

.algo {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 4px;
  padding: 18px 22px; margin: 18px 0;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text); line-height: 1.9;
  overflow-x: auto;
}
.algo .algo-title {
  font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.algo .ind  { padding-left: 18px; display: block; }
.algo .ind2 { padding-left: 36px; display: block; }
.algo .ind3 { padding-left: 54px; display: block; }
.algo .kw   { color: var(--accent); }
.algo .cm   { color: var(--text-muted); font-style: italic; }
.algo .algo-tag {
  float: right; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0 7px; margin-left: 12px; border-radius: 9px;
  border: 1px solid currentColor; line-height: 1.7;
}
.algo .tag-critic { color: var(--accent3); }
.algo .tag-actor  { color: var(--accent2); }

.diagram {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 4px;
  padding: 20px 22px; margin: 20px 0;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text); line-height: 1.4;
  overflow-x: auto;
  white-space: pre;
}

/* ── Rick Roll overlay ── */
#rickroll-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.25s ease;
}

.rickroll-window {
  width: min(82vw, 960px);
  height: min(78vh, 620px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.7);
}

/* the rktbtl game overlay reuses .rickroll-window chrome but is larger. These
   live here (not in the page's inline <style>) so the sidebar play button works
   on every page, not just the rktbtl page. */
.rktbtl-window { width: min(96vw, 1080px) !important; height: min(92vh, 780px) !important; }
.rktbtl-window.maxed { width: 100vw !important; height: 100vh !important; border-radius: 0 !important; }
.rktbtl-frame { flex: 1; width: 100%; border: none; background: #0a0e14; }

.rickroll-titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.rickroll-dots { display: flex; gap: 6px; }

.rickroll-close-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #e05252; cursor: pointer; flex-shrink: 0;
  transition: opacity 0.15s;
}
.rickroll-close-dot:hover { opacity: 0.7; }

/* macOS traffic-light window controls (rktbtl overlay) */
.tl-dot {
  width: 12px; height: 12px; border-radius: 50%;
  cursor: pointer; flex-shrink: 0;
  transition: filter 0.15s;
}
.tl-red { background: #ff5f57; }
.tl-yellow { background: #febc2e; }
.tl-green { background: #28c840; }
.tl-dot:hover { filter: brightness(1.18); }

.rickroll-title {
  margin-left: 8px;
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--font-mono);
}

.rickroll-video {
  flex: 1;
  width: 100%;
  border: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.t-file { color: var(--accent2); display: inline-block; min-width: 160px; }
.t-filelabel { color: var(--text-muted); font-size: 11px; }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Code-file blocks ── */
.code-file {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 18px 0;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
}
.code-file-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.code-file-name {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.code-file-name .cf-path { color: var(--text-muted); }
.code-file-name .cf-file { color: var(--accent3); }
.code-file-link {
  font-size: 10px;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.06em;
  transition: color 0.15s;
}
.code-file-link:hover { color: var(--accent); }
.code-body {
  margin: 0;
  padding: 14px 18px;
  overflow-x: auto;
  line-height: 1.7;
  color: var(--text);
  white-space: pre;
  font-size: 12px;
}
.code-body .c  { color: var(--text-muted); font-style: italic; }  /* comment */
.code-body .kw { color: var(--accent); }                           /* keyword */
.code-body .fn { color: var(--accent3); }                          /* function */
.code-body .st { color: var(--accent2); }                          /* string */
.code-body .nm { color: var(--accent); }                           /* number */
.code-body .tp { color: #7c6f9f; }                                 /* type hint */

/* ── Plot figures ── */
.plot-figure {
  margin: 24px 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.plot-figure img,
.plot-figure video {
  width: 100%;
  display: block;
}
.plot-figure .rollout-video {
  width: auto;
  max-width: 420px;
  margin: 0 auto;
  background: #000;
}
.plot-caption {
  padding: 10px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  line-height: 1.6;
}
.plot-caption strong { color: var(--text-dim); }

/* row of side-by-side rollout gifs */
.rollout-row {
  display: flex;
  gap: 6px;
  margin: 24px 0 0;
}
.rollout-row .rollout-item {
  flex: 1 1 0;
  min-width: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.rollout-row .rollout-item img {
  width: 100%;
  display: block;
}
.rollout-row .rollout-label {
  padding: 8px 10px;
  font-size: 11px;
  text-align: center;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  line-height: 1.5;
}
.rollout-row .rollout-label strong { color: var(--text); font-weight: 500; }

/* ── Inline pill badges ── */
.pill {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 2px;
  font-weight: 500;
  vertical-align: middle;
  margin: 0 2px;
}
.pill-blue  { color: #2563eb; background: color-mix(in srgb, #2563eb 10%, transparent); }
.pill-green { color: var(--accent2); background: color-mix(in srgb, var(--accent2) 10%, transparent); }

/* ── Step list ── */
.step-list { list-style: none; margin: 0 0 14px 0; padding: 0; counter-reset: step; }
.step-list li {
  display: flex; gap: 14px; margin-bottom: 10px;
  counter-increment: step;
}
.step-list li::before {
  content: counter(step);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 10px; font-weight: 500; margin-top: 2px;
}

/* ── In-page TOC ── */
#toc-panel {
  display: none;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.toc-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 20px;
  margin-bottom: 6px;
}

#toc-list { list-style: none; padding: 0; margin: 0; }

#toc-list li a {
  display: block;
  padding: 3px 20px 3px 18px;
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  line-height: 1.45;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

#toc-list li a:hover { color: var(--accent); }

#toc-list li a.toc-active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

@media (max-width: 720px) {
  .site-wrapper { grid-template-columns: 1fr; }
  aside { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 16px 0; }
  main { padding: 32px 24px; }
  header { padding: 0 20px; }
  .hero { flex-direction: column; align-items: center; text-align: center; gap: 14px; margin: 8px 0 28px; }
  .hero-portrait { width: 160px; height: 160px; }
  .hero-text h1 { font-size: 34px; }
  .hero-sub { margin: 12px auto 0; }
}

/* ── Home orbital map (progressive enhancement; the cards below it are the
   fallback for mobile, reduced-motion, and no-JS). Rendered on a pixel canvas. ── */
#sol-map { margin: 6px 0 34px; }
.sol-stage { position: relative; }
.sol-stage canvas { display: block; width: 100%; image-rendering: pixelated; }

#sol-labels { position: absolute; inset: 0; pointer-events: none; }
.sol-mlabel, .sol-plabel { position: absolute; font-family: var(--font-mono); white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity .3s; color: #403c36; text-shadow: 0 1px 1px rgba(255,255,255,.7); }
.sol-mlabel { font-size: 11px; letter-spacing: .02em; }
.sol-astlabel { position: absolute; font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .04em; color: var(--accent); white-space: nowrap; pointer-events: none; opacity: 0;
  transform: translateY(-50%); text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.sol-astlabel.show { animation: sol-astpulse 1s ease-in-out infinite; }
@keyframes sol-astpulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }
:root[data-theme="dark"] .sol-astlabel { color: #ffbf5a; }
.sol-plabel { font-size: 11.5px; letter-spacing: .03em; transform: translate(-50%, -100%); }
.sol-mlabel.show, .sol-plabel.show { opacity: 1; }
.sol-mlabel.right { transform: translateY(-50%); }
.sol-mlabel.left  { transform: translate(-100%, -50%); }
:root[data-theme="dark"] .sol-mlabel, :root[data-theme="dark"] .sol-plabel { color: #c9d3de; text-shadow: 0 1px 2px #000; }

.sol-tip { position: absolute; max-width: 250px; padding: 9px 11px; border-radius: 6px; border: 1px solid;
  font-family: var(--font-mono); font-size: 10.5px; line-height: 1.45; pointer-events: none; opacity: 0;
  transition: opacity .16s; z-index: 5; background: rgba(255,253,250,.97); border-color: #ddd7cc; color: var(--text-dim); }
.sol-tip b { display: block; font-size: 11px; margin-bottom: 3px; letter-spacing: .02em; color: var(--text); }
.sol-tip.show { opacity: 1; }
:root[data-theme="dark"] .sol-tip { background: rgba(10,14,22,.93); border-color: #2a3442; color: #aeb9c6; }
:root[data-theme="dark"] .sol-tip b { color: #e6edf5; }

.sol-hint { position: absolute; left: 12px; bottom: 10px; font-family: var(--font-mono);
  font-size: 10px; letter-spacing: .08em; pointer-events: none; color: #9b9083; }
:root[data-theme="dark"] .sol-hint { color: #5a6b80; }
.sol-back { position: absolute; right: 12px; top: 11px; opacity: 0; pointer-events: none; transition: opacity .3s;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; padding: 6px 11px; border-radius: 5px;
  cursor: pointer; border: 1px solid; background: rgba(255,255,255,.6); border-color: #d0c9bd; color: var(--text-dim); }
.sol-back.show { opacity: 1; pointer-events: auto; }
:root[data-theme="dark"] .sol-back { background: rgba(8,12,20,.55); border-color: #26303e; color: #9fb0c2; }

/* small screens fall back to the cards */
@media (max-width: 759px) { #sol-map { display: none !important; } }
