:root {
  color-scheme: light;
  --ground: #e8ebee;
  --paper: #fafbfc;
  --ink: #24272a;
  --muted: #535e67;
  --line: #d6dce0;
  --accent: #ad3908;
  --pin: #f05a18;
  font-family: Bahnschrift, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); }
button, input, select { font: inherit; }
button, select { color: inherit; }
button {
  min-height: 44px; padding: 8px 13px; border: 1px solid #b8c0c7;
  background: var(--paper); cursor: pointer;
}
button:hover:not(:disabled) { background: #edf0f2; }
button:disabled, input:disabled { cursor: default; opacity: .58; }
button[aria-disabled="true"] { cursor: default; }
button[aria-pressed="true"], .primary { background: var(--ink); color: white; border-color: var(--ink); }
button[aria-pressed="true"]:hover:not(:disabled), .primary:hover:not(:disabled) { background: #3d4247; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: var(--accent); text-underline-offset: .17em; }
.frame { max-width: 1496px; margin: auto; padding: 0 clamp(12px, 2vw, 28px) 18px; }
.top {
  min-height: 48px; display: flex; gap: 16px; align-items: center; justify-content: space-between;
  font-size: .875rem; color: var(--muted);
}
.brand { font-size: 1.1rem; font-style: italic; font-weight: 750; color: var(--ink); text-decoration: none; }
main { background: var(--paper); border: 1px solid var(--line); }
header { padding: 22px clamp(16px, 2vw, 28px) 18px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.75rem, 4vw, 2rem); font-weight: 680; letter-spacing: -.03em; }
h2 { font-size: 1rem; font-weight: 650; }
.intro { margin-top: 6px; line-height: 1.45; color: var(--muted); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) clamp(294px, 27vw, 350px); }
.viewer { min-width: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stage { position: relative; height: clamp(390px, 58vh, 640px); background: #dfe4e8; }
.stage canvas {
  position: absolute; top: 54px; left: 0;
  display: block; width: 100%; height: calc(100% - 86px);
}
.stage-head { position: absolute; z-index: 1; top: 12px; left: 14px; right: 14px; pointer-events: none; }
.stage-label { font-size: .86rem; font-weight: 650; }
.stage-caption { margin-top: 4px; color: var(--muted); font-size: .8rem; }
.compare-labels {
  position: absolute; z-index: 1; top: 58px; inset-inline: 0;
  display: grid; grid-template-columns: 1fr 1fr; text-align: center;
  font-size: .8rem; font-weight: 650; pointer-events: none;
}
.compare-labels span { color: var(--muted); font-weight: 400; }
.compare-labels span::before { content: " · "; }
.engine-labels {
  position: absolute; z-index: 1; top: 58px; left: 50%;
  width: var(--cylinder-label-width, 90%); transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  text-align: center; font-size: .84rem; font-weight: 650; pointer-events: none;
}
.engine-labels span { display: block; color: var(--muted); margin-top: 3px; font-size: .75rem; font-weight: 400; }
.engine-labels [data-latest], .engine-controls [data-latest] { color: var(--accent); }
.legend {
  position: absolute; z-index: 1; bottom: 12px; left: 14px; right: 14px; display: flex; flex-wrap: wrap;
  column-gap: 16px; row-gap: 3px; pointer-events: none; font-size: .78rem;
}
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; background: #65737e; border: 1px solid #45525c; }
.legend span:nth-child(2) i { background: #c9d0d5; border-color: #78858e; }
.legend span:nth-child(3) i { background: var(--pin); border-color: var(--accent); }
.camera { padding: 8px 12px; border-top: 1px solid var(--line); }
.view-levels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.engine-controls { display: flex; gap: 6px 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.engine-controls p:first-child { font-size: .9rem; color: var(--ink); }
.engine-controls p { margin: 0; }
.engine-controls p:last-child { flex-basis: 100%; }
.engine-controls [data-latest] { text-decoration: underline; text-underline-offset: 3px; }
.engine-controls:not([hidden]) ~ .camera-note { display: none; }
.view-sides { display: flex; gap: 6px; margin-top: 6px; }
.view-sides button { flex: 1 1 0; min-width: 0; }
.camera p { margin-top: 8px; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.lift-comparison { padding: 14px 16px; border-top: 1px solid var(--line); }
.lift-heading { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; }
.lift-key { display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: .8rem; }
.lift-key span { display: flex; align-items: center; gap: 5px; }
.lift-key span::before { content: ""; width: 16px; border-top: 2px dashed #465767; }
.lift-key span:last-child::before { border-top: 2px solid var(--accent); }
#lift-chart { width: 100%; height: 146px; display: block; margin: 10px 0 4px; }
.lift-comparison p, .guide p, .guide dd { color: var(--muted); font-size: .875rem; line-height: 1.5; }
.guide { padding: 18px clamp(16px, 2vw, 28px); border-bottom: 1px solid var(--line); }
.guide dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 24px; }
.guide dl div { border-top: 1px solid var(--line); padding-top: 9px; }
.guide dt { font-weight: 650; }
.guide dd { margin: 4px 0 0; }
aside { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.panel { padding: 16px; border-bottom: 1px solid var(--line); }
.panel:last-child { border: 0; }
.profiles { display: flex; gap: 6px; margin-top: 10px; }
.profiles button { flex: 1; }
.phase-list { padding: 0; margin: 10px 0 0; list-style: none; }
.phase-list li { padding: 8px 10px; border-left: 2px solid var(--line); font-size: .86rem; color: var(--muted); }
.phase-list [aria-current="step"] { border-color: var(--pin); background: #eff1f3; color: var(--ink); font-weight: 650; }
.explanation { min-height: 4.35em; margin-top: 8px; font-size: .875rem; line-height: 1.45; color: var(--muted); }
.transport { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.transport button { min-width: 86px; }
.stroke-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.stroke-buttons button { padding: 6px; font-size: .85rem; }
.stroke-description { min-height: 3em; margin-top: 8px; font-size: .85rem; line-height: 1.4; color: var(--muted); }
select { min-height: 44px; background: var(--paper); border: 1px solid #b8c0c7; padding: 0 5px; }
.cycle-label { margin-top: 14px; display: flex; justify-content: space-between; gap: 8px; font-size: .875rem; }
output { font-family: Consolas, monospace; font-variant-numeric: tabular-nums; }
input { display: block; width: 100%; height: 28px; margin: 3px 0 0; accent-color: var(--accent); }
.note { padding: 13px clamp(16px, 2vw, 28px); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); }
.note span:last-child { display: flex; flex-wrap: wrap; gap: 5px 14px; }
.fallback { margin: auto; padding: 60px 16px 20px; line-height: 1.55; max-width: 640px; }
.fallback img { display: block; width: 100%; max-height: 290px; object-fit: contain; margin: 0 auto 10px; }
[hidden] { display: none !important; }
@media (max-width: 760px) {
  .workspace { display: flex; flex-direction: column; }
  .viewer, aside { display: contents; }
  .stage { order: 1; height: clamp(365px, 46vh, 455px); border-top: 1px solid var(--line); }
  .stage canvas { height: calc(100% - 90px); }
  .stage:has(#engine-labels:not([hidden])) { height: clamp(255px, 35vh, 330px); }
  .engine-labels span { font-size: .65rem; }
  .camera {
    order: 2; padding: 8px; border: 0; border-bottom: 1px solid var(--line);
  }
  .camera button { padding: 5px 4px; font-size: .83rem; }
  .view-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-panel { order: 3; }
  .cycle-panel { order: 4; }
  .lift-comparison { order: 5; border-top: 0; border-bottom: 1px solid var(--line); }
  .guide dl { grid-template-columns: minmax(0, 1fr); }
  .panel:last-child { border-bottom: 1px solid var(--line); }
  .phase-list { display: flex; }
  .phase-list li { flex: 1; border-left: 0; border-top: 2px solid var(--line); padding: 8px 5px; }
  .explanation { min-height: 2.9em; }
}
.stage:has(.fallback:not([hidden])) { height: auto; }
