/* Colors and type are the site's own, copied from assets/css/styles.css. */

:root {
  color-scheme: light;
  --bg-color: #fff;
  --text-color: #333;
  --heading-color: #333;
  --meta-color: #595959;
  --border-color: #eaeaea;
  --focus-color: #8a4b00;
  --text-small: 0.75rem;
  --text-base: 1rem;
  --text-large: 1.25rem;
  --text-xlarge: 1.5rem;
  --yellow-50: #fffde7;
  --yellow-100: #fff9c4;
  --yellow-500: #ffeb3b;
  --yellow-600: #fdd835;
  --yellow-900: #f57f17;
  --gray-100: #f5f5f5;
  --gray-900: #212121;
  --radius-sm: 3px;
  --radius-lg: 8px;
  --font-family:
    -apple-system, blinkmacsystemfont, "Segoe UI", roboto, "Helvetica Neue",
    arial, sans-serif;
  --font-serif: georgia, serif;
  --header-bg: #f8f5f0;
  --warning-bg: var(--yellow-100);
  --warning-color: var(--yellow-900);
  --input-background: var(--bg-color);

  /* This tool's few extras, built from the site's colors. */
  --chip-on-bg: var(--yellow-100);
  --chip-on-line: var(--yellow-900);
  --stage-bg: var(--header-bg);
  --ply: #ecdcbc;
  --wood: #dcbd87;
  --wood-line: #8a6337;

  /* The drawing's ink and paper: its labels are drawn in currentColor. */
  --picture-ink: var(--text-color);
  --picture-paper: transparent;

  /* The render's own colors: its canvas before the first frame, and the
     pale wall it stands against, the same in either scheme. */
  --render-bg: #ece7df;
  --render-wall: #f8f5f0;
  --picture-muted: var(--meta-color);

  /* Plan cards. Light scheme uses the warm paper; dark mode uses the
     header surface so the cards stay in the site's palette. */
  --card-bg: #fffcf8;
  --card-line: #e4ddd2;
  --ink: #241f1a;

  /* Drawings. Plywood, holes, and the outlet keep their colors in both
     schemes; text and lines take the ink and muted colors around them. */
  --draw-font: var(--font-family);
  --draw-muted: var(--meta-color);
  --draw-ply: #e6d0a8;
  --draw-on-ply: #2a2a28;
  --draw-ply-light: #f3e6c8;
  --draw-base: #cbb892;
  --draw-hole: #9a3412;
  --draw-halo: #fffaf3;
  --draw-outlet: rgb(255 255 255 / 55%);
  --draw-outlet-line: #9c2f2f;
  --drill-row-width: 288px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --heading-color: #f5f5f5;
    --meta-color: #a0a0a0;
    --border-color: #333;
    --focus-color: var(--yellow-500);
    --gray-100: #2d2d2d;
    --header-bg: #1e1e1e;
    --warning-bg: rgb(255 235 59 / 10%);
    --warning-color: #fff59d;
    --input-background: #1e1e1e;
    --chip-on-bg: rgb(255 235 59 / 14%);
    --chip-on-line: var(--yellow-500);
    --ply: #3a3227;
    --wood-line: #c9a46c;
    --picture-ink: #2a2a28;
    --picture-paper: #efe8da;
    --picture-muted: #5c5852;
    --draw-muted: var(--meta-color);
    --draw-ply: #e6d0a8;
    --draw-on-ply: #2a2a28;
    --draw-ply-light: #f3e6c8;
    --draw-base: #cbb892;
    --draw-hole: #9a3412;
    --draw-halo: #fffaf3;
    --draw-outlet: rgb(255 255 255 / 55%);
    --draw-outlet-line: #9c2f2f;
    --card-bg: var(--header-bg);
    --card-line: var(--border-color);
    --ink: var(--heading-color);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg-color);
  scroll-padding-top: 130px;
}

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-color);
  background: var(--bg-color);
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.35;
}

:focus-visible {
  outline: 3px solid var(--focus-color);
  outline-offset: 2px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

/* Tool header, as on the other tools. */

.tool-header {
  position: sticky;
  z-index: 50;
  top: 0;
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
}

.tool-nav {
  display: flex;
  gap: 16px;
  align-items: center;
  width: 100%;
  padding: 12px 16px;
}

.tool-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  color: var(--gray-900);
  text-decoration: none;
  background: var(--yellow-600);
  border-radius: var(--radius-sm);
}

.page {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto 64px;
}

.intro h1 {
  margin: 18px 0 2px;
  font-size: var(--text-xlarge);
  font-weight: 600;
  line-height: 1.2;
  color: var(--heading-color);
  letter-spacing: -0.01em;
}

.intro p {
  max-width: 72ch;
  margin: 0 0 12px;
  color: var(--meta-color);
}

/* The first screen: the picture is the interface. */

.stage {
  display: grid;
  grid-template:
    "pre fig books" auto
    "pre fig hts" 1fr
    "back fig ticks" auto
    / minmax(170px, 210px) minmax(0, 1fr) minmax(190px, 230px);
  gap: 10px 20px;
  padding: 16px 20px 18px;
  background: var(--stage-bg);
  border-radius: var(--radius-lg);
}

.stage > * {
  min-width: 0;
}

.figure {
  position: relative;
  grid-area: fig;
  margin: 0;
}

#elevation {
  --draw-muted: var(--picture-muted);

  scroll-margin-top: 80px;
  display: block;
  overflow: visible;
  width: 100%;
  height: clamp(260px, calc(100vh - 360px), 560px);
  color: var(--picture-ink);
  background: var(--picture-paper);
  border-radius: var(--radius-lg);
}

.picture-help {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin: 0;
}

.picture-help .help-line {
  max-width: 260px;
  margin-top: 4px;
  padding: 6px 10px;
  text-align: right;
  background: var(--bg-color);
  border-radius: var(--radius-lg);
}

/* The render fills the picture's panel; the controls sit on it. Vertical
   swipes on it scroll the page; sideways ones turn the picture. */
#view3d {
  display: block;
  width: 100%;
  height: clamp(300px, calc(100vh - 520px), 640px);
  cursor: grab;
  touch-action: pan-y;
  background: var(--render-bg);
  border-radius: var(--radius-lg);
}

#view3d:active {
  cursor: grabbing;
}

/* When the render fails, the front drawing is the picture again. */
.figure.drawn #view3d {
  display: none;
}

.figure .view-status {
  margin: 0 0 6px;
}

/* A help button over the pale render keeps a background in both schemes. */
.figure .help:not([aria-expanded="true"]) {
  background: var(--bg-color);
}

/* Below the first screen, the front drawing of the same design. */
.front-drawing {
  position: relative;
  margin: 56px 0 0;
}

.view-status {
  margin: 0;
  font-size: var(--text-small);
  color: var(--meta-color);
}

.view-status:empty {
  display: none;
}

.mini {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0 0 6px;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--heading-color);
}

.mini-out {
  margin: 6px 0 0;
  font-weight: 400;
  color: var(--meta-color);
}

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

.q-books {
  grid-area: books;
}

.q-height {
  grid-area: hts;
  align-self: center;
}

.q-ticks {
  grid-area: ticks;
  align-self: end;
}

.q-back {
  grid-area: back;
  align-self: end;
}

.q-presets {
  grid-area: pre;
}

.q-books,
.q-height,
.q-ticks {
  text-align: right;
}

.q-books .mini,
.q-height .mini,
.q-books .seg,
.q-height .seg {
  justify-content: flex-end;
}

[aria-pressed] {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

[aria-pressed="true"] {
  background: var(--chip-on-bg);
  border-color: var(--chip-on-line);
  box-shadow: inset 0 0 0 1px var(--chip-on-line);
}

.icon {
  display: block;
  width: 34px;
  height: 24px;
}

.icon-tall {
  width: 22px;
  height: 32px;
}

.icon-preset {
  width: 56px;
  height: 32px;
}

.i-case {
  fill: var(--wood);
  stroke: var(--wood-line);
  stroke-width: 1;
}

.i-line,
.i-frame {
  fill: none;
  stroke: var(--wood-line);
  stroke-width: 1;
}

.i-floor {
  fill: none;
  stroke: var(--meta-color);
  stroke-width: 1;
  opacity: 0.5;
}

.sil {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 54px;
  min-height: 78px;
  padding: 6px 6px 4px;
  font-size: var(--text-small);
  line-height: 1.2;
}

.sil small {
  font-size: var(--text-small);
  color: var(--meta-color);
}

.pic {
  padding: 5px 6px;
}

.swatch {
  padding: 2px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 50%;
}

.swatch[aria-pressed="true"] {
  background: transparent;
  border-color: var(--chip-on-line);
  box-shadow: none;
}

.swatch svg {
  display: block;
  width: 28px;
  height: 28px;
}

.swatch circle {
  stroke: rgb(0 0 0 / 20%);
  stroke-width: 1;
}

.presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.preset {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  padding: 6px 2px;
  font-size: var(--text-small);
  color: var(--text-color);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
}

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

/* Openings: a plus and a minus on the case. */

.q-openings {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 50%;
  display: flex;
  gap: 8px;
  align-items: center;
  transform: translate(-50%, 0);
  padding: 3px 6px 3px 3px;
  font-size: 0.85rem;
  white-space: nowrap;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 12%);
}

/* Just inside the top, so the drawing's depth label above stays clear. */
.q-openings.on-case {
  transform: translate(-50%, 10px);
}

/* On the render, the plus and minus sit on the top's front edge and hang
   just below it, a little smaller, so what stands on the top stays in
   view; the picture keeps the books under them low. On a phone they sit
   over the wall above the case. */
.q-openings.on-case.on-edge {
  gap: 4px;
  padding: 2px 4px 2px 2px;
  font-size: 0.8rem;
  transform: translate(-50%, -4px);
}

.q-openings.on-edge .step {
  width: 26px;
  height: 26px;
  font-size: 1.05rem;
}

.q-openings.on-case.on-wall {
  transform: translate(-50%, 0);
}

.q-openings .help-line {
  position: absolute;
  top: 100%;
  left: 50%;
  width: max-content;
  max-width: 240px;
  margin-top: 6px;
  white-space: normal;
  transform: translateX(-50%);
}

.step {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: var(--text-large);
  line-height: 1;
  color: var(--gray-900);
  background: var(--yellow-600);
  border: 0;
  border-radius: 50%;
}

/* Width: a dimension line under the case, with the number beside it. */

.q-width {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}

.q-width.on-case {
  position: absolute;
  color: var(--picture-ink);
  z-index: 2;
  margin: 0;
  transform: translateY(-50%);
}

.dim-line {
  position: relative;
  flex: 1 1 auto;
  min-width: 40px;
  height: 22px;
  border-radius: var(--radius-sm);
}

.q-width:not(.on-case) .dim-line {
  max-width: 320px;
}

/* The line itself, with an end tick on the left like a drawn dimension. */
.dim-line::before,
.dim-line::after {
  position: absolute;
  content: "";
  background: var(--picture-ink);
}

.dim-line::before {
  top: 50%;
  right: 0;
  left: 0;
  height: 2px;
  transform: translateY(-50%);
}

.dim-line::after {
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 2px;
}

.dim-handle {
  position: absolute;
  top: 50%;
  right: 0;
  width: 22px;
  height: 22px;
  cursor: ew-resize;
  touch-action: none;
  background: var(--yellow-600);
  border: 2px solid var(--gray-900);
  border-radius: 50%;
  transform: translate(50%, -50%);
}

.q-width.on-case .width-number {
  position: absolute;
  left: calc(100% + 20px);
}

/* The render says when the number goes under the line's end. */
.q-width.on-case.below .width-number {
  top: calc(100% + 4px);
  right: -11px;
  left: auto;
}

.width-number {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-weight: 600;
  white-space: nowrap;
}

.width-number input {
  width: 4.2em;
  padding: 3px 6px;
  font-weight: 600;
  color: var(--text-color);
  text-align: right;
  background: var(--input-background);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.width-number .help-line {
  position: absolute;
  top: 100%;
  left: 0;
  width: max-content;
  max-width: 230px;
  margin-top: 6px;
  white-space: normal;
}

/* The two optional ticks. */

.tick-row {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin: 2px 0;
}

.tick {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 0.85rem;
  cursor: pointer;
}

.tick input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--yellow-900);
}

.q-ticks .help-line {
  flex-basis: 100%;
  margin-left: auto;
}

.tick-row:has(.help-line:not([hidden])) {
  flex-wrap: wrap;
}

.outlet-place {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 8px;
  align-items: center;
  margin-top: 4px;
  font-size: var(--text-small);
  color: var(--meta-color);
  text-align: left;
}

.outlet-place input {
  width: 100%;
  min-width: 0;
  accent-color: var(--yellow-900);
}

.outlet-place output {
  font-weight: 600;
  color: var(--text-color);
}

/* Help: a small question mark that shows one sentence. */

.help {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--meta-color);
  background: transparent;
  border: 1px solid var(--meta-color);
  border-radius: 50%;
}

.help[aria-expanded="true"] {
  color: var(--gray-900);
  background: var(--yellow-600);
  border-color: var(--yellow-900);
}

.help-line {
  display: block;
  max-width: 230px;
  font-size: var(--text-small);
  font-weight: 400;
  line-height: 1.35;
  color: var(--meta-color);
}

.mini .help-line {
  flex-basis: 100%;
}

.q > .help-line,
.q .tick-row .help-line {
  margin-top: 2px;
}

/* The plan card, after the shelf drawing and before the steps. */

.plan-card {
  margin: 0 0 20px;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-line);
  border-radius: 12px;
}

#summary h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--heading-color);
}

.plan-name {
  margin: 4px 0 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--heading-color);
}

.plan-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 12px 0;
}

.plan-stats div {
  min-width: 0;
}

.plan-stats dt {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--meta-color);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.plan-stats dd {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: var(--heading-color);
}

.plan-stats .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.4em;
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-color);
}

.keep {
  white-space: nowrap;
}

#summary-line {
  margin: 0 0 10px;
  font-size: 0.8rem;
  line-height: 1.2;
}

.plan-warn {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 1rem;
  line-height: 1.5;
  color: #241f1a;
  background: #fff9c4;
  border-radius: var(--radius-lg);
}

.share {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  justify-content: flex-start;
}

.share button,
.csv button {
  min-height: 44px;
  padding: 4px 14px;
  font-size: 1rem;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 999px;
}

.share .primary {
  font-weight: 600;
  color: var(--gray-900);
  background: var(--yellow-600);
  border-color: var(--yellow-900);
}

.status,
.saved {
  margin: 8px 0 0;
  font-size: 1rem;
  color: var(--meta-color);
  text-align: left;
}

.status:empty {
  display: none;
}

.text-button {
  padding: 0;
  color: inherit;
  text-decoration: underline;
  background: none;
  border: 0;
}

.fine {
  font-size: var(--text-small);
  color: var(--meta-color);
}

.shop-box {
  display: grid;
  gap: 6px;
  max-width: 70ch;
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--header-bg);
  border-radius: var(--radius-lg);
}

.thickness-field {
  display: grid;
  gap: 2px;
}

.field-help {
  margin: 0;
  max-width: 62ch;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--meta-color);
}

.field-help:empty,
#shop-note:empty {
  display: none;
}

#shop-note {
  margin: 0;
}

.shop-box label {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.shop-box input[type="number"] {
  width: 5.5em;
  padding: 3px 6px;
  font: inherit;
  color: var(--text-color);
  background: var(--input-background);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.cut-lede {
  max-width: 70ch;
}

.cut-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.part-card {
  padding: 14px 16px;
  background: var(--bg-color);
  border: 1px solid var(--card-line);
  border-radius: 12px;
}

.part-card .part-name,
.part-card .part-qty,
.part-card .part-size,
.part-card .part-meta,
.part-card .part-note {
  margin: 0;
}

.part-card .part-name {
  font-size: 1rem;
  font-weight: 600;
}

.part-qty::before {
  font-weight: 400;
  color: var(--meta-color);
  content: "× ";
}

.part-size {
  margin-top: 4px;
}

.cut-size {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: var(--heading-color);
}

.cut-planning,
.part-meta,
.part-note {
  display: block;
  margin-top: 2px;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.35;
  color: var(--meta-color);
}

@media (width < 720px) {
  .cut-size {
    font-size: 1.5rem;
  }

  .plan-stats {
    grid-template-columns: 1fr 1fr;
  }

  .share {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .share .primary {
    grid-column: 1 / -1;
  }

  .share button {
    min-width: 0;
    padding-inline: 10px;
    white-space: nowrap;
  }
}

/* A warning, if one of the answers breaks something. */

.warnings {
  max-width: 76ch;
  margin: 16px auto 0;
  padding: 0;
  list-style: none;
}

.warnings:empty {
  display: none;
  margin: 0;
}

.warnings li {
  margin: 8px 0;
  padding: 10px 14px;
  color: var(--text-color);
  background: var(--warning-bg);
  border-left: 3px solid var(--warning-color);
  border-radius: var(--radius-sm);
}

/* The plan, in work order: one card, then six steps. */

.drawing-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--heading-color);
}

.plan {
  max-width: 76ch;
  margin: 28px auto 0;
}

.step-nav-wrap {
  position: sticky;
  z-index: 40;
  top: 69px;
  margin: 0 0 10px;
  background: var(--bg-color);
}

.step-nav-wrap::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 28px;
  height: 100%;
  pointer-events: none;
  content: "";
  background: linear-gradient(to right, transparent, var(--bg-color));
  opacity: 0;
}

.step-nav-wrap.can-scroll::after {
  opacity: 1;
}

.step-nav {
  display: flex;
  gap: 6px;
  padding: 8px 0;
  overflow-x: auto;
  background: var(--bg-color);
}

.step-nav a {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--text-color);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--border-color);
  border-radius: 999px;
}

.step-nav a[aria-current="step"] {
  color: var(--bg-color);
  background: var(--ink);
  border-color: var(--ink);
}

.plan-section {
  position: relative;
  margin-top: 10px;
  background: var(--card-bg);
  border: 1px solid var(--card-line);
  border-radius: 12px;
}

.plan-section summary {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 12px 96px 12px 16px;
  cursor: pointer;
  list-style: none;
}

.plan-section summary::-webkit-details-marker {
  display: none;
}

.plan-section summary::marker {
  content: "";
}

.step-index {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bg-color);
  background: var(--ink);
  border-radius: 50%;
}

.step-titles {
  min-width: 0;
}

.plan-section h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--heading-color);
}

.step-kicker {
  display: block;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--meta-color);
}

.plan-section > details {
  display: block;
}

.step-done {
  position: absolute;
  z-index: 1;
  top: 8px;
  right: 8px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  cursor: pointer;
}

.step-done input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
}

.step-body {
  padding: 0 16px 16px;
}

.plan-steps {
  margin: 0;
}

.plan-steps p,
.plan-steps .step-with-detail,
.saw-line,
.fact {
  margin: 0 0 10px;
}

.fact b,
.saw-line b {
  display: block;
  margin-bottom: 2px;
  font-weight: 600;
}

.fact p,
.saw-line p,
.step-line {
  margin: 0;
}

.group-label {
  margin: 16px 0 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--meta-color);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.buy-group:first-child .group-label {
  margin-top: 0;
}

.buy-check,
.buy-line {
  display: flex;
  flex: 1 1 220px;
  gap: 10px;
  align-items: flex-start;
  min-height: 44px;
  padding: 4px 0;
  cursor: pointer;
}

.buy-check input,
.buy-line input {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.2rem;
}

.step-with-detail > .step-line {
  display: block;
}

/* Saw-cut habits: a short label, one line when it is opened. */
.cut-habit,
.step-detail {
  margin: 0 0 2px;
}

.cut-habit summary,
.step-detail summary {
  width: fit-content;
  padding: 2px 0;
  font-weight: 600;
  cursor: pointer;
}

.cut-habit .habit-line,
.step-detail .habit-line {
  display: block;
  max-width: 62ch;
  margin: 2px 0 8px 1.25rem;
  color: var(--meta-color);
}

.numbered {
  padding-left: 2rem;
}

.numbered li {
  margin: 0 0 10px;
  padding-left: 4px;
}

.buy-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.buy-list li {
  padding: 6px 0;
}

.priced .buy-text {
  flex: 1 1 12rem;
}

.priced {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: center;
  justify-content: space-between;
}

.price {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.price input {
  width: 8.5em;
  padding: 4px 8px;
  text-align: right;
  background: var(--input-background);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.price output {
  min-width: 4em;
  font-weight: 600;
}

#buy-cost {
  margin-top: 10px;
}

.sheets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px 24px;
  margin: 16px 0;
}

@media (width >= 720px) {
  .sheets {
    grid-template-columns: 1fr 1fr;
  }
}

.sheets h3 {
  grid-column: 1 / -1;
  margin: 12px 0 0;
  font-size: var(--text-base);
}

.sheets .sheet-note {
  grid-column: 1 / -1;
}

.sheet-figure {
  margin: 0;
}

/* A sheet drawing is laid out at its figure's width: no fill around it. */
.sheet-figure svg {
  display: block;
  max-width: 100%;
  height: auto;
  overflow: visible;
}

.sheet-figure figcaption {
  font-size: var(--text-small);
}

/* The drilling rows lay out their own grid inside. */
.pocket-diagrams {
  margin-top: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 6px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  color: var(--heading-color);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.csv {
  margin: 12px 0 0;
}

.decided {
  margin-top: 48px;
}

.decided h2 {
  margin: 0 0 10px;
  font-size: var(--text-large);
  color: var(--heading-color);
}

.decided ul {
  margin: 0;
  padding-left: 1.2rem;
}

.decided li {
  margin: 0 0 8px;
}

.research {
  margin-top: 40px;
  color: var(--meta-color);
}

.research summary {
  min-height: 44px;
  padding: 10px 0;
  font-weight: 600;
  cursor: pointer;
}

.research h3 {
  margin: 16px 0 6px;
  font-size: var(--text-base);
  color: var(--heading-color);
}

.research ul {
  padding-left: 1.2rem;
}

.research li {
  margin: 0 0 6px;
}

.visually-hidden {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  white-space: nowrap;
  border: 0;
  clip-path: inset(50%);
}

/* A phone: the picture first, then one column of questions. */

@media (width < 900px) {
  .stage {
    grid-template:
      "fig" auto
      "hts" auto
      "books" auto
      "back" auto
      "ticks" auto
      "pre" auto / minmax(0, 1fr);
    gap: 14px;
    padding: 12px;
  }

  #elevation {
    height: clamp(260px, 90vw, 460px);
  }

  #view3d {
    height: clamp(300px, 100vw, 480px);
  }

  /* The plus and minus take the top of the picture on a phone, so its
     help goes to the bottom left corner. */
  #picture > .picture-help {
    inset: auto auto 32px 6px;
    align-items: flex-start;
  }

  .front-drawing {
    margin-top: 32px;
  }

  /* No room beside the line on a phone: the number goes under its end. */
  .figure {
    padding-bottom: 24px;
  }

  .q-width.on-case .width-number {
    top: calc(100% + 4px);
    color: var(--picture-ink);
    right: -11px;
    left: auto;
  }

  .q-width.on-case.beside .width-number {
    top: auto;
    right: auto;
    left: calc(100% + 20px);
  }

  /* The number sits at the right of the picture: its help opens leftward. */
  .width-number .help-line {
    right: 0;
    left: auto;
  }

  /* Under the picture, each group sits centred in the column, as in the
     first-screen prototype's phone layout. */
  .q-books,
  .q-height,
  .q-ticks,
  .q-back,
  .q-presets {
    text-align: center;
  }

  .q .mini,
  .q .seg,
  .tick-row {
    justify-content: center;
  }

  .help-line {
    max-width: none;
  }

  .presets {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
  }

  /* Each name on one line, so the five sit on one baseline. */
  .preset {
    padding-inline: 0;
    font-size: 0.7rem;
    white-space: nowrap;
  }

  .icon-preset {
    width: 100%;
    max-width: 56px;
  }
}

@media print {
  .tool-header,
  .intro,
  .figure,
  .q,
  .share,
  .status,
  .saved,
  .no-print,
  .help-line,
  .step-nav,
  .step-nav-wrap {
    display: none !important;
  }

  .plan-section > details,
  .plan-section > details > .step-body,
  .plan-section > .step-done {
    display: block !important;
  }

  .plan-section > details::details-content {
    display: block !important;
  }

  .step-done {
    position: static;
  }

  .cut-habit .habit-line,
  .step-detail .habit-line {
    color: #000;
  }

  .stage {
    display: block;
    padding: 0;
    background: none;
  }

  .research {
    display: none;
  }

  body {
    color: #000;
    background: #fff;
  }
}

/* ==== Drawings: front drawing, sheets, drilling rows ==== */

.drawing {
  color: var(--text-color);
  font-family: var(--draw-font);
}

/* Two cases stacked on a narrow page take the height they need. */
#elevation[data-stacked] {
  height: auto;
}

/* As the picture, the width line under the stacked cases stands for the
   whole run, so the last case's own width does not show under it. */
.figure.drawn [data-under-control] {
  display: none;
}

.drawing text {
  fill: currentcolor;
}

.drawing text.muted {
  fill: var(--draw-muted);
}

.drawing .part {
  fill: var(--draw-ply);
  stroke: var(--draw-on-ply);
  stroke-width: 1;
}

.drawing .shelf-adjustable {
  fill: var(--draw-ply-light);
  stroke-dasharray: 10 6;
}

.drawing .base {
  fill: var(--draw-base);
}

.drawing .outlet {
  fill: var(--draw-outlet);
  stroke: var(--draw-outlet-line);
  stroke-width: 1.5;
}

.drawing .dim,
.drawing .leader {
  fill: none;
  stroke: currentcolor;
  stroke-width: 1;
}

.drawing .leader {
  stroke: var(--draw-muted);
}

.drawing .reach {
  stroke: var(--draw-muted);
  stroke-width: 1;
}

.drawing .reach.on-light {
  stroke: var(--draw-on-ply);
  stroke-opacity: 0.75;
}

.drawing .reach.on-dark {
  stroke: var(--draw-halo);
  stroke-opacity: 0.85;
}

.drawing .reach.younger {
  stroke-dasharray: 6 4;
}

.drawing .reach.older {
  stroke-dasharray: 2 4;
}

.drawing .pocket-mark {
  fill: var(--draw-hole);
  stroke: var(--draw-halo);
  stroke-width: 1;
}

.drawing .shelf-pop {
  visibility: hidden;
  pointer-events: none;
  fill: var(--draw-on-ply);
  paint-order: stroke;
  stroke: var(--draw-halo);
  stroke-width: 3px;
  stroke-linejoin: round;
}

/* Shelves and dividers change on hover and focus. A mouse or a pen grabs
   them anywhere; a finger drags them by their grips only, so the drawing
   still scrolls under a thumb. touch-action: none on the grips says so,
   but browsers ignore it on SVG shapes: direct.js stops the scroll for a
   touch that starts on a grip. */
.drawing .shelf {
  cursor: grab;
}

.drawing .divider {
  cursor: ew-resize;
}

.drawing .shelf.active {
  cursor: grabbing;
}

.drawing .grip {
  touch-action: none;
}

/* Focus shows on the part itself, not as a box around it. */
.drawing .shelf:focus,
.drawing .divider:focus {
  outline: none;
}

.drawing .shelf:hover .part,
.drawing .shelf:focus .part,
.drawing .shelf.active .part,
.drawing .divider:hover .divider-panel,
.drawing .divider:focus .divider-panel,
.drawing .divider.active .divider-panel {
  stroke: var(--focus-color);
  stroke-width: 2;
}

.drawing .shelf:hover .shelf-adjustable,
.drawing .shelf.active .shelf-adjustable {
  fill: var(--draw-ply);
}

.drawing .has-pop:hover + .shelf-pop,
.drawing .has-pop:focus + .shelf-pop {
  visibility: visible;
}

/* The grips look like the width line's handle on the first screen. */
.drawing .grip-body {
  fill: var(--yellow-600);
  stroke: var(--gray-900);
  stroke-width: 2;
}

.drawing .grip-line {
  stroke: var(--gray-900);
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* An unpainted margin round each grip, wider for a finger. */
.drawing .grip-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 10;
  pointer-events: all;
}

/* The two opening widths over a divider in hand, or focused. */
.drawing text.lit {
  font-weight: 700;
  fill: var(--gray-900);
  paint-order: stroke;
  stroke: var(--yellow-600);
  stroke-width: 6px;
  stroke-linejoin: round;
}

.drawing .hit {
  fill: none;
  stroke: transparent;
  stroke-width: 10;
  pointer-events: stroke;
}

/* Each opening's plus and minus, over the place the drawing kept for
   them, in the same buttons as the openings' plus and minus. */
.opening-steps {
  position: absolute;
  z-index: 1;
  width: 0;
  height: 0;
}

.opening-steps .steps {
  position: absolute;
  display: flex;
  gap: 4px;
  transform: translate(-50%, -50%);
}

.opening-steps button {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: var(--text-large);
  line-height: 1;
  color: var(--gray-900);
  background: var(--yellow-600);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.opening-steps button:disabled {
  color: var(--meta-color);
  background: var(--gray-100);
  cursor: default;
}

.opening-steps button:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

/* Out of the way while a part is dragged. */
.opening-steps.dragging {
  visibility: hidden;
}

@media (pointer: coarse) {
  .drawing .grip-hit {
    stroke-width: 22;
  }

  .opening-steps button {
    width: 40px;
    height: 40px;
  }
}

.drawing .controls {
  fill: none;
  pointer-events: none;
}

.drawing text.on-ply {
  fill: var(--draw-on-ply);
}

.drawing .sheet {
  fill: var(--draw-ply-light);
}

.drawing .spare {
  fill: var(--draw-ply-light);
  stroke: var(--draw-on-ply);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

.sheet-title {
  margin: 20px 0 6px;
  font-family: var(--draw-font);
  font-size: 0.92rem;
  font-weight: 600;
}

.sheet-key {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  margin: 8px 0 0;
  padding: 0;
  color: var(--draw-muted);
  font-family: var(--draw-font);
  font-size: 0.85rem;
  list-style: none;
}

.sheet-key b {
  color: var(--text-color);
}

.sheet-figure .sheet-steps {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.sheet-steps li {
  margin: 2px 0;
}

.drill-heading {
  margin: 20px 0 8px;
  font-family: var(--draw-font);
  font-size: 0.95rem;
}

.drill-rows {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, var(--drill-row-width)), 1fr)
  );
  gap: 18px 32px;
}

.drill-item {
  min-width: 0;
  margin: 0;
}

.drill-help {
  margin: 4px 0 0;
  color: var(--draw-muted);
  font-family: var(--draw-font);
  font-size: 0.78rem;
  line-height: 1.3;
}

.drill-row svg.drawing {
  display: block;
  max-width: 100%;
  height: auto;
}

.drill-caption {
  color: var(--draw-muted);
  font-family: var(--draw-font);
  font-size: 0.8rem;
  line-height: 1.25;
}

.drill-caption p {
  margin: 2px 0 0;
}

.drill-title {
  color: var(--text-color);
}

.drawing .pocket-hole {
  fill: var(--draw-hole);
}

.drawing .pin-hole {
  fill: var(--draw-on-ply);
}
