[hidden] {
  display: none !important;
}

.tool-main {
  padding-block: 2rem 5rem;
}

.tool-shell {
  width: min(1180px, calc(100% - 2rem));
  margin-inline: auto;
}

.tool-kicker,
.section-kicker,
.phase-step span,
.frame-slot-label,
.playback-stamp,
.run-tag,
.test-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-header {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.75fr);
  gap: 2rem;
  align-items: end;
  padding-block: 2rem 2.4rem;
  border-bottom: 1px solid var(--rule);
}

.tool-header h1 {
  max-width: 850px;
  margin: 0.35rem 0 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 7vw, 6.4rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.88;
}

.tool-header p {
  max-width: 760px;
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.7vw, 1.2rem);
  line-height: 1.55;
}

.teaching-notice {
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-left: 5px solid var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.teaching-notice strong {
  display: block;
  margin-bottom: 0.25rem;
}

.teaching-notice p {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.phase-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-block: 1.25rem;
  border: 1px solid var(--rule);
  background: var(--surface);
}

.phase-step {
  position: relative;
  min-height: 76px;
  padding: 0.8rem 0.9rem;
  color: var(--muted);
  border-right: 1px solid var(--rule);
}

.phase-step:last-child {
  border-right: 0;
}

.phase-step::after {
  position: absolute;
  right: 0.9rem;
  bottom: 0.7rem;
  width: 9px;
  height: 9px;
  content: "";
  border: 1px solid currentColor;
  border-radius: 50%;
}

.phase-step strong {
  display: block;
  margin-top: 0.25rem;
  color: inherit;
  font-size: 0.92rem;
}

.phase-step.is-active {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.phase-step.is-active::after {
  background: var(--accent);
  border-color: var(--accent);
}

.phase-step.is-complete {
  color: var(--ink-soft);
}

.phase-step.is-complete::after {
  background: var(--ink-soft);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(285px, 0.7fr);
  gap: 1.25rem;
  align-items: start;
}

.drawing-panel,
.guide-panel,
.timeline-panel,
.compare-panel,
.boundary-note,
.test-panel {
  border: 1px solid var(--rule);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.drawing-panel {
  min-width: 0;
  padding: 0.75rem;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 5 / 3;
  border: 1px solid var(--ink);
  background: rgb(255, 254, 249);
  touch-action: none;
}

.playback-stamp {
  position: absolute;
  z-index: 3;
  top: 0.65rem;
  left: 0.65rem;
  padding: 0.3rem 0.45rem;
  color: rgb(32, 34, 38);
  background: rgba(255, 254, 249, 0.92);
  border: 1px solid rgba(32, 34, 38, 0.28);
  pointer-events: none;
}

#drawCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#drawCanvas:focus-visible {
  outline: 4px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: -5px;
}

.canvas-overlay {
  position: absolute;
  z-index: 2;
  top: 0.7rem;
  left: 0.7rem;
  max-width: calc(100% - 1.4rem);
  padding: 0.35rem 0.55rem;
  color: rgb(32, 34, 38);
  background: rgba(255, 254, 249, 0.92);
  border: 1px solid rgba(32, 34, 38, 0.32);
  box-shadow: 2px 2px 0 rgba(32, 34, 38, 0.12);
  pointer-events: none;
}

.drawing-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.75rem;
  align-items: end;
  margin-top: 0.75rem;
}

.tool-control-group {
  min-width: 0;
}

.tool-control-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.swatch-row,
.size-row,
.button-row,
.compare-controls,
.run-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.swatch,
.size-choice {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  cursor: pointer;
}

.swatch::before {
  width: 20px;
  height: 20px;
  content: "";
  background: var(--swatch-color);
  border: 1px solid rgba(32, 34, 38, 0.3);
  border-radius: 50%;
}

.swatch[aria-pressed="true"],
.size-choice[aria-pressed="true"] {
  color: var(--surface);
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--surface);
}

.size-choice::before {
  width: var(--dot-size);
  height: var(--dot-size);
  content: "";
  background: currentColor;
  border-radius: 50%;
}

.compact-btn,
.playback-btn,
.run-button {
  min-height: 38px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  color: var(--ink);
  background: var(--surface-2);
  font: 600 0.78rem/1 var(--font-body);
  cursor: pointer;
}

.compact-btn[aria-pressed="true"],
.run-button[aria-pressed="true"] {
  color: var(--surface);
  background: var(--ink);
  border-color: var(--ink);
}

.compact-btn:disabled,
.playback-btn:disabled,
.run-button:disabled,
.primary-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.guide-panel {
  position: sticky;
  top: 1rem;
  padding: 1.15rem;
}

.guide-panel h2,
.timeline-panel h2,
.compare-panel h2,
.test-panel h2 {
  margin: 0.2rem 0 0.55rem;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  font-weight: 500;
  line-height: 1.05;
}

.guide-copy,
.panel-intro,
.boundary-note p,
.test-panel p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.prompt-field,
.feature-field {
  display: grid;
  gap: 0.35rem;
  margin-top: 1rem;
}

.prompt-field span,
.feature-field span {
  font-weight: 700;
}

.prompt-field input,
.feature-field input {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--rule);
  color: var(--ink);
  background: var(--surface-2);
  font: inherit;
}

.prompt-field input:disabled {
  opacity: 0.75;
}

.constraint-card {
  margin-block: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--rule);
  background: var(--surface-2);
}

.constraint-card strong {
  display: block;
  margin-bottom: 0.2rem;
}

.constraint-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.45;
}

.primary-action {
  width: 100%;
  min-height: 50px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--ink);
  color: var(--surface);
  background: var(--ink);
  font: 700 0.92rem/1.2 var(--font-body);
  cursor: pointer;
}

.secondary-action {
  width: 100%;
  min-height: 44px;
  margin-top: 0.55rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--rule);
  color: var(--ink);
  background: transparent;
  font: 600 0.85rem/1.2 var(--font-body);
  cursor: pointer;
}

.unlock-action {
  border-style: dashed;
}

.danger-action {
  color: var(--danger, rgb(143, 42, 42));
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.timeline-panel,
.compare-panel,
.test-panel {
  margin-top: 1.25rem;
  padding: 1.15rem;
}

.branch-timeline {
  display: grid;
  grid-template-columns: minmax(105px, 0.35fr) minmax(0, 0.65fr) minmax(0, 3fr);
  gap: 0.75rem;
  align-items: stretch;
  margin-top: 1rem;
}

.timeline-shared,
.run-label,
.run-slots {
  min-width: 0;
}

.timeline-shared {
  grid-row: 1 / 3;
}

.timeline-shared .frame-slot {
  height: 100%;
  min-height: 145px;
}

.run-label {
  display: grid;
  align-content: center;
  min-height: 68px;
  padding: 0.7rem;
  border: 1px solid var(--rule);
}

.run-label p {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.35;
}

.run-label-a {
  border-left: 6px solid var(--accent);
}

.run-label-b {
  border-left: 6px double var(--ink);
}

.run-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.frame-slot {
  position: relative;
  display: grid;
  overflow: hidden;
  min-height: 68px;
  padding: 0;
  border: 1px dashed var(--rule);
  color: var(--muted);
  background: var(--surface-2);
}

button.frame-slot {
  cursor: pointer;
}

.frame-slot img {
  width: 100%;
  height: 100%;
  min-height: 68px;
  object-fit: cover;
}

.frame-slot-label {
  position: absolute;
  right: 0.25rem;
  bottom: 0.25rem;
  padding: 0.15rem 0.25rem;
  color: rgb(32, 34, 38);
  background: rgba(255, 254, 249, 0.88);
  border: 1px solid rgba(32, 34, 38, 0.25);
}

.frame-slot.is-current {
  border: 3px solid var(--accent);
}

.frame-slot.is-locked {
  border-style: solid;
  border-color: var(--ink-soft);
}

.frame-slot.is-pending::before {
  place-self: center;
  content: "Pending";
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.compare-grid {
  display: grid;
  grid-template-columns: minmax(230px, 0.68fr) minmax(0, 1.32fr);
  gap: 1.25rem;
  margin-top: 1rem;
}

.compare-instructions {
  padding-right: 1rem;
  border-right: 1px solid var(--rule);
}

.compare-instructions ol {
  margin: 1rem 0 0;
  padding-left: 1.25rem;
}

.compare-instructions li {
  margin-bottom: 0.55rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.run-button {
  flex: 1 1 110px;
}

.compare-controls {
  justify-content: space-between;
  margin-top: 0.85rem;
  padding-block: 0.7rem;
  border-block: 1px solid var(--rule-soft);
}

.playback-btn {
  min-width: 44px;
}

.fps-control {
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  flex: 1 1 220px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.fps-control input {
  width: 100%;
}

.guided-action {
  margin-top: 0.9rem;
}

.compare-note {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.boundary-note {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  border-left: 6px solid var(--ink);
}

.boundary-note strong {
  display: block;
  margin-bottom: 0.25rem;
}

.live-status {
  min-height: 1.4em;
  margin: 1rem 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.self-test-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.self-test-list li {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  background: var(--surface-2);
  font-size: 0.82rem;
}

.self-test-list li[data-result="pass"] {
  border-left: 5px solid var(--success, rgb(43, 112, 73));
}

.self-test-list li[data-result="fail"] {
  border-left: 5px solid var(--danger, rgb(143, 42, 42));
}

.tool-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.8rem;
}

/* Coherence Animator page structure */
.ca-shell {
  width: min(1180px, calc(100% - 2rem));
  margin-inline: auto;
  padding-block: 2rem 5rem;
}

.tool-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding-block: 2rem 1.7rem;
}

.tool-title {
  max-width: 950px;
  margin: 0.35rem 0 0.65rem;
  font-family: var(--font-display);
  font-size: clamp(3rem, 8.5vw, 7rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 0.88;
}

.tool-dek {
  max-width: 830px;
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.7vw, 1.2rem);
  line-height: 1.55;
}

.tool-idea {
  width: fit-content;
  max-width: 760px;
  margin-top: 1.1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--ink);
  background: var(--surface);
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 700;
}

.ca-notice {
  margin-bottom: 1.25rem;
  border-left: 6px solid var(--accent);
}

.ca-notice .tool-notice-inner {
  line-height: 1.5;
}

.ca-notice strong {
  display: block;
  margin-bottom: 0.15rem;
}

.phase-step b,
.phase-step small {
  display: block;
}

.phase-step b {
  margin-top: 0.22rem;
  color: inherit;
  font-size: 0.92rem;
}

.phase-step small {
  margin-top: 0.1rem;
  font-size: 0.72rem;
}

.animator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(285px, 0.7fr);
  gap: 1.25rem;
  align-items: start;
}

.canvas-panel {
  min-width: 0;
  padding: 0.75rem;
  border: 1px solid var(--rule);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.canvas-head,
.section-heading {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 0.75rem;
}

.canvas-head h2,
.section-heading h2,
.phase-one-note h2 {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  font-weight: 500;
  line-height: 1.05;
}

.mini-label,
.toolbar-label,
.timeline-label,
.target-label {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.reference-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.reference-badge {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.66rem;
}

.canvas-summary {
  min-height: 1.35em;
  margin: 0.65rem 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.drawing-toolbar {
  grid-template-columns: minmax(190px, 1fr) minmax(130px, 0.55fr) 1fr auto auto auto;
}

.control-group {
  min-width: 0;
}

.color-controls,
.size-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.color-choice,
.size-choice {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  cursor: pointer;
}

.color-choice::before {
  width: 19px;
  height: 19px;
  content: "";
  background: var(--choice-color);
  border: 1px solid rgba(32, 34, 38, 0.25);
  border-radius: 50%;
}

.size-choice::before {
  width: var(--choice-size);
  height: var(--choice-size);
  content: "";
  background: currentColor;
  border-radius: 50%;
}

.color-choice[aria-pressed="true"],
.size-choice[aria-pressed="true"] {
  color: var(--surface);
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--surface);
}

.utility-button,
.run-toggle button,
.playback-buttons button {
  min-height: 38px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  color: var(--ink);
  background: var(--surface-2);
  font: 600 0.78rem/1 var(--font-body);
  cursor: pointer;
}

.utility-button[aria-pressed="true"],
.run-toggle button[aria-pressed="true"] {
  color: var(--surface);
  background: var(--ink);
  border-color: var(--ink);
}

.utility-button.danger,
.text-button {
  color: var(--danger, rgb(143, 42, 42));
}

.utility-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.field-label {
  display: block;
  margin-top: 1rem;
  font-weight: 700;
}

#promptInput {
  width: 100%;
  min-height: 44px;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--rule);
  color: var(--ink);
  background: var(--surface-2);
  font: inherit;
}

.field-help {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.frame-target {
  display: grid;
  gap: 0.18rem;
  margin-block: 1rem;
  padding: 0.8rem;
  border: 1px solid var(--rule);
  background: var(--surface-2);
}

.frame-target span:last-child {
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.4;
}

.recovery-row {
  display: flex;
  justify-content: center;
  margin-top: 0.6rem;
}

.text-button {
  padding: 0.35rem;
  border: 0;
  background: transparent;
  font: 600 0.77rem/1.2 var(--font-body);
  text-decoration: underline;
  cursor: pointer;
}

.guide-boundary {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}

.guide-boundary p {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.45;
}

.section-heading > p {
  max-width: 480px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.45;
  text-align: right;
}

.timeline-grid {
  display: grid;
  grid-template-columns: minmax(95px, 0.3fr) 38px minmax(0, 2.7fr);
  gap: 0.65rem;
  align-items: stretch;
  margin-top: 1rem;
}

.shared-frame-column {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0.35rem;
}

.branch-lines {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 0.75rem;
  padding-block: 1.2rem 0;
}

.branch-lines span {
  position: relative;
  border-block: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}

.branch-lines span::before {
  position: absolute;
  top: 50%;
  right: 100%;
  width: 16px;
  content: "";
  border-top: 1px solid var(--rule);
}

.run-rows {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 0.75rem;
}

.run-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.55fr) minmax(0, 1.45fr);
  gap: 0.55rem;
}

.run-label {
  display: grid;
  align-content: center;
  min-height: 82px;
  padding: 0.65rem;
  border: 1px solid var(--rule);
  background: var(--surface-2);
}

.run-label span {
  margin-top: 0.2rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.3;
}

.run-row[data-run="a"] .run-label {
  border-left: 6px solid var(--accent);
}

.run-row[data-run="b"] .run-label {
  border-left: 6px double var(--ink);
}

.frame-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.frame-slot {
  min-height: 82px;
}

.frame-slot.locked {
  border-style: solid;
  border-color: var(--ink-soft);
}

.frame-slot.current {
  border: 3px solid var(--accent);
}

.frame-slot img {
  position: absolute;
  inset: 0;
}

.slot-number,
.slot-state {
  position: absolute;
  z-index: 1;
  padding: 0.12rem 0.25rem;
  color: rgb(32, 34, 38);
  background: rgba(255, 254, 249, 0.9);
  border: 1px solid rgba(32, 34, 38, 0.22);
  font-family: var(--font-mono);
  font-size: 0.62rem;
}

.slot-number {
  top: 0.2rem;
  left: 0.2rem;
}

.slot-state {
  right: 0.2rem;
  bottom: 0.2rem;
}

.compare-controls {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(190px, 0.7fr);
  gap: 0.85rem 1rem;
  align-items: end;
  margin-top: 1rem;
}

.feature-field {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  font-weight: 700;
}

.feature-field input {
  width: 100%;
  min-height: 42px;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--rule);
  color: var(--ink);
  background: var(--surface-2);
  font: inherit;
}

.run-toggle,
.playback-buttons {
  display: flex;
  gap: 0.4rem;
}

.run-toggle button {
  flex: 1;
}

.playback-buttons button {
  min-width: 44px;
}

.fps-control {
  margin: 0;
}

.compare-action {
  grid-column: 1 / -1;
}

.comparison-protocol ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 1rem 0 0;
  padding: 0;
  counter-reset: protocol;
  list-style: none;
}

.comparison-protocol li {
  padding: 0.7rem;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  background: var(--surface-2);
  font-size: 0.78rem;
  line-height: 1.4;
  counter-increment: protocol;
}

.comparison-protocol li::before {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--ink);
  content: counter(protocol, decimal-leading-zero);
  font-family: var(--font-mono);
  font-weight: 600;
}

.phase-one-note {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-left: 6px solid var(--ink);
  background: var(--surface);
}

.phase-one-note p:last-child {
  max-width: 900px;
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.status-region {
  min-height: 1.4em;
  margin-top: 1rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.self-test {
  margin-top: 0.75rem;
}

@media (max-width: 900px) {
  .tool-header,
  .workspace-grid,
  .compare-grid,
  .animator-grid {
    grid-template-columns: 1fr;
  }

  .guide-panel {
    position: static;
  }

  .compare-instructions {
    padding-right: 0;
    padding-bottom: 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .branch-timeline {
    grid-template-columns: minmax(90px, 0.35fr) minmax(0, 1fr);
  }

  .drawing-toolbar {
    grid-template-columns: minmax(190px, 1fr) minmax(130px, 0.6fr) auto auto auto;
  }

  .toolbar-spacer {
    display: none;
  }

  .timeline-shared {
    grid-row: auto;
    grid-column: 1 / -1;
  }

  .timeline-shared .frame-slot {
    width: min(220px, 100%);
    min-height: 110px;
  }
}

@media (max-width: 680px) {
  .tool-main {
    padding-top: 1rem;
  }

  .tool-shell {
    width: min(100% - 1rem, 1180px);
  }

  .ca-shell {
    width: min(100% - 1rem, 1180px);
    padding-top: 1rem;
  }

  .tool-header {
    gap: 1.2rem;
    padding-block: 1.25rem 1.6rem;
  }

  .phase-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .phase-step:nth-child(2) {
    border-right: 0;
  }

  .phase-step:nth-child(-n + 2) {
    border-bottom: 1px solid var(--rule);
  }

  .drawing-toolbar {
    grid-template-columns: 1fr;
  }

  .canvas-head,
  .section-heading {
    display: grid;
    align-items: start;
  }

  .reference-badges {
    justify-content: flex-start;
  }

  .section-heading > p {
    text-align: left;
  }

  .timeline-grid {
    grid-template-columns: 1fr;
  }

  .branch-lines {
    display: none;
  }

  .shared-frame-column {
    max-width: none;
  }

  .run-row {
    grid-template-columns: 1fr;
  }

  .frame-slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compare-controls,
  .comparison-protocol ol {
    grid-template-columns: 1fr;
  }

  .compare-action {
    grid-column: auto;
  }

  .branch-timeline {
    grid-template-columns: 1fr;
  }

  .timeline-shared,
  .run-label,
  .run-slots {
    grid-column: 1;
  }

  .run-slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-shared .frame-slot {
    width: 100%;
  }

  .self-test-list {
    grid-template-columns: 1fr;
  }
}

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

@media print {
  .nav,
  .drawing-toolbar,
  .guide-panel .button-row,
  .compare-controls,
  .guided-action,
  .test-panel {
    display: none !important;
  }

  .tool-shell {
    width: 100%;
  }

  .drawing-panel,
  .guide-panel,
  .timeline-panel,
  .compare-panel,
  .boundary-note {
    box-shadow: none;
    break-inside: avoid;
  }
}
