/* ============================================================
   写歪歪 · 数学练习生成器
   ============================================================ */

.control-panel [hidden] {
  display: none !important;
}

.math-type-select {
  width: 100%;
  min-height: 40px;
}
.math-type-select select {
  width: 100%;
  padding-left: 12px;
  font-size: 11px;
  font-weight: 600;
}
.type-desc {
  margin: 8px 1px 0;
  color: #9b918a;
  font-size: 9.5px;
  line-height: 1.65;
}

.math-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 11px;
  padding: 7px 11px;
  color: #a36a4d;
  border: 1px solid #f6e2d7;
  border-radius: 10px;
  background: #fff9f5;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.control-panel .control-scroll {
  padding-bottom: 46px;
}

.math-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.math-presets .quick-chip {
  min-height: 26px;
  padding: 4px 7px;
  font-size: 9px;
}

.segmented.math-op-seg button {
  min-width: 51px;
  padding-right: 7px;
  padding-left: 7px;
  font-size: 9.5px;
}
.segmented.math-range-seg button {
  min-width: 46px;
  padding-right: 6px;
  padding-left: 6px;
  font-size: 9px;
}
.segmented.math-form-seg button {
  min-width: 50px;
  padding-right: 7px;
  padding-left: 7px;
  font-size: 9.5px;
}
.segmented.math-column-seg button {
  min-width: 39px;
  padding-right: 5px;
  padding-left: 5px;
  font-size: 9px;
}

/* 数学练习页 */
.math-sheet-content {
  flex: 1 1 auto;
  min-height: 0;
  padding-top: 4mm;
  overflow: hidden;
}
.math-grid {
  display: grid;
  width: 100%;
  align-content: start;
}
.math-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 1.3mm 1.5mm;
  border-bottom: 0.18mm solid #f6f0ec;
}
.math-index {
  position: absolute;
  top: 1.2mm;
  left: 1.1mm;
  color: #c1b4ac;
  font-family: "Arial", "PingFang SC", sans-serif;
  font-size: 2.45mm;
  font-weight: 600;
  line-height: 1;
}
.math-equation {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.14em;
  color: #2b2522;
  font-family: "Arial", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: var(--math-font-size, 22px);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.12;
  white-space: nowrap;
}
.math-token {
  display: inline-block;
}
.math-blank {
  display: inline-block;
  width: 1.7em;
  height: 1.08em;
  margin: 0 0.06em;
  border-bottom: 0.28mm solid #3a332e;
  transform: translateY(-0.04em);
}

/* 竖式 */
.math-item.is-vertical {
  padding-top: 1.8mm;
  padding-bottom: 1.4mm;
}
.vertical-problem {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: max-content;
  min-width: 13mm;
  padding-top: 0.6mm;
  color: #2b2522;
  font-family: "Arial", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: var(--math-font-size, 22px);
  font-weight: 600;
  line-height: 1.12;
}
.vertical-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.22em;
  white-space: nowrap;
}
.vertical-op {
  width: 1.05em;
  flex: 0 0 auto;
  text-align: left;
}
.vertical-num {
  min-width: 2.35em;
  text-align: right;
  letter-spacing: 0.02em;
}
.vertical-line {
  width: 100%;
  height: 0;
  margin: 0.35mm 0 0.75mm;
  border-top: 0.3mm solid #3a332e;
}
.vertical-answer {
  width: 100%;
  height: 1.22em;
  border-bottom: 0.28mm solid #3a332e;
}

/* 答案页 */
.answer-sheet-content {
  flex: 1 1 auto;
  min-height: 0;
  padding-top: 4mm;
  overflow: hidden;
}
.answer-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: 100%;
  min-height: 100%;
  align-content: start;
}
.answer-item {
  display: flex;
  align-items: center;
  gap: 0.45em;
  min-width: 0;
  padding: 0.3mm 2mm;
  border-bottom: 0.16mm solid #f6f0ec;
  color: #2b2522;
  font-family: "Arial", "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: 3.15mm;
  font-weight: 600;
}
.answer-index {
  flex: 0 0 auto;
  min-width: 2.4em;
  color: #b9ada5;
  font-size: 2.45mm;
  font-weight: 500;
  text-align: right;
}
.answer-value {
  overflow: hidden;
  color: #302a26;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-page.math-sheet {
  --math-font-size: 22px;
}

/* 破十法 / 凑十法过程 */
.math-item.is-process {
  align-items: flex-start;
  justify-content: center;
  padding: 2.2mm 2.4mm;
}
.process-problem {
  display: flex;
  flex-direction: column;
  gap: 1.1mm;
  width: 100%;
  padding-left: 2mm;
}
.process-original {
  display: flex;
  align-items: baseline;
  gap: 0.14em;
  color: #2b2522;
  font-family: "Arial", "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: var(--math-font-size, 22px);
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
}
.process-lines {
  display: flex;
  flex-direction: column;
  gap: 0.65mm;
  padding-left: 4.2mm;
}
.process-line {
  display: flex;
  align-items: baseline;
  gap: 0.12em;
  color: #736861;
  font-family: "Arial", "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: calc(var(--math-font-size, 22px) * 0.7);
  font-weight: 500;
  line-height: 1.1;
  white-space: nowrap;
}
.process-original .math-blank { width: 1.55em; height: 1.05em; }
.process-line .math-blank { width: 1.3em; height: 0.95em; border-bottom-color: #736861; }

/* 数的分成树 */
.math-item.is-composition {
  align-items: center;
  justify-content: center;
  padding: 1.4mm;
}
.decompose-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.decompose-total {
  color: #2b2522;
  font-family: "Arial", "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: calc(var(--math-font-size, 22px) * 1.02);
  font-weight: 700;
  line-height: 1;
}
.decompose-connector {
  position: relative;
  width: 62%;
  height: 7.5mm;
}
.decompose-connector::before,
.decompose-connector::after {
  content: "";
  position: absolute;
  top: 0;
  width: 49%;
  height: 0;
  border-top: 0.28mm solid #bdb1a9;
}
.decompose-connector::before {
  left: 50%;
  transform: rotate(30deg);
  transform-origin: left top;
}
.decompose-connector::after {
  right: 50%;
  transform: rotate(-30deg);
  transform-origin: right top;
}
.decompose-parts {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 82%;
}
.decompose-part {
  min-width: 2.2em;
  color: #2b2522;
  font-family: "Arial", "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: calc(var(--math-font-size, 22px) * 0.9);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}
.decompose-part.is-blank {
  width: 2.2em;
  min-width: 2.2em;
  height: 1.15em;
  border-bottom: 0.28mm solid #3a332e;
}

/* 比大小 */
.math-item.is-compare {
  padding: 1.4mm;
}
.compare-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  color: #2b2522;
  font-family: "Arial", "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: calc(var(--math-font-size, 22px) * 0.82);
  font-weight: 600;
  white-space: nowrap;
}
.compare-side { display: inline-block; }
.compare-circle {
  display: inline-block;
  flex: 0 0 auto;
  width: 1.25em;
  height: 1.25em;
  border: 0.3mm solid #3a332e;
  border-radius: 50%;
}

/* 认识钟表 */
.math-item.is-clock {
  flex-direction: column;
  gap: 1.1mm;
  padding: 1.4mm;
}
.clock-problem {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1mm;
}
.clock-svg {
  width: 28mm;
  height: 28mm;
  overflow: visible;
}
.clock-time {
  display: flex;
  align-items: baseline;
  gap: 0.16em;
  color: #4a423d;
  font-family: "Arial", "PingFang SC", sans-serif;
  font-size: calc(var(--math-font-size, 22px) * 0.78);
  font-weight: 500;
  line-height: 1;
}
.clock-paren { color: #958a83; }
.clock-colon { color: #2b2522; font-weight: 700; }
.time-blank {
  display: inline-block;
  width: 1.7em;
  height: 1.05em;
  border-bottom: 0.28mm solid #3a332e;
}

/* 数独 */
.sudoku-sheet-content {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding-top: 3mm;
}
.sudoku-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4mm;
  width: 100%;
}
.sudoku-instruction {
  max-width: 160mm;
  margin: 0;
  color: #8c817a;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 3.05mm;
  line-height: 1.55;
  text-align: center;
}
.sudoku-grid {
  display: grid;
  box-sizing: border-box;
  border: 0.7mm solid #3a332e;
  background: #fff;
}
.sudoku-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: #2b2522;
  border-right: 0.2mm solid #b9ada5;
  border-bottom: 0.2mm solid #b9ada5;
  font-family: "Arial", "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: var(--sudoku-font, 7mm);
  font-weight: 600;
  line-height: 1;
}
.sudoku-cell.box-right { border-right: 0.7mm solid #3a332e; }
.sudoku-cell.box-bottom { border-bottom: 0.7mm solid #3a332e; }
.sudoku-cell.last-col { border-right: 0; }
.sudoku-cell.last-row { border-bottom: 0; }

.math-equation.is-division-remainder {
  font-size: calc(var(--math-font-size, 22px) * 0.8);
}

@media (max-width: 1180px) {
  .segmented.math-op-seg button { min-width: 44px; font-size: 9px; }
  .segmented.math-range-seg button { min-width: 40px; font-size: 8.5px; }
  .segmented.math-form-seg button { min-width: 43px; font-size: 9px; }
  .segmented.math-column-seg button { min-width: 34px; font-size: 8.5px; }
  .math-summary { font-size: 9px; }
}

@media (max-width: 560px) {
  .math-presets .quick-chip { font-size: 9px; }
  .math-summary { align-items: flex-start; flex-direction: column; gap: 3px; }
  .segmented.math-op-seg,
  .segmented.math-range-seg,
  .segmented.math-form-seg,
  .segmented.math-column-seg { width: 100%; }
  .segmented.math-op-seg button,
  .segmented.math-range-seg button,
  .segmented.math-form-seg button,
  .segmented.math-column-seg button { flex: 1; min-width: 0; }
  .param-row.math-form-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }
  .param-row.math-column-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }
}
