/* ==========================================================================
   the virtual form — shared styles
   Minimal: Barlow, #F7F7F7, thin rules, em-dash lists.
   Widgets borrow Houdini's parameter colours (green = key, blue = animated).
   ========================================================================== */

:root {
  --bg: #F7F7F7;
  --surface: #FFFFFF;
  --surface-2: #F0F0F0;
  --surface-3: #E4E4E4;
  --text: #111111;
  --muted: #666666;
  --faint: #ABABAB;
  --border: #DDDDDD;
  --border-strong: #BBBBBB;

  /* Houdini's parameter field colours */
  --key: #8CCB73;          /* keyframe on this frame */
  --key-ink: #0F2608;
  --anim: #86BFD0;         /* animated, no key on this frame ("blue", 青緑) */
  --anim-ink: #0A2129;
  --pending: #F1D36E;      /* changed, not keyed yet */
  --pending-ink: #2E2406;
  --error: #D0473F;
  --flag: #3D7DD8;         /* display flag */

  /* channel colours, as in Houdini: x red, y green, z blue */
  --ch-x: #D9534F;
  --ch-y: #43A047;
  --ch-z: #3F7BD9;

  /* 3D viewports and 2D figures */
  --vp-bg: #E9E9E9;
  --vp-grid: #D3D3D3;
  --vp-grid-strong: #B9B9B9;
  --vp-geo: #D8D8D8;
  --vp-edge: #2E2E2E;
  --vp-ink: #111111;
  --vp-highlight: #EE8A2A;  /* selection */
  --vp-soft: #FFFFFF;

  --font: 'Barlow', 'Noto Sans JP', system-ui, -apple-system, 'Hiragino Sans', 'Yu Gothic UI', Meiryo, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: 40px;
  --measure: 700px;
  --max: 1320px;
}

[data-theme="dark"] {
  --bg: #111111;
  --surface: #171717;
  --surface-2: #1E1E1E;
  --surface-3: #2A2A2A;
  --text: #F2F2F2;
  --muted: #A3A3A3;
  --faint: #5E5E5E;
  --border: #2C2C2C;
  --border-strong: #474747;

  --key: #4E8C39;
  --key-ink: #EEF8E9;
  --anim: #3B7A8C;
  --anim-ink: #E8F6FA;
  --pending: #9C8026;
  --pending-ink: #FFF7DC;

  --vp-bg: #1B1B1B;
  --vp-grid: #2A2A2A;
  --vp-grid-strong: #3C3C3C;
  --vp-geo: #8E8E8E;
  --vp-edge: #0B0B0B;
  --vp-ink: #F2F2F2;
  --vp-soft: #262626;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 72px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.85;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--text);
}

img,
svg,
canvas {
  display: block;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 1px dotted var(--text);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Top bar ──────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px var(--gutter);
}

.brand {
  font-size: 18px;
  font-weight: 400;
  text-decoration: none;
  line-height: 1;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.topnav a {
  font-size: 16px;
  color: var(--muted);
  text-decoration: none;
  line-height: 1;
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  transition: color .15s;
}

.topnav a:hover {
  color: var(--text);
}

.topnav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--text);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: color .15s;
}

.icon-btn:hover {
  color: var(--text);
}

main {
  flex: 1;
}

/* ── Footer ───────────────────────────────────────────────────────────── */

.site-foot {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 40px var(--gutter) 48px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 12px;
  color: var(--muted);
}

.site-foot a {
  color: var(--muted);
  text-decoration: none;
}

.site-foot a:hover {
  color: var(--text);
}

/* ── Home ─────────────────────────────────────────────────────────────── */

.home {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 72px var(--gutter) 40px;
  animation: fadeIn .5s ease both;
}

.home-hero {
  max-width: 720px;
}

.kicker {
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--muted);
}

.home-hero h1 {
  font-size: 48px;
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -.01em;
  margin: 10px 0 18px;
}

.home-hero p {
  color: var(--muted);
  max-width: 560px;
}

.latest {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 40px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  min-width: 300px;
  transition: border-color .15s;
}

.latest:hover {
  border-color: var(--text);
}

.latest small {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .04em;
}

.latest strong {
  font-size: 20px;
  font-weight: 400;
}

.course-block {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 40px;
  border-top: 1px solid var(--border);
  margin-top: 72px;
}

/* the top rule spaces the first week like the lines between weeks */
.course-head {
  padding-top: 11px;
}

.home .course-block:first-of-type {
  margin-top: 24px;
}

.course-block h2 {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .08em;
}

.course-block h2 a {
  text-decoration: none;
}

.course-block h2 a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.course-facts {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

/* Week lists (home and course page) */

.week-list {
  list-style: none;
}

.week-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}


.week-n {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.week-title {
  min-width: 0;
}

.week-title a {
  text-decoration: none;
}

.week-title a::after {
  content: ' →';
  color: var(--muted);
  transition: margin .15s;
}

.week-title a:hover::after {
  color: var(--text);
}

.week-meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.week-row.locked,
.week-row.locked .week-n,
.week-row.locked .week-meta {
  color: var(--faint);
}

.week-units {
  grid-column: 2 / -1;
  list-style: none;
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  columns: 2;
  column-gap: 32px;
}

.week-units li {
  break-inside: avoid;
  padding: 1px 0;
}

.week-units a {
  color: var(--muted);
  text-decoration: none;
}

.week-units a:hover {
  color: var(--text);
}

.week-units .seen::before {
  content: '✓ ';
  color: var(--text);
}

.meter {
  display: inline-block;
  vertical-align: middle;
  width: 64px;
  height: 2px;
  background: var(--border);
  margin-left: 10px;
  position: relative;
}

.meter i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--text);
}

/* ── Course page ──────────────────────────────────────────────────────── */

.course-page {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 40px var(--gutter) 40px;
  animation: fadeIn .5s ease both;
}

.course-page .course-head h1 {
  font-size: 36px;
  font-weight: 300;
  line-height: 1.2;
  margin: 8px 0 14px;
}

.course-page .course-block {
  margin-top: 48px;
}

/* ── Lesson layout ────────────────────────────────────────────────────── */

.lesson {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 64px;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 8px var(--gutter) 40px;
}

/* Sidebar: course outline */

.outline {
  position: sticky;
  top: 20px;
  align-self: start;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
  padding: 4px 6px 24px 0;
  scrollbar-width: thin;
}

.outline-course {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .1em;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 14px;
}

.outline-course:hover {
  color: var(--text);
}

.outline-weeks {
  list-style: none;
}

.outline-week > a,
.outline-week > span {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 4px;
  padding: 5px 0;
  text-decoration: none;
}

.outline-week .n {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.outline-week.locked > span,
.outline-week.locked .n {
  color: var(--faint);
  cursor: default;
}

.outline-week.current > a {
  font-weight: 500;
}

.outline-units {
  list-style: none;
  margin: 2px 0 10px 30px;
  border-left: 1px solid var(--border);
}

.outline-group {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
  padding: 10px 0 2px 12px;
}

.outline-group:first-child {
  padding-top: 4px;
}

.outline-unit a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px;
  gap: 6px;
  padding: 3px 0 3px 12px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

.outline-unit a:hover {
  color: var(--text);
}

.outline-unit a[aria-current="true"] {
  color: var(--text);
  border-left-color: var(--text);
}

.tick {
  font-size: 11px;
  color: var(--text);
  opacity: 0;
}

.seen > .tick,
.seen .tick {
  opacity: 1;
}

.outline-close {
  display: none;
}


.seq-mode .seq-done:hover,
.seq-mode .seq-reset:hover {
  color: var(--text);
}

.lesson-main .outline-toggle {
  display: none;
}

.scrim {
  display: none;
}

/* Lesson header */

.crumbs {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.crumbs a {
  color: var(--muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--text);
}

.crumbs span[aria-hidden] {
  margin: 0 6px;
}

.lesson-head {
  margin: 18px 0 0;
  max-width: var(--measure);
}

.lesson-head h1 {
  font-size: 36px;
  font-weight: 300;
  line-height: 1.25;
  margin: 6px 0 12px;
}

.lesson-head .lede {
  color: var(--muted);
}

/* Unit sequence bar (edX-style) */

.seq {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: stretch;
  margin: 32px 0 44px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.seq-arrow {
  flex: 0 0 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
}

.seq-arrow:hover:not(:disabled) {
  color: var(--text);
}

.seq-arrow:disabled {
  color: var(--faint);
  cursor: default;
}

.seq-arrow.prev {
  border-right: 1px solid var(--border);
}

.seq-arrow.next {
  border-left: 1px solid var(--border);
}

.seq-track {
  flex: 1;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.seq-track::-webkit-scrollbar {
  display: none;
}

.seq-group {
  display: flex;
  flex-direction: column;
  padding: 5px 8px 0;
}

.seq-group + .seq-group {
  border-left: 1px solid var(--border);
}

.seq-group-label {
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
  letter-spacing: .04em;
  white-space: nowrap;
  padding: 0 2px;
}

.seq-items {
  display: flex;
}

.seq-item {
  position: relative;
  width: 36px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  text-decoration: none;
}

.seq-item:hover {
  color: var(--text);
}

.seq-item[aria-current="true"] {
  color: var(--text);
  border-bottom-color: var(--text);
}

.seq-item.seen::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--key);
}

.seq-item .tip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.4;
  padding: 5px 9px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
  z-index: 5;
}

.seq-item:hover .tip,
.seq-item:focus-visible .tip {
  opacity: 1;
}

.seq-mode {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  border-left: 1px solid var(--border);
  font-size: 12px;
}

.seq-mode button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  white-space: nowrap;
}

.seq-mode button[aria-pressed="true"] {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Units */

.units[data-mode="single"] .unit:not(.is-active) {
  display: none;
}

.unit {
  animation: fadeIn .35s ease both;
}

.unit-head {
  margin-bottom: 32px;
  max-width: var(--measure);
}

.unit-num {
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.unit-head h2 {
  font-size: 28px;
  font-weight: 300;
  line-height: 1.35;
  margin-top: 4px;
}

.unit-head .en {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.block {
  max-width: var(--measure);
  margin-bottom: 40px;
}

.block-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 14px;
}

.block-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.unit > .block-label {
  max-width: var(--measure);
}

.lesson-main {
  min-width: 0;
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--key);
  vertical-align: middle;
}

.notes h3 {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
  margin: 30px 0 10px;
}

.notes h3:first-child {
  margin-top: 0;
}

.notes p {
  margin-bottom: 12px;
}

.notes ul,
.aside ul,
.qa-a ul {
  list-style: none;
  margin-bottom: 12px;
}

.notes li,
.aside li,
.qa-a li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 6px;
}

.notes li::before,
.aside li::before,
.qa-a li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--muted);
}

.notes ol {
  list-style: none;
  counter-reset: n;
  margin-bottom: 12px;
}

.notes ol > li {
  counter-increment: n;
  padding-left: 28px;
}

.notes ol > li::before {
  content: counter(n);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  top: 5px;
  line-height: 1;
}

.notes li ul {
  margin: 6px 0 0;
}

.said {
  margin: 18px 0 20px;
  padding-left: 18px;
  border-left: 1px solid var(--border-strong);
  font-size: 17px;
  font-weight: 300;
  line-height: 1.7;
}

.said cite {
  display: block;
  font-size: 12px;
  font-style: normal;
  color: var(--muted);
  margin-top: 4px;
}

.aside {
  border-left: 2px solid var(--text);
  padding: 2px 0 2px 20px;
}

.aside p {
  margin-bottom: 10px;
}

.aside p:last-child,
.aside ul:last-child {
  margin-bottom: 0;
}

.content-note {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.75;
  margin-bottom: 36px;
  max-width: var(--measure);
}

.content-note strong {
  font-weight: 500;
}

kbd {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 2px 6px 1px;
  background: var(--surface);
  white-space: nowrap;
  display: inline-block;
}

code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0 5px;
  border-radius: 2px;
  white-space: nowrap;
}

.ui {
  font-family: var(--mono);
  font-size: .9em;
  white-space: nowrap;
}

strong {
  font-weight: 500;
}

.terms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.term {
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  background: var(--surface);
}

.term span {
  color: var(--muted);
}

figure {
  margin: 8px 0 28px;
}

figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
}

figcaption {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  margin-top: 8px;
}

.figure-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Q&A blocks */

.qa {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 28px;
}

.qa:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.qa-q {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 26px 1fr;
}

.qa-q::before {
  content: 'Q';
  color: var(--muted);
  font-weight: 400;
}

.qa-a {
  padding-left: 26px;
}

.qa-a p {
  margin-bottom: 10px;
}

/* "Beyond": things not said in class, right under the question they extend */

.beyond {
  margin: 14px 0 4px 26px;
  padding: 10px 0 2px 16px;
  border-left: 2px solid var(--text);
}

.beyond-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 6px;
}

/* Tables (summary) */

.table-wrap {
  overflow-x: auto;
  margin-bottom: 12px;
}

table.ref {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.6;
}

table.ref th,
table.ref td {
  text-align: left;
  vertical-align: top;
  padding: 8px 14px 8px 0;
  border-bottom: 1px solid var(--border);
}

table.ref th {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .1em;
  color: var(--muted);
}

table.ref td:first-child {
  white-space: nowrap;
}

.toc {
  list-style: none;
  counter-reset: none;
  columns: 2;
  column-gap: 32px;
}

.toc li {
  break-inside: avoid;
  padding: 2px 0;
  display: grid;
  grid-template-columns: 28px 1fr;
}

.toc .n {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.toc a {
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Bottom pager */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 80px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.pager a {
  display: flex;
  flex-direction: column;
  max-width: 48%;
  text-decoration: none;
  line-height: 1.5;
}

.pager a small {
  font-size: 12px;
  color: var(--muted);
}

.pager a:hover span {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.pager .next {
  margin-left: auto;
  text-align: right;
}

/* ── Widgets ──────────────────────────────────────────────────────────── */

.widget {
  margin: 4px 0 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  line-height: 1.6;
  position: relative;
}

.widget.loading {
  min-height: 220px;
}

.widget.loading::before {
  content: '読み込み中…';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.wbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  min-height: 38px;
}

.wbar-title {
  letter-spacing: .03em;
}

.wbar-title b {
  font-weight: 500;
  color: var(--text);
  margin-right: 6px;
}

.wbody {
  padding: 16px;
}

.wcols {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.wcols.even {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.wstack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wfoot {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
}

.vp {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 220px;
  background: var(--vp-bg);
  overflow: hidden;
}

.vp.wide {
  aspect-ratio: 16 / 9;
}

.vp.square {
  aspect-ratio: 1 / 1;
}

.vp > canvas {
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.vp-hint {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
  line-height: 1.4;
}

.vp-badge {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
  font-family: var(--mono);
  line-height: 1.5;
}

.vp-badge.right {
  left: auto;
  right: 10px;
  text-align: right;
}

.vp-zoomhint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}

.vp-zoomhint.show {
  opacity: 1;
}

.vp-label {
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  color: var(--vp-ink);
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.vp-label.beside {
  margin: -11px 0 0 12px;
}

.vp-label.hl {
  color: var(--vp-highlight);
  font-weight: 600;
}

.fig2d {
  position: relative;
  width: 100%;
  background: var(--vp-bg);
  aspect-ratio: 1 / 1;
  touch-action: none;
}

.fig2d canvas,
.fig2d svg {
  width: 100%;
  height: 100%;
}

/* Controls */

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ctl {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 10px;
}

.ctl > label,
.ctl > .ctl-label {
  color: var(--muted);
  line-height: 1.35;
}

.ctl output {
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ctl-group-label {
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--muted);
  margin-top: 4px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--border-strong);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text);
  margin-top: -5.5px;
  border: none;
}

input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--border-strong);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: none;
}

input[type="range"]:disabled {
  opacity: .35;
  cursor: default;
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.seg button {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--muted);
  padding: 2px 0;
  cursor: pointer;
  position: relative;
  line-height: 1.5;
}

.seg button:hover {
  color: var(--text);
}

.seg button[aria-pressed="true"] {
  color: var(--text);
}

.seg button[aria-pressed="true"]::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--text);
}

.seg button:disabled {
  color: var(--faint);
  cursor: default;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 5px 12px;
  cursor: pointer;
  transition: border-color .12s, background-color .12s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--text);
}

.btn:disabled {
  color: var(--faint);
  cursor: default;
}

.btn.primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.btn.small {
  font-size: 12px;
  padding: 3px 9px;
}

.btn kbd {
  font-size: 10px;
  padding: 1px 4px;
  color: var(--muted);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 0;
}

.switch::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  flex: 0 0 auto;
}

.switch[aria-pressed="true"] {
  color: var(--text);
}

.switch[aria-pressed="true"]::before {
  background: var(--text);
  border-color: var(--text);
  box-shadow: inset 0 0 0 2px var(--surface);
}

.readout {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.7;
}

.readout .dim {
  color: var(--muted);
}

.readout .big {
  font-size: 22px;
  font-family: var(--font);
  font-weight: 300;
}

.ok {
  color: var(--ch-y);
}

.ng {
  color: var(--error);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 2px 10px;
  cursor: pointer;
  color: var(--text);
}

.chip:hover {
  border-color: var(--text);
}

.chip.on {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translate(-50%, -6px);
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  padding: 6px 12px;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 20;
  max-width: 90%;
  text-align: center;
  line-height: 1.5;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Steps checklist and "try it" */

.steps {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 6px;
  color: var(--muted);
  line-height: 1.55;
}

.steps li::before {
  content: counter(step);
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
}

.steps li.done {
  color: var(--text);
}

.steps li.done::before {
  content: '✓';
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.try {
  border-top: 1px dashed var(--border-strong);
  padding: 12px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.try-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .1em;
  color: var(--muted);
}

.try-text {
  flex: 1 1 260px;
}

.try-state {
  font-size: 12px;
  color: var(--muted);
}

.try.done .try-state {
  color: var(--text);
}

.try.done .try-state::before {
  content: '✓ ';
}

.try input[type="text"],
.try input[type="number"] {
  font-family: var(--mono);
  font-size: 13px;
  width: 90px;
  padding: 3px 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 2px;
}

/* Content gate (patterns some people find hard to look at) */

.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  min-height: 260px;
  padding: 32px 24px;
  background: var(--surface-2);
  color: var(--muted);
}

.gate p {
  max-width: 420px;
}

/* ── Houdini-style parameter pane ─────────────────────────────────────── */

.pane {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.4;
}

.pane-head .node-name {
  font-family: var(--mono);
  font-weight: 600;
}

.pane-head .node-type {
  color: var(--muted);
}

.pane-body {
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.parm {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.parm-label {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.parm-label:hover {
  color: var(--text);
}

.parm-fields {
  display: flex;
  gap: 4px;
  min-width: 0;
}

.field {
  flex: 1 1 0;
  min-width: 0;
  height: 26px;
  display: flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 0 6px;
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  white-space: nowrap;
  touch-action: none;
  transition: background-color .12s, color .12s;
}

.field.is-key {
  background: var(--key);
  color: var(--key-ink);
  border-color: var(--key);
}

.field.is-anim {
  background: var(--anim);
  color: var(--anim-ink);
  border-color: var(--anim);
}

.field.is-pending {
  background: var(--pending);
  color: var(--pending-ink);
  border-color: var(--pending);
}

.field.is-error {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.field.is-selected {
  box-shadow: 0 0 0 1px var(--surface), 0 0 0 2px var(--text);
}

.field.is-editing {
  cursor: text;
  background: var(--surface);
  color: var(--text);
}

.field input {
  all: unset;
  width: 100%;
  font: inherit;
  color: inherit;
  cursor: text;
}

.field.is-disabled {
  opacity: .45;
  cursor: default;
}

.parm-slider {
  grid-column: 2;
}

.pane-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 10px 10px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 11px;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  vertical-align: -1px;
  margin-right: 5px;
  border-radius: 1px;
}

.legend .k {
  background: var(--key);
}

.legend .a {
  background: var(--anim);
}

.legend .p {
  background: var(--pending);
}

.legend .s {
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.ctxmenu {
  position: fixed;
  z-index: 1000;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .14);
  padding: 4px 0;
  font-size: 13px;
  line-height: 1.4;
}

.ctxmenu button {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 6px 14px;
  cursor: pointer;
}

.ctxmenu button small {
  color: var(--muted);
}

.ctxmenu button:hover:not(:disabled) {
  background: var(--surface-2);
}

.ctxmenu button:disabled {
  color: var(--faint);
  cursor: default;
}

.ctxmenu hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* ── Playbar ──────────────────────────────────────────────────────────── */

.playbar {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 10px 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  user-select: none;
  -webkit-user-select: none;
}

.playbar.standalone {
  border: 1px solid var(--border);
}

.pb-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pb-timeline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.pb-ruler {
  position: relative;
  flex: 1 1 auto;
  min-width: 120px;
  height: 36px;
  cursor: pointer;
  touch-action: none;
}

.pb-ruler canvas {
  width: 100%;
  height: 100%;
}

.pb-btn {
  width: 28px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
}

.pb-btn:hover {
  border-color: var(--border-strong);
}

.pb-btn[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
}

.pb-btn.mode {
  width: auto;
  padding: 0 8px;
  font-size: 12px;
  gap: 6px;
}

.pb-field {
  width: 50px;
  height: 24px;
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  padding: 0 2px;
  flex: 0 0 auto;
}

.pb-field.global {
  color: var(--muted);
  width: 46px;
}

.pb-field::-webkit-inner-spin-button {
  display: none;
}

.pb-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  flex: 0 0 auto;
}

.pb-label {
  font-size: 11px;
  color: var(--muted);
}

.pb-select {
  height: 24px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0 4px;
}

.pb-spacer {
  flex: 1;
}

/* ── Mini network view ────────────────────────────────────────────────── */

.net {
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
}

.net svg {
  width: 100%;
  height: auto;
}

.net .wire {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.4;
}

.net .node-body {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1;
}

.net .node.selected .node-body {
  stroke: var(--vp-highlight);
  stroke-width: 1.6;
}

.net .node-name {
  font-family: var(--mono);
  font-size: 11px;
  fill: var(--text);
}

.net .node-type {
  font-size: 10px;
  fill: var(--muted);
}

.net .node {
  cursor: pointer;
}

.net.static .node,
.net.static .flag {
  cursor: default;
}

.net.static {
  max-width: 520px;
}

.net .node.ghost {
  opacity: .3;
  cursor: default;
}

.net .flag {
  fill: var(--surface-3);
  stroke: var(--border-strong);
}

.net .flag.on {
  fill: var(--flag);
  stroke: var(--flag);
}

.net .port {
  fill: var(--surface);
  stroke: var(--muted);
}

.net .port-n {
  font-family: var(--mono);
  font-size: 9px;
  fill: var(--muted);
}

/* Spreadsheet */

.sheet {
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
}

.sheet-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  font-family: var(--font);
  font-size: 12px;
}

.sheet-tabs button {
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  padding: 4px 10px;
  color: var(--muted);
  cursor: pointer;
}

.sheet-tabs button[aria-pressed="true"] {
  color: var(--text);
  background: var(--surface-2);
}

.sheet-rows {
  max-height: 196px;
  overflow-y: auto;
}

.sheet-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  padding: 1px 10px;
  cursor: default;
  font-variant-numeric: tabular-nums;
}

.sheet-row:nth-child(even) {
  background: var(--surface-2);
}

.sheet-row.hl {
  background: var(--vp-highlight);
  color: #111;
}

.sheet-row .dim {
  color: var(--muted);
}

.sheet-row.hl .dim {
  color: #3a2a12;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .lesson {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .outline {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    max-height: none;
    z-index: 200;
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 24px 20px 40px;
    transform: translateX(-102%);
    transition: transform .22s ease;
    visibility: hidden;
  }

  body.outline-open .outline {
    transform: none;
    visibility: visible;
  }

  .outline-close {
    display: block;
    margin: -6px 0 12px auto;
  }

  .scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .3);
    z-index: 150;
  }

  body.outline-open .scrim {
    display: block;
  }

  .lesson-main .outline-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
  }
}

@media (max-width: 820px) {
  :root {
    --gutter: 16px;
  }

  .topbar {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .home {
    padding-top: 40px;
  }

  .home-hero h1 {
    font-size: 36px;
  }

  .course-block {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin-top: 56px;
  }

  .week-units {
    columns: 1;
  }

  .lesson-head h1 {
    font-size: 30px;
  }

  .unit-head h2 {
    font-size: 24px;
  }

  .wcols,
  .wcols.even {
    grid-template-columns: minmax(0, 1fr);
  }

  .wbody {
    padding: 12px;
  }

  .ctl {
    grid-template-columns: 104px minmax(0, 1fr) 46px;
  }

  .toc {
    columns: 1;
  }

  .figure-pair {
    grid-template-columns: 1fr;
  }


}

@media (max-width: 480px) {
  .latest {
    min-width: 0;
    width: 100%;
  }

  .parm {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .pager a small {
    display: none;
  }
}

/* ── Print: every unit, no chrome, no interactive windows ─────────────── */

@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
  }

  .topbar,
  .site-foot,
  .outline,
  .outline-toggle,
  .seq,
  .pager,
  .scrim,
  .widget,
  .no-print {
    display: none !important;
  }

  .lesson {
    display: block;
    padding: 0;
  }

  .units[data-mode] .unit {
    display: block !important;
    animation: none;
  }

  .unit + .unit {
    break-before: page;
  }

  body.print-one .unit:not(.print-target) {
    display: none !important;
  }

  body.print-one .lesson-head,
  body.print-one .crumbs {
    display: none;
  }

  .print-note {
    display: block !important;
  }
}

.print-note {
  display: none;
  font-size: 12px;
  color: var(--muted);
}

/* ── Motion ───────────────────────────────────────────────────────────── */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Clickable steps (jump to that step) */
.step-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.step-link:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 復習 (multiple choice) */
.quiz {
  list-style: none;
  counter-reset: q;
  display: flex;
  flex-direction: column;
  gap: 26px;
  font-size: 14px;
  line-height: 1.7;
}

.quiz > li {
  counter-increment: q;
}

.quiz-q {
  font-weight: 500;
  margin-bottom: 10px;
}

.quiz-q::before {
  content: '問' counter(q) '　';
  color: var(--muted);
  font-weight: 400;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.quiz-option {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-align: left;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 7px 12px;
  cursor: pointer;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--text);
}

.quiz-option:disabled {
  cursor: default;
  color: var(--muted);
}

.quiz-option.right {
  border-color: var(--key);
  background: var(--key);
  color: var(--key-ink);
}

.quiz-option.wrong {
  border-color: var(--error);
  color: var(--error);
}

.quiz-letter {
  font-size: 11px;
  color: var(--muted);
  flex: 0 0 auto;
}

.quiz-option.right .quiz-letter {
  color: inherit;
}

.quiz-why {
  margin-top: 8px;
  font-size: 13px;
}

.quiz-why span {
  font-weight: 500;
  margin-right: 4px;
}

.quiz-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.quiz-score {
  font-family: var(--mono);
  font-size: 13px;
}

@media (max-width: 820px) {
  .quiz-options {
    grid-template-columns: minmax(0, 1fr);
  }
}

.quiz-fig {
  display: block;
  width: 100%;
  max-width: 300px;
  height: auto;
  margin: 0 0 10px;
  border: 1px solid var(--border);
}
