.learning-tools {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 0 0;
  font-size: 13px;
  color: #526e63;
  position: relative;
}
.learning-tools label,
.demo-preferences label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}
.learning-tools input,
.demo-preferences input {
  width: 18px;
  height: 18px;
  accent-color: #34866c;
}
.learning-options {
  margin-left: auto;
  position: relative;
}
.learning-options summary {
  cursor: pointer;
  padding: 10px 0;
}
.learning-options > div {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 3;
  width: 245px;
  padding: 16px;
  background: #fff;
  border: 1px solid #d4e1d9;
  border-radius: 6px;
  box-shadow: 0 8px 24px #29413c12;
}
.learning-options label {
  display: flex;
  justify-content: space-between;
}
#voice-status,
#demo-audio-status {
  color: #657b6d;
  font-size: 12px;
  line-height: 1.7;
  margin: 8px 0 0;
}
.lesson-bar {
  flex-wrap: wrap;
  gap: 10px 14px;
}
.lesson-bar h2 {
  flex: 1 1 200px;
}
.icon-text {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.icon-text svg,
.icon-button svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.demo-launch {
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid #9dc8b9;
  border-radius: 5px;
  background: #e7f3ee;
  color: #276f57;
  font-size: 13px;
}
.demo-launch:hover {
  background: #d8ece3;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
  border: 1px solid #d4e1d9;
  border-radius: 5px;
  color: #3e6c5c;
  background: white;
}
.icon-button:disabled {
  opacity: 0.4;
  cursor: default;
}
.quiet:disabled {
  opacity: 0.45;
  cursor: default;
}
#demo-practice {
  margin-left: 8px;
}
.icon-button.primary {
  color: #fff;
  background: #34866c;
  border-color: #34866c;
}
#demo-dialog {
  width: min(880px, calc(100% - 24px));
  max-height: 90vh;
  max-height: 90svh;
  margin: auto;
  padding: 0;
  border: 1px solid #c3d8ce;
  border-radius: 8px;
  color: #29413c;
  background: #fff;
  overflow: auto;
  overscroll-behavior: contain;
}
#demo-dialog::backdrop {
  background: #163a35a6;
}
.demo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid #e0e9e4;
  font-size: 13px;
  color: #5d7e70;
}
.demo-header .icon-button {
  border: 0;
}
.demo-body {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  align-items: center;
}
.demo-stage {
  min-width: 0;
  height: 330px;
  background: #eff6f4;
  border-radius: 6px;
  padding: 18px;
}
.scene-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.demo-script {
  min-width: 0;
}
.demo-script h2 {
  font-size: 21px;
  line-height: 1.6;
}
#demo-caption {
  font-size: 16px;
  line-height: 1.95;
  min-height: 140px;
  margin: 12px 0 16px;
  overflow-wrap: anywhere;
}
.demo-preferences {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 24px 12px;
  color: #526e63;
  font-size: 12px;
}
.demo-preferences #demo-audio-status {
  flex: 1 1 100%;
  margin: 0;
}
.demo-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 20px;
  border-top: 1px solid #e0e9e4;
  background: white;
  position: sticky;
  bottom: 0;
  z-index: 2;
}
#demo-step {
  min-width: 56px;
  text-align: center;
  color: #637e6f;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.demo-formula {
  font-size: 24px;
  line-height: 1.4;
  font-weight: 650;
  text-align: center;
  color: #34685b;
  overflow-wrap: anywhere;
}
.scene-note {
  margin: 0;
  color: #586f68;
  font-size: 13px;
  text-align: center;
  line-height: 1.7;
}
.demo-groups {
  display: grid;
  grid-template-columns: repeat(var(--group-columns, 3), minmax(0, 1fr));
  gap: 8px;
  max-width: 310px;
  width: 100%;
}
.demo-dots {
  display: grid;
  grid-template-columns: repeat(3, 8px);
  gap: 4px;
  justify-content: center;
  align-content: center;
  padding: 8px;
  min-height: 52px;
  border: 1px solid #b8d4d7;
  border-radius: 5px;
  background: #fff;
}
.demo-dots i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #578eaa;
  display: block;
  animation: tile-arrive 0.38s both;
  animation-delay: calc(var(--order, 0) * 20ms);
}
.demo-dots b {
  grid-column: 1/-1;
  font-size: 12px;
  text-align: center;
  line-height: 1.2;
  color: #436a7d;
  margin-top: 2px;
}
.demo-dots.incoming {
  border-color: #ddbf81;
  background: #fff8e9;
}
.incoming i {
  background: #c39242;
}
.demo-bundles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 290px;
}
.demo-dots.bundle {
  grid-template-columns: repeat(5, 6px);
  gap: 3px;
  border: 2px solid #c69a4f;
  background: #fff5de;
  animation: bundle-exchange 0.7s both;
  animation-delay: calc(var(--order, 0) * 90ms);
}
.bundle i {
  width: 6px;
  height: 6px;
  background: #c39242;
  animation: none;
}
.bundle b {
  color: #966d2b;
}
.demo-dots.loose {
  grid-template-columns: repeat(9, 8px);
  border: 0;
  background: transparent;
  min-height: 20px;
}
.demo-write {
  display: grid;
  grid-template-columns: 1fr 30px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}
.demo-write > div {
  display: grid;
  text-align: center;
  gap: 16px;
}
.demo-write span {
  font-size: 12px;
  color: #647b70;
}
.demo-write b {
  font-size: 54px;
  line-height: 1.5;
  font-weight: 600;
  border-radius: 6px;
}
.write-carry b {
  color: #966d2b;
  background: #f5e8c8;
  animation: carry-left 0.75s both;
}
.write-digit b {
  color: #2d7b60;
  background: #d3eadf;
  animation: digit-down 0.65s both;
}
.demo-write .exchange-arrow {
  font-size: 25px;
  color: #aa8248;
}
.shift-number {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 3px;
  font-size: 44px;
  font-variant-numeric: tabular-nums;
}
.shift-number > b:first-child {
  color: #357d67;
  animation: carry-left 0.7s both;
}
.shift-placeholders {
  color: #b18035;
  animation: digit-down 0.7s 0.3s both;
}
.demo-partials {
  display: grid;
  justify-items: end;
  gap: 5px;
  min-width: 190px;
  font-family: ui-monospace, monospace;
  font-size: 30px;
}
.demo-partials > div {
  color: #6a887a;
  animation: digit-down 0.5s both;
}
.demo-partials > strong {
  border-top: 2px solid #75998a;
  color: #28765e;
  width: 100%;
  text-align: right;
}
.demo-chocolate {
  width: min(280px, 100%);
  aspect-ratio: 1.6;
  display: grid;
  grid-template-columns: repeat(var(--columns, 1), minmax(0, 1fr));
  gap: 5px;
  padding: 6px;
  background: #c0a18a;
  border-radius: 5px;
}
.demo-chocolate > span {
  border-radius: 3px;
  background: #e2cdbd;
  box-shadow:
    inset 3px 3px #ffffff30,
    inset -3px -3px #62453628;
  animation: tile-arrive 0.45s both;
  animation-delay: calc(var(--order) * 65ms);
}
.demo-chocolate > span.selected {
  background: #79503e;
  box-shadow:
    inset 3px 3px #b7876759,
    inset -3px -3px #40291d55;
}
.demo-fraction-bar {
  display: grid;
  grid-template-columns: repeat(var(--parts), minmax(0, 1fr));
  gap: 2px;
  width: 100%;
  height: 46px;
  background: #c0a18a;
  padding: 3px;
  border-radius: 3px;
}
.demo-fraction-bar > span {
  background: #e2cdbd;
}
.demo-fraction-bar > span.selected {
  background: #79503e;
  animation: tile-arrive 0.6s both;
  animation-delay: calc(var(--order) * 75ms);
}
.demo-hundred {
  width: 200px;
  height: 200px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 2px;
  padding: 4px;
  background: #ccddd7;
}
.demo-hundred > span {
  background: white;
}
.demo-hundred > span.selected {
  background: #568eac;
  animation: tile-arrive 0.3s both;
  animation-delay: calc(var(--order) * 9ms);
}
.demo-hundred > span.focus-tile {
  outline: 2px solid #bf8d39;
  outline-offset: -2px;
}
.demo-whole {
  color: #486e59;
  background: #d6e9dc;
  padding: 4px 12px;
  border-radius: 3px;
  font-size: 12px;
}
.scene-hundred {
  gap: 8px;
}
.scene-hundred .demo-formula {
  font-size: 21px;
}
.demo-number-line {
  position: relative;
  width: calc(100% - 24px);
  height: 74px;
  margin-top: 46px;
  border-top: 3px solid #7b9b8a;
}
.number-line-marker {
  position: absolute;
  left: var(--position);
  top: -7px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #a7793b;
  transform: translateX(-50%);
  animation: digit-down 0.8s both;
}
.number-line-label {
  position: absolute;
  bottom: 23px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 21px;
  color: #936c33;
  white-space: nowrap;
}
.near-start .number-line-label {
  left: 0;
  transform: none;
}
.near-end .number-line-label {
  left: auto;
  right: 0;
  transform: none;
}
.number-line-ticks {
  display: flex;
  justify-content: space-between;
}
.number-line-ticks > span {
  width: 1px;
  height: 10px;
  background: #7b9b8a;
  font-size: 12px;
  color: #5a786a;
  padding-top: 13px;
}
.number-line-ticks > span:last-child {
  text-indent: -6px;
}
.number-row .active-cell {
  animation: active-column 0.7s ease-out;
}
@keyframes tile-arrive {
  from {
    opacity: 0.25;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes bundle-exchange {
  from {
    opacity: 0.3;
    transform: translateX(22px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes carry-left {
  from {
    opacity: 0.25;
    transform: translateX(28px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes digit-down {
  from {
    opacity: 0.25;
    translate: 0 -12px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@keyframes active-column {
  from {
    background: #f6db9a;
  }
  to {
    background: #e2eee7;
  }
}
html[data-reduced-motion="true"] *,
html[data-reduced-motion="true"] *::before,
html[data-reduced-motion="true"] *::after {
  animation: none !important;
  transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
@media (max-width: 760px) {
  .learning-tools {
    gap: 6px 12px;
  }
  .learning-options {
    margin-left: 0;
    position: static;
  }
  .learning-options > div {
    right: 0;
    left: auto;
    max-width: 100%;
  }
  .lesson-bar h2 {
    flex-basis: 100%;
  }
  #demo-dialog {
    width: calc(100% - 16px);
  }
  .demo-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
  }
  .demo-stage {
    height: 280px;
    padding: 14px;
  }
  .demo-script h2 {
    font-size: 19px;
  }
  #demo-caption {
    min-height: 0;
    font-size: 15px;
    margin: 8px 0 12px;
  }
  .demo-preferences {
    padding: 0 16px 12px;
  }
  .demo-controls {
    gap: 10px;
    padding: 10px;
  }
  .demo-formula {
    font-size: 22px;
  }
  .demo-groups {
    gap: 6px;
  }
  .demo-dots {
    padding: 5px;
  }
  .demo-hundred {
    width: 180px;
    height: 180px;
  }
  .demo-header {
    padding: 8px 16px;
  }
}
