.factor-tool {
  background: #ffffff;

  border: 1px solid var(--math-line);
  border-radius: 18px;

  box-shadow: var(--math-shadow);

  overflow: hidden;
}


.factor-tool-head {
  display: flex;
  align-items: start;
  justify-content: space-between;

  gap: 20px;

  padding: 25px 28px 20px;

  border-bottom: 1px solid var(--math-line);
}


.factor-tool-head h1 {
  margin: 0 0 7px;

  font-size: 30px;
}


.factor-tool-head p {
  margin: 0;

  color: var(--math-text-soft);

  font-size: 13px;
  line-height: 1.7;
}


.factor-grade {
  flex: 0 0 auto;

  padding: 6px 9px;

  background: #fff2da;

  border-radius: 8px;

  color: #9b6416;

  font-size: 11px;
  font-weight: 800;
}


.factor-workspace {
  display: grid;

  grid-template-columns:
    minmax(0, 1.45fr)
    minmax(300px, 0.75fr);
}


.factor-input-panel {
  min-width: 0;

  padding: 25px 28px;

  border-right: 1px solid var(--math-line);
}


.factor-input-panel h2 {
  margin: 0 0 18px;

  font-size: 16px;
}


.factor-expression {
  display: grid;

  grid-template-columns:
    minmax(90px, 1fr)
    54px
    minmax(90px, 1fr)
    54px
    minmax(70px, 0.8fr);

  align-items: center;

  gap: 7px;
}


.factor-coefficient {
  position: relative;

  min-width: 0;
}


.factor-coefficient input {
  width: 100%;
  height: 50px;

  padding: 0 34px 0 8px;

  background: #ffffff;

  border: 1px solid var(--math-line);
  border-radius: 9px;

  color: var(--math-text);

  text-align: center;

  font-size: 18px;
  font-weight: 800;

  outline: none;
}


.factor-coefficient span {
  position: absolute;

  top: 50%;
  right: 10px;

  transform: translateY(-50%);

  color: var(--math-text);

  font-size: 17px;
  font-weight: 900;

  pointer-events: none;
}


.factor-expression select,
.factor-constant {
  width: 100%;
  height: 50px;

  background: #ffffff;

  border: 1px solid var(--math-line);
  border-radius: 9px;

  color: var(--math-text);

  text-align: center;

  font-size: 17px;
  font-weight: 800;

  outline: none;
}


.factor-expression select {
  padding: 0 7px;

  cursor: pointer;
}


.factor-constant {
  padding: 0 8px;
}


.factor-coefficient input:focus,
.factor-expression select:focus,
.factor-constant:focus {
  border-color: var(--math-primary);

  box-shadow:
    0 0 0 3px
    rgba(47, 111, 237, 0.1);
}


.factor-help {
  margin: 12px 0 0;

  color: var(--math-text-soft);

  text-align: center;

  font-size: 11px;
  line-height: 1.6;
}


.factor-actions {
  display: flex;
  justify-content: center;

  gap: 8px;

  margin-top: 22px;
}


.factor-actions button {
  min-height: 44px;

  border: 0;
  border-radius: 9px;

  font-weight: 800;

  cursor: pointer;
}


.factor-calculate {
  min-width: 165px;

  background: var(--math-primary);

  color: #ffffff;
}


.factor-clear {
  min-width: 76px;

  background: #eef1f6;

  color: #566176;
}


.factor-error {
  margin: 14px 0 0;

  color: #c0392b;

  text-align: center;

  font-size: 12px;
  font-weight: 700;
}


.factor-result-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  min-height: 245px;

  padding: 24px;

  background: #f8faff;

  text-align: center;
}


.factor-result-label {
  margin-bottom: 8px;

  color: var(--math-text-soft);

  font-size: 12px;
  font-weight: 800;
}


.factor-result {
  color: var(--math-primary);

  font-size: 32px;
  font-weight: 900;

  line-height: 1.5;

  word-break: break-word;
}


.factor-original {
  margin-top: 10px;

  color: var(--math-text-soft);

  font-size: 13px;
}


.factor-steps {
  padding: 22px 28px 27px;

  border-top: 1px solid var(--math-line);
}


.factor-steps-head h2 {
  margin: 0 0 12px;

  font-size: 16px;
}


.factor-steps-list {
  display: grid;

  gap: 7px;
}


.factor-step {
  display: flex;

  gap: 12px;

  padding: 10px 12px;

  background: #f7f9fc;

  border-radius: 9px;
}


.factor-step-number {
  flex: 0 0 auto;

  width: 24px;
  height: 24px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: var(--math-primary-soft);

  border-radius: 50%;

  color: var(--math-primary);

  font-size: 11px;
  font-weight: 900;
}


.factor-step-text {
  color: #43506a;

  font-size: 13px;
  line-height: 1.7;
}


.factor-info-grid {
  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  gap: 10px;

  margin-top: 20px;
}


.factor-info-card {
  padding: 18px;

  background: #ffffff;

  border: 1px solid var(--math-line);
  border-radius: 13px;
}


.factor-info-card h2 {
  margin: 0 0 8px;

  font-size: 15px;
}


.factor-info-card p {
  margin: 0;

  color: var(--math-text-soft);

  font-size: 12px;
  line-height: 1.7;
}


@media (max-width: 820px) {

  .factor-workspace {
    grid-template-columns: 1fr;
  }


  .factor-input-panel {
    border-right: 0;
    border-bottom: 1px solid var(--math-line);
  }


  .factor-result-panel {
    min-height: 165px;
  }

}


@media (max-width: 560px) {

  .factor-tool-head {
    padding: 20px 18px;
  }


  .factor-tool-head h1 {
    font-size: 26px;
  }


  .factor-grade {
    display: none;
  }


  .factor-input-panel {
    padding: 20px 12px;
  }


  .factor-expression {
    grid-template-columns:
      minmax(70px, 1fr)
      46px
      minmax(70px, 1fr)
      46px
      minmax(58px, 0.8fr);

    gap: 4px;
  }


  .factor-coefficient input,
  .factor-expression select,
  .factor-constant {
    height: 46px;

    font-size: 15px;
  }


  .factor-coefficient input {
    padding-right: 29px;
  }


  .factor-coefficient span {
    right: 7px;

    font-size: 15px;
  }


  .factor-result {
    font-size: 27px;
  }


  .factor-info-grid {
    grid-template-columns: 1fr;
  }

}
