:root {
  color-scheme: light;
  --ink: #152d35;
  --muted: #50636a;
  --paper: #f6f8f5;
  --surface: #fff;
  --line: #d8e2df;
  --accent: #175b53;
  --accent-dark: #123c36;
  --accent-light: #e7f2ec;
  --blue: #1968b5;
  --orange: #a94c16;
  --green: #237358;
  --purple: #6947a7;
  --radius: 14px;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--paper);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; line-height: 1.75; }
[hidden] { display: none !important; }
h1, h2, h3, p, figure, dl { margin: 0; }
h1, h2, h3 { line-height: 1.32; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.05rem); letter-spacing: -.035em; }
h3 { font-size: 1.08rem; }
p { overflow-wrap: break-word; }
a { color: var(--accent); text-underline-offset: .23em; }
button, input, select { font: inherit; }
button, select, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .47; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid #1a79cc;
  outline-offset: 3px;
}
button, select, input[type=number] {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #b7c9c4;
  border-radius: 7px;
  padding: .34rem .7rem;
}
button:not(:disabled):hover, select:hover { border-color: var(--accent); background: var(--accent-light); }
input[type=range] { width: 100%; min-width: 0; accent-color: var(--accent); }
.wrap { width: min(1140px, calc(100% - 3rem)); margin-inline: auto; }
.skip { position: absolute; inset: .5rem auto auto .5rem; z-index: 1; transform: translateY(-160%); background: white; padding: .5rem; }
.skip:focus { transform: none; }
.sitebar { background: white; border-bottom: 1px solid var(--line); }
.sitebar-inner { display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: .75rem; }
.sitebar a { font-weight: 650; text-decoration: none; }
.sitebar a:hover { text-decoration: underline; }
.brand { font-size: clamp(.98rem, 3vw, 1.23rem); color: var(--ink); letter-spacing: -.05em; white-space: nowrap; }
.brand strong { color: var(--accent); }
.sitebar-inner > :last-child:not(.brand) { font-size: .83rem; text-align: right; }
.crumb { display: flex; gap: .7rem; font-size: .82rem; color: var(--muted); padding-block: 1.15rem; }
.hero {
  display: grid;
  grid-template-columns: 1fr minmax(280px, .89fr);
  align-items: center;
  gap: clamp(1.8rem, 5vw, 4rem);
  background: var(--accent-light);
  border: 1px solid #cfe3d7;
  border-radius: 22px;
  padding: clamp(1.3rem, 5vw, 3.45rem);
}
.kicker { color: var(--accent); font: 700 .73rem/1.5 ui-monospace, monospace; letter-spacing: .15em; }
.hero h1 { font-size: clamp(2.35rem, 7vw, 5rem); letter-spacing: -.075em; font-weight: 800; margin-top: .35rem; }
.hero-en { color: var(--accent); font-size: clamp(1rem, 2vw, 1.35rem); font-weight: 650; margin-top: .15rem; }
.hero-copy { color: #314e4a; margin-block: .95rem 1.35rem; max-width: 35em; }
.primary-link, .accent-button { display: inline-flex; align-items: center; gap: .75rem; background: var(--accent-dark); color: white; border: 1px solid var(--accent-dark); border-radius: 8px; padding: .58rem .9rem; text-decoration: none; font-weight: 650; }
.primary-link:hover, .accent-button:not(:disabled):hover { background: var(--accent); color: white; }
.hero-figure { background: #163b3a; border: 1px solid #285451; border-radius: var(--radius); overflow: hidden; }
.hero-figure figcaption { color: #dbede7; border-top: 1px solid #37615e; font-size: .8rem; padding: .55rem 1rem; }
.hero-grid, .hero-wall, .hero-spring { fill: none; }
.hero-grid { stroke: #28514f; }
.hero-wall { stroke: #abc9be; stroke-width: 1.5; }
.hero-spring { stroke: #b7dbcf; stroke-width: 2; stroke-linejoin: round; }
.hero-svg-label { fill: #effbf6; font: 600 13px ui-monospace, monospace; }
svg { display: block; width: 100%; height: auto; }
.chapter-nav { display: flex; flex-wrap: wrap; gap: .45rem 1.4rem; padding: .8rem 0; margin-block: .6rem 1.9rem; border-bottom: 1px solid var(--line); }
.chapter-nav a { font-size: .85rem; font-weight: 650; text-decoration: none; padding-block: .25rem; }
.chapter-nav a:hover { text-decoration: underline; }
.lesson-section { padding-block: 1.6rem; scroll-margin-top: 1rem; }
.lesson-section + .lesson-section { margin-top: .6rem; border-top: 1px solid var(--line); }
.lesson-section > p { margin-block: .8rem 1.1rem; max-width: 76ch; }
.equation-grid, .mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.equation, .math-scroll, .mode-values { overflow-x: auto; }
.equation, .mode-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem; }
.equation h3, .mode-card p { color: var(--muted); font-size: .87rem; }
.main-equation { border-left: 3px solid var(--accent); }
.muted { color: var(--muted); }
.mode-grid { margin-top: .9rem; }
.mode-card h3 { display: flex; justify-content: space-between; gap: 1rem; }
.mode-card.plus { border-top: 3px solid var(--green); }
.mode-card.minus { border-top: 3px solid var(--purple); }
.mode-values { margin-top: 1rem; border: 1px solid var(--line); border-radius: 10px; background: white; }
.mode-values table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: .86rem; font-variant-numeric: tabular-nums; }
.mode-values caption { padding: .45rem .8rem; text-align: left; font-weight: 700; background: var(--accent-light); }
.mode-values th, .mode-values td { border-top: 1px solid var(--line); padding: .46rem .8rem; text-align: right; }
.mode-values th:first-child { text-align: left; }
.notice { background: var(--accent-light); border-left: 3px solid var(--accent); padding: .8rem 1rem; border-radius: 0 7px 7px 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.section-heading .kicker { margin-bottom: .35rem; }
.status, #preset-name { font-size: .75rem; font-weight: 700; background: var(--accent-light); color: var(--accent-dark); padding: .22rem .63rem; border-radius: 20px; }
.preset-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; margin-bottom: 1rem; }
.preset { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; text-align: start; gap: .2rem .6rem; padding: .65rem .9rem; }
.preset span { font-size: .74rem; color: var(--muted); }
.preset.plus strong { color: var(--green); }
.preset.minus strong { color: var(--purple); }
.preset[aria-pressed=true] { border-color: var(--accent); background: var(--accent-light); box-shadow: inset 0 0 0 1px var(--accent); }
.lab-layout { display: grid; grid-template-columns: minmax(0, 2.16fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.visual-column, .settings-column { min-width: 0; display: grid; gap: .85rem; }
.apparatus { border-radius: var(--radius); background: #102e39; color: #f1fbfa; overflow: hidden; padding: .9rem 1rem; }
.apparatus-head { display: flex; justify-content: space-between; align-items: center; gap: .7rem; }
#clock { background: #20414d; border-radius: .45rem; padding: .19rem .55rem; font: 650 .83rem/1.65 ui-monospace, monospace; white-space: nowrap; }
.apparatus svg { background: radial-gradient(ellipse at center, #1a3f4a, transparent 72%); }
.spring, .spring-wall, .spring-equilibrium { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.spring { stroke: #c9dbdf; stroke-width: 2.4; }
.spring.middle { stroke: #91dfc4; }
.spring.disconnected { visibility: hidden; }
.spring-wall { stroke: #b5cfd5; stroke-width: 2; }
.spring-equilibrium { stroke: #7b9ba4; stroke-dasharray: 5 6; }
.diagram-label { font: 500 17px sans-serif; fill: #c9dde1; }
.mass-square.first { fill: #2c7bc9; }
.mass-square.second { fill: #b95217; }
.mass-label { font: 700 21px ui-monospace, monospace; fill: #fff; }
.apparatus-readout { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; margin-top: .25rem; }
.apparatus-readout > div { background: #20414d; padding: .4rem .6rem; border-radius: 6px; }
.apparatus-readout dt { font-size: .72rem; }
.apparatus-readout dd { margin: 0; color: white; font: 600 .88rem/1.6 ui-monospace, monospace; }
.apparatus .blue { color: #a8d5ff; }
.apparatus .orange { color: #ffc397; }
.apparatus figcaption { color: #c0d4d8; margin-top: .55rem; font-size: .7rem; }
.time-panel, .plot-card, .wave-card, .settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.time-panel, .wave-card, .settings-card { padding: .85rem .95rem; }
.time-buttons, .time-options, .wave-options { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; font-size: .83rem; }
#play { background: var(--accent); border-color: var(--accent); color: white; }
#play:not(:disabled):hover { background: var(--accent-dark); }
.seek-row { display: flex; gap: .65rem; align-items: center; margin-block: .55rem; font-size: .83rem; white-space: nowrap; }
.time-options input { width: 6.8em; }
.settings-jump { display: none; }
.phase-section > p { font-size: .86rem; color: var(--muted); margin-block: .35rem .6rem; }
.phase-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.plot-card { padding: .55rem .65rem .65rem; }
.plot-card figcaption { font-weight: 750; font-size: .88rem; }
.plot-card figcaption span { float: right; font-weight: 550; }
.plot-card p { text-align: center; color: var(--muted); font: .77rem/1.5 ui-monospace, monospace; }
.blue { color: var(--blue); }
.orange { color: var(--orange); }
.green { color: var(--green); }
.purple { color: var(--purple); }
.plot-grid, .plot-axis { stroke: #d9e4e1; }
.plot-axis { stroke: #849d9c; }
.plot-card svg text, .wave-card svg text { fill: #42565d; font: 10px ui-monospace, monospace; }
.wave-card svg text { font-size: 14px; }
.plot-trace { fill: none; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.plot-point { stroke: white; stroke-width: 1.4; }
.plot-cursor { stroke: #163534; stroke-width: 1.5; stroke-dasharray: 4 4; }
.wave-card summary { font-weight: 700; }
.wave-options { justify-content: space-between; margin: .55rem 0 .2rem; }
.wave-options span { white-space: nowrap; }
#wave-note { font-size: .77rem; }
.settings-head { display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
fieldset { border: 0; padding: 0; min-width: 0; margin: .75rem 0; }
legend { width: 100%; padding: 0 0 .3rem; border-bottom: 1px solid var(--line); font-size: .79rem; font-weight: 700; color: var(--accent); }
.field { display: grid; grid-template-columns: minmax(0, 1fr) 5.35rem; align-items: center; gap: .1rem .3rem; margin-top: .38rem; }
.field label { font-size: .81rem; font-weight: 650; }
.field label span { font-size: .73rem; color: var(--muted); }
.field input[type=number] { width: 100%; padding: .1rem .36rem; font-size: .79rem; font-variant-numeric: tabular-nums; }
.field input[type=range], .field small { grid-column: 1 / -1; margin-inline: 0; }
.field input[type=range] { cursor: pointer; }
.field small { color: var(--muted); font-size: .72rem; }
#initial-momentum, .beat-readout { font-size: .74rem; margin-block: .35rem; }
.beat-readout { border-top: 1px solid var(--line); padding-top: .45rem; }
#reset { margin-top: .38rem; font-size: .8rem; }
.energy-total { display: flex; align-items: center; justify-content: space-between; gap: .55rem; margin: .5rem 0; font-size: .84rem; }
.energy-total strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; color: var(--accent); }
.energy-bar { display: flex; height: .58rem; background: #e6eeeb; border-radius: .3rem; overflow: hidden; }
.energy-bar span { flex-basis: 0; }
.energy-list { margin-block: .32rem .63rem; font-size: .76rem; }
.energy-list > div { display: flex; justify-content: space-between; gap: .55rem; padding: .17rem 0; }
.energy-list dt i { display: inline-block; width: .62rem; height: .62rem; border-radius: 2px; margin-right: .28rem; }
.energy-list dd { margin: 0; font-variant-numeric: tabular-nums; text-align: end; }
.kinetic { background: #2c82ae; }
.outer { background: #cd7831; }
.coupling { background: #a35c90; }
.mode-p { background: var(--green); }
.mode-m { background: var(--purple); }
.reading { max-width: 900px; }
.reading > h3 { margin-top: 1.25rem; }
.worked-steps, .exercise-list { padding-left: 1.55rem; }
.worked-steps > li, .exercise-list > li { margin-block: .75rem 1.2rem; padding-left: .35rem; }
.worked-steps li::marker, .exercise-list li::marker { font-weight: 750; color: var(--accent); }
.worked-steps li p, .exercise-list li p { margin-block: .5rem; }
.worked-steps .equation { margin-block: .5rem; }
.exercise-list details { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .75rem; margin-top: .4rem; }
.exercise-list details summary { color: var(--accent); font-weight: 650; font-size: .87rem; }
.exercise-list .equation { background: var(--paper); }
.site-footer { margin-top: 2.2rem; background: #ebf1ed; border-top: 1px solid var(--line); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .65rem; padding-block: 1.2rem; font-size: .85rem; }
.directory { padding-block: 1.9rem 1rem; min-height: 64vh; }
.directory .hero { display: block; }
.directory .hero h1 { font-size: clamp(2rem, 6.5vw, 4.1rem); }
.directory .lesson-section { max-width: 820px; }
.directory .lesson-section h2 { margin-bottom: .75rem; }
.lesson-link { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .45rem 1.05rem; padding: 1.1rem 1.25rem; background: white; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); text-decoration: none; }
.lesson-link:hover { border-color: var(--accent); }
.lesson-link p { font-size: .9rem; color: var(--muted); }
.lesson-link span { grid-column: 2; grid-row: 1 / 3; font-size: 1.4rem; }
@media (max-width: 770px) {
  .hero { grid-template-columns: 1fr; }
  .hero-figure { max-width: 425px; }
  .lab-layout { grid-template-columns: 1fr; }
  .settings-jump { display: inline; }
}
@media (max-width: 530px) {
  .wrap { width: calc(100% - 1.6rem); }
  .sitebar-inner { min-height: 56px; }
  .equation-grid, .mode-grid, .phase-grid { grid-template-columns: minmax(0, 1fr); }
  .hero { border-radius: 15px; }
  .preset-strip { gap: .3rem; }
  .preset { display: block; padding: .46rem .37rem; font-size: .83rem; }
  .preset span { display: block; font-size: .66rem; }
  .apparatus { padding: .72rem; }
  .apparatus-readout > div { padding: .35rem; }
  .apparatus-readout dt { font-size: .65rem; }
  .apparatus-readout dd { font-size: .75rem; }
  .plot-card svg { max-height: 240px; }
  .equation, .math-scroll { font-size: clamp(.82rem, 3.7vw, 1rem); }
  .wave-card svg text { font-size: 11px; }
}
