.arithmetic-page {
  width: min(1280px, calc(100% - 32px));
}
.arithmetic-page .tool-heading { padding: 14px 0 11px; }
.arithmetic-page .tool-heading h1 { font-size: clamp(30px, 3.3vw, 43px); }
.arithmetic-lab .visual-stage { padding: 13px; }
.arithmetic-lab .equation-band { min-height: 50px; }
.arithmetic-lab .equation-band strong {
  max-width: 82%;
  overflow-wrap: anywhere;
  font-size: clamp(20px, 2vw, 28px);
  text-align: right;
}

.arithmetic-scene {
  min-height: 272px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr) 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 11px 0;
}
.arithmetic-side {
  min-width: 0;
  min-height: 248px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 9px;
  border: 1px solid #eadcc8;
  border-radius: 18px;
  background: rgba(255, 255, 255, .76);
}
.arithmetic-side.side-a { box-shadow: inset 0 4px 0 rgba(233, 132, 59, .64); }
.arithmetic-side.side-b { box-shadow: inset 0 4px 0 rgba(43, 152, 139, .64); }
.result-side { box-shadow: inset 0 4px 0 rgba(85, 116, 202, .64); }
.result-side .side-key { color: #3d58ac; background: #edf1ff; }

.arithmetic-circle-holder {
  width: min(170px, 13vw);
  aspect-ratio: 1;
}
.arithmetic-circle-svg {
  width: 92%;
  height: auto;
  display: block;
  overflow: visible;
  border-radius: 50%;
}
.arithmetic-sector {
  fill: var(--sector-color);
  stroke: rgba(87, 60, 36, .48);
  stroke-width: 1.2;
  transition: fill .3s ease, stroke .3s ease;
}
.arithmetic-ring { fill: none; stroke: rgba(79, 54, 31, .62); stroke-width: 2.5; }
.arithmetic-ornament {
  fill: none;
  stroke: rgba(255, 248, 219, .86);
  stroke-width: 1.7;
  stroke-dasharray: 3 4;
}
.arithmetic-circle-holder.is-placeholder {
  border-style: dashed;
  color: #7e8bb5;
  background: rgba(237, 241, 255, .62);
}
.result-placeholder { font-size: 44px; font-weight: 900; }

.operation-sign,
.equals-sign {
  display: grid;
  place-items: center;
  color: #43516a;
  font-size: 32px;
  font-weight: 950;
}
.operation-sign[data-operation="add"] { color: #b8511f; }
.operation-sign[data-operation="subtract"] { color: #226d65; }
.result-copy {
  min-height: 32px;
  margin: 0;
  color: #5d6980;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.arithmetic-lab .invariant-line { min-height: 50px; }
.arithmetic-lab .control-deck { padding: 17px; }
.arithmetic-case strong { font-size: 12px; }
.arithmetic-case span { font-size: 8px; }
.arithmetic-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 11px;
}
.summary-item {
  min-height: 58px;
  display: grid;
  place-items: center;
  padding: 6px;
  border: 1px solid rgba(85, 116, 202, .22);
  border-radius: 12px;
  color: #67738a;
  background: #f1f4ff;
  font-size: 9px;
  font-weight: 900;
  text-align: center;
}
.summary-item strong { color: #3d58ac; font-size: 23px; line-height: 1; }
.reduction-copy {
  min-height: 32px;
  margin: 9px 0 0;
  color: #687485;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}
.arithmetic-lab .truth-note { margin-top: 9px; }
[data-tool-state="commonizing"] .arithmetic-circle-holder { animation: arithmetic-hold .42s ease; }
[data-tool-state="settled"] .arithmetic-circle-svg { animation: arithmetic-arrive .4s ease both; }

@keyframes arithmetic-hold {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}
@keyframes arithmetic-arrive {
  from { opacity: .45; transform: scale(.97); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 980px) {
  .arithmetic-page { width: calc(100% - 28px); }
  .arithmetic-scene { min-height: 250px; }
  .arithmetic-side { min-height: 226px; }
  .arithmetic-circle-holder { width: min(156px, 20vw); }
  .arithmetic-lab .control-deck { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 9px 16px; }
  .arithmetic-lab .control-heading { grid-row: span 2; }
  .arithmetic-lab .action-row { margin-top: 0; }
  .arithmetic-summary { margin-top: 0; }
  .arithmetic-lab .reduction-copy,
  .arithmetic-lab .truth-note { grid-column: 1 / -1; margin-top: 0; }
}

@media (max-width: 720px) {
  .arithmetic-page .tool-heading { padding-top: 16px; }
  .arithmetic-scene {
    grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr) 26px minmax(0, 1fr);
    gap: 4px;
  }
  .arithmetic-side { min-height: 215px; padding: 7px 4px; }
  .arithmetic-circle-holder { width: min(145px, 25vw); }
  .arithmetic-side .side-head { gap: 5px; }
  .arithmetic-side .side-head strong { font-size: 20px; }
  .arithmetic-side .side-key { min-width: 24px; min-height: 24px; }
  .arithmetic-side .side-transform { max-width: 100%; padding: 4px 5px; font-size: 9px; white-space: normal; text-align: center; }
  .operation-sign,
  .equals-sign { font-size: 25px; }
  .arithmetic-lab .control-deck { display: block; }
  .arithmetic-lab .action-row,
  .arithmetic-summary,
  .arithmetic-lab .reduction-copy,
  .arithmetic-lab .truth-note { margin-top: 10px; }
}

@media (max-width: 430px) {
  .arithmetic-page .tool-heading h1 { font-size: 26px; }
  .arithmetic-lab .visual-stage { padding: 9px; }
  .arithmetic-lab .equation-band { align-items: flex-start; flex-direction: column; gap: 2px; }
  .arithmetic-lab .equation-band strong { max-width: 100%; font-size: 17px; text-align: left; }
  .arithmetic-scene {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 0;
  }
  .arithmetic-side {
    min-height: 148px;
    grid-template-columns: 138px minmax(0, 1fr);
    grid-template-areas:
      "circle head"
      "circle transform"
      "circle copy";
    justify-items: stretch;
    gap: 4px 8px;
    padding: 7px;
  }
  .arithmetic-circle-holder { grid-area: circle; width: 134px; }
  .arithmetic-side .side-head { grid-area: head; justify-content: flex-start; }
  .arithmetic-side .side-transform { grid-area: transform; justify-self: start; }
  .result-copy { grid-area: copy; text-align: left; }
  .operation-sign,
  .equals-sign {
    min-height: 27px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .72);
    font-size: 22px;
  }
  .arithmetic-lab .invariant-line { grid-template-columns: 1fr; }
  .arithmetic-case strong { font-size: 10px; }
  .arithmetic-case span { font-size: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .arithmetic-circle-holder,
  .arithmetic-circle-svg { animation: none !important; }
}
