/* callcc.me — monochrome, with a shell accent */

:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --fg: #f0f0f0;
  --mute: #8a8a8a;
  --line: #262626;
  --line-strong: #666666;
  --header-offset: calc(var(--header-h, 4rem) + .5rem);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --sans: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans", "Noto Sans JP", sans-serif;
  --pad: clamp(1.25rem, 5vw, 4rem);
}

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

html { scroll-behavior: smooth; scroll-padding-top: var(--header-offset); }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; text-decoration: none; }
code, pre, .mono { font-family: var(--mono); }
code { font-size: 0.92em; }
.dim { color: var(--mute); }

:focus-visible { outline: 1px solid var(--fg); outline-offset: 4px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link {
  position: fixed;
  top: .5rem;
  left: .5rem;
  z-index: 20;
  padding: .4rem .8rem;
  background: var(--fg);
  color: var(--bg);
}
.skip-link:not(:focus) { clip-path: inset(50%); }
main[tabindex="-1"]:focus { outline: none; }

/* 背景の細いグリッド */
.grid-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
}

/* Header */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem var(--pad);
  background: rgba(11,11,11,0.72);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.logo { font-family: var(--mono); font-weight: 700; letter-spacing: 0.02em; }

.site-header nav { display: flex; gap: clamp(1rem, 3vw, 2.5rem); }
.site-header nav a {
  position: relative;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--mute);
  transition: color .2s;
}
.site-header nav a .dot { opacity: 0; transition: opacity .2s; }
.site-header nav a::after {
  content: "";
  position: absolute;
  left: 0; bottom: -4px;
  width: 100%; height: 1px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .3s ease;
}
.site-header nav a:hover { color: var(--fg); }
.site-header nav a:hover .dot { opacity: 1; }
.site-header nav a:hover::after { transform: scaleX(1); transform-origin: left; }

/* reading のドロップダウン。リンクと開閉ボタン (▾) を分け、details で JS なしに開閉する */
.nav-drop { position: relative; display: flex; align-items: center; gap: .3rem; }
.nav-drop details { position: static; }
.nav-drop summary {
  list-style: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--mute);
  padding: 0 .2rem;
}
.nav-drop summary::-webkit-details-marker { display: none; }
.nav-drop summary:hover, .nav-drop details[open] summary { color: var(--fg); }
.nav-drop summary:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }
.site-header .nav-menu {
  position: absolute;
  top: calc(100% + .8rem);
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  padding: .5rem 0;
  background: #0b0b0b;
  border: 1px solid var(--line);
}
.site-header .nav-menu a { padding: .35rem 1rem; white-space: nowrap; }
.site-header .nav-menu a::after { display: none; }
.site-header .nav-menu a:hover, .site-header .nav-menu a:focus-visible { color: var(--fg); background: rgba(255,255,255,0.06); }

/* ページ内目次 (見出しの下) */
.page-toc { display: flex; flex-wrap: wrap; gap: .3rem 1.5rem; margin-top: 1.5rem; font-family: var(--mono); font-size: 0.8rem; }
.page-toc a { color: var(--mute); }
.page-toc a:hover { color: var(--fg); }
/* トップのヒーローでは、タイトル直下の情報行の下に目次を出す */
.hero-meta + .page-toc { margin-top: 2.5rem; }

/* Hero */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6rem var(--pad) 4rem;
}

.hero-prompt {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--mute);
  margin-bottom: 1.75rem;
}
.ps1 { color: var(--fg); font-weight: 700; }

.hero-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(2.8rem, 11vw, 9.5rem);
  line-height: 1;
  letter-spacing: -0.04em;
  white-space: nowrap;
}
.hero-title .paren { color: var(--mute); font-weight: 400; }

.cursor {
  display: inline-block;
  width: 0.5em;
  height: 0.85em;
  margin-left: 0.08em;
  vertical-align: -0.05em;
  background: var(--fg);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.hero-sub {
  margin-top: 2.5rem;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  color: var(--mute);
  letter-spacing: 0.12em;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--mute);
  letter-spacing: 0.15em;
}
.hero-meta .rule { flex: 0 0 60px; height: 1px; background: var(--line); }

/* Sections */
.section {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 3fr;
  gap: 2rem;
  padding: clamp(4rem, 10vw, 8rem) var(--pad);
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 1rem;
  align-content: start;
}
.section-head .num { font-family: var(--mono); font-size: 0.75rem; color: var(--mute); }
.section-head h2 {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3em;
}
.section-head .path {
  flex-basis: 100%;
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--mute);
}

.section-body { max-width: 44rem; }
.section-body.wide { max-width: none; min-width: 0; }
.section-body > p + p { margin-top: 1.25rem; }
.section-body > p:not(.lead) { color: var(--mute); }

.lead {
  font-size: clamp(1.25rem, 2.4vw, 1.9rem);
  line-height: 1.5;
  font-weight: 500;
  letter-spacing: 0;
}

/* About の「継続を読む」 */
.reads-title { margin-top: 2rem; font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.15em; color: var(--mute); }
.reads { margin-top: 0.75rem; padding-left: 1.25rem; line-height: 1.9; }

/* finger 風の小さな表 */
.finger {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2.5rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 0.8rem;
}
.finger dt { color: var(--mute); font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase; }

/* Life */
.life {
  margin-top: 1.75rem;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.015);
  max-width: 62rem;
}
.life-bar, .life-ctrl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 0.6rem 1rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--mute);
}
.life-bar { border-bottom: 1px solid var(--line); }
.life-bar span:first-child { color: var(--fg); font-weight: 700; }
.life-bar b { color: var(--fg); font-weight: 400; }
.life-stat { margin-left: auto; }
.life-ctrl { border-top: 1px solid var(--line); gap: 0.5rem; }
.life-ctrl.ctrl-actions { border-top: 0; border-bottom: 1px solid var(--line); }
.life-state { margin-left: auto; }

.ctrl-actions, .ctrl-group, .share-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.ctrl-actions { column-gap: 1rem; }
.ctrl-group { max-width: 100%; }
.ctrl-icon { display: inline-block; min-width: 1.2em; text-align: center; }
.share-link input { flex: 1 1 14rem; min-width: 0; }

.life-note {
  padding: 0.6rem 1rem 0;
  font-size: 0.8rem;
  color: var(--mute);
  min-height: 1.8em;
}
.life-note::before { content: "# "; font-family: var(--mono); }

.life-select { display: flex; align-items: center; gap: 0.5rem; margin-right: 0.5rem; }
.ctrl-actions .life-select { max-width: 100%; margin-right: 0; }
.ctrl-actions .life-select span { flex-shrink: 0; }
.ctrl-actions .life-select select { min-width: 0; }
.life-select select {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.3rem 2rem 0.3rem 0.6rem;
  cursor: pointer;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--mute) 50%),
    linear-gradient(135deg, var(--mute) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.life-select select:hover { border-color: var(--mute); }

.life-grid {
  padding: 1rem;
  font-size: 13px;
  line-height: 1.1;
  color: var(--fg);
  cursor: crosshair;
  user-select: none;
  overflow-x: auto;   /* 狭い画面では 80 列を横スクロールで見る */
  overflow-y: hidden;
}
.life-cursor { color: var(--bg); background: var(--fg); }
.life-noscript { padding: 1rem; font-family: var(--mono); font-size: 0.8rem; color: var(--mute); }

.life-ctrl button {
  font: inherit;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.life-ctrl button:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* Contact */
.mailform { display: grid; gap: 1.75rem; }
.mailform .row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.75rem; }
.field { display: grid; gap: 0.35rem; }
.field span {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--mute);
  transition: color .2s;
}
.field:focus-within span { color: var(--fg); }
.field input,
.field textarea {
  width: 100%;
  font: inherit;
  color: var(--fg);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  padding: 0.4rem 0;
  outline: 0;
  border-radius: 0;
  transition: border-color .2s;
}
.field textarea { resize: vertical; line-height: 1.7; }
.field input:focus,
.field textarea:focus {
  border-color: var(--fg);
  box-shadow: 0 1px 0 var(--fg);
}
.field input:focus-visible,
.field textarea:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 4px;
}
.mailform .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.mf-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem; }
.send {
  font: inherit;
  font-weight: 600;
  color: var(--bg);
  background: var(--fg);
  border: 1px solid var(--fg);
  padding: 0.75rem 1.75rem;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.send span { display: inline-block; transition: transform .3s; }
.send:hover { background: transparent; color: var(--fg); }
.send:hover span { transform: translateX(4px); }
.send:disabled { opacity: 0.5; cursor: wait; }

.mf-result { font-size: 0.8rem; color: var(--mute); white-space: pre-wrap; }
.form-note { margin-top: 1rem; font-size: 0.8rem; color: var(--mute); }
.mf-result.ok { color: var(--fg); }
.mf-result.err { color: var(--fg); font-weight: 700; }

/* Footer */
.site-footer {
  display: flex;
  justify-content: space-between;
  padding: 2rem var(--pad);
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--mute);
  letter-spacing: 0.1em;
}

/* CGI の結果ページ */
.cgi-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem var(--pad);
}
.cgi-page pre { font-size: 0.9rem; color: var(--mute); }
.cgi-page .msg { margin-top: 1rem; font-size: clamp(1.1rem, 2.4vw, 1.6rem); color: var(--fg); }
.cgi-page .sub { margin-top: 0.75rem; color: var(--mute); }
.cgi-page a {
  align-self: flex-start;
  margin-top: 2.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--fg);
}

/* 読み物ページ (reading.html) */
.hero-short { min-height: auto; padding-top: 9rem; padding-bottom: 3rem; }
.page-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(1.8rem, 6vw, 4rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.page-note { margin-top: 1.5rem; max-width: 44rem; font-size: 0.9rem; color: var(--mute); }
.page-note a, .disclosure a { border-bottom: 1px solid var(--mute); }
.list-head { font-size: 1rem; font-weight: 700; margin: 2.5rem 0 0.75rem; }
.list-head:first-child { margin-top: 0; }
.list-head .dim { font-weight: 400; font-size: 0.85rem; }
.reading { list-style: none; border-top: 1px solid var(--line); }
.reading li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}
.reading a { flex: 1 1 18rem; transition: color .2s; }
.reading a:hover { color: var(--mute); }
.reading a::before { content: "> "; font-family: var(--mono); color: var(--mute); }
.reading span { font-size: 0.8rem; color: var(--mute); }
/* Web 観測録の「特に好きなサイト」 (cheat.sh のような端末の出力) */
.links-picks {
  margin-top: 2rem;
  max-width: 44rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  background: rgba(11, 11, 11, 0.85);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.8;
  overflow-x: auto;
}
.links-picks a { border-bottom: 1px solid var(--mute); }
.books {
  list-style: none;
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 2rem 1.25rem;
}
.books a { display: grid; gap: 0.4rem; align-content: start; }
.books img {
  width: 110px;
  height: 160px;
  object-fit: contain;
  object-position: left bottom;
  background: #141414;
  transition: opacity .2s;
}
.books b { font-weight: 400; font-size: 0.85rem; line-height: 1.5; }
.books span { font-size: 0.72rem; line-height: 1.5; color: var(--mute); }
.books a:hover img { opacity: 0.75; }
.books a:hover b { color: var(--mute); }
.books li .note {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--mute);
}
/* 読んでよかった本のグループ（シリーズなど。tools/build-books.py が生成） */
.book-group { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.book-group h3 { font-family: var(--mono); font-size: 0.95rem; font-weight: 400; }
.book-group .group-note { margin-top: 0.6rem; max-width: 44rem; font-size: 0.85rem; line-height: 1.7; color: var(--mute); }
.book-group + .books { margin-top: 3rem; }
.disclosure { margin-top: 1.5rem; font-size: 0.75rem; color: var(--mute); }

.pg { list-style: none; border-top: 1px solid var(--line); }
.pg li {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) 2fr;
  gap: 0.25rem 1.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.pg .en { font-family: var(--mono); font-size: 0.8rem; color: var(--mute); }
.pg .en:hover, .pg span a:hover { color: var(--fg); text-decoration: underline; }
.pg span { display: flex; flex-wrap: wrap; gap: 0.15rem 1.25rem; color: var(--mute); }
.pg span a { color: var(--fg); }
.pg i { font-style: normal; font-size: 0.72rem; color: var(--mute); margin-left: 0.4rem; }
.pg-note { margin-bottom: 0.75rem; font-size: 0.8rem; line-height: 1.7; }

/* Essays の左列: 見出しと本をスクロールしても左に表示し続ける */
#essays .section-head {
  position: sticky;
  top: 5rem;
  align-self: start;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}
.pg-side { flex-basis: 100%; margin-top: 2.5rem; }
.pg-side-title { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.15em; }
.pg-side-title .dim { margin-left: 0.5rem; letter-spacing: 0; }
.books.compact { margin-top: 1rem; grid-template-columns: 1fr; gap: 1rem; }
.books.compact a { grid-template-columns: 56px 1fr; gap: 0.1rem 0.75rem; }
.books.compact img { width: 56px; height: 80px; grid-row: span 2; }
.books.compact b { font-size: 0.8rem; align-self: end; }
.books.compact span { align-self: start; }

/* Responsive */
@media (max-width: 720px) {
  .site-header { flex-wrap: wrap; gap: .5rem; }
  .site-header nav { flex-wrap: wrap; gap: .3rem 1rem; }
  .hero { padding-top: 10rem; }
  .section { grid-template-columns: 1fr; }
  .mailform .row { grid-template-columns: 1fr; }
  .life-grid { font-size: 11px; padding: 0.75rem; }
  .life-stat { margin-left: 0; }
  .pg li { grid-template-columns: 1fr; }
  #essays .section-head { position: static; max-height: none; overflow: visible; }
  .books.compact { grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* Markdown から生成するページ */
.markdown { min-width: 0; overflow-wrap: anywhere; }
.markdown h1, .markdown h2, .markdown h3 { margin: 2rem 0 1rem; font-family: var(--mono); }
.markdown > :first-child { margin-top: 0; }
.markdown p, .markdown ul, .markdown ol, .markdown pre, .markdown .table-scroll { margin-bottom: 1.5rem; }
.markdown ul { list-style: disc; padding-left: 1.5rem; }
.markdown ol { list-style: decimal; padding-left: 1.5rem; }
.markdown li { margin: 0.4rem 0; }
/* 文中のリンクは下線で示す (ナビ・目次・カード・ボタン類は対象外) */
.hero-sub a,
.section-body > p:not(.more) a,
.finger dd a,
.form-note a,
.markdown a,
.reads a,
.site-footer p a {
  text-decoration: underline;
  text-decoration-color: var(--mute);
  text-decoration-thickness: 1px;
  text-underline-offset: .25em;
}
.hero-sub a:hover,
.section-body > p:not(.more) a:hover,
.finger dd a:hover,
.form-note a:hover,
.markdown a:hover,
.reads a:hover,
.site-footer p a:hover {
  color: var(--fg);
  text-decoration-color: currentColor;
}
.markdown pre { overflow-x: auto; padding: 1rem; border: 1px solid var(--line); }
.markdown pre code { white-space: pre; }
.markdown code { font-family: var(--mono); font-size: 0.9em; }
.markdown .table-scroll { overflow-x: auto; }
.markdown table { border-collapse: collapse; width: 100%; }
.markdown th, .markdown td { padding: 0.6rem; text-align: left; border: 1px solid var(--line); }
.markdown th { font-family: var(--mono); }
.markdown time { font-size: 0.85em; color: var(--mute); }

/* 1 行の ![説明](パス) から作る図 (グラフの SVG など) */
.markdown .figure { margin-bottom: 1.5rem; }
.markdown .figure img { display: block; width: 100%; max-width: 45rem; height: auto; border: 1px solid var(--line); }

/* 段に分けたピラミッドの図 (```pyramid) */
.markdown .pyramid-fig { margin-bottom: 1.5rem; padding: 1rem; border: 1px solid var(--line); }
.pyramid { display: block; width: 100%; max-width: 28rem; height: auto; margin: 0 auto; }
.pyramid-band { fill: none; stroke: var(--fg); stroke-width: 1.5; stroke-linejoin: round; }
.pyramid-label { fill: var(--fg); font-family: var(--sans); font-size: 22px; font-weight: 700; }

/* vim チートシートの移動の図 (```keymap) */
/* 本の列があると本文が狭くなるので、図は本文の幅に縮め、それでも入らない幅では一覧にする（横スクロールを出さない）。 */
.markdown .keymap-scroll { overflow-x: auto; margin-bottom: 1.5rem; container-type: inline-size; }
.markdown ul.keymap {
  display: grid;
  /* 8 列目は上下の移動 (gg ?text C-f /text など) が縦に並ぶ列なので、少し広くとる */
  grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(3.8rem, 1.3fr) repeat(6, minmax(0, 1fr));
  gap: 0.6rem 0.2rem;
  padding: 1rem 0.4rem;
  border: 1px solid var(--line);
  list-style: none;
}
.markdown .keymap li { margin: 0; display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.25; overflow-wrap: normal; }
.keymap code { font-weight: 700; font-size: 1rem; }
.keymap .km-r7 code, .keymap .km-c8 code { font-size: 1.15rem; }
.keymap span { margin-top: 0.2rem; font-size: 0.7rem; color: var(--mute); }
.km-r1 { grid-row: 1; }
.km-r2 { grid-row: 2; }
.km-r3 { grid-row: 3; }
.km-r4 { grid-row: 4; }
.km-r5 { grid-row: 5; }
.km-r6 { grid-row: 6; }
.km-r7 { grid-row: 7; }
.km-r8 { grid-row: 8; }
.km-r9 { grid-row: 9; }
.km-r10 { grid-row: 10; }
.km-r11 { grid-row: 11; }
.km-r12 { grid-row: 12; }
.km-r13 { grid-row: 13; }
.km-c1 { grid-column: 1; }
.km-c2 { grid-column: 2; }
.km-c3 { grid-column: 3; }
.km-c4 { grid-column: 4; }
.km-c5 { grid-column: 5; }
.km-c6 { grid-column: 6; }
.km-c7 { grid-column: 7; }
.km-c8 { grid-column: 8; }
.km-c9 { grid-column: 9; }
.km-c10 { grid-column: 10; }
.km-c11 { grid-column: 11; }
.km-c12 { grid-column: 12; }
.km-c13 { grid-column: 13; }
.km-c14 { grid-column: 14; }
@container (max-width: 38rem) {
  .markdown ul.keymap { grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); }
  .keymap li { grid-row: auto; grid-column: auto; }
}

/* フォームの部品（/repl/・/status/・/contact/ など。旧 /tools/tools.css から移した） */
.tool label { display: block; margin: .7rem 0 .3rem; }
.tool input:not([type=checkbox]), .tool textarea, .tool select { display: block; width: 100%; padding: .6rem; background: var(--bg); color: var(--fg); border: 1px solid var(--line); font: inherit; }
.tool button { margin: .7rem .6rem .7rem 0; padding: .4rem .8rem; background: var(--bg); color: var(--fg); border: 1px solid var(--mute); cursor: pointer; font: inherit; }
.tool .ctrl-actions { margin: .7rem 0; }
.tool :is(.ctrl-actions, .share-link) button { margin: 0; }
.tool :where(.sort-op, .ctrl-actions, .fullscreen-bar) button:disabled { opacity: .5; cursor: default; }
.scheme-picture { width: min(100%, 480px); height: auto; aspect-ratio: 1; background: var(--bg); }
#repl-picture:fullscreen { background: var(--bg); }
#repl-picture:fullscreen .scheme-picture { display: block; width: 100%; height: 100%; }
#repl-picture:fullscreen .repl-picture-controls { position: absolute; top: 1rem; right: 1rem; }
.tool pre { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 2rem; }
.tool section { margin-bottom: 3rem; scroll-margin-top: max(0px, calc(6rem - var(--header-offset))); }
.tool :focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

/* /continuation/ */
.continuation { min-width: 0; }
.continuation textarea { font-family: var(--mono); resize: vertical; }
.continuation-examples, .continuation-controls { display: flex; flex-wrap: wrap; gap: .5rem; margin: .7rem 0; }
.continuation :is(.continuation-examples, .continuation-controls) button { min-width: 0; max-width: 100%; margin: 0; overflow-wrap: anywhere; }
.cron-examples { display: flex; flex-wrap: wrap; gap: .5rem; margin: .7rem 0; }
.cron-check .cron-examples button { margin: 0; font-family: var(--mono); }
.cron-check .cron-option { display: flex; gap: .5rem; align-items: baseline; }
.cron-check .cron-error { color: var(--fg); border-left: 2px solid var(--fg); padding-left: .8rem; }
.cron-check .cron-warn { color: var(--fg); }
.cron-check .cron-info { color: var(--mute); }
.cron-check :is(.cron-notes, .cron-next) { padding-left: 1.4rem; }
.continuation button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.continuation button:disabled { opacity: .5; cursor: default; }
.continuation .continuation-expression { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.continuation-expression mark { background: var(--fg); color: var(--bg); }
.continuation-frames, .continuation-saved, .continuation-discarded { min-width: 0; overflow-wrap: anywhere; }
.continuation-frame { min-width: 0; margin: .3rem 0; padding: .35rem .2rem; border: 1px solid var(--line-strong); font-family: var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
/* 深い入れ子でも横幅を取り続けないよう、内側の枠は outline で描く。 */
.continuation-frame .continuation-frame .continuation-frame .continuation-frame .continuation-frame .continuation-frame { padding-inline: 0; border: 0; outline: 1px solid var(--line-strong); }
.continuation-top { border-color: var(--line); }
.continuation-frame-label { color: var(--mute); font-family: var(--sans); font-size: .85em; }
.continuation-hole { color: var(--fg); font-weight: bold; }
.continuation-saved { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; }
.continuation-saved-item { min-width: 0; }
.continuation-saved-item h3, .continuation #continuation-jump-details h3 { margin: 1rem 0 .3rem; }
.continuation-discarded-frame { margin: .3rem 0; padding: .35rem .55rem; border: 1px solid var(--line); color: var(--mute); font-family: var(--mono); white-space: pre-wrap; text-decoration: line-through; }

.life-import { margin-top: 1rem; }
.life-import textarea, .life-import input { width: 100%; background: var(--bg); color: var(--fg); border: 1px solid var(--line); padding: .5rem; }

.life-import button { font: inherit; color: var(--fg); background: transparent; border: 1px solid var(--line); padding: .3rem .8rem; margin: .5rem 0; cursor: pointer; }
.life-import label { display: block; }
.life-import summary { cursor: pointer; margin-top: .6rem; }
.life-import p { color: var(--mute); font-size: .8rem; }

/* 背景で動くライフゲーム、進化シミュレーション、SICP の図形言語、フラクタル */
.life-bg, .evolution-bg, .picture-bg, .fractal-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, #000 35%, transparent 85%);
}

/* Lisp の節や SICP・黄金分割などの項目が見えている間だけ背景を出す */
.evolution-bg[data-section], .picture-bg, .fractal-bg[data-targets] { opacity: 0; transition: opacity .8s; }
.evolution-bg:where([data-section]).is-visible, .picture-bg.is-visible, .fractal-bg.is-visible { opacity: 1; }
body.picture-bg-on .evolution-bg, body.fractal-bg-on .evolution-bg, body.fractal-bg-on .picture-bg { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .evolution-bg[data-section], .picture-bg, .fractal-bg[data-targets] { transition: none; }
}

/* ノート内の実行できる Scheme ブロック */
.markdown pre.scheme-run { margin-bottom: 0; }
.markdown .scheme-run-controls { display: flex; gap: .6rem; margin: .5rem 0; }
.markdown .scheme-run-controls button { padding: .4rem .8rem; background: var(--bg); color: var(--fg); border: 1px solid var(--mute); cursor: pointer; font: inherit; }
.markdown .scheme-run-controls button:disabled { opacity: .5; cursor: default; }
.markdown .scheme-run-controls :focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
.markdown pre.scheme-run-out { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 2rem; }

/* Shared page details. */
.site-header nav a[aria-current="page"],
.site-header nav a.is-section {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--mute);
  text-underline-offset: .35em;
}
.back-link {
  display: inline-block;
  align-self: flex-start;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--mute);
}
.back-link:hover,
.back-link:focus-visible { color: var(--fg); }
.site-footer { flex-wrap: wrap; gap: 1rem; }
.site-footer .footer-link { font-size: .75rem; }
/* 背景を止めるボタン。本文の右上 (ヘッダーの下) に置き、スクロールすると本文と一緒に流れる */
main > .bg-toggle {
  position: absolute;
  top: calc(var(--header-h, 4rem) + .75rem);
  right: var(--pad);
  z-index: 5;
  padding: .3rem .7rem;
  border: 1px solid var(--line);
  background: rgba(11,11,11,0.72);
  color: var(--mute);
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .04em;
  cursor: pointer;
}
/* 記号は読み上げない (代替テキストを空にする) */
main > .bg-toggle::before { content: "❚❚ "; content: "❚❚ " / ""; }
main > .bg-toggle[data-state="off"]::before { content: "▶\FE0E  "; content: "▶\FE0E  " / ""; }
main > .bg-toggle:hover,
main > .bg-toggle:focus-visible { color: var(--fg); border-color: var(--mute); }
main > .bg-toggle:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }
.site-footer .footer-bg,
.site-footer .footer-support,
.site-footer .footer-disclosure { flex-basis: 100%; margin: 0; letter-spacing: 0; }
.page-date { margin-top: 1rem; font-size: .8rem; }
.page-curl { margin-top: 1rem; font-size: .8rem; }
.markdown blockquote {
  margin: 1.5rem 0;
  padding: .5rem 1rem;
  border-left: 2px solid var(--mute);
  color: var(--mute);
}

/* Pages without a section label keep the full reading column. */
.section-prose { grid-template-columns: minmax(0, 1fr); }

/* チートシートの本は本文の右に固定する。本文の左端は本の無いページとそろえる。 */
.section-prose.has-side { grid-template-columns: minmax(0, 44rem) minmax(200px, 18rem); justify-content: start; gap: 3rem; }
.has-side .cheat-side {
  margin-top: 0;
  position: sticky;
  top: 5rem;
  align-self: start;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}
@media (max-width: 720px) {
  .section-prose.has-side { grid-template-columns: minmax(0, 1fr); }
  .has-side .cheat-side { position: static; max-height: none; overflow: visible; }
}

/* 無限平面の hashlife */
.life-canvas { display: block; width: 100%; height: 65vh; min-height: 240px; background: var(--bg); touch-action: none; cursor: grab; }
.life-canvas:active { cursor: grabbing; }
.life-ctrl input[type="range"] { flex: 1; min-width: 120px; accent-color: var(--fg); }
#life-timing, #life-speed { color: var(--mute); font-size: .8rem; }
.life-stage + .life-note { border-top: 1px solid var(--line); padding-top: .5rem; }

/* fullscreen (fullscreen.js)。exit などのボタンは全画面のときだけ出す */
.life-stage .fullscreen-bar { display: none; }
.life-stage.is-fullscreen { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 1rem; background: var(--bg); }
.life-stage.is-fullscreen .fullscreen-bar { display: flex; border-top: 0; }
.life-stage.is-fullscreen .life-grid { flex: none; overflow: hidden; }
.life-stage.is-fullscreen .life-canvas { flex: 1; height: auto; min-height: 0; }

/* 通常版と hashlife 版の切り替え */
.life-modes { display: flex; flex-wrap: wrap; align-items: stretch; gap: .5rem; margin-top: 1rem; font-family: var(--mono); font-size: .85rem; }
.life-modes > span { align-self: center; color: var(--mute); margin-right: .25rem; }
.life-modes a { display: inline-flex; flex-direction: column; padding: .45rem 1rem; border: 1px solid var(--mute); color: var(--fg); text-decoration: none; }
.life-modes a small { font-size: .7rem; color: var(--mute); }
.life-modes a:hover { border-color: var(--fg); }
.life-modes a[aria-current="page"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.life-modes a[aria-current="page"] small { color: var(--bg); opacity: .75; }

/* トップの「curl で使う」: 見出しの直後に一覧を置く */
#curl .reads { margin-top: 0; }

/* 「ブラウザーで試す」: /experiments/ はページ名・短いリンク名・一行説明 */
.experiments-list { max-width: 62rem; min-width: 0; }
.experiments-list h2 { margin: 2rem 0 1rem; font-family: var(--mono); }
.experiments-list .tool-list { margin-top: 0; }
.experiments-list h2:first-child { margin-top: 0; }
/* トップの「ls」: ヘッダーの項目ごとに説明 1 行 */
.ls-list { list-style: none; }
.ls-list li + li { margin-top: 0.5rem; }
.ls-name { font-family: var(--mono); }
.ls-name .dot { color: var(--mute); }
.tool-list { margin-top: 0.75rem; list-style: none; }
.tool-list li {
  display: grid;
  grid-template-columns: 22.5rem minmax(0, 1fr);
  gap: 0 1.5rem;
  align-items: baseline;
  padding: 0.5rem 0;
  border-top: 1px dashed var(--line);
}
.tool-list li:last-child { border-bottom: 1px dashed var(--line); }
/* ディレクトリ表記と名前を別の列に分け、名前は太字にしない */
.tool-list .tool-name { display: grid; grid-template-columns: 10.5rem minmax(0, 1fr); gap: 0 1.5rem; align-items: baseline; }
.tool-list .tool-short { font-family: var(--mono); font-size: 0.8rem; color: var(--mute); white-space: nowrap; }
.tool-list .tool-title { color: var(--fg); }
.tool-list .tool-name:hover .tool-title { text-decoration: underline; text-underline-offset: .25em; }
.tool-list .tool-name:hover .tool-short { color: var(--fg); }
.tool-list .tool-extra { font-size: 0.85rem; color: var(--mute); }
.tool-list .tool-extra a { text-decoration: underline; text-decoration-color: var(--mute); text-underline-offset: .25em; }
.tool-list .tool-extra a:hover { color: var(--fg); }
.tool-list p { font-size: 0.9rem; color: var(--mute); line-height: 1.6; }
@media (max-width: 720px) {
  .tool-list li { grid-template-columns: minmax(0, 1fr); }
  .tool-list .tool-name { grid-template-columns: 10.5rem minmax(0, 1fr); gap: 0 1rem; }
  .tool-list p { margin-top: 0.15rem; }
}

/* 「ブラウザーで試す」の見出しの下に置くパーティクルライフ。狭い画面では小さくして一覧の前に置く。
   クリックするとパーティクルライフのページを開く（キーボードでは一覧のリンクから開く） */
.tool-preview-link { display: block; flex-basis: 100%; max-width: 240px; margin-top: 1.5rem; cursor: pointer; }
.tool-preview { display: block; width: 100%; aspect-ratio: 1; border: 1px solid var(--line); background: var(--bg); transition: border-color .15s; }
.tool-preview-link:hover .tool-preview { border-color: var(--line-strong); }
/* プレビューの下の説明。シェルのコメントのように 1 文ずつ改行し、目立たない灰色にする */
.tool-preview-note { display: block; margin-top: .4rem; font-family: var(--mono); font-size: .62rem; line-height: 1.5; color: var(--line-strong); white-space: pre-line; }
@media (max-width: 720px) {
  .tool-preview-link { max-width: 160px; margin-top: 1rem; }
}
