:root {
  color-scheme: dark;
  --background: #171421;
  --surface: #211b2b;
  --inset: #1a1622;
  --line: #473c53;
  --text: #f7f0ff;
  --muted: #c9bdd6;
  --amber: #ffd087;
  --cyan: #a2efeb;
  --pink: #ffabc1;
  --display: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 1.5rem; }
body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: radial-gradient(ellipse 75rem 40rem at 12% -13rem, #30243d, transparent 68%), var(--background);
  font: 1rem/1.58 var(--body);
}
main { flex: 1; }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.12; text-wrap: balance; }
h1 { font-size: clamp(2.25rem, 4.8vw, 3.95rem); letter-spacing: -.047em; overflow-wrap: anywhere; }
h2 { font-size: clamp(1.3rem, 2.3vw, 1.7rem); letter-spacing: -.025em; }
h3 { font-size: 1.25rem; letter-spacing: -.022em; }
a { color: var(--cyan); text-underline-offset: .23em; }
a:hover { color: var(--text); }
a, button, input, select, summary { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
svg { display: block; max-width: 100%; }

.container { width: min(1200px, calc(100% - clamp(2rem, 6vw, 5rem))); margin-inline: auto; }
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus { position: absolute; z-index: 5; top: .5rem; left: .5rem; padding: .65rem 1rem; background: var(--inset); }

.masthead { border-bottom: 1px solid var(--line); }
.masthead-inner, .footer-inner {
  display: flex;
  min-height: 4.1rem;
  align-items: center;
  justify-content: space-between;
  gap: .8rem 1.5rem;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--display);
  font-size: 1.11rem;
  font-weight: 700;
  letter-spacing: -.04em;
}
.brand svg { width: 2rem; height: 2rem; color: var(--cyan); }
.masthead nav, .footer nav { display: flex; gap: .8rem 1.55rem; flex-wrap: wrap; }
.masthead nav a, .footer nav a { color: var(--muted); font-size: .9rem; font-weight: 550; text-decoration: none; }
.masthead nav a:hover, .footer nav a:hover, .masthead nav a[aria-current] { color: var(--cyan); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.03fr);
  gap: clamp(1.5rem, 5vw, 5rem);
  align-items: center;
  padding-block: clamp(3.2rem, 7vw, 6.4rem) clamp(3.3rem, 6vw, 5rem);
}
.hero h1 { text-wrap: initial; }
.hero h1 span { color: var(--cyan); display: block; }
.hero-copy p { max-width: 32rem; margin-top: 1.15rem; color: var(--muted); font-size: clamp(1.02rem, 1.7vw, 1.2rem); }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.55rem; }
.button {
  min-height: 2.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .55rem .9rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  color: var(--text);
  background: #2c2436;
  font-size: .875rem;
  font-weight: 680;
  line-height: 1.24;
  text-decoration: none;
  text-align: center;
}
.button:hover { background: #3a2d44; border-color: #887697; color: var(--text); }
.button-primary { color: #181926; background: var(--cyan); border-color: var(--cyan); }
.button-primary:hover { color: #181926; background: #d7f9f6; border-color: #d7f9f6; }
.button-quiet { color: var(--muted); background: transparent; }
.button:disabled { cursor: default; opacity: .48; }

.hero-monitor {
  min-width: 0;
  position: relative;
  padding: .65rem .78rem;
  border: 1px solid #61516d;
  border-radius: .75rem;
  background: #272030;
  box-shadow: 0 1.4rem 4rem #0b081464;
}
.hero-monitor::before, .hero-monitor::after {
  content: "";
  display: block;
  height: .36rem;
  margin-block: .2rem;
  border-radius: .15rem;
  background: repeating-linear-gradient(90deg, #5b4a67 0 .65rem, transparent .65rem 1.5rem);
}
.monitor-bar {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .2rem;
  color: var(--amber);
  font: .82rem/1.2 var(--mono);
}
.hero-monitor svg { width: 100%; border: 1px solid #504458; border-radius: .35rem; }
.hero-monitor figcaption { padding: .66rem .2rem; font-size: .875rem; }
.hero-monitor figcaption a { font-weight: 570; }

.home-section { margin-bottom: clamp(3rem, 6vw, 5rem); }
.section-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1.1rem; margin-bottom: 1.2rem; }
.section-heading h2 { font-size: clamp(1.7rem, 3vw, 2.25rem); }
.section-heading p { color: var(--muted); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: .7rem; }
.tool-card {
  min-width: 0;
  padding: 1.05rem;
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .5rem;
  text-decoration: none;
}
.tool-card:hover { background: #2b2236; border-color: #8f788a; }
.tool-icon {
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  padding: .25rem;
  margin-top: .08rem;
  border-radius: .3rem;
  color: var(--amber);
  background: #34283b;
}
.tool-tag, .section-tag { color: var(--amber); font: 600 .82rem/1.4 var(--mono); }
.tool-card h3 { margin-block: .32rem .45rem; text-wrap: initial; }
.tool-card p { color: var(--muted); font-size: .94rem; line-height: 1.5; }

.example-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; align-items: start; }
.example-group { background: var(--surface); border: 1px solid var(--line); border-radius: .45rem; }
.example-group summary { padding: .85rem .95rem; }
.example-group summary span { color: var(--muted); white-space: nowrap; font-weight: 400; font-size: .875rem; margin-inline-start: .55rem; }
summary { cursor: pointer; font-weight: 630; }
summary::marker { color: var(--amber); }
summary:hover { color: var(--cyan); }
.guide-list { margin: .4rem 0 0; list-style: none; padding: 0; }
.guide-list li { border-top: 1px solid var(--line); }
.guide-list a { display: block; padding-block: .68rem; text-decoration: none; line-height: 1.36; }
.guide-list a:hover { text-decoration: underline; }
.example-group .guide-list { margin: 0 .95rem; }

.crumbs { margin-block: 1.1rem .5rem; }
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: .2rem .5rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: .85rem;
  color: var(--muted);
}
.crumbs li { display: flex; gap: .5rem; overflow-wrap: anywhere; }
.crumbs li + li::before { content: "/"; color: #92849e; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--cyan); }

.page-heading { max-width: 63rem; padding-block: 1.35rem 1.65rem; }
.page-heading h1 { margin-top: .3rem; text-wrap: initial; }
.page-lead { max-width: 48rem; margin-top: .85rem; font-size: clamp(1rem, 1.5vw, 1.14rem); color: var(--muted); }

.workbench {
  display: grid;
  grid-template-columns: minmax(0, .74fr) minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
}
.control-panel, .results-panel, .related {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: .65rem;
  padding: clamp(.9rem, 2vw, 1.45rem);
  background: var(--surface);
}
.results-panel { background: var(--inset); }
.panel-heading {
  display: flex;
  gap: .6rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  min-height: 2.7rem;
  margin-bottom: .75rem;
}
.panel-heading .button { min-height: 2.45rem; }
.panel-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.results-shortcut { display: none; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem .7rem; }
.field { min-width: 0; display: flex; flex-direction: column; align-items: stretch; }
.field-wide { grid-column: 1 / -1; }
.field label, .share-panel label { display: block; color: var(--text); font-size: .89rem; font-weight: 620; line-height: 1.28; }
.field input, .field select, .share-panel input {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  margin-top: .3rem;
  padding: .5rem .59rem;
  border: 1px solid #5e4f6d;
  border-radius: .38rem;
  background-color: var(--inset);
  color: var(--text);
  line-height: 1.2;
}
.field input { font-family: var(--mono); }
.field select {
  appearance: none;
  text-overflow: ellipsis;
  padding-right: 1.6rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - .86rem) center, calc(100% - .59rem) center;
  background-size: .28rem .28rem;
  background-repeat: no-repeat;
}
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--pink); }
.field-help, .share-panel p { color: var(--muted); font-size: .82rem; line-height: 1.36; margin-top: .25rem; }
.validation {
  margin-top: .85rem;
  padding: .6rem .75rem;
  color: var(--pink);
  background: #412638;
  border-radius: .35rem;
  font-size: .92rem;
}

.readouts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line); border-radius: .46rem; overflow: hidden; background: var(--line); }
.readouts:empty { display: none; }
.readout { min-width: 0; padding: .65rem .75rem; background: #262031; }
.readout dt { color: var(--muted); font-size: .82rem; line-height: 1.28; }
.readout dd {
  color: var(--text);
  font: 650 clamp(.92rem, 1.55vw, 1.12rem)/1.25 var(--mono);
  margin-top: .25rem;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.readout dd small { font: 500 .78rem/1.3 var(--body); color: var(--muted); }
.readout-primary {
  grid-column: 1 / -1;
  background: #263237;
  padding: .8rem .95rem;
}
.readout-primary dt { color: #def4f2; font-size: .9rem; }
.readout-primary dd { color: var(--cyan); font-size: clamp(1.25rem, 3vw, 2.05rem); }
.readout-primary dd small { font-size: .95rem; }
.readout:last-child:nth-child(even) { grid-column: 1 / -1; }

.result-status {
  margin-block: .85rem;
  border-left: .18rem solid var(--line);
  padding: .42rem .7rem;
  color: var(--muted);
  background: #262030;
  font-size: .91rem;
  line-height: 1.44;
}
.result-status.tone-warn { color: var(--pink); border-color: var(--pink); }
.result-status.tone-good { color: var(--cyan); border-color: var(--cyan); }
.readout.tone-warn dd { color: var(--pink); }
.readout.tone-good dd { color: var(--cyan); }
.result-figure figcaption { color: var(--muted); font-size: .85rem; font-weight: 630; margin-bottom: .35rem; }
#diagram { border-radius: .42rem; overflow: hidden; }
#diagram svg { width: 100%; height: auto; }
#diagram:empty { display: none; }

#result-table:not(:empty) { margin-top: 1rem; }
.ladder-table { width: 100%; border-collapse: collapse; text-align: right; font-size: .85rem; table-layout: fixed; }
.ladder-table caption { text-align: left; color: var(--text); font-weight: 650; margin-bottom: .32rem; }
.ladder-table :is(td, th) { border-top: 1px solid var(--line); padding: .35rem .18rem; overflow-wrap: anywhere; }
.ladder-table :is(td, th):first-child { text-align: left; }
.ladder-table th { color: var(--muted); font-weight: 600; }
.ladder-table td { font-family: var(--mono); }

.toolbar { margin-top: .9rem; display: flex; gap: .45rem; flex-wrap: wrap; }
.toolbar .button { flex: 0 1 auto; }
.share-panel { margin-top: .7rem; }
.share-panel input { color: var(--cyan); font: .83rem/1.3 var(--mono); }
.print-settings { display: none; }

.notes-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, .65fr);
  gap: 1.4rem;
  margin-block: 1.65rem clamp(3rem, 6vw, 5rem);
  align-items: start;
}
.notes-flow > section + section { margin-top: 1.6rem; }
.notes-flow h2, .related h2 { margin-bottom: .7rem; }
.notes-flow p { max-width: 46rem; color: var(--muted); }
.notes-flow p + p { margin-top: .65rem; }
.experiment {
  padding: .85rem 1rem;
  border-left: .17rem solid var(--amber);
  background: #2a2232;
}
.faq details { border-top: 1px solid var(--line); }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { padding-block: .65rem; }
.faq .faq-answer { padding: 0 .9rem .75rem; }
.related .button { margin-top: .7rem; }

.prose-layout { padding-block: clamp(1.7rem, 5vw, 4rem); max-width: 48rem; }
.prose-layout section { margin-top: 1.6rem; }
.prose-layout h2 { margin-bottom: .55rem; }
.prose-layout p { color: var(--muted); }
.prose-layout > p:last-child { margin-top: 1.4rem; }
.prose-layout.missing { padding-block: clamp(4rem, 9vw, 7rem); }
.prose-layout .section-tag { color: var(--amber); }
.missing h1 { margin-block: .35rem .8rem; }

.footer { border-top: 1px solid var(--line); margin-top: auto; }
.footer-inner { padding-block: 1.1rem; }
.footer p { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .8rem; }
.footer p span { color: var(--muted); font-size: .875rem; }

@media (max-width: 850px) {
  .hero { grid-template-columns: 1fr; }
  .hero h1 span { display: inline; }
  .hero-monitor { max-width: 40rem; }
  .workbench, .notes-layout { grid-template-columns: 1fr; }
  .fields { column-gap: .85rem; }
  .results-shortcut { display: inline-flex; }
}

@media (max-width: 520px) {
  .masthead-inner { gap: .45rem .8rem; min-height: 3.7rem; }
  .brand { font-size: 1.02rem; }
  .brand svg { width: 1.7rem; height: 1.7rem; }
  .masthead nav { gap: .7rem; }
  .masthead nav a:last-child { display: none; }
  .hero { padding-top: 2.45rem; }
  .hero h1 span { display: block; }
  .example-groups { grid-template-columns: 1fr; }
  .field:has(> :is(#field-mode, #field-resolution, #field-shutterBy, #field-driveMode)) { grid-column: 1 / -1; }
  .field input, .field select { min-height: 2.8rem; font-size: 1rem; }
  .button { padding-inline: .77rem; }
  .footer nav { gap: .8rem; }
}

@page { size: A4; margin: 13mm; }

@media print {
  :root {
    color-scheme: light;
    --text: #181422;
    --muted: #494151;
    --line: #bbb5c2;
    --cyan: #1e565b;
    --amber: #67410c;
    --pink: #7a2840;
  }
  body { display: block; min-height: 0; color: var(--text); background: #fff; font-size: 10pt; line-height: 1.37; }
  .container { width: 100%; }
  .masthead, .crumbs, .footer, .skip-link, .control-panel, .toolbar, .share-panel, .notes-layout,
  .hero-actions, .button, .example-groups { display: none !important; }
  .page-heading { padding-block: 0 .5rem; }
  h1 { font-size: 22pt; }
  h2 { font-size: 13pt; }
  .page-lead { margin-top: .35rem; font-size: 10pt; }
  .workbench { display: block; }
  .results-panel { border: 0; padding: 0; background: #fff; display: flex; flex-direction: column; }
  .panel-heading { min-height: 0; margin-bottom: .4rem; }
  .readouts { grid-template-columns: repeat(4, minmax(0, 1fr)); border: 0; background: #fff; }
  .readout, .readout-primary { background: #fff; border: 1px solid var(--line); padding: .34rem .44rem; }
  .readout-primary { grid-column: span 2; }
  .readout:last-child:nth-child(even) { grid-column: auto; }
  .readout-primary dt, .readout dd { color: var(--text); }
  .readout dd { font-size: 11pt; }
  .readout dt, .readout small { font-size: 8pt; }
  .result-status { background: #fff; margin-block: .46rem; }
  .result-figure { max-width: 31rem; break-inside: avoid; print-color-adjust: exact; }
  #result-table:not(:empty) { margin-top: .4rem; }
  .ladder-table { font-size: 8.5pt; break-inside: avoid; }
  .ladder-table :is(td, th) { padding: .14rem; }
  .print-settings { display: block; order: -1; margin-bottom: .6rem; }
  .print-settings dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .16rem .5rem; margin-top: .3rem; }
  .print-settings dl div { border-top: 1px solid var(--line); padding: .12rem .25rem; }
  .print-settings dt { color: var(--muted); font-size: 8.5pt; }
  .print-settings dd { overflow-wrap: anywhere; }
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, .82fr); gap: 1rem; padding-block: 0 .8rem; }
  .hero-copy p { font-size: 10pt; margin-top: .4rem; }
  .hero-monitor { max-width: 24rem; box-shadow: none; padding: .35rem .5rem; }
  .home-section { margin-bottom: .5rem; }
  .section-heading { margin-bottom: .5rem; }
  #worked-examples { display: none; }
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem; }
  .tool-card { background: #fff; color: var(--text); padding: .45rem; break-inside: avoid; }
  .tool-card p { font-size: 9.5pt; }
  .prose-layout { padding-block: 0; }
}
